Hello Guest it is April 27, 2024, 03:33:48 AM

Author Topic: How does G30 work?  (Read 869 times)

0 Members and 1 Guest are viewing this topic.

How does G30 work?
« on: January 18, 2023, 05:52:42 PM »
Hi,
I have need for G30.  This is from the Gcode manual.

Code: [Select]
G30 – 2nd, 3rd, 4th Zero Return
G30 functions the same way as G28, moving the machine to a zero return point via an intermediate
point. However, instead of sending the machine to the home position, G30 movement ends at a user
definable 2nd, 3rd, or 4th zero return point, specified by P2, P3, or P4 respectively. If P is omitted the 2nd
zero return point is selected. This is handy for tool changers that are not located at the home position
or any number of other applications.
Format: G30 P__ X__ Y__ Z__ A__ B__ C__
The 2nd zero return point is defined by # variables as follows:
Axis P2 # Variables P3 # Variables P4 # Variables
X     5301               5311              5321
Y     5302               5312              5322
Z     5303               5313              5323
A     5304               5314              5324
B     5305               5315              5325
C     5306               5316              5326
The position values in the # variables can be set in a program or in MDI mode

The problem is that no matter what numbers I put into the pound variables the machine always drives to the machine zero (0,0,0) rather than the coordinates
UI have programmed into the pound variables. Does anyone know what I'm doing wrong?.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: How does G30 work?
« Reply #1 on: January 18, 2023, 07:47:18 PM »
Hi,
I've made a few discoveries, one of which appears to be that the Gcode manual is wrong with respect to the pound varibles used.

In particular reading the Gcode manual for G30 suggests that the variable associated with P2 are #5301,#5302,#5303 etc but that is not in fact correct.
The variables associated with P2 are in fact #5351,#5352,#5353 etc.

These are from my own post:
https://www.machsupport.com/forum/index.php?topic=40051.0
and these values were discovered/evaluated by poppabear:

Quote
G 30 XPOS       5181
G 30 YPOS       5182
G 30 ZPOS       5183
G 30 APOS       5184
G 30 BPOS       5185
G 30 CPOS       5186
WORK SHIFT X       5201
WORK SHIFT Y       5202
WORK SHIFT Z       5203
WORK SHIFT A       5204
WORK SHIFT B       5205
WORK SHIFT C       5206
FIXTURES START       5221       // Fixture start in Parameter list
               Fixture increment is 20, Increment from fixture to fixture. G54 – G59
G 30 P2 XPOS       5351
G 30 P2 YPOS       5352
G 30 P2 ZPOS       5353
G 30 P2 APOS       5354
G 30 P2 BPOS       5355
G 30 P2 CPOS       5356
G 30 P3 XPOS       5361
G 30 P3 YPOS       5362
G 30 P3 ZPOS       5363
G 30 P3 APOS       5364
G 30 P3 BPOS       5365
G 30 P3 CPOS       5366
G 30 P4 XPOS       5371
G 30 P4 YPOS       5372
G 30 P4 ZPOS       5373
G 30 P4 APOS       5374
G 30 P4 BPOS       5375
G 30 P4 CPOS       5376

I have tested them and they are correct namely:

P1 #5181  #5182 #5183 etc
P2 #5351 #5352 #5353 etc
P3 #5361 #5362 #5363 etc
P4 #5371 #5272 #5373 etc

If anyone from NFS is reading this would they please confirm my observations and if they are found correct  then update/correct the gcode manual.

There is more to this yet. As it turns out if you do not include an axis in the G30 block then it will not move nor will it return to the required coordinate.

For example:

G90 G30 P1
will cause no movement what ever. If however you MDI:
G90 G30 P1 X50
then the machine moves to X=50 in work coordinates and then moves to the #5181 but neither of the Y or Z axes move.
I conclude that in order for G30 to work you must include all axes that you wish to move, firstly through the intermediate point in absolute work coordinates and then it will
go to the home location specified by the pound variables locations P1, P2, P3 or P4.

I have yet to do enough experimenting to decide how it works in G91 mode.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline Graham Waterworth

*
  • *
  •  2,673 2,673
  • Yorkshire Dales, England
    • View Profile
Re: How does G30 work?
« Reply #2 on: January 18, 2023, 09:21:50 PM »
Its a long time since I used G30 but from memory it is used with U,V & W e.g.

G21 G40 G00 G80 (start block)
G91 G28 U0 V0 W0 (got to machine home)
G30 U0 V0 W0 P1 (go to stored position)
G50 X250. Y150. Z296.185 (set datum position)
G00 X200. Y200. Z150. (go to safe position)
G50 X200. Y200. Z150. (make this the new datum)
M1

N1 T01 M6
Etc.
Without engineers the world stops
Re: How does G30 work?
« Reply #3 on: January 18, 2023, 09:53:16 PM »
Hi Graham,
I think I've got it sorted.

It appears that G30 will move ONLY the nominated axes, that is to say the axes listed in the G30 block. The numeric component of each axis,
say X10, is the location of the intermediate point, and then the machine linearly interpolates from the intermediate location to the stored point.

If you wish for the machine to go direct to the stored point then you use a G91 mode with zero moves in each of the applicable axes. Thus:

G91 G30 P1 X0 Y0 Z0

will cause the machine to go direct from its current location to the stored point P1, with P1 being in machine coordinates.

Conversely a:

G90 G30 P1 X0 Y0 Z50

will cause the machine to rapid to X0,Y0 and Z=50mm, so 50mm above the work zero and from there linearly interpolate to the stored P1 location.

So after some experimentation I think I have got it sorted out. There is a fault in the documentation though, the # variables listed in the Gcode manual
do match those that are actually used.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline thosj

*
  •  532 532
    • View Profile
Re: How does G30 work?
« Reply #4 on: January 19, 2023, 08:37:19 AM »
I've been using this for a while with the Fusion 360 post, wonder where I got the pound variables? My guess is Chad Bird!! Somehow he/we figured it out a few years ago when working on Fusion posts:)
--
Tom
Re: How does G30 work?
« Reply #5 on: January 19, 2023, 10:10:11 AM »
Yeah.  I asked Autodesk to add the G30 as an option for safe retracts.  They obliged. 
I went digging in some old fanuc manuals and did some testing with the Macro Variables (Pound Variables) and found the appropriate ones.  I think I had Newfangled update their manuals to match my findings; but that's been a few years.  I modified the Fusion post to allow the use for a G30P2 for a tool change position.

Use G30 like G28
G91 G30 X Y Z
G90

or 

G91 G30 P2 X Y Z
G90
Chad Byrd
Re: How does G30 work?
« Reply #6 on: January 19, 2023, 03:26:03 PM »
Hi,
I've started using the Machining Extensions of Fusion and for rotary four axis tool paths the more normal Clearance Height optin in the Fusion post no longer works.
G30 is the other good option, but I've never used it before and was struggling to understand how it works. I am reasonably happy about how
it works now but still need to use it properly.

I have used the G30 option in the Fusion post, and now I understand how G30 works its doing exactly as required and as coded. Thus I can have
no complaints about the Fusion post.

I understand I can put the machine coordinates of the safe location in the P1 variables, and that would be fine for say a tool changer which never varies
however I'm trying to replicate a Clearnce Height option For this I would require the Z axis to retract say 50mm above the external diameter of the part.
The X, Y location could be just its current X,Y location......ie
G91 G30 P1  Z10 would work. My understanding is that this would leave the X,Y location unchanged, the Z axis would retract upward by 10mm and then drive to the
Z coordinate of the P1 location. This would be fine.

This is the final few lines of code of a Gcode file produced by Fusion with rotary toolpaths:

Code: [Select]
M9
G30 G91 Z0.
G90
G0 A0.
G30 G91 X0. Y0.
G90
M30

Excepting that the Z axis does not retract to an intermediate point this combination works just fine....IF.....I program P1 location properly.

My plan is to write a small macro which would populate the P1 location in # variables, and that data could be derived from the existing G54.....or whatever
work coordinate set is in use. I cannot find a way for a macro to interrogate Machs core to provide the current work coordinate set. Can anyone think of a means to do so?
I'm thinking something like:

local CurrentSet= mc.mcGet????(inst)     --CurrentSet is an integer describing the current work coordinate offsets in use, eg '54' for G54, '55' for G55 etc

The remainder of the macro would extract the work offsets from the current set, and then apply at least the X and Y offsets directly to the P1 location and the Z offset
would be augmented by some reasonable value for clearance, say 50mm, and that applied to the Z coordinate of the P1 location.

If I can achieve this then I think I could put a macro call into the Gcode file produced by Fusion and it would automatically populate the P1 location and would
require no editing of the existing Fusion code.

Thats  the theory......what is actually practical remains to be seen!

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: How does G30 work?
« Reply #7 on: January 19, 2023, 03:37:39 PM »
Craig, can you just set the #5351,#5352,and #5353 variables right from the G Code Program? 
I'm not quite sure I understand what you are asking for; if it is to get the current location for X and Y, then use the following resource.
https://www.machinetoolhelp.com/Applications/macro/system_variables.html
Look here at starting at #5021 and #5041.  These are the system variables for where the machine is currently at (machine position as well as work coordinate positoin)
Just use these to set your positions for X Y. 
You can access these from a macro or from the program you are running. 
You should be able to set the position from the program itself.... exp:  #5351 = #5021

I rarely use Mach 4's api calls for getting positions, I always find the System Variable it is stored in and I use it. 

As far as I know, I have only ever used the Machine position for G30... not the work coordinate system I'm currently in....

Are you wanting to add this to the Fusion post?
let me know what you come up with. 
« Last Edit: January 19, 2023, 03:40:17 PM by Cbyrdtopper »
Chad Byrd
Re: How does G30 work?
« Reply #8 on: January 19, 2023, 04:06:34 PM »
Hi,

Quote
Craig, can you just set the #5351,#5352,and #5353 variables right from the G Code Program?

Yes, that can be done, and it would work. What I want to do is automate it. I would prefer to use the Fusion generated Gcode file without alteration,
excepting the addition of one macro call, say m450(), for instance.

The purpose of the macro is to populate the  #5351,#5352,and #5353 variables. For this I would require the machine coordinates of the work zero,
that would suffice for the X and Y axis and the Z axis zero plus 50mm say. The most convenient place to get that data is as you say the system variables,
but I'd like to be sure that I'm using the variables that correspond to the work coordinate offset set that is actually in use.

Lets imagine for instance that the machine is in G55 mode and yet my macro causes the #5351,#5352,and #5353 to be populated but from the G54 set,
that would not end well.

That's why I would like to be able to interrogate Mach's core for the current G54, G55, G56 etc.....so that the macro can select the correct data set,

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: How does G30 work?
« Reply #9 on: January 19, 2023, 04:15:25 PM »
Hi,

Quote
As far as I know, I have only ever used the Machine position for G30... not the work coordinate system I'm currently in....

When I was experimenting with G30 yesterday I found the the intermediate point is described in the current work coordinate system but the final
location is described in machine coordinates.

For instance
G90 G30 X50 Y50 Z50

will cause the machine to drive to 50,50,50 in the current work coordinate system and then drive to the final location described by P1, P2, etc in machine coords.

Or alternately
G91 G30 X50 Y50 Z50

will cause the machine to drive an additional 50mm in X, 50mm in Y and 50mm in Z from its current position and thereafter drive to its final location described by P1, P2 etc in machine coords.

Craig

'I enjoy sex at 73.....I live at 71 so its not too far to walk.'