How do I read current system variable into my Gcode program?
15 Feb 2018 00:04 #105965
by waxelson
Replied by waxelson on topic How do I read current system variable into my Gcode program?
Rod,
Yes, but first let me summarize the situation.
I have a large telescope mirror spinning at 35 PRM on a platform that can be moved in and out using the Y-axis, although it is kept fixed during polishing. Above the mirror surface, the Z-axis has a rapidly spinning polishing pad on the tool spindle.
To polish an optic, the machine does a long series of coordinated moves in X and Z that allows the pad to trace the exact profile of the optical surface, as the mirror spins below. Each X value has a unique Z value associated with it. This Z value at X can be labeled as "Zx".
When the polishing head is "up", a fixed positive offset is added to Zx, to cause it to raise the polishing pad above the current surface position. When the polishing head is "down", a fixed negative offset is "added" to Zx, to cause it to press into the surface with a predetermined amount of force.
There is one revolution of the optic on the spinning platform (the U-axis) for each move in the X direction. On every revolution, there are alternating zones where the pad should be alternately up and down. Typically, there are two work zones where the pad needs to be down. The rest of the time it must be up.
So, if I could know exactly where the rotating platform was at any moment, I could command the Z-axis up or down appropriately. How can I get that parameter value in realtime?
Thanks,
Wayne
Yes, but first let me summarize the situation.
I have a large telescope mirror spinning at 35 PRM on a platform that can be moved in and out using the Y-axis, although it is kept fixed during polishing. Above the mirror surface, the Z-axis has a rapidly spinning polishing pad on the tool spindle.
To polish an optic, the machine does a long series of coordinated moves in X and Z that allows the pad to trace the exact profile of the optical surface, as the mirror spins below. Each X value has a unique Z value associated with it. This Z value at X can be labeled as "Zx".
When the polishing head is "up", a fixed positive offset is added to Zx, to cause it to raise the polishing pad above the current surface position. When the polishing head is "down", a fixed negative offset is "added" to Zx, to cause it to press into the surface with a predetermined amount of force.
There is one revolution of the optic on the spinning platform (the U-axis) for each move in the X direction. On every revolution, there are alternating zones where the pad should be alternately up and down. Typically, there are two work zones where the pad needs to be down. The rest of the time it must be up.
So, if I could know exactly where the rotating platform was at any moment, I could command the Z-axis up or down appropriately. How can I get that parameter value in realtime?
Thanks,
Wayne
Please Log in or Create an account to join the conversation.
15 Feb 2018 02:19 #105967
by rodw
Replied by rodw on topic How do I read current system variable into my Gcode program?
I don't know enough about the LCNC internals but I would think it would be easy enough to write a component that took
axis.X.teleop-pos-cmd as an input and if it had changed since last call to the servo thread, update the Z position (possibly with an NML command) The plasma torch height stuff does something similar but receives a voltage as input. Yours is much simpler as you know exactly where Z should be but look at the THC and THCUD component for inspiration.
github.com/LinuxCNC/linuxcnc/blob/master.../components/thc.comp
github.com/LinuxCNC/linuxcnc/blob/master...omponents/thcud.comp
axis.X.teleop-pos-cmd as an input and if it had changed since last call to the servo thread, update the Z position (possibly with an NML command) The plasma torch height stuff does something similar but receives a voltage as input. Yours is much simpler as you know exactly where Z should be but look at the THC and THCUD component for inspiration.
github.com/LinuxCNC/linuxcnc/blob/master.../components/thc.comp
github.com/LinuxCNC/linuxcnc/blob/master...omponents/thcud.comp
Please Log in or Create an account to join the conversation.
15 Feb 2018 21:43 #105993
by waxelson
Replied by waxelson on topic How do I read current system variable into my Gcode program?
Rod,
Thanks!
I am taking a look...
Wayne
Thanks!
I am taking a look...
Wayne
Please Log in or Create an account to join the conversation.
15 Feb 2018 22:38 - 15 Feb 2018 22:38 #105996
by rodw
Replied by rodw on topic How do I read current system variable into my Gcode program?
Wayne, I got that wrong. I had another look as I want to use this myself.
axis.z.pos-cmd gives absolute position on the axis ignoring any touch offs or G92's etc
I think you need the relative position
halui.axis.z.pos-relative
axis.z.pos-cmd gives absolute position on the axis ignoring any touch offs or G92's etc
I think you need the relative position
halui.axis.z.pos-relative
Last edit: 15 Feb 2018 22:38 by rodw.
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
16 Feb 2018 13:11 #106013
by Todd Zuercher
Replied by Todd Zuercher on topic How do I read current system variable into my Gcode program?
I'm not so sure that this wouldn't be best/easiest just done in g-code?
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
16 Feb 2018 13:29 #106014
by Todd Zuercher
#2 Sounds to me like a scaling issue. It sounds like you have the axis scaled in steps or counts per revolution. If you want it in degrees you need to scale it in counts per degree (divide your scale setting by 360.)
#3 yes it will work that way if you have it scaled in degrees rather than revolutions, see #2.
Replied by Todd Zuercher on topic How do I read current system variable into my Gcode program?
#1 Theoretically it should work either way, but I do know in the past Linuxcnc has struggled with using a rotary axis as linear or visa-versa.Tod,
In a recent response to Grotius you said:
"If you want accurate updates of hal pin values to use in your g-code file it much more reliable to use motion digital in and analog in hal pins and M62-M68 commands get those values into g-code parameters."
I think this approach could work for me as well, if I could get my rotary axis under better control. Right now I am able to spin it at a constant rate (thanks to help from you a few weeks ago... using the M68 E0 Qx.x command but I cannot command it to a position.
1) If I was to reconfigure my rotating platform to be axis 'C' (a "proper" angular axis in linuxcnc) instead of 'U' (a secondary linear axis...), would I get better angular control?
2) Currently, the u_pos_fb parameter displays values in cumulative decimal angles instead of degrees (0 to 359.99). So, after more than 241 revolutions, the value reads something like "241.5342", which is problematic. This is despite the fact I have WRAPPED_ROTARY = 1, which the documentation says should produce values between 0 and 359.99.
3) If an angular axis is properly configured, is it possible to send it to a specific angle? Something like:
G1 C40 F5 (Move the C rotary axis to 40 degrees at 5 degrees/sec)
4) If all this can be made to work, I should be able to do what I need to do using Gcode something like this:
G1 C40 F5 (Move the C rotary axis to 40 degrees at 5 degrees/sec)
M64 P0 (Move the Z-axis into contact)
G1 C100 F5 (Move the C rotary axis to 100 degrees at 2 degrees/sec)
M65 P0 (Lift the Z-axis away from contact)
Is this possible?
Thanks again for all your help...
Wayne
#2 Sounds to me like a scaling issue. It sounds like you have the axis scaled in steps or counts per revolution. If you want it in degrees you need to scale it in counts per degree (divide your scale setting by 360.)
#3 yes it will work that way if you have it scaled in degrees rather than revolutions, see #2.
Please Log in or Create an account to join the conversation.
16 Feb 2018 19:13 #106038
by waxelson
Replied by waxelson on topic How do I read current system variable into my Gcode program?
Tod,
1) I have changed the hal.file to make the rotating platform be the 'C' axis rather than 'U'. But I haven't seen any difference in operation, yet.
2) Yes, I could change the scaling to represent degrees of rotation rather than number of revolutions but I would still have the problem of "c-pos-fb" displaying the total cumulative degrees, rather than just the current angle between 0 and 359.99. My WRAPPED_ROTARY = 1 setting should do this but it is not. Is there something else I need to change to switch from cumulative degrees to current angle?
3) If I was to integrate Rod's suggestion and examine the parameter "halui.axis.c.pos-relative" to obtain the current angle of 'C', what syntax do I use in Gcode to refer to that parameter?
4) But doesn't halui reside of the non-realtime portion of the system? I assume the "angle of C" value must exist in the realtime module EMCMOT. How can I access that value and coordinate moves in Z with it in realtime?
Thanks,
Wayne
1) I have changed the hal.file to make the rotating platform be the 'C' axis rather than 'U'. But I haven't seen any difference in operation, yet.
2) Yes, I could change the scaling to represent degrees of rotation rather than number of revolutions but I would still have the problem of "c-pos-fb" displaying the total cumulative degrees, rather than just the current angle between 0 and 359.99. My WRAPPED_ROTARY = 1 setting should do this but it is not. Is there something else I need to change to switch from cumulative degrees to current angle?
3) If I was to integrate Rod's suggestion and examine the parameter "halui.axis.c.pos-relative" to obtain the current angle of 'C', what syntax do I use in Gcode to refer to that parameter?
4) But doesn't halui reside of the non-realtime portion of the system? I assume the "angle of C" value must exist in the realtime module EMCMOT. How can I access that value and coordinate moves in Z with it in realtime?
Thanks,
Wayne
Please Log in or Create an account to join the conversation.
16 Feb 2018 21:43 #106045
by rodw
Replied by rodw on topic How do I read current system variable into my Gcode program?
Wayne, sorry about suggesting halui. There are other real time pins but the ones I found only report absolute coordinates. Perhaps you can use the halui reading at the start of a run to calculate the offset to apply to the absolute coordinates.
I just had a look at an A axis on one of my configs and it increments past 360 as well with or without wrapped rotary enabled. I don't have a motor attached, maybe its changing it to count in degrees vs revs or something.
You can work around this with some maths. It would be a bit messy in hal but should be doable, easy in a component.
This current thread is trying to do something similar to what you are wanting to do (adjusting an axis position on the fly.)
forum.linuxcnc.org/10-advanced-configura...-correct-axis-errors
It will be interesting to see if it works. But its only adjusting absolute units.
You can use M67/M68 to set a pin used by a component from Gcode. If you also want to change it on the console it gets a bit more complicated as you need to send the result of M68 to a pin in your screen handler so it can access and act on.
I just had a look at an A axis on one of my configs and it increments past 360 as well with or without wrapped rotary enabled. I don't have a motor attached, maybe its changing it to count in degrees vs revs or something.
You can work around this with some maths. It would be a bit messy in hal but should be doable, easy in a component.
This current thread is trying to do something similar to what you are wanting to do (adjusting an axis position on the fly.)
forum.linuxcnc.org/10-advanced-configura...-correct-axis-errors
It will be interesting to see if it works. But its only adjusting absolute units.
You can use M67/M68 to set a pin used by a component from Gcode. If you also want to change it on the console it gets a bit more complicated as you need to send the result of M68 to a pin in your screen handler so it can access and act on.
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
16 Feb 2018 23:22 #106052
by Todd Zuercher
Replied by Todd Zuercher on topic How do I read current system variable into my Gcode program?
For the wrapped rotary to work the axis must be scaled in degrees. If it is in revolutions it won't wrap until 360 revs.
Please Log in or Create an account to join the conversation.
16 Feb 2018 23:53 #106055
by waxelson
Replied by waxelson on topic How do I read current system variable into my Gcode program?
Todd,
Thanks!
That makes perfect sense.
I will give it a try...
Thanks again,
Wayne
Thanks!
That makes perfect sense.
I will give it a try...
Thanks again,
Wayne
Please Log in or Create an account to join the conversation.
Time to create page: 0.408 seconds