System variable for current Z machine position
- emcPT
- Topic Author
- Offline
- Platinum Member
- Posts: 698
- Thank you received: 138
I am writing a subprogram to suit my machine and I need to get the current Z machine position.
Looking at:
linuxcnc.org/docs/html/gcode/overview.html, I would use:
#<_z> - Return current machine Z coordinate. Same as #5422.
I tested using 5022 or 5422, but both return the actual relative position, not the machine position that I am looking for.
Would this be a bug or am I looking at the wrong variable?
I am using a custom 2.6 pre
Thank you
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
- Posts: 25
- Thank you received: 761
I think it is a case of imprecise phraseology
5420-5428
Current Position including all offsets and in the current program units for X, Y, Z, A, B, C, U, V & W, volatile.
5422 returns the current relative position in the active co-ordinate system I believe, so it definately does not return machine position despite
what this says
#<_z> - Return current machine Z coordinate. Same as #5422.
I have never needed to access actual machine position from gcode and was rather surprised to find there was no set of parameters for it,
unless I too cannot see them.
You can get machine position programmatically from halui.axis.n.pos-commanded (float, out) - Commanded axis position in machine coordinates
but that does not assist you much.
One way would be to touch off one of the co-ordinate systems to 0,0,0 at home and then it will mirror machine position and you can use that
regards
Please Log in or Create an account to join the conversation.
- emcPT
- Topic Author
- Offline
- Platinum Member
- Posts: 698
- Thank you received: 138
I will wait a bit more to see if there is anyone using it (maybe it already exists). If not I will think about possible turnarounds but yours is quite good: "One way would be to touch off one of the co-ordinate systems to 0,0,0 at home and then it will mirror machine position and you can use that"
Please Log in or Create an account to join the conversation.
- Rick G
- Offline
- Junior Member
- Posts: 28
- Thank you received: 156
Please Log in or Create an account to join the conversation.
- emcPT
- Topic Author
- Offline
- Platinum Member
- Posts: 698
- Thank you received: 138
Please Log in or Create an account to join the conversation.
- BigJohnT
- Offline
- Administrator
- Posts: 7330
- Thank you received: 1177
Hi
I think it is a case of imprecise phraseology
5420-5428
Current Position including all offsets and in the current program units for X, Y, Z, A, B, C, U, V & W, volatile.
5422 returns the current relative position in the active co-ordinate system I believe, so it definately does not return machine position despite
what this says
The description is more precise now
JT
Please Log in or Create an account to join the conversation.
- alan_3301
- Offline
- Elite Member
- Posts: 258
- Thank you received: 33
Then subtracting the correct parameter #5211 through #5219 or #5221 through #5390 from #5420 - #5428.
what do you think?
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
- Posts: 23560
- Thank you received: 4858
I tested using 5022 or 5422, but both return the actual relative position, not the machine position that I am looking for.
A roundabout way to get machine absolute position is to perform a G30.1 then read #5183
www.linuxcnc.org/docs/html/gcode/gcode.html#sec:G30-G30_1
Please Log in or Create an account to join the conversation.
- Rick G
- Offline
- Junior Member
- Posts: 28
- Thank you received: 156
G91 G38.3 Z.00001
#1001=#5061
#1002=#5062
Or as Alan suggested if you know what coordinate system you are going to work in work with the parameter and the offset.
Rick G
Please Log in or Create an account to join the conversation.
- emcPT
- Topic Author
- Offline
- Platinum Member
- Posts: 698
- Thank you received: 138
I tested using 5022 or 5422, but both return the actual relative position, not the machine position that I am looking for.
A roundabout way to get machine absolute position is to perform a G30.1 then read #5183
www.linuxcnc.org/docs/html/gcode/gcode.html#sec:G30-G30_1
This was the most straight forward method, so I believe I will use it.
Thank you
Please Log in or Create an account to join the conversation.