Lost Step Counter
- DieselJoe
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 1
18 Oct 2018 11:59 #118988
by DieselJoe
Replied by DieselJoe on topic Lost Step Counter
I believe that when I tried to use your code I was so much not understanding what I was doing, I may have introduced mistakes.
For instance, I didn't know the correct syntax for python. I referred to what I knew from "C", where "spaces" are not important.
And as was understanding a bit more , I made few experiences, and finally wanted to know what I was doing in my linuxcnc program...
Thank you again
For instance, I didn't know the correct syntax for python. I referred to what I knew from "C", where "spaces" are not important.
And as was understanding a bit more , I made few experiences, and finally wanted to know what I was doing in my linuxcnc program...
Thank you again
Please Log in or Create an account to join the conversation.
- DieselJoe
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 1
18 Oct 2018 15:57 #119000
by DieselJoe
Replied by DieselJoe on topic Lost Step Counter
Please Log in or Create an account to join the conversation.
- MartyJ
- Offline
- Senior Member
Less
More
- Posts: 48
- Thank you received: 13
19 Apr 2020 02:14 - 19 Apr 2020 02:19 #164566
by MartyJ
Replied by MartyJ on topic Lost Step Counter
Hi all, I'm using AndyPugh's code from the first page of this thread unmodified except replacing "axis" with "joint".
I'm loading 4 counts of miss_step, it loads as a module and all four counts have created the pins:
etc for joints 0 through 3.
This works and I can see them in Halshow. But as soon as I add the following lines to my HAL, LinuxCNC won't launch.
The error I get on launch is:
Any ideas? Hoping to get this working to troubleshoot some issues I've been having. Thanks for any help!
(INI/HAl attached)
Warning: Spoiler!
#!/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 = "joint.%i.pos-cmd" %i
p2 = "joint.%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
I'm loading 4 counts of miss_step, it loads as a module and all four counts have created the pins:
miss_step.joint.0.motor-pos-cmd
miss_step.joint.0.pos-cmd
etc for joints 0 through 3.
This works and I can see them in Halshow. But as soon as I add the following lines to my HAL, LinuxCNC won't launch.
net check0 miss_step.joint.0.pos-cmd joint.0.motor-pos-cmd
net Xpos miss_step.joint.0.motor-pos-cmd
The error I get on launch is:
...
Pin 'miss_step.joint.0.pos-cmd' does not exist
337
...
Any ideas? Hoping to get this working to troubleshoot some issues I've been having. Thanks for any help!
(INI/HAl attached)
Last edit: 19 Apr 2020 02:19 by MartyJ. Reason: code formatting
Please Log in or Create an account to join the conversation.
- DieselJoe
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 1
19 Apr 2020 04:26 #164578
by DieselJoe
Replied by DieselJoe on topic Lost Step Counter
The hal links are in your "post GUI" ?
The following user(s) said Thank You: MartyJ
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23170
- Thank you received: 4860
19 Apr 2020 10:35 #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.
- MartyJ
- Offline
- Senior Member
Less
More
- Posts: 48
- Thank you received: 13
19 Apr 2020 16:06 - 19 Apr 2020 16:18 #164651
by MartyJ
Replied by MartyJ on topic Lost Step Counter
Ok, looks like that part is resolved. Move AndyPugh's:
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:
then the error I get is that x-pos-cmd isn't a pin.
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:
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: 19 Apr 2020 16:18 by MartyJ.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23170
- Thank you received: 4860
19 Apr 2020 16:24 #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
What you can't do is net a signal to a signal.
So I think you want
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.
- MartyJ
- Offline
- Senior Member
Less
More
- Posts: 48
- Thank you received: 13
20 Apr 2020 01:09 - 20 Apr 2020 01:09 #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:
And the connections in my custom_postgui.hal file:
my version of miss_step script:
#!/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:
net motoroffsetx miss_step.mot_off_x <= joint.0.motor-offset
net joint_x miss_step.joint_x <= joint.0.pos-cmd
Last edit: 20 Apr 2020 01:09 by MartyJ.
Please Log in or Create an account to join the conversation.
- Jeff_in_Wa
- Offline
- Senior Member
Less
More
- Posts: 68
- Thank you received: 5
15 Jun 2021 00:48 #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
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
- Visitor
15 Jun 2021 01:00 #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.076 seconds