Lost Step Counter

More
6 years 6 months ago #164620 by andypugh
Replied by andypugh on topic Lost Step Counter
Possibly you need "loadusr -W" in the line that loads the component, so it waits for the component to be loaded before moving on to the rest of the HAL file.
The following user(s) said Thank You: MartyJ

Please Log in or Create an account to join the conversation.

More
6 years 6 months ago - 6 years 6 months ago #164651 by MartyJ
Replied by MartyJ on topic Lost Step Counter
Ok, looks like that part is resolved. Move AndyPugh's:
Code:
net check0 miss_step.joint.0.pos-cmd joint.0.motor-pos-cmd net Xpos miss_step.joint.0.motor-pos-cmd

lines to being in the postgui HAL file.

The error is now that the pin "joint.0.motor-pos-cmd" is already connected to the signal 'x-pos-cmd' which is part of my main HAL setup. Is there a way to do this using the "x-pos-cmd" signal, my understanding being that once the signal is set up, we can use it many times?

If I change it to this:
Code:
net check0 miss_step.joint.0.pos-cmd x-pos-cmd net Xpos miss_step.joint.0.motor-pos-cmd

then the error I get is that x-pos-cmd isn't a pin.
Last edit: 6 years 6 months ago by MartyJ.

Please Log in or Create an account to join the conversation.

More
6 years 6 months ago #164654 by andypugh
Replied by andypugh on topic Lost Step Counter
The signal is always the first thing after a net. But you can use the same signal in many net commands.

What you can't do is net a signal to a signal.

So I think you want
Code:
net x-pos-cmd miss_step.joint.0.pos-cmd
The following user(s) said Thank You: MartyJ

Please Log in or Create an account to join the conversation.

More
6 years 6 months ago - 6 years 6 months ago #164705 by MartyJ
Replied by MartyJ on topic Lost Step Counter
Thanks, gents. Much appreciated. I got this going, I just view them with Halmeter, and it's helped me diagnose some step timing issues.

my version of miss_step script:
Code:
#!/usr/bin/python import hal, time h = hal.component("miss_step") h.newpin("mot_off_x", hal.HAL_FLOAT, hal.HAL_IN) h.newpin("joint_x", hal.HAL_FLOAT, hal.HAL_IN) h.newpin("lost_x", hal.HAL_FLOAT, hal.HAL_OUT) h.ready() previous_offset_x = 0.00 allowed_offset = 0.001 try: while 1: time.sleep(1) # X # make difference between previous offset and current offset, print the deviation if > specified if (h['mot_off_x']-previous_offset_x) >= allowed_offset or (h['mot_off_x']-previous_offset_x) <= -allowed_offset: h['lost_x'] = round(h['mot_off_x']-previous_offset_x, 3) previous_offset_x = h['mot_off_x'] except KeyboardInterrupt: raise SystemExit

And the connections in my custom_postgui.hal file:
Code:
net motoroffsetx miss_step.mot_off_x <= joint.0.motor-offset net joint_x miss_step.joint_x <= joint.0.pos-cmd
Last edit: 6 years 6 months ago by MartyJ.

Please Log in or Create an account to join the conversation.

More
5 years 4 months ago #212082 by Jeff_in_Wa
Replied by Jeff_in_Wa on topic Lost Step Counter
So, I have spent a lot of time trying to get the original code to work using gmoccapy. I have it working but with unexpected results.

When I home the machine, I get the message box which shows the value in X. Perfect.

I thought, great, now I can load some gcode, run it and see which axis is having problems.

When I move the gantry to set up the 0,0,0 points, the machine takes off on it's own. A miss_step message box
pops up with some random number.

I can't even stop the jog unless I hit the e stop.

I thought, maybe this is a compatibility issue with gmoccapy. Maybe not.

Here is my code:

miss_step file:

#!/usr/bin/python
import hal, time
import sys
from Tkinter import *
import tkMessageBox

root = Tk()
root.withdraw()
h = hal.component("miss_step")

count = 1
for opt in sys.argv[1:]:
(dummy, count) = opt.split("=")
if dummy != "count":
count = 1

pins = []
for i in range(int(count)):
p1 = "axis.%i.pos-cmd" %i
p2 = "axis.%i.motor-pos-cmd" %i
d = 0
t = [p1, p2, d]
pins.append(t)
h.newpin(p1, hal.HAL_FLOAT, hal.HAL_IN)
h.newpin(p2, hal.HAL_FLOAT, hal.HAL_IN)

h.ready()
try:
flag = False
while 1:
time.sleep (1)
for t in pins:
if h[t[0]]-h[t[1]] != t[2]:
flag = True
t[2] = h[t[0]]-h[t[1]]
if flag == True:
flag = False
message = ""
for t in pins:
message = message + t[0] + " = %f\n"%t[2]
ret = tkMessageBox._show("Homing Position Differs",
message,
tkMessageBox.QUESTION, tkMessageBox.OK)
root.update()
except KeyboardInterrupt:
raise SystemExit

---

Here is my custom_postgui.hal code:

# -- AndyPugh zero checker connections
#net check0 miss_step.axis.0.pos-cmd axis.x.pos-cmd
#net Xpos miss_step.axis.0.motor-pos-cmd

---

Here is the custom.hal code:

#loadusr -W /home/jeff/Desktop/Mauer-Mill/miss_step count=3

---

I not only cannot get this code to work without taking over the machine during jogs, but wonder if
there is a way to monitor the two Y joints? I don't have any idea how to do that. It is there that I
am having problems. X and Z are fine. I can't keep the two Y's on my gantry machine to stay in sync.

Thanks much

Please Log in or Create an account to join the conversation.

  • BeagleBrainz
  • New Member
  • New Member
More
5 years 4 months ago #212084 by BeagleBrainz
Replied by BeagleBrainz on topic Lost Step Counter
I made a reply in the other thread, mentioning you may need to look at joints rather axes (plural of axis)

Please Log in or Create an account to join the conversation.

Time to create page: 0.470 seconds
Powered by Kunena Forum