reading Pokeys pins

C Scripting questions and answers
Post Reply
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

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
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4647
Joined: Sun Sep 05, 2010 6:14 am
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
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

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 6:15 am, edited 1 time in total.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4647
Joined: Sun Sep 05, 2010 6:14 am
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
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

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

Re: reading Pokeys pins

Post by ArtF »

Gary:

Thx, that points to the error, I must not be resetting the planner after the scripted Axis position
set. Ill fix that up. Thx for your tests, when I wrote Auggie I put in a lot of code that has never
been tested, I added it just in case. Much of this problem seems related to simply being
untested code.  Comes from writing a controller in a year. :)

Ill let you know when the fix is online.

Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Ok thanks

Hopefully you have some code to read the encoder pins13  I would like to be able to setup the pin for spindle index  1 rev per if possible.
and also be able to  use pin17 for pwm output 0-10v for the spindle speed  control.. but first things first lets get probing going first..

I know I keep bring this up but is there a way to get the global script running so I don't have to run it first in the script edit then use the button.

Thanks gary
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4647
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

  I believe you can poll the encoder counts from the pokeys, but I dont think you can
the index. Ill have to look up what information the pokeys sends back on that.

  You can use any PWM channel you like. Examples of that are in the laser control
library as I use that library to control pwm power for the lasers.

As to the problem with the script having to be run before the button call to it will
function, Im still not sure whats going on there. I'll take a look to see how one of mine
works and perhaps we can figure why yours doesn't mimic it..

Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

I don't own a laser so that Greek to me right now...

I did look at the laser lib didn't see anything for pwm only turning on and off relays for air blow?

looked in the gcode lib that had some on pwm spindle speed don't look like its functional and looks like you need a real high spindle speed over 25000 to get it to return a value other than 0 not sure on how you are sending the pwm pulse. I'm used to just sending m3 s3600, or similar. right now I do have m3 and m8 working for turning on the spindle relay and coolant and m5 and m9 to turn off relays.

I thought I read some where that you are using motor 8 for laser control, I may be wrong.

I think pin17 is just a pwm pin for 0 to 10 v output I tried setting pin17 but haven't any luck changing the voltage output...

But this is a later problem  :-\

One thing at a time first probing, we are almost there, just a couple things not quite right, but I know you will get it...

Gary
 
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4647
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

Just uploaded a new Auggie that should rest the planner after you use SetAxisPos so that
subsequent moves do not overrun. Let me know if this fixes the current script problem.

I use motor channel 8 for realtime pwm control, but this isn't how you'd do it for a spindle,
in that case youd call the PWM script calls to set up a channel , a base frequency and an output
level. We'll go into that after this probing is all settled..

Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Ok will test it out

I think the PWM channel is 5 if I'm reading things right but after probing is going...

Gary
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

Here is some numbers I am getting all are with g31 x-3 and retract after probe is hit I set the axis to .250,  then do a g00 x1

Probe run started at 0  - hit at -.3955  reset to .250 retracted to  0.6255          - started at positive hit at negative ended at positive
Probe run started at .6455  - hit at -.3802  reset to .250 retracted to  1.2758    - started at positive hit at negative ended at positive
Probe run started at 1.2758 - hit at -.2863  reset to .250 retracted to  1.8120    - started at positive hit at negative ended at positive
Probe run started at 1.1820 - hit at +.5002  reset to .250 retracted to  1.5681  - started at positive hit at positive ended at positive

Seems close to before I think is there a way to tell if the version of auggie has changed....

I thought I left a message last night about this but don't see it, that's a good thing I was having all kinds of problems last night
estop getting triggered off every time I had the line to setaxispos(.250) in the code, if I removed it all was good, now decided to try again tonight and I don't seem to be having the problem maybe I was having a computer gulch …

looked at the way I have mach4 setup for my spindle I am using ob5(10) step/dir and ob5(10) set to motor5 with the smoothstepper


Thanks gary

User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4647
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

  Thx, I neglected to update the version number. Ill have to do some checking to see why its the same.
Ill be away though until a week from Monday getting some sun. Ill fix this up when I return;
It does look like nothing changed.. which is odd as I reset the last position during any SetAxisPos call..

Sorry for the delay on this reply, I didn't get a message on this post for some reason.

Sounds like your driving your spindle with step pulses from Mach3, if so we'll set it on
an axis and use the FreeAxis calls to simply set a frequency. That can be added into
the spindle off and on calls as far as making the spindle work at any frequency. The FreeAxis
axis ( 4 of them) can be used individually at any frequency output and can be left as simply
frequency instead of step counts.

Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Ok Thanks

Your coming to the sun i'd like to get out of the sun, been getting way to hot for me in the summer and winter! down here in Florida can't even work in the garage most of the time.

have a great trip...

gary
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4647
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

Im freezing..  .. Be back in a week..

Art
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest