|
Click any image on this page to enlarge
|
Summing up so far there is MPos and WPos and a work envelope. Next up an example. Looking at the image to the left there is a part held in a vise. The WPos is X-5 Y-2 and this G54 WPos is located at a corner of the fixed jaw. The values of G54 have been stored in the control register.
On the left is a drawing of the part. The drawing origin is the top left.
Here the work origin has been chosen in CAM software. In CAM the work origin could be placed anywhere, even some distance from the part. In this case the logical X0 Y0 position matches the drawing origin. The tri-color triad sits at the the work piece origin and the arrows point out the positive directions.
Referring back to the first image hopefully a logical pattern is apparent. The fixed jaw never changes position so it's a good spot for Y0. The left end of the vise matches the CAD/CAM X0. Work holding is something to keep in mind at the CAD/CAM stage of making a part.
A very basic program for making the round hole with a tool of the same diameter:
G20 (move in inches)
G54 (Use G54 WPos)
G00 X0.25 Y-0.25 (A rapid XY move to the hole position)
S400 M03 (400 RPM clocwise if spindle isn't manual)
G00 Z0.2 (Rapid Z move to 0.2" above the part)
G01 Z-0.125 F50 (Feed to 0.125" depth at 50 ipm)
G00 Z0.2 (Rapid Z move to 0.2" above the part)
M02 (program finished)
The code above is the first time a Z WPos is mentioned. The reason for this is Z WPos can be more complex than X or Y WPos. On a machine not using tool length offsets the Z WPos is most commonly the distance the Z axis travels from HOME (MPos Z0) until the tool touches the top of the part. For example if the machine is at HOME (MPos Z0) with a tool in the spindle and the machine Z axis is moved Z -3" before the tool touches the top of the part, the G54 Z WPos is -3". Going back to the vise example G54 would be X -5, Y -2, Z -3.
Users coming from a 3D printer background may prefer to measure WPos Z0 from the bottom surface of a part. This is certainly possible if the CAM program was created with that in mind. In my experience placing WPos Z0 at the top of a part is the convention and I'll offer 2 possible reasons why.
Reading the previous g-code it could be rewritten with WPos Z0 at the bottom of the part. (The part is 0.125" thick)
G20 (move in inches)
G54 (Use G54 WPos)
G00 X0.25 Y-0.25 (A rapid XY move to the hole position)
S400 M03 (400 RPM clocwise if spindle isn't manual)
G00 Z0.325 (Rapid Z move to 0.2" above the part)
G01 Z0 F50 (Feed to 0.125" depth at 50 ipm)
G00 Z0.325 (Rapid Z move to 0.2" above the part)
M02 (program finished)
Only a small change, a bit messier to read but no problem. Now create 7 holes spaced an inch apart with no 2 depths the same.
First a program with WPos Z0 at the top of the part. The part is 2" thick but knowing that isn't important to the program. The g-code below is only the Z plunge moves and lateral and retract moves aren't shown.
G54
G01 Z-1.000 F50
Z-0.125
Z-0.500
Z-0.771
Z-0.994
Z-1.350
Z-0.846
Reads like a book. Now the same plunge moves with WPos Z0 at the bottom of the part.
G54
G01 Z 1.000 F50
Z 0.750
Z 1.500
Z 1.229
Z 1.006
Z 0.650
z 1.154
Without using a calculator how deep is the tool plunging into the work? If the part thickness was unknown what's the depth of the holes and can this code be reused on a thicker piece of material (without creating a fake WPos Z0). Unlike a 3D printer milling is a subtractive process and code written to be subtractive is easier to read and write.
The image on the left represents a generic DRO as might appear on a cnc user interface. Pressing the MPos will display the current distance from HOME position. If the machine is
at HOME these numbers should all read zero. With the MPos readout active, jog the machine to WPos X0,Y0,Z0 of the vise example, the numbers should read X -5.000 Y -2.000 Z -3.000. If the machine is left in this position and the WPos button is pressed the DRO numbers will once again read zeros. In addition the UI is likely to have a window scrolling the g-code lines as they are processed by the control.
Normally when running a program the DRO will be set to display WPos. If the WPos Z0 is set to the top of the part it's easy to visualize the next Z move by looking at the displayed g-code. When the tool is at the top of the part the DRO reads Z0. If the next command is Z -0.5 it's obviously a move 0.5" below the top of the part. If the WPos Z0 is the bottom of the part the depth of cut will be: (thickness of part) - (commanded position) trying to do that mental math gymnastics while a program is running is impractical and potentially dangerous. Of course some users don't pay attention to the DRO and others have a DRO that displays distance-to-go.
I recommend using the part top as WPos Z0 unless there is a compelling reason to do otherwise. For the reasons given and for a few other reasons that were not given. If the reasons supplied aren't convincing, look through some cnc text books or on-line tutorials provided by industry. Examine how they explain set-up and programming to students and new users and some consistent approaches to work offsets will be noticed. All of that said do whatever makes you comfortable and happy. If you're reading a blog like this one cnc is unlikely to be the way you pay the bills. And if the machine is all yours the 2nd shift won't leave a dead fish in your toolbox for having unconventional methods.
When running a machine for the first time the temptation will be to load a tool and start cutting. A better plan is taking time to understand the machine and the g-code that commands the machine. At the minimum know the commands G00 and G01. Start by getting the HOME position defined in the control and also define the travel limits. After HOMING the machine, jog to the centre of the XY travel which should be at or near the centre of the table. At this position set WPos to X0 Y0, this will be the G54 offset. Make some XY motion using G00 and G01 commands in MDI mode. Try positive moves and negative moves and diagonal moves. At any time G00 X0 Y0 will return back to the centre. To return to HOME try G53 G00 X0 Y0, G53 is a special command that moves in the MPos coordinate system. When feeling confident with XY, set the G54 Z0 and play with the Z moves. Go through this exercise and the first time running a program will be less of a mystery. Learn the machine and it will be fun instead of frustration.