I have already asked this on the general forum:
How can I read the current X,Y,Z into parameters to use in calculations?
A reply there suggested using #5021, #5022 etc. This doesn't seem to work in EMC2. (V2.2.8) and I suspect may be Fanuc-specific.
What I am trying to do is to write a simple general-purpose lathe block, where I can say "starting where you are now, face of to Z=40mm in 0.5mm cuts". Easy enough, except that I can't find a way to read the current position in order to return to the same X for the next cut.
I am sure that there are other ways to do this, too. Perhaps I have too much of a manual machinist / generic coder mindset and am not getting the G-code thing.
look at http://linuxcnc.org/docs/2.3/html/gc...8,-G30:-Return
G28.1 and G30.1 saves the current absolute postions in 5161-5166 and 5181-5186 respectivly
(remember this is un-offset)
I had tried that (almost the first thing I tried) but I got "unknown G-code". Looks like I will have to lug the CNC computer upstairs to where the network is and get 2.3 :-)
Originally Posted by samco
Sorry - yes. that is only in 2.3.
You could use G92 to set the position that the machine is at, to whatever you want.
Eg G92 X0 Y0 Z0 sets the current position to X, Y, Z 0 . One problem is it also offset all the other coordinate systems by whatever the difference was of current position and requested position. meaning if you were at X 2 and G92 x 0, you offset -2 inches so all the other coordinate systems will subtract - 2 from X.
So remember to cancel G92 afterwards (G92.1). See the manual for more info.
It is easy to get your self in trouble with G92 if you forget to cancel it.
Try G92 to set the current position to whatever you specify. The run your facing program.
then remember to cancel G92 with G92.1
The problem with G92 is that then my facing program won't know when to finish.
However, having upgraded to 2.3 it looks like G28.1 will do exactly what I want.
What I want to do is to jog the tool to a safe position close to the work, then automatically face off to a fixed X position. G92 would move that fixed X position....
Here is what I came up with. Be gentle, this is my first ever actual G-code program.
#1 = 40 ( Finish length)
#2 = 20 ( metres/min surface speed )
#3 = .25 ( Cut )
#13 = #5061 (starting X)
#14 = #5063 (starting Z)
G96 D1000 S#2
O100 WHILE [#14 LT #1]
#14 = [#14 - #3]