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:

  Ive confirmed some of this and fixed it already. It seems I added a few bugs in adding probing,
and in the case of GetTruePos , I had never used it so I missed a section I should have rem'ed out
to stop offset comp. , I will put out a new version tomorrow after I run some verification tests.

Thx
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:

  New Auggie is online..

Notes:

  I found and fixed a problem with Probehit and with syncing after a probe. Problem was
the planner was syncing before the final position was read. I tested this with a script..

Engine.GCode("G31X50");
block("MotionStill");
if( GlobalGet("ProbeHit") )
{
  print("Probe was hit");
}
else
{
print("Probe not hit");
}
Engine.GCode("G1X0");

  It is consitant and shows probehit or not, and always returns to
0.
  I cant repeat the homing issue, mine homes and reads all zero's afterwards.
The work coordinates seem to be fine here, I tested with a script that
moved from -3 to 3 three times. It stops at 3.0 , if I then zero the script
still moves from -3 to 3 as new coordinated. Work coordinates are the normal view,
the machine coordinates are the raw coordinates the pokeys sees itself at, the
work coordinates are, like in mach3, just that with offsets applied.

Let me know how you make out..

Art


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

Re: reading Pokeys pins

Post by gburk »

Ok Seems good haven't run a lot of test but no problem now when axis runs to end with out a probe hit I tested your code in the script run..

and I ran this thought global with a button press it also ran good no problem, running and returning to 1,
still have to run the script in the script run before It will run with a button press but now I only have to run it once, so that's good, but is there a way so it doesn't have to loaded into the script edit and run first?.

I had to invert my probe other wise it was always  triggered,,

also when probe is hit the axis doesn't stop dead it moves past the probe hit, it looks like enough to crash into the switch's..
will test some more with some added code to see if backing off will  see the switch being released ok.

I'm using Inch not metric.. hence the different numbers from you code.
 
global ZeroToPlate = function()
{
print("probe test");
GlobalSet("ProbeInvert",0);
Engine.GCode("G31 X-3 F100");
block("MotionStill");
if( GlobalGet("ProbeHit") )
{
  ProbePos = Engine.GetAxisPos( 1 ); // Get probe position
  print("Probe Position = ",ProbePos); // show probe position
  print("Probe was hit");
}
else
{
print("Probe not hit");
};
Engine.GCode("G1X1");
};

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

Re: reading Pokeys pins

Post by gburk »

Art

Ok the problem I'm having is - if I have a touch off  plate say .250 thick now I probe to plate then set axis dro to .250 at plate  then I want to retract to 1.0 when I do a g1 x1 it go's to 1.6 even higher over 2.0, it seems not to know its sitting at .250 after I set the dro to .250, if I remember right that would work in mach3 or you could set axis to 0.0 and move touchplate - 1.. then set dro to 1, making any sense?.

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:

>>also when probe is hit the axis doesn't stop dead it moves past the probe hit, it looks like enough to crash into the switch's..will test some more with some added code to see if backing off will  see the switch being released ok.

  This is typical with probes. You dont want to simply stop, steps could be lost. So typically when the
probe is hit, it trips to a deceleration phase, then stops. That why if you then get the probe hit points
from a script you'll see they are not the final rest position. Two things you can do for that is to either
probe at a lower feedrate, or set axis acceleration to a higher value.

    Normally Auggie is 6th order for motion, BUT when a probe trips to hit status during a probe,
the pokeys switches to internal planner and slows down based on the setting of accel. Its a mach3
type of bang bang slowdown trajectory. The slower you go the faster you stop.

  That why typically one would feed in a little quick, the plate would be on a spring so allow for the
slight crash, and then you'd withdraw very slowly to stop one step within leaving the plate.That would
be considered zero.

>>k the problem I'm having is - if I have a touch off  plate say .250 thick now I probe to plate then set axis dro to .250 at plate  then I want to retract to 1.0 when I do a g1 x1 it go's to 1.6 even higher over 2.0, it seems not to know its sitting at .250 after I set the dro to .250, if I remember right that would work in mach3 or you could set axis to 0.0 and move touchplat e - 1.. then set dro to 1, making any sense?.


  That ones weird. I specifically tested that here to ensure it still moved to proper position
after a hit. Yes, you should be able to set the dro to .250 and then G1 to x0; Ill test that
again tomorrow to see what might be going on. This is on the work coordinates tab right?
Not the machine coords tab? Sounds like we're close anyway...


Art

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

Re: reading Pokeys pins

Post by gburk »

Art

>This is on the work coordinates tab right?
>Not the machine coords tab? Sounds like we're close anyway...

Yes word cords,
also I don't think I can read the mach cords in a script I think I had said this one before

if I use gettruepos not sure if command is correct don't rem off top of my head but it returns the same value as the getaxispos work cords ,,

I will try slowing probe down, and or a higher acceleration..

when probe is it are you returning the probe position with a call, or just using getaxispos?,,


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 »

Gary:

I should have mentioned, I fixed also the GetTruePos() to give you back the machine coordinates.
When you probe, if it hits the end position is the actual stop position not the probe position.
To get the probe hit position, you call GetGlobal("ProbePos0"); (for x)

  After the axis has decelerated, the planner position is set to the last position of actual motion.
If you wish to go to the point it hit at, you should be able to do a g1 move to the ProbePos0 in
your case. Take note the probe may or may not unactivate as that point in space will be the trigger
position of the probe switch so various factors may make it too close to release.

  It sounds to me like you may be hitting some sort of race condition where the last coordinate
hasnt updated to the planner before calling for the G1 after the probe. You might want to add
a yield(); just before the g1. A yield is just a way of lettign auggie catch up with any tasks its
doing so if one suspects your going to fast in commands, a block for "motionstill" or a yield()
is a good way to make sure things sync up.. It may not help, but as I found mine to be accurate
each time I think it may be the speed of my system vs yours perhaps. This type of thing is hard
to find  but there are many threads running doing various tasks so I worry about syncing at
times , and a yield may help.

  psuedo code example..
{
  Engine.GCode("G31X10F50");
  block("MotionStill");
  if( GlobalGet("ProbeHit")
    {
      yield();
      ProbePos = GlobalGet("ProbePos0");
      Engine.GCode("G1X" + ProbePos );
      print( "Probe Successfull. Zero Me.");
  }
  else
  {
      print( "Probe Failed.Too far away, zero me and try again.");
  }
     

}


Art


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

Re: reading Pokeys pins

Post by gburk »

Art

Set the probe speed lower and its a lot better, should be good enough not to go way past the end stop..

You are mostly right the system is not updated fast enough now that the probe is running slower, I can see it better looks like if probe is hit at -0.430 or so when I do a g1 x1 it retracts to +1.4 or so for some reason it seems to be adding the current pos to the 1 for retract make sense ?

will test the new stuff..

tested you code work good but I added so to set axis to .250 and the retract to 1 but still go's past one to 1.3 or more heres the code maybe I am doing something wrong still added another yield for testing but made no difference..

also looks like gettruepos is working now.

  GlobalSet("ProbeInvert",0);
  Engine.GCode("G31 X-3 F10");
  block("MotionStill");
  if( GlobalGet("ProbeHit"))
    {
    yield();
    ProbePos = GlobalGet("ProbePos0");
    Engine.GCode("G1X" + ProbePos );
    block("MotionStill");
    xpos = Engine.GetAxisPos( 1 );
    print("Probe Successfull. Zero Me. "+xpos+"  probe pos "+ProbePos);
    Engine.SetAxisPos( .250, null, null, null );
    yield();
    Engine.GCode("G1 X1 F50");
    block("MotionStill");
  }
  else
  {
    print("Probe Failed.Too far away, zero me and try again.");
  }
   

Gary


Gary 
Last edited by gburk on Fri Mar 15, 2019 5:15 pm, edited 1 time in total.
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

  Try this script for me. I ran it several times with probe hit and no probe hit, it returns to X=0 every time.
Id like to know if your does different. There's a bit of a dance going on when a probe is hit. First, the program stops motion.It clears the planner of any subsequent moves. It then flags the system to refresh the planners current position to wherever it stopped. The next move in the script is to move to x=0.

  Now if the move to x=0 happens before the probe internals have reset the planner, it may still think its at
the last commanded position, which is the norm. This means if the probe stopped you at x= .5, but didnt set the planner to .5, it will still think your last move ended at X10, or whatever the stop was. So a move to x1 may move 9 units up. But if the planner knows it stopped at .5, then it should move only .5 to get to zero.Your symptoms seem to show its stopping on the probe, but not resyncing to the actual position the
machine coordinates are now at. Im just not sure why mine works..but perhaps both of ours work
on this script but fail on yours. Let me know what this simple script does..



Engine.GCode("G31X10");
block("MotionStill");
if( GlobalGet("ProbeHit") )
{
  print("Probe was hit");
}
else
{
print("Probe not hit");
}
Engine.GCode("G1X0");

  Does it always end at x=0 on the work coordinate display?

Thx
Art

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

Re: reading Pokeys pins

Post by gburk »

Art

ran the script 10 or 15 times let it run to end 5 time always returned to 0, hit probe at different distances and always returned to 0

then added the line to set axis position to .250, let it run to end g31x10 then set the position to .250 so now axis position is set to .250 and then the g1x0 runs  but go's past 0  to -9.9498.

so far as I can tell right now its good endless you reset the work position from where it stops. does the same thing if you hit the probe but stops at different - positions I assume it reversing to the - value from the probe hit so if I hit the probe at 3.467 when  axis reset to .250 it travel's to -3.467 not exactly the back distance but in the area

hope this helps a little

thanks gary
Post Reply