SMC_ToolRadiusCorr (FB)¶
FUNCTION_BLOCK SMC_ToolRadiusCorr
SMC_ToolRadiusCorr
creates a shifted path to compensate for the
radius of a tool.
In the shifted path, each point has a defined distance to
the original point (tool radius correction).
A typical application is the milling of a programmed contour with a
milling drill of a certain diameter. In order to compensate the radius
of the drill, the milling drill must follow a shifted path.
This function block replaces SMC_ToolCorr.
The main feature is to also support 3d-movements
and to respect the current correction plane
(i.e. at decoding time the plane that circles would be defined in).
We always use SMC_TOOLCORRMODE.TC_RAMP_IN
,
so the input eMode
is no longer necessary.

Tool radius correction is controlled by the g-code:
G41
(G42
) starts correction to the left (right),
G40
ends it.
Example 1: Simple tool radius correction
G-Code
N0 G41 D3 (start correction)
N1 G0 X3 Y10 F100 E1000 E-1000
N2 G1 X7 Y10
N3 G1 X10 Y0
N4 G40 (end correction)
N5 G1 X20
In the above example, the element in sentence N1 is used for ramping in, the one in sentence N5 for ramping out.

Example 2: Tool radius correction in different planes
G-Code
N0 G41 D1 F100 (start correction)
N1 G16 I1 J1 K1 (set correction plane)
N2 G1 X5
N3 G2 X0 Y5 R5
N4 G40 (turn off correction)
N5 G1 X0 Y7.5
N6 G42 D1 (start correction)
N7 G16 I1 J1 K-1 (with different correction plane)
N8 G1 Y10
N9 G3 X10 Y0 R15
This example shows how tool radius correction can work
in different planes. The correction plane is changed with G16
.
The elements in sentence N5 and N8 are used for ramping out and
ramping in again.

Note
At inside corners, the projections of the corrected (shifted) elements onto the correction plane will usually intersect and we shorten those elements accordingly. Concerning the component which is perpendicular to the correction plane (z when correcting in the xy plane), the new meeting point will equal component of the original corner. The value of the additional axes at the point of intersection will also equal the value of the additional axes at the original corner.
G75 during tool radius correction is not supported: The correction of one element strongly depends on the following, which can’t be known if there is a G75 in between. A G75 must not follow a G40, either: The first movement after G40 is used for ramping out and therefore still “belongs” to the correction block. For the same reason, we get in trouble if the in-queue is full without containing a second cartesian element (e.g. only M-functions), and also return an error.
If the correction radius or the correction plane or the correction side (left or right) changes from one element to the other, we will act like at the beginning of tool correction and use the element with the new parameters for ramping in.
Changing the planes during tool correction is not supported. Jumps (G92 or implicitly by G43) during tool correction are not supported. Splines with degree 5, as created by SMC_SmoothPath or SMC_SmoothMerge, are not supported yet.
G0 elements can be used during tool radius correction. They will be shifted and cut like G1 elements.
Ellipses (G08/G09) are not supported. An error will be reported when an ellipse element is detected during active tool radius correction.
- InOut:
Scope
Name
Type
Comment
Input
bExecute
BOOL
Starts on rising edge
bAbort
BOOL
If
TRUE
, the current processing of this function block is abortedbAppend
BOOL
As long as this input remains
FALSE
, the DataOutQueue will be cleared at each reset. As long as it remainsTRUE
, newly incoming data will be written to the end of the DataOutQueue.poqDataIn
POINTER TO SMC_OUTQUEUE
Input path queue
nSizeOutQueue
UDINT
The size of pbyBufferOutQueue in bytes
pbyBufferOutQueue
POINTER TO ARRAY [0..0] OF SMC_GEOINFO
The buffer for the output queue
dAdditionalToolRadius
LREAL
This variable defines an additional tool radius. Whenever a new tool radius correction starts, it is added to the tool radius defined in the SMC_GEOINFO structure. The path will then be shifted by the new tool radius. If this variable is modified during an active tool radius correction, it will have no effect until the active tool radius correction ends and a new tool radius correction is started (with
G41
orG42
). Note: The additional tool radius may also be negative. If the sum of the additional tool radius and the radius defined in the SMC_GEOINFO structure is negative, the correction side is inverted (left <-> right).Output
bDone
BOOL
Indicates the entire input path has been processed
bBusy
BOOL
Indicates the function block is still busy processing
bError
BOOL
An error has occurred
wErrorID
SMC_ERROR
Error-ID
poqDataOut
POINTER TO SMC_OUTQUEUE
Output path queue