Lost Step Counter

More
8 years 2 weeks ago - 8 years 2 weeks ago #118984 by DieselJoe
Replied by DieselJoe on topic Lost Step Counter
I think I made good progress during the last 12 hours...
I don't fully understand your code, but it was an inspiration.
I succeed making a code that seems to work.
Thank you a lot.
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 try: while 1: time.sleep(1) # make difference between previous offset and current offset, print the deviation if > 0.01 if (h['mot_off_x']-previous_offset_x) >= 0.01 or (h['mot_off_x']-previous_offset_x) <= -0.01: h['lost_x'] = h['mot_off_x']-previous_offset_x previous_offset_x = h['mot_off_x'] # reset deviation display if joint has moved for more than 5mm if h['joint_x'] >= 5: h['lost_x'] = 0 except KeyboardInterrupt: raise SystemExit

and the connections:
Code:
net my-motoroffsetx miss_step.mot_off_x <= axis.0.motor-offset net my-lost_x pyvcp.x-lostSteps <= miss_step.lost_x net my-joint_x miss_step.joint_x <= axis.0.joint-pos-cmd
Last edit: 8 years 2 weeks ago by DieselJoe.

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

More
8 years 2 weeks ago #118987 by andypugh
Replied by andypugh on topic Lost Step Counter
I don't understand why my code didn't just work for you, it worked when I tested it.
Perhaps the problem was that it was working perfectly and you had no problems? My version only pops-up the message when the homing offsets change.

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

More
8 years 2 weeks ago #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

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

More
8 years 1 week ago #119000 by DieselJoe
Replied by DieselJoe on topic Lost Step Counter

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

More
6 years 6 months ago - 6 years 6 months ago #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".

Warning: Spoiler!


I'm loading 4 counts of miss_step, it loads as a module and all four counts have created the pins:
Code:
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.
Code:
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:
Code:
... 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)
Attachments:
Last edit: 6 years 6 months ago by MartyJ. Reason: code formatting

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

More
6 years 6 months ago #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.

Time to create page: 1.853 seconds
Powered by Kunena Forum