As always reference the LinuxCNC manuals and the LinuxCNC Wiki for more information.
Move to a Predefined Position
G28 and G30 move the machine to a predefined position with an optional way point before moving to the position stored. The positions must be defined using G28.1 and G30.1. The purpose of moving to a predefined position is to put the mill in a known position before starting the G code and after ending the G code. This can be used as a part change position or a tool change position.
When you run LinuxCNC for the first time the .var file contains a list of all the numbered variables used by LinuxCNC. All of the variables will start out as 0.0000. So if you issue a G28 without setting the variables the machine will rapid from the current position to the machine home position and if anything is in the way well you will crash into it.
G28 and G30 take optional axis words and will move from the current position to the position of the axis words including any offsets then move to the absolute machine position contained in the variables. The axis words location will include any offsets that are in effect at the time the G28/30 plus axis words is issued.
Ok, lets set up G28 to move to a predefined position. First determine the absolute machine postion you want to move to with no offsets in effect. Using G53 to prefix your move you know your moving in the base machine coordinate system.
G53 G0 X-2.0 Y2.0 Z0.0 (move to the position) G28.1 (store the current absolute position in the variables)
Lets say we are machining out a pocket and when done we want to move above the top of the material and then to the predefined position stored in the variables for G28. We have a Z offset set so the top of the material is Z0. We want to move to 1/2" above the material then to the part change position.