Script+Pokeys

C Scripting questions and answers
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script+Pokeys

Post by ArtF »

Hi A:

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

  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();  - 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?


  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);  //this makes the LED turn off, then on again in 3 seconds.

  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?

  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  Script  to test "Pin_1" and set "Pin_9".

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

global  Pin_1 = function( state )
{
  //if state is 1, then button is pressed, if 0, it is released. "Toggle" property
  //of button will change how this is called, once per click or on press AND release.
    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?

  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.

    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  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..  :-) ).
    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.

  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.  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
User avatar
Mooselake
Old Timer
Posts: 522
Joined: Sun Dec 26, 2010 12:21 pm
Location: Mooselake Manor

Re: Script+Pokeys

Post 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
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script+Pokeys

Post by ArtF »

Hi Kirk:

 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.

 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
Attachments
2016-07-30_22-23-54.jpg
Ya-Nvr-No
Old Timer
Posts: 188
Joined: Wed Sep 08, 2010 11:15 am

Re: Script+Pokeys

Post by Ya-Nvr-No »

Just so everyone knows what the original image was, turned out pretty good I thought.
Attachments
testdog.jpg
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: Script+Pokeys

Post by DanL »

you can see what it is
satco
Old Timer
Posts: 28
Joined: Tue Jan 19, 2016 5:23 am

Re: Script+Pokeys

Post 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?
  Mylabel = Label("Main_LABEL_66");
  MyLabel.SetText("Yho");
return mistake
  Mylabel = Label("Main_LABEL_66");
  Mylabel.SetBkgndColor(0x444400);
return mistake
if only
  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...
  It is a very beautiful result!

Best regards,
Anatolii.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script+Pokeys

Post by ArtF »


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

  I just tried ..

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

  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);

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

};
MonitorPin9();


  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?

  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

satco
Old Timer
Posts: 28
Joined: Tue Jan 19, 2016 5:23 am

Re: Script+Pokeys

Post by satco »

Hi Art,
I test following:

pinstate = Pokeys1.GetPinDig(9);
if( pinstate == 1 )
    {
  print("pinstate"+1);
    }
else
{
print("pinstate"+0);
}

It works good. Then I test:

global  MonitorPin9 = function()
{
  while(1)
  {
    block( "MotionPin9");
    pinstate = Pokeys1.GetPinDig(9);
    if( pinstate == 1 )
    {
  print(" pinstate");
    }
  }
};
MonitorPin9();

I have no reaction on Pin9 changes. Where is error? The same result with "IOPin9".

Best regards,
Anatolii.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script+Pokeys

Post by ArtF »

Anatolii:

Hmm, I just tried this in the script window as a test..

block("MotionPin1");
print("Done");


  Run that script and the script light should stay flashing. Its waiting on the block.
When I jumper pin1 to ground, the word done is printed in the log and the light stops flashing.

Can you try that test for me? Seems to work here, the block gets released if I go from 1 to 0 or 0 to 1..

Thx
Art
satco
Old Timer
Posts: 28
Joined: Tue Jan 19, 2016 5:23 am

Re: Script+Pokeys

Post by satco »

Hi Art,

I set "NO" button among Pin1 and GND. In NO condition Pin1 hase 3.7V. In NC Pin1 hase 0V.

I have tested:
block("MotionPin1");
print("Done"+Pokeys1.GetPinDig(11));


I push Button to NC and wait in this condition. The word "Done0" is printed in the log and the light stops flashing.
So the block gets released if I go from 1 to 0.

My mistake is I try to set blok to Pin9. Pin9 in my Hard is DigOut :)

Best regards,
Anatolii.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script+Pokeys

Post by ArtF »

Anatolii:

lol, makes sense. I do such things as well. Glad to hear it works. You can also block on multiple options if you like.. for example...


myblock = block( "MotionPin9" , "IOPin9", "MotionPin11");

if( myblock == "MotionPin9" ) { .......do whateer" };

etc..

  Just so you ( and anyone else working with blocks.. ) knows.

  This makes it possible to write one script that monitors and deals efficiently with multiple pins.
This can save a lot of scripting in multiple scripts. Its unknown how many you can run simultaneously..
Ive run up to 50 scripts at once while Gcode runs as a test, but Im assuming this depends on CPU
power and your system. Not many people run Auggie , so it will take awhile for limitations to be
figured out fully. All I know is it runs my laser pretty good. :)

Art

satco
Old Timer
Posts: 28
Joined: Tue Jan 19, 2016 5:23 am

Re: Script+Pokeys

Post by satco »

Hi Art,

Auggie like a sleeping Dragon. I will be very glad to help you wake him up. If I can to test or make  anything else, let me know please.

Is it possible to block an Analog Input. If input signal change - start script? It will be a very powerful tool to work with analog signals.

Best regards,
Anatolii.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script+Pokeys

Post by ArtF »

Hi A:

  It isnt really possible to block on an analogue because I havent set any way to set a range.
Ask me about this in the fall, if I add a couple calls to set a blocking range, it owuld be possible
to block on signal change of more than a set tolerance.Analogues tend to swing, so I was worried abotu too many block calls.

Thx

Art
satco
Old Timer
Posts: 28
Joined: Tue Jan 19, 2016 5:23 am

Re: Script+Pokeys

Post by satco »

Hi Art,

Ok, I test block and waiting fall.

Best regards,
Anatolii.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest