Page 1 of 3

Script+Pokeys

Posted: Wed Jul 13, 2016 1:54 am
by satco
Hi Art,

I try to control of PoKeys i/o pins.

Test SetRelay() and SetOC(). It works good!

Then I write a script from your topic  "Script/GCode interface":

global ServiceIO Pin15 = function()
{
  while(1)
    {
      block("IOPin15");
      //do what you wish to happen
      // on pin15 change here.
    }
}

But do not understand where is main screen init script.

Can you write some examples of scripts for:
-set output digital pin
-set analog output pin
-get analog input pin (is it possible to wait a setting level of signal)

Is it possible to make buttons for:
-start the process
-kill the process

Best regards,
Anatolii.

Re: Script+Pokeys

Posted: Sun Jul 17, 2016 3:11 am
by ArtF
Hi Anatoli:

first, make sure the function name has no space.. as in ..

//
global ServiceIOPin15 = function()
{
  while(1)
    {
      block("IOPin15");
      //do what you wish to happen
      // on pin15 change here.
    }
}

  This is a valid call, and shoudl work fine. You DO need to call it to start it up.
In the library itself, you coudl put a call to that function immediately after its
been declared..

      //do what you wish to happen
      // on pin15 change here.
    }
}
ServiceIOPin15();


  Or, you can place a call to the function in the screen init library available to be checked out
in the editor.

  TO set a Dig Pin..you need an IO var.. in the laserspindle library you will see a var I create for Motion ..
global SpindleControl = Motion(); , you need a similar on for IO in your example...

global MyIO = IO();
global ServiceIO Pin15 = function()
{
  while(1)
    {
      block("IOPin15");
      //do what you wish to happen
      // on pin15 change here.
      if( timetoturnonpin16dig )
      {
            IO.SetPinDig( pin , 1 ); //set pin "pin" to a 1.
            IO.SetPinAna( anapin, value); //value is an integer from 0 - DAC max). This is not yet implemented, analogue shoudl
                                                        //done shortly, I havent needed it yet, but now that youve asked, Ill turn it on.
            pintype = IO.GetPinType( pin ); //returns a number indicating pin type in pokeys

//    PK_PinCap_pinRestricted  = 0,          // Pin is not used
//    PK_PinCap_reserved      = 1,          // --
//    PK_PinCap_digitalInput  = 2,          // Digital input
//    PK_PinCap_digitalOutput  = 4,          // Digital output
//    PK_PinCap_analogInput    = 8,          // Analog input (only on selected pins)
//    PK_PinCap_analogOutput  = 16,          // Analog output (only on selected pins)
//    PK_PinCap_triggeredInput = 32,          // Triggered input
//    PK_PinCap_digitalCounter = 64,          // Digital counter (only on selected pins)
//    PK_PinCap_invertPin      = 128          // Invert digital pin polarity

          Anavalue = IO.GetPinAna( 5 );  //return 32 bit integer of ADC reading.. (This IS implemented..)

        }
   
    }
}

I will turn on Analogue and let you know when you can call it..

Art






Re: Script+Pokeys

Posted: Sun Jul 17, 2016 3:16 am
by ArtF
Oh, if you want to calla  function from a button, just name the button variable to the function..

If a button is called "CallMyFunc" as its variable... pressing it will call CallMyFunc( 1 or 0) depnding on press or release..

Art

Re: Script+Pokeys

Posted: Tue Jul 19, 2016 7:57 am
by satco
Hi Art,

thank you very much for explanations.

Now I can easy test (read type), set and read PoKeys pins.
a = Pokeys1.GetPinDig(1);
a1 = Pokeys1.GetPinType(1)

Leave some questions with:
1. block("IOPin1");  // when I put it in function and call it, LEDs "Dwell" and "Script' turn on and Auggie stop respons any Buttons, only EStop.
2. I set Button named "MyFirst". It calls function MyFirst. Can I set HotKey for this Button or function?

Best regards,
Anatolii.

Re: Script+Pokeys

Posted: Tue Jul 19, 2016 1:51 pm
by ArtF
Hi A:

>>Leave some questions with:
>>1. block("IOPin1");  // when I put it in function and call it, LEDs "Dwell" and "Script' turn on and Auggie stop respons any Buttons, only >>EStop.

  It depends on how you call it. If called in a GCode program, it will stop the execution until the script ends.. and that one doesnt..
so you need to start the function with "Engine.GoPara()" , this detaches the script from the Gcode and lets it run in parallel. If you
call the function from a button, it should work.  I havent personally used it on a block, so Ill schedule a check to make sure its not buggy.

2. I set Button named "MyFirst". It calls function MyFirst. Can I set HotKey for this Button or function?

  Yes, once the script is in the library, it should then show up in the hotkeys selections.. just set a key to call the function.

Art




Re: Script+Pokeys

Posted: Thu Jul 28, 2016 12:11 am
by satco
Hi Art,

1.I start  function with "ServiceIOPin1();" it stops the execution until the script ends. Ok. Then I try  to start the function with "Engine.GoParallel.ServiceIOPin1();" see code below:

global ServiceIOPin1 = function()
{
&nbsp; while(Pokeys1.GetPinDig(1)<1)
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; MyFirst();
&nbsp; &nbsp; &nbsp; &nbsp; sleep(1);
&nbsp; &nbsp; &nbsp; };
};
Engine.GoParallel.ServiceIOPin1();

It doesn't work. I see on the screen:

---System---about to run
script MDI execution begins
End of MDI Script run

2.How to set and read LEDs?

Best regards,
Anatolii.

Re: Script+Pokeys

Posted: Thu Jul 28, 2016 2:19 am
by ArtF
Hi A:

Glad to see your playing with the scripting..

&nbsp; A script must be set as a parallel scrip or not by the script.. to make a scrip parallel, do it like this..

>>
global ServiceIO Pin1 = function()
{
&nbsp; Engine.GoParallel();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Gcode will immediatley continue..
&nbsp; while(Pokeys1.G etPinDig(1)<1)
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; MyFirst();
&nbsp; &nbsp; &nbsp; &nbsp; sleep(1);
&nbsp; &nbsp; };
};

&nbsp; You may put this at the point in the script where you want the Gcode calling it to continue..

for example..

global ServiceIO Pin1 = function()
{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; while(Pokeys1.G etPinDig(1)<1)
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; MyFirst();
&nbsp; &nbsp; &nbsp; &nbsp; sleep(1);
&nbsp; &nbsp; };
&nbsp; &nbsp; &nbsp; Engine.GoParallel();&nbsp; //Gcode will continue when pin1 goes high and the while exits..
};

&nbsp; An LED can be controlled ina&nbsp; couple of ways.. If it has a variable name, then

GlobalSet("ledvariablename", 1 ); will turn it on.. 0 will turn it off.

You can also make&nbsp; a variable to a LED. If you right click on one you can get its identifier if its not
a variable. IT may be MAIN_LED_0 for example. If so, you can make an led with

myled = Led("MAIN_LED_0");
myled.SetStateMask(7);&nbsp; //this woudl turn on the first 3 leds in a bar of leds.. 7 is 00000111 binary, so turns on first 3 leds, if only
1 led exists in that led, then
myled.SetStateMask(1); will turn it on..

Good luck
Art




Re: Script+Pokeys

Posted: Fri Jul 29, 2016 7:49 pm
by satco
Hi Art,

Thank you for so complete explanations. Script is VERY powerful tool!
1. Engine.Go Parallel();&nbsp; - ok,
2. GlobalGet/Set Button, LED, Slider - ok,
3. I set LED ID number "0" on Main Screen. Following script does not work:
myled = Led("MAIN_LED_ 0");
myled.Set StateMask (7);
where is my mistake?
4. How Get/Set Label?
5. Help please with Block. I have Button (VarName "Pin_1") and LED (VarName "Pin_9"). Is it possible to start parallel looped&nbsp; Script&nbsp; to test "Pin_1" and set "Pin_9".
6. Mach3 has a very powerful tool - screens . Does Auggie has the similar?

Best regards,
Anatolii.


Re: Script+Pokeys

Posted: Sat Jul 30, 2016 1:29 am
by ArtF
Hi A:

>>Thank you for so complete explanati ons. Script is VERY powerful tool!

&nbsp; It IS, its more powerfull than most any contoller has near as I can see. It can run a great many scripts simultaneously
and in various situations. While pretty heavily tested, it definitely has limitations and problems we're unaware of, Auggie
has few safeties, its designed to let you do what YOU Want, because its designed for and by me for my experiments. Ive only
used it for lasers so many normal cnc bugs may exist, but eventually Ill get to the spot where I need more normal cnc
so problems there will get addressed.

>> 1. Engine.Go Parallel();&nbsp; - ok,
>>2. GlobalGet/Set Button, LED, Slider - ok,

>>3. I set LED ID number "0" on Main Screen. Following script does not work:
myled = Led("MAIN_LED_ 0");
myled.Set StateMask (7);
where is my mistake?


&nbsp; I just tested here with an LED I dropped on the screen..with this script.

led = Led("Main_LED_6");
led.SetStateMask(0);
sleep(3);
led.SetStateMask(1);&nbsp; //this makes the LED turn off, then on again in 3 seconds.

&nbsp; It may be because your using a number thats not 1 or 0 on a single led, a 7 should
only be used on an LED with at least 3 leds. Also, make sure no other system is controlling that
led, whatever signal is controlling it may override your script control. Also, make sure you restart
after editing the screen, sometimes a control will not be seen until a restart. Also, very important,
make sure only the LED is the only MAIN_LED_ 0, if other led's have a 0 as their ID, only the first
one will work, set the ID to 666 as a test, then MAIN_LED_666 should work.

4. How Get/Set Label?

&nbsp; Much the same way.

Mylabel = Label("Main_Label_2");
MyLabel.SetText("new text");
or Mylabel.SetBkColor( 0x444400 );


5. Help please with Block. I have Button (VarName "Pin_1") and LED (VarName "Pin_9"). Is it possible to start parallel looped&nbsp; Script&nbsp; to test "Pin_1" and set "Pin_9".

&nbsp; If you have a button named "Pin_1" , then if you create a library function of

global&nbsp; Pin_1 = function( state )
{
&nbsp; //if state is 1, then button is pressed, if 0, it is released. "Toggle" property
&nbsp; //of button will change how this is called, once per click or on press AND release.
&nbsp; &nbsp; GlobalSet("Pin_9", state);
}

So generally, you wouldnt waste cpu time polling a button, allow the button to call you instead.
By making a function equal to the variable name, that function will be called automatically when the
item changes. This is much more efficient than polling. Use signal and block to "poll" an input signal
as that too is fast and efficient and requires no polling. (Though you CAN poll if you like with simple sleep
call in a script.)


6. Mach3 has a very powerful tool - screens . Does Auggie has the similar?

&nbsp; Do you mean Screen4? (Scream4 as I call it? ). Auggie is really a replacement for Scream4, or started
to be. It got too powerfull so I made it auggie and called it a controller. Auggies power is as a screen
designer, when you enter EDIT mode, you can control the screen, redesign it completely or do any
other function related to screens. Auggies editing mode is much more powerfull and easier to use
than Scream4 ever was. Its also much less buggy or annoying, so long as one remembers to save
and restarts after a full edit, youll find the screen editing is very powerfull and allows for scripts to be
attached to any control even at design time. Watch the video's on screen design, once you start doing it,
its incredibly easy to do. Auggie is a good way to make a scripted control panel to do almost
anything hardware related, (Ill be driving galvos with it soon..) not only CNC.

&nbsp; &nbsp; Auggie is a strange program, its better than Mach3 by quite a bit for any experimenter, and for a custom
machine that doesnt do conventional cnc and needs custom screens, I think its one of the best on the web&nbsp; but will never
replace Mach3 as I have no intention of pushing it there. Like all gearotics tools, it was written for my use,
but Im gratified others find it useful. Unlike the other tools in Gearotics package, a controller needs quite a base
of users to get known, and after running Mach3 for a decade, Im far too into retirement to go there.
(Although I know if I attached an ESS and a PMDX we'd be awful busy around here.) , Auggie will be a group success
to me if 20 of us end up controlling machines with it and are happy with its speed and power, though as I use it
almost everyday myself, its already a success to me. Mach3 has around 100,000 users ( as a comparison..&nbsp; :-) ).
&nbsp; &nbsp; While I screamed at Screen4 daily, I get annoyed with Auggie's designing only periodically, thats quite an improvment.
So when your bored, Id recommend deleting the things on Auggies screen you dont need, and redesigning it, a couple
hours of doing that and youll find your quite an expert on control panels in general.

&nbsp; Auggie will continue to grow as I go, though much more will be in Gearotic in terms of function. Gearotic will now call
Auggie for functions like Wizards, so the two programs are about to merge more tightly together so that people can use
what they like and ignore what they dont need.&nbsp; I have ordered some surplus galvos to work with on a new laser machine, so Ill
be attaching an Arduino to help , likley only a very small few will use something like galvo's, but the arduino communications
interface may be of interest to people when I get there. Auggies powerfull scripting combined with the cheapness of an arduino
may allow for some interesting projects.


Sorry for the long letter, I thought maybe youd be interested in the future plans for Auggie.. (and its early and Im bored and
stuck on a piece of code.. :) anyone know a good solution for malfatti circles?

Hope it helps,
Art

Re: Script+Pokeys

Posted: Sat Jul 30, 2016 6:43 am
by Mooselake
ArtF wrote:anyone know a good solution for malfatti circles?
I thought it was pretty interesting that Malfatti circles never give a solution to the Malfatti problem, but the greedy algorithm might be it.

Least you think I've remembered (and added to) what I learned 40+ years ago it's from a googled article, and like everything on the Internet it must be right...

So are these going to be a new addition to flourishes, and how will fertilizer affect them :)

Kirk

Re: Script+Pokeys

Posted: Sat Jul 30, 2016 2:48 pm
by ArtF
Hi Kirk:

&nbsp;Well, the flourishes work quite well at the moment, but as Yanvrno noted, ( the only guy to have tested them) ,
you just nvrno what your gonna get. You enter a fertilizer for bushiness, and a motif for shape, but the motif is a
control reall yof the outside boundry sizes in a circle packing algorithm, the shapes do get intuitive when you get used to them,
but I wondered.. what if you could point to a photograph to set the motif.

&nbsp;SO Im experimenting with it.. this , for example is th ebasis graph from a photo of a dog.. needs work, but it shows
perhaps photos could set a quick motif for a vines tendencies....

Art

Re: Script+Pokeys

Posted: Sat Jul 30, 2016 3:30 pm
by Ya-Nvr-No
Just so everyone knows what the original image was, turned out pretty good I thought.

Re: Script+Pokeys

Posted: Sat Jul 30, 2016 6:35 pm
by DanL
you can see what it is

Re: Script+Pokeys

Posted: Sat Jul 30, 2016 11:22 pm
by satco
Hi Art,

>>3. I set LED ID number...
My mistake is - use "Var. Name" and "ID" simultaneously. Now all ok.

>>4. How Get/Set Label?
&nbsp; Mylabel = Label("Main_LABEL_66");
&nbsp; MyLabel.SetText("Yho");
return mistake
&nbsp; Mylabel = Label("Main_LABEL_66");
&nbsp; Mylabel.SetBkgndColor(0x444400);
return mistake
if only
&nbsp; Mylabel = Label("Main_LABEL_66");
no mistake

>>5. Help please with Block.
...you wouldnt waste cpu time polling a button, allow the button to call you instead.
By making a function equal to the variable name, that function will be called automatic ally when the item changes.

Does it work fo Pokeys pin?
Pokeys1 Pin Dig IN(1);
Pokeys1.Pin Dig OUT(9);

>>6. Mach3 has a very powerful tool - screens .
I have no problem with Auggie Editor of Panel and Screen. It is really very powerfull and easy to use Editor. Video gives all needed information. It is more powerful than in Mach3. I have placed wrong question.

The question is: How to change user interfase (like Program run, MDI, Settings, ets.) during Auggie works? Is it possible to set Hot Keys to load different screens or panels?

>>Mach3 has around 100,000 users...
&nbsp; It is a very beautiful result!

Best regards,
Anatolii.

Re: Script+Pokeys

Posted: Sun Jul 31, 2016 5:33 am
by ArtF

>>4. How Get/Set Label?
>>&nbsp; Mylabel = Label("Main_LABE L_66");
>>&nbsp; MyLabel.S etText("Yho");
>>return mistake
>>&nbsp; Mylabel = Label("Main_LABE L_66");
>> Mylabel.S etBkgndCo lor(0x444400);
>>return mistake

&nbsp; I just tried ..

Mylabel = Label("JogPanel_LABEL_0");
Mylabel.SetText("fgh");
Mylabel.SetBkgndColor(0xfff,0x0f0);

&nbsp; Sorry about the color, you need 2 numbers, one for on segments, one for off.. other than that the above works fine here.



>>5. Help please with Block.
>>...you wouldnt waste cpu time polling a button, allow the button to call you instead.
>>By making a function equal to the variable name, that function will be called automatic ally when the item changes.

Does it work fo Pokeys pin?
Pokeys1 Pin Dig IN(1);
Pokeys1.P in Dig OUT(9);

&nbsp; No. You need to have a screen interface object to deal with, its the object that calls
the script. So it must be a button or a dro..or even a label.. probably not good for monitoring a pin..

To do it with blocking, just add something like this to a library file..

global&nbsp; MonitorPin9 = function()
{
&nbsp; while(1)
&nbsp; {
&nbsp; &nbsp; block( "MotionPiin9");&nbsp; //or you cold use IOPin9
&nbsp; //
&nbsp; //&nbsp; when you reach here, its because pin9 has changed..
&nbsp; &nbsp; pinstate = MyMotion.GetPinDig(9);&nbsp;
&nbsp; &nbsp; if( pinstate == 1 )
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; //do what you need to do. Take not that if you change pin9, youll get called again..
&nbsp; &nbsp; &nbsp; &nbsp; //so make sure you dont get into a loop where your change makes this gets called which then changes it..etc...
&nbsp; &nbsp; }
&nbsp; }

};
MonitorPin9();


&nbsp; In the library, the function will get declared, and then start runnign immediatley as you call it right after declaring it..



>>6. Mach3 has a very ...... I have placed wrong question.
>>The question is: How to change user interfase (like Program run, MDI, Settings, ets.) during Auggie works? Is it possible to set Hot Keys to load different screens or panels?

&nbsp; Ahh. You cannot as yet. I havent adding a call for a screen swap, though I plan to. I just havent had to as yet.

Thx
Art