Script+Pokeys

C Scripting questions and answers
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 5 guests