SMC_SmoothPath (FB)

 

FUNCTION_BLOCK SMC_SmoothPath

The SMC_SmoothPath function block can be used for path-prepro­cessing. `SMC_SmoothPath smoothes the corners of a given path and therefore create a smooth path (slur path). Such a smooth path is neces­sary for applications relying not as much on the exactness of the path than on constant path velocity. Thus, corners exceeding a reduction of the velocity to 0 have to be avoided.

The path will be cut in a defined distance to the corner and a spline will be inserted. The distance is given by the SMC_GEOINFO structure of the first object to be smoothed and by the input dEdgeDistance. The sum of both values defnies the distance to the corner.

SMC_SmoothPath_1.png

Proceeding of SMC_SmoothPath

All SMC_GEOINFO objects that are found in the Input SMC_OUT­QUEUE structure will be checked one after the other. The smooth-path functionality will be executed for all objects, which are located between the instructions G51 and G50.

M-function at the rounded corner

If there is a M-function at the corner that will be smoothed, then the M-function remains but is moved to the end of the smoothed corner. This behavior is consistent with the behavior of SMC_RoundPath .

H-function at a rounded corner

If there is a H-function bewtween the first cut point and the corner (1), the point is moved to the smoothed path (1'). The distance to the start point remains the same. If there a H-function between the corner and the second cut point (3) the point is also moved to the smoothed path (3'), so that the distance to the end point remains the same.

The position of the moved H-functions is limited so that they don't cross the center of smoothed path. Otherwise the order of the H-functions might change (2', 4').

SMC_SmoothPath_2.png

Example 1: Smoothing by splines

G-Code

N000 G01 X10 Y0 F100
N010 G51 D2 (smoothing angles with angle distance 2 on)
N020 G01 X10 Y20
N030 G01 X20 Y20
N040 G01 X20 Y0
N050 G50 (smoothing angels off)
N060 G01 X30

The following figure shows a path with smoothed angles. The smoothing is turned on by position 10/0 and is turned off by position 20/0. Then all angles between these positions are smoothed by splines.

SMC_SmoothPath_3.png

Example 2: Input bSymmetricalDistances

G-Code

N000 G01 X10 Y0 F100
N010 G51 D10 (smoothing angles with angle distance 2 on)
N020 G01 X10 Y20
N030 G01 X20 Y20
N040 G01 X20 Y0
N050 G50 (smoothing angels off)
N060 G01 X30

The example shows the curve of the function block, when the angle distance is larger than the half of the object. The following figure shows the curve with bSymmetricalDistances=FALSE. Here the object is too short, so it is smoothed up to the center of the angles (see the horizontal line).

SMC_SmoothPath_4.png

In the following figure bSymmetricalDistances is set. By arriving the first angle it is detected, whether half of the object length of the shorter one is larger than the angle distance defined by D (10). Thereby both objects are applied with angle distance 5. By arriving the second angle the line element is shortened to length 5, so that the remaining half object has got a length of 2.5 and the angle distance of 2.5 is applied for both objects.

SMC_SmoothPath_5.png

Example 3: Input eMode

G-Code

N000 G51 D10 (smoothing angles with angle distance 2 on)
N010 G01 X0 Y10
N020 G01 X10 Y10
N030 G01 X10 Y0
N040 G50 (smoothing angels off)

By setting the input eMode of function block SMC_SmoothPath, the user has the possibility to define the element type applied for the smoothing. Default type is "Spline3" (SP_SPLINE3), i.e. a third-degree polynomial in each dimension. This can be changed to "Spline5" (SP_SPLINE5), however. Fifth-degree polynomials have the advantage, that with the second derivation a continuous connection to the previous/next object can be achieved. This affects a limited jerk.

Dynamic curves along the X-axis with eMode=Spline3

SMC_SmoothPath_6.png

Dynamic curves along the X-axis with eMode=Spline5

SMC_SmoothPath_7.png

A smoothing segment always contains the same tool correction informa­tion (i.e. lengths and diameter) as the first of the two segments inbe­tween of which it is inserted.

InOut:

Scope

Name

Type

Initial

Comment

Input

bExecute

BOOL

FALSE

Starts on rising edge.

bAbort

BOOL

FALSE

If TRUE, the current processing of this function block is aborted

bAppend

BOOL

FALSE

As long as this input is set to FALSE, the poqDataOut queue will be cleared at each reset. As long as it is set to TRUE, newly incoming data will be written to the end of the poqDataOut-queue.

poqDataIn

POINTER TO SMC_OUTQUEUE

NULL

The input path queue

dEdgeDistance

LREAL

0

This input variable contains the value, which – added to the corresponding tool-radius value of the SMC_GEOINFO object – determines the (minimum) distance to an angle, at which the particular objects will be cut and replaced by a spline (see above examples). This value may be modified online. Therefore, it is possible to correct an offline predefinition (by the SMC_GEOINFO structure) in online state.

dAngleTol

LREAL

0.001

This input prescribes the value for the angle tolerance, up to which a path bend should not be smoothed.

nSizeOutQueue

UDINT

0

This variable contains the size of the data buffer pbyBufferOutQueue in bytes.

The list of SMC_GEOINFO structure objects will be written to. This buffer must be large enough to hold at least five SMC_GEOINFO objects. Otherwise, the function block will not execute any actions at all. Its size may be predefined, but may be modified later only during a reset. It is recommended to create the buffer as described by the example below:

ExampleBuf: ARRAY[1..50] OF SMC_GeoInfo;

The correct buffer size will then be retrieved by use of the operator sizeof(ExampleBuf).

pbyBufferOutQueue

POINTER TO ARRAY [0..0] OF SMC_GEOINFO

NULL

This input must point to the first byte of the memory area being allocated for the SMC_OUTQUEUE structure. This area must be at least as big as defined in nSizeOutQueue. Typically the allocation of the memory buffer is done within the declaration part of the IEC-program by defining a byte-array (ExampleBuf: ARRAY[1..50] OF SMC_GEOINFO;). The value may be predefined, but may then be modified during a reset only.

eMode

SMC_SMOOTHPATHMODE

SP_SPLINE3

Element type applied for the smoothing of the axes.

bSymmetricalDistances

BOOL

TRUE

If bSymmetricalDistances is set, it is checked, whether the shorter distance of the objects of the just achieved angle (edge) is shorter than D. If it is TRUE, then the distance of the shorter distance is used, if it is FALSE, the angle distance defined in D is used.

bImprovedSymmetricCuts

BOOL

FALSE

IF bSymmetricalDistances is set, the first element is cut at most in half.

If the option bImprovedSym­metricCuts is set, this limita­tion is lifted. In some cases this results in a better smoothing.

eAddAxMode

SMC_SMOOTHPATHADDAXMODE

SPAA_LATE

The way how additional axis are treated. If SMC_SmoothMerge is used, this parameter should be set to mode SPAA_EXACT.

dMinimumCurvatureRadius

LREAL

0

If a spline, that would be inserted in a edge, contains a position where its curvature radius is less than this parameter, this edge is not smoothed. In this situation no spline is inserted, but the original path is maintained and a stop is executed in the edge.

bCheckCurvature

BOOL

FALSE

If TRUE, it is checked if the curvature of adjacent elements is equal. If this is not the case, the path will be smoothed.

dRelativeCurvatureTol

LREAL

0.001

The maximum allowed relative difference in the curvature. Only used if bCheckCurvature is TRUE.

bCheckAddAxVelJump

BOOL

If TRUE the axis A, B and C are checked for velocity jumps. Should be set if SMC_SmoothMerge is used.

dMaxAddAxVelDifference

LREAL

The maximum allowed velocity jump [units/sec]. This input is evaluated if bCheckAddAxVelJump is TRUE. Recommended: maxAcceleration * taskCycleTime

Output

bDone

BOOL

FALSE

This output will be set to TRUE as soon as the input data from poqDataIn has been processed completely. Thereafter, the module will not perform any further actions until it gets reset. If input bExecute is FALSE, bDone will be reset to FALSE.

bBusy

BOOL

FALSE

TRUE, while execution of function block is not finished

bError

BOOL

FALSE

Signals, that an error has occurred within the function block

wErrorID

SMC_ERROR

0

Error identification

poqDataOut

POINTER TO SMC_OUTQUEUE

NULL

The output path queue

udiStopsDueToCurvatureRadius

UDINT

0

Number of edges that could not be smoothed because of the dMinimumCurvatureRadius setting