reading Pokeys pins

C Scripting questions and answers
Post Reply
gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

Art

yes I created a global var FloodOnOff
I have a button to turn on flood relay  and a led I was trying to set global FloodOnOff = 0
then if I hit the flood button FloodOnOff  would = 0 and relay would turn on and change FloodOnOff = 1 and when button again relay would shutoff and  FloodOnOff set back to 0 but when I set FloodOnOff to 1 it always reverts back to 0 so of course the second button press won't shut off the relay
I worked around this by using getrelay instead.

is there a way for engine.gcode('G31',axis,'-25F100') to except a value like axis ='Z'
so I will call the probe function like probing("Z',10,100)
then probing function start like probing(axis,distance,feedrate)}{
also doesn't seem to be a way to set the var axis to a char on the receiving function it  receives 'Z' as an int..

as far as the probing routine it will not run as long as pokeys is connect
the g31 may not work in  simulation but I can get the dro running to -25 in simulator

but I have to have the script loaded in local edit then run the script hit stop once or twice
then hit my button script and then the z dro runs to -25

but just can't get to work with pokeys connected

thanks gary
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Hi Gary:

>>yes I created a global var FloodOnOff ....

    As I recall there's some strange syntax possible here, Id have to see the code for it.
You wouldn't use GlobalSet or GlobalGet for actual script globals, only for Auggie internals.
For a script global you'd declare it in a global scope.. like before the function declaration..

ex:
(In a loading library like Gcode or System)

global FloodOn = 0; //declare script global in global scope outside of function.

global function FloodOnOff( state )
{
    if(...)
      FloodOn = 1; //should be able to simply use the global name here.. no GlobalSet or get required.
}

>>is there a way for engine.gcode('G31',axis,'-25F100') to except a value like axis ='Z'
>> so I will call the probe function like probing("Z",10,100)

  All variables are automatic. so for example..

global function Probing( axis, dist, feedrate )
{
  string = "G31" + axis + " " + dist + "F" + feedrate;
  print( string ); //as a test
  Engine.GCode( string );
}

to use:
  Probing( "Z" , -10, 100 );

  Again, top of head so excuse me if Im off a bit on syntax.


>>as far as the probing routine it will not run as long as pokeys is connect
>>the g31 may not work in  simulation but I can get the dro running to -25 in simulator

  I verified that simulation will not run G31, effects are unknown  so it may explain lockup
or strange effects.

>>but I have to have the script loaded in local edit then run the script hit stop once or twice
>>then hit my button script and then the z dro runs to -25
>>but just can't get to work with pokeys connected

  Make sure your script and globals are in a library checked to be loaded. Libraries are
reinitialized each reset of system to ensure all globals are current and all scripts are
registered. If it doesnt recognize a script, lets find why. If the script is recognized,
but the probe just doesnt move, it may be the probe is already being seen as hit.
The ProbeInvert and GlobalSet("ProbeInvert", n ); will have an effect. Make sure
that a G31 entered in single line MDI works, if no motion occures, change the setting
of ProbeInvert in the settings. If the probe moves, then the probeinvert is set correectly.

  Ignore the results of sim test, it doesnt show anything usefull.

  Just to be clear, the script commands GlobalSet and GlobalGet are used only
with Auggie internals, theres about a hundred of them that may be used. All
others are simply used as script names for direct reference.

Art

gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

Art

I wasn't using globelset  or get for the flood, but don't need it anyway using getrelay and that works fine...

I tested the probe script again with pokeys on engine.gcode doesn't seen to work with g31 I get no motor movement
I changed the engine.gcode form g31 to g0 and motors ran fine so I'll leave this one up to figure out I'm kind of lost now..

but the g31 and probe hit do work from single line mdi.

thanks gary   
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Hi Gary:

>>I wasn't using globelset  or get for the flood, but don't need it anyway using getrelay and that works fine...

  Ahh, ok. Sorry if I explain too much at times or much such assumptions, Ive been doing support
now for decades and Ive found too much is better than too little.

>>I changed the engine.gc ode form g31 to g0 and motors ran fine so I'll leave this one up to figure out I'm kind of lost now..but the g31 and probe hit do work from single line mdi.

  Could be me, Ive been testing from mainly the single line MDI myself. Though I did also
test the Engine.GCode.. I will check to see why the script may have broken..

Art

ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

Just tried this in the script window. Can you try it and tell me what it does?

Engine.GCode("G31Z-25F500");
axis = "Z";
string = "G31"+axis+"0" + "F" + 100;
print(string);
Engine.GCode(string);

  On the toolpath screen you should see the line printed
as "G31Z0F100" as well..

Art
gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

Art

Tried it in the script window G31 Doesn't move the dro's or motor the same results as running though the lib script
I changed to G0 and the motor ramped up to -25 and then ramped to 0 and I did get the printout on the display screen
with both g0 and g31..

gary
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Thats what Id expect if the ProbeInvert was set wrong. But then it wouldn't
work in GCode single line mdi if that were true.

  The script I listed was one I tested on my machine.. so it must be a setting somewhere..
Ill give it some thought and look in the code to see why it may not go.

Art
gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

I have the probe active high low problem with mach3 and 4, mach4 needs it set high mach3 needs it low not sure what auggie has it set at but when its triggered my script to read pin19 is triggered..

I removed the print statements for the pin19 script and replaced it with an led on screen seems to work ok...

gary

ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

  Auggie assumes Active High, but if in the config/planner you set
ProbeInvert, Auggie will then assume active low.
  The trigger of a script will happen no matter if it toggles from
a 1 to a 0, or a 0 to a 1. Either will trigger a script.

  So if a g31 is sensed, and the probe is sensed as already hit,
no motion will occur. It will just trip right at start.

  So I need to confirm..

A GCode single line MDI of G31 works?
A script call to G31 doesn't?

  Are both true?

Thx
Art
gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

Yes both are true.

I will change the setting in the planner and see if that has any effect..

Have a question I thought you were not going to add the probing. What changed your mind? I'm not complaining I'm enjoying testing it, maybe more fun for me than you

but thanks gary
Post Reply