Read axis position

More
19 Apr 2011 21:26 #9127 by ioiotutu
Read axis position was created by ioiotutu
Hi,
is it possible read axis position into a program?

I would read axis X position in a soubroutine to send different M-codes if the X axis is in a special position:


O102 if [X-position>200]
M101
G0A100
O102 else
M102
G0A-100
O102 endif

Thanks.

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

More
20 Apr 2011 18:40 #9188 by andypugh
Replied by andypugh on topic Re:Read axis position
Yes, you can do that.

Which version of EMC2 are you using?

If you are on a recent version, then you can use #5420 for X, #5421 for Y etc.

With the older versions you can play a bit of a trick with G92. You offset the coordinates to make the current position 0,0,0, read out the G92 offset parameters, and the cancel the offset.

G92 x0 y0 z0 (store position)
g92.2
#1 = #5211 (starting X)
#2 = #5212 (starting Y)
#13 = #5213 (starting Z)
g92.1

However, check if #5420 works first. You can just type
(debug, #5420)
in the MDI tab and see if the number printed matches the current X. (don't forget the comma!)

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

More
20 Apr 2011 20:33 #9200 by ioiotutu
Replied by ioiotutu on topic Re:Read axis position
Thanks,
my version is 2.4.6, but if i type (debug,#5421) the answer is "######"

Work fine the G92 version that you suggest, also if it is a little complicate.
I found another solution with G28.1 and the variables #5161-#5166.

with my version is it possible read the position directly from variables?

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

More
20 Apr 2011 21:47 #9203 by andypugh
Replied by andypugh on topic Re:Read axis position
Be careful, G28 uses the Absolute (G53) coordinate frame. If you have any work offsets it will be wrong.

(That is why I ended up using G92)

#5420 etc is a V2.5 version. I believe that is available as an update from the buildbot, though I have never done it that way.

(Bear in mind that 2.5 is not actually released yet)

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

More
21 Apr 2011 11:42 #9219 by piasdom
Replied by piasdom on topic Re:Read axis position
what's the differences between g92 and g54..g55.g56...etc?
usually i have to cut pockets side by side(4 or 8) and used g92 in earlier version
and found it very hard for me. so i haven't used it since.

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

More
21 Apr 2011 13:28 #9222 by andypugh
Replied by andypugh on topic Re:Read axis position
G92 is a temporary offset controlled from within G-code and will tend to be used and reset within a single G-code file.

Typically the G54, 55 etc coordinate systems will remain constant for days or years, being (say) the left and right sides of a vice, the top of a table, the centre of a rotary table etc.

But, it's your machine, you can use it any way you like.

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

More
21 Apr 2011 13:43 #9224 by piasdom
Replied by piasdom on topic Re:Read axis position
well, i tried g92(attached) but i can't get it to do me right :)
i'll offset, but i have to offset it at -1.9 instead of positive 1.9.
and in the file, it cuts one time and at z-.04. the finished depth
is z-.3 in the file.

File Attachment:

File Name: while.ngc
File Size:1 KB
Attachments:

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

More
21 Apr 2011 15:49 #9228 by andypugh
Replied by andypugh on topic Re:Read axis position
G92 X1.9 means "The current position has an X coordinate of 1.9"

So, if you want cutting to start 1.9" to the right, you can either go to the new point and G92 X0, or stay where you are and say "this is now -1.9, carry on at zero"

A typical use would be a subroutine to cut out a D-sub hole. the calling routine would position the cutter at the centre of the shape, then the subroutine would G92 X0 Y0 and then cut the shape with all coordinates referenced to the centre of the cutout, then G92.1 on exit.

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

More
21 Apr 2011 17:55 #9236 by piasdom
Replied by piasdom on topic Re:Read axis position
why doesn't it cut the other do/while. just cuts it at z-.7.
z-.7 is wrong. why not cut the whole do/while again at x1.9 ?
and why do i had to use negative offset to get it to go to the positive side ?

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

More
21 Apr 2011 18:44 #9238 by andypugh
Replied by andypugh on topic Re:Read axis position
piasdom wrote:

why doesn't it cut the other do/while.

Probably because they both have the same O-number. EMC2 uses the O-number to tell which Do belongs to each While.

and why do i had to use negative offset to get it to go to the positive side ?

Because you are not saying "offset X by this much" you are saying "offset X so that the current position is this value"

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

Time to create page: 0.230 seconds
Powered by Kunena Forum