SMC_NCDecoder (FB)

 

FUNCTION_BLOCK FINAL SMC_NCDecoder

This function block is used to convert a CNC program (Din 66025, G-code), into a list of SMC_GEOINFO objects. In each cycle, one line of the program is decoded.

Note

The maximum number of M-functions in a row is 64. If the G-Code contains more than 64 M-functions in a row, the error SMC_DEC_OUTQUEUE_RAN_EMPTY occurs. This restriction can be circumvented by inserting a G75 previous to the first M-function of the sequence. G4-elements count as M-functions, too.

Note

As from V3.5 SP2 of the programming system, iLineNumberDe­coded stores the just coded 0-based line number of the CNC file. In earlier versions, in particular CODESYS V2.3, the sentence number (= value of the N-word) had been stored there.

InOut:

Scope

Name

Type

Initial

Comment

Inout

ncprog

SMC_CNC_REF

This variable holds the CNC program. The program may have been created by the IEC-program or within the CNC-Editor.

Input

bExecute

BOOL

Execution starts on the rising edge.

bAbort

BOOL

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

bAppend

BOOL

As long as this input remains FALSE, the DataOutQueue will be cleared at each reset. The value TRUE will cause newly incoming data to be written to the end of the DataOutQueue.

bStepSuppress

BOOL

When this input is TRUE, lines of the CNC program starting with ‚/’ will be ignored. Otherwise they will be processed.

piStartPosition

SMC_POSINFO

Start position of the path.

vStartToolLength

SMC_Vector3d

Start tool length.

nSizeOutQueue

UDINT

This variable contains the size of the data buffer, the list of SMC_GEOINFO structure objects will be written to. This buffer must be able 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 appropriate buffer size will then be retrieved by use of the operator sizeof(ExampleBuf).

pbyBufferOutQueue

POINTER TO ARRAY [0..0] OF SMC_GEOINFO

This input must point to the first byte of the memory area that is 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 in the declaration part of the IEC-program by defining an array of SMC_GEOINFO (e.g. BUF: ARRAY[1..50] OF SMC_GEOINFO; for a buffer that can store 50 path elements). The value may be predefined, but may be modified later on only during a reset.

bEnableSyntaxChecks

BOOL

Turns on syntax checks that will detect invalid G-code and stop with an error in this case. It is recommended to use the syntax checks.

eOriConv

SMC_ORI_CONVENTION

SMC_ORI_CONVENTION.ADDAXES

Defines the way the orientation in the A/B/C words is interpreted.

For movement commands (such as G01, G02, ...), the value determines how A/B/C are treated. For values other than SMC_ORI_CONVENTION.``ADDAXES``, the angles A/B/C may be normalized, even if no coordinate rotation has been programmed. For example with orientation convention ZYZ, a programmed orientation of A=90° B=0° C=0° may result in the (equivalent) rotation A=0° B=0° C=90° in the path element.

For commands that set the decoder coordinate system (G54/G55/G56), the value determines how the coordinates A/B/C are treated. If the value is SMC_ORI_CONVENTION.``ADDAXES``, then A/B/C are treated as independent additional axes, for which offsets are set. For all other values, A/B/C are treated as an orientation, and the decoder coordinate system is rotated accordingly.

Note

If used with tool correc­tion functions such as SMC_ToolLength­Corr, the same orienta­tion convention has to be used there.

dCircleTolerance

LREAL

Tolerance to decide whether the definition of a circle makes sense.

  • case definition via target-position and radius: If the distance between start- and end-position (both projected onto the circle plane) is greater than 2 * the radius + MAX(fCir­cleTolerance, 1e-06), the circle will be converted into a line.

  • case definition via target- and center-position: Let x be the maximum of the distance between start- and center-position and the distance between target- and center-position (projecting everything onto the circle plane). If those distances differ by more than MAX(fCircleToler­ance, 0.1 * x), the circle will be converted into a line.

Output

bDone

BOOL

This variable will be set to TRUE as soon as the input data has been processed completely. The function block will not perform any further actions until it gets reset.

bBusy

BOOL

TRUE, while execution of function block is not finished.

bError

BOOL

Signals that an error has occurred within the function block.

wErrorID

SMC_ERROR

Error identification

poqDataOut

POINTER TO SMC_OUTQUEUE

Pointer to the SMC_OUTQUEUE structure that manages the decoded SMC_GEOINFO objects.

iStatus

SMC_DEC_STATUS

The current status.

iLineNumberDecoded

DINT

The variable contains the 0-based line number of the CNC file.

GCodeText

SMC_GCODE_TEXT

The G-Code text.