reading Pokeys pins

C Scripting questions and answers
Post Reply
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 hooked it all up here, the table seems to probe fine in the X and Y axis, I cant test
the Z on mine for technical reasons at the moment, but as far as I can see it
all seems to be running at speed during the probe and after...

Let me know what you find, it may be some setting or another ..

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

Re: reading Pokeys pins

Post by gburk »

Sorry Art;

Probably left to many messages and am confusing you?

1 ? I am finding that running a script to check the probing pin19 must take to much time from the gui and that's why the main screen dro only updates after the axis has move around 0.254?
without the script the screen dro updates fine?

2 ? I am probing now on the X Axis Setting?s for xaxis are ENB = TRUE, REV = FALSE, STEPS PER   
= 2500.000000 , MAX ACC = 19.999001, MAX VEL = 1000.00000, SLIMITS = FALSE,  HOMING REV = TRUE,  HSPEED = 20,  HOME RET SP = 50,  MAP MOTOR 1.

3 - Maybe taking a break and rebooting the computer was what I needed, motor seems to be running fine now with both g0 and g31 the g31 runs at a slower speed but I assume you have the feed rete set lower for probing I did try F100 and ran a little faster so looks good...

have you figured a way yet to read a register or variable to get feed back to see if the probe was hit or went to the enter axis travel distance?.
looks to me like in a script it may be to slow for probing, but seeing your programing over the years you may have a way...

thanks gary

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

Re: reading Pokeys pins

Post by gburk »

Art

maybe you can use the scripting I did a little more research and tried using the yield() after the print line in my script and now the dro's display correctly
and when I hit the probe I get the printed message pin19 hit I may get the message printed twice but the dro is running steady now..

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:

  Thx, good to know. A script shouldn't take any time at all if it uses a line like

Block("MotionPin19");

  that stops the script altogether until Auggie sees pin19 toggle, at which point the
script will continue onwards..

  The script command

a = GlobalGet("ProbeHit");

  will make "a" true if the probe hit on the last G31.

x = GobalGet("ProbePos0") will return the X position of the hit.  1,2,3 will give you y,z,a axis positions
where the probe hit and before decelerating.

  If your just doing a zeroing to a touch plate you may want a script something like this one
designed to be called from a zeroed Z axis position somewhere less than 1" above the touchplate.
User is expected to zero axis when it stops. Because it rises off plate at such a slow feedrate
you will stop withing a step or so of probe hit. If you make the feedrate of rise F1, youd probably
stop exactly on the zero point.

global function ZeroToPlate()
{
  GlobalSet("ProbeInvert",0); //set probe to normal state
  Engine.GCode("G31Z-25F100"); //probe 25mm down in Z
  Block("MotionStill"); //wait for all motion to stop, no system delay for this.
  if( !GlobalGet("ProbeHit"))
    { print"No hit on probe ..Try again closer to plate.");
      return;
    } //we didnt hit the probe during the move
  GlobalSet("ProbeInvert",1); //invert probe switch
  Engine.GCode("G31Z0F10"); //probe upwards slowly till switch releases
  Block("MotionStill"); //wait for all motion to stop, no system delay for this.
  if( GlobalGet("ProbeHit"))
  {
      print("Zero Axis, probe complete.");
      GlobalSet("Zero3",1); //this will zero axis #3-Z (the numbering starts at 1 for X in zeroing
                                      //function even though some other functions start with 0 for X
  }
    else { print(" Error in touchoff" ); };

}

    Thats off top of head, untested so you may find lots of syntax errors there.. :)
Art




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

Re: reading Pokeys pins

Post by ArtF »

BTW:

  Do not use G43 at this time, I just fixed a problem with zeroing
when toollengthoffset is in effect and it affects the zeroing..Next update
should fix that issue.

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

Re: reading Pokeys pins

Post by gburk »

Art

For some reason I'm having a problem creating panels, I tried to make a panel with 3 buttons and 3 labels
when in panel mode and scripting, then when I go to edit a script it shows no buttons only the labels all as main label 0
if I put a script into the label its there every time I load the panel thought panel create mode but no buttons and 1 did give the buttons a number 1 to 3

if I go back to the main screen I have the panel placed on the screen ok now I script edit from the main screen still shows all labels under that panel
but  it didn't carrier over the scripts  from the panel edit screen create mode.. and of course the buttons don't work, I guess because its only picking up the labels no buttons

I have created panels with  buttons from older versions of auggie with no problems
let me know if I'm doing something wrong ? or something has changed

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

Re: reading Pokeys pins

Post by gburk »

here is the script that works

global  FloodOffOn = 0;
global  MonitorPin19 = function()
{
  //Pokeys1.SetPinDig( 19 , 0 ); // turn off pin 19, ( assumed to be digital output)

  while(1)
  {
    print("Pin 19 Check");
    block( "MotionPin19");  //or you cold use IOPin9

  //
  //  when you reach here, its because pin9 has changed..
    pinstate = Pokeys1.GetPinDig(19); 
    print("Pin 19 Changed");
    yield();
        //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.. .
  }
};
MonitorPin19();

should I replace yield with a block?

also trying to wrap my head around global vars
I set global  FloodOffOn = 0;

if I use FloodOffOn in button script and change its value to 3, when I call the button script a second time the value is back to 0 
so I assume setting it as a global then its not changeable ? 

also is it possible to read the encoder pins I think pin13 as a one rev index rpm?

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

Re: reading Pokeys pins

Post by gburk »

Art

put this in lib
global ZeroToPlate = function(a,d,f)
{
  print("a = ",a);
  print("d = ",d);
  print("f = ",f);
  GlobalSet("ProbeInvert",0); //set probe to normal state
  Engine.GCode("G31Z-25F100"); //probe 25mm down in Z
  Block("MotionStill"); //wait for all motion to stop, no system delay for this.
  if( !GlobalGet("ProbeHit"))
    {
      print("No hit on probe ..Try again closer to plate.");
      return;
    } //we didnt hit the probe during the move
  GlobalSet("ProbeInvert",1); //invert probe switch
  Engine.GCode("G31Z0F10"); //probe upwards slowly till switch releases
  Block("MotionStill"); //wait for all motion to stop, no system delay for this.
  if( GlobalGet("ProbeHit"))
  {
      print("Zero Axis, probe complete.");
      GlobalSet("Zero3",1); //this will zero axis #3-Z (the numbering starts at 1 for X in zeroing
                                      //function even though some other functions start with 0 for X
  }
    else { print(" Error in touchoff" );
};
}; 

called from button

ZeroToPlate (1,2,3);


its strange I was in simulator mode pressed the button
and the z moved to -25

can't get it to work a second time in simulator or with pokeys
it does print 1 2 3 but no axis movement
so I know its calling the function just strange it worked once

do you suggest a better way to call the function?

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:

  Im sim mode the G31 will not function. ITs because half of the probe work is done in
the Pokeys itself. The simulator probably didnt understand the PROBE type trajectory
and simply passed it on as a feed move. Trouble is, the pokeys needs to shut off the
probeing mode. Sim mode wont do G31's as a result..

>should I replace yield with a block?

  In your example, you can remove the yield(). the next line encountered is
to print "ProbeCheck" and then it blocks anyway. So replacing yield with block
would break it as it would need two probehits..one for each block.

A yield simply passes control back to the program so it can process other
threads and then immediately returns. So yields are good practise if doing
a long calculation as you can pass control back every once in a while to
allow auggie to work, but in the case of a block, the program stops entirely
until the event occurs.

>>if I use FloodOffOn in button script and change its value to 3, when I call the button script a second time the value is back to 0 
so I assume setting it as a global then its not changeabl e ? 

  Ill have to check this.  Ill get back to you.

I think you can get encoder count... but not the index pin itself, typically they
pass so fast youd never see it. Ill check what the call is for the count.

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:

>>For some reason I'm having a problem creating panels, I tried to make a panel with 3 buttons and 3 labels when in panel mode and scripting, then when I go to edit a script it shows no buttons only the labels all as main label 0 if I put a script into the label its there every time I load the panel thought panel create mode but no buttons and 1 did give the buttons a number 1 to 3

  This one gets confusing. Originally I was adding scripts to the panels and sub screens that were hard
coded by the panel designed into the panel itself. That script could then be overridden if one
wished by editing it in the screen containing the panel. This virtual override was thought to be
safer but I found it too confusing. So when you design a panel, just name the various interfaces
by a variable name and dont do any scripting. When the panel loads the label names and such
will be decorated to stop duplications, but the variable names will be fine.

  So, if for example you have a DRO on a Zeroing panel, just give it a variable name of
m_MyZeroXDRO for example. Then once the panel is saved and is part of a screen, add your
scripts to any library file (or make a new library file for that panel.). Adding a
function like

global function m_MyZeroXDRO( value )
{
}

  Should then make that function get called when the dro is typed into. You can
send to it as well with GlobalSet("m_MyZeroXDRO",value) or get from it with
GlobalGet..

  Its the best way to attach scripts to objects, I highly advise not hard scripting in the
panel designer, its very messy unless your me and know all the strange interaction
with the virtual override system.

  On your question about  FloodOn, did you mean you created a global variable named
FloodOn or were you trying to access an internal var of that name. (There is no var
of that name internally.). There is a script to set flood mist in the Gcode library
which you can call from a script of your own as well. I didnt add any way I dont
think to check the current state. The GCode library hardcodes what relays to use
with flood and mist. So I guess you could check the relay state in a script to
see if its on or off.

Art


Post Reply