Radius compensation works similarly in most CNC machines, but there are differences in how to use the syntax and when to activate/ deactivate the compensation, etc. Here we will explain how to use the G40, G41, and G42 codes in CNC Simulator Pro.

First rule:

G41 (left side compensation) and G42 (right side compensation) should be used on the first G01 transportation in XY that is used to approach the contour that is about to be milled.

Example:

image

 

In this case, let us say that position 1 (lower-left corner of the square) is located in X50 Y50. Then the approaching block would look like this:

G01 G41 X50 Y50...

This will activate left-side compensation. The real movement will not be to X50 and Y50. This is because the tool will stop before the programmed position (depending on the tool radius).

Second rule:

G40 must be used to cancel the compensation when a contour is done and the mill leaves the contour, either by leaving in XY or in Z. Do not keep the compensation on when a contour is ready. Cancel it with G40 and reactivate it again when you approach another contour.

image

At the red arrow, we leave the contour. This should be written as:

G00 G40 X0 Y0

Alternatively, we can leave the contour by going straight up in Z. Then we write:

G00 G40 Z40

Please note that we can only cancel radius compensation on traverses in Z. To activate it, we need to do an XY-movement with G01.

Third rule:

The approaching distance and the leaving distance should not be shorter than the tool diameter.

Example program of a simple square using the three rules:

$AddEmbeddedRegPart

1 20 20
ET3 M6 (10 mm mill)
G00 X10 Y10 Z40
G00 Z25
G01 G41 X20 Y20 F200 S200 M3 (Approach and activate)
Y50
X50
Y20
X20
G00 G40 Z40 (Go straight up and deactivate)
M30


image

Please note that when you are going to mill a pocket contour, you will have to approach the pocket from the inside. Let us demonstrate with another example:

image

Let us this time say that position 1 is located at X30 Y30 and that the square has sides 70x70. Also, let us use a diameter 10 mm tool.

This means that we should position the tool at X40 Y40 to not break rule three (X/Y + tool diameter) and go down to our milling depth. Then we approach position one and activate the compensation with G42 (right side this time).

Leaving the contour from the inside is slightly trickier than from the outside as we must take care not to cut outside the corner, and at the same time finish it off correctly.

Therefore, do not cancel the radius compensation on the leaving block as it will confuse the compensation to go outside the pocket. Instead, do it on the block after leaving the contour.

Also, there is another complication hidden here. The radius compensation algorithm works by calculating the tangential points of a circle (the mill) and two lines or arcs (this movement and the next movement). This works fine when the compensated moves are not approaching or leaving. As you can see from the picture below, the lower-left corner will be unfinished if we leave by going back to the same point we used when approaching the contour.

image

The green arrow represents the leaving block.

Here is how it looks in the simulator.

image

To avoid this problem we need to create a final line that goes straight up (positive) in Y and does not change in X. This will create a 90-degree corner that will allow the mill to finish off the corner.

image

The green arrow is our leaving block. Note how it allows the tool to go all the way into the corner before we cancel the radius compensation.

The complete example:

$AddEmbeddedRegPart

1 20 20
ET3 M6 (10 mm mill)
G00 X40 Y40 Z40 (Position over)
G01 Z25 F250 S1000 M3 (Feed down)
G01 G42 X30 Y30 (Approach and activate RC)
Y70
X70
Y30
X30
G01 Y40 (Do not cancel here)
G00 G40 Z40 (Go straight up and cancel RC)
M30


image

Please note that when you single-step through a compensated CNC program, you will see the movements delayed. This is normal as the CNC code interpreter needs a couple of blocks to be able to calculate the tool moves. It can therefore look as though the simulator and the editor are out of sync.

Z movements
As you have noticed, we talk about contours when dealing with radius compensation. CNC Simulator Pro considers a contour to be a number of connected lines and arcs at the same Z-level. After activating G41 or G42 any Z movements will be ignored. To change the Z depth, first, cancel the radius compensation using G40, then change Z and reactivate it using G41 or G42.

Important note for version 2.0.1.0 and later

The above-mentioned limitation of movements in Z does no longer applies. You can move in Z as much as you like during the compensated tool path.

Let us end this tutorial with a more realistic example. Study the drawing. We will cut the outside contour on the left side using G41 and the pocket on the inside using G42, going clockwise around both contours. We will be using the techniques and rules we have studied in this tutorial. Note that we will not do any roughing on the part, just the final fine-cuts for this demonstration only.

image

 

$Millimeters

$Mill

$DefineMillWorkpiece "M::N:" 1 100 100 20

$AddDefinedPart 1 20 20

 

N10 ETM06 (6 mm mill diameter)

N20 G92 X20 Y20 Z20 (Move zero point)

N30 G00 X-10 Y-10

N40 G00 Z-10

N50 G00 X0

N60 M08 M03

N70 G01 G41 Y50 F250 S1000 (Approach and activate)

N80 G01 X10 Y60

N90 G01 X20

N100 G03 X40 Y80 IJ20

N110 G02 X60 Y100 I20 J0

N120 G01 X90

N130 G01 X100 Y90

N140 G01 Y30

N150 G01 X90

N160 G03 X70 Y10 IJ-20

N170 G01 Y0

N180 G01 X30

N190 G01 X-10 Y40

N200 G00 G40 Z20 (Cancel RC)

N210 G00 X80 Y70 (10 mm on the inside for approach)

N220 G01 Z-10 F50 (Go down)

N230 G01 G42 X90 (Approach and activate)

N240 Y60

N250 G02 X50 R-20

N260 G01 Y70

N270 G02 X90 R-20

N280 G01 Y60

N290 G00 G40 Z20 (Cancel RC)

N300 M09
N310 M02