SMC_NCInterpreter (FB)

FUNCTION_BLOCK FINAL SMC_NCInterpreter

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

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.

InOut:

Scope

Name

Type

Initial

Comment

Inout

sentences

SMC_GSentenceQueue

The input queue of g-code sentences

Input

bExecute

BOOL

Execution starts on the rising edge.

bAbort

BOOL

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

bAppend

BOOL

If TRUE, a rising edge of bExecute won't lead to a reset of the out-queue. Instead, newly incoming data will be written to the end of the out-queue.

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

TRUE

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 correction functions such as SMC_ToolLengthCorr, the same orientation 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(fCircleTolerance, 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(fCircleTolerance, 0.1 * x), the circle will be converted into a line.

pInterpreterStack

POINTER TO BYTE

Allows to supply a buffer for the interpreter stack. If 0, a default buffer of size 10240 Bytes is used. If <> 0, the given buffer will be used. This input is read each cycle.

nInterpreterStackSizeBytes

UDINT

The size of the buffer pointed to by pInterpreterStack. Note that the size needs to be at least 1024 Bytes.

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

errorPos

SMC_NC_SourcePosition

The source-position where an error has been detected.

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.

CallstackInfo

SMC_NCCallstackInfo

aActivePrograms

ARRAY [0..(SoftMotion_NC2_Constants.IPR_CALLSTACK_SIZE - 1)] OF STRING

The currently active programs and subprograms. aActivePrograms[0] holds the name of the (sub)program that is currently interpreted. If it is a sub-program, then aActivePrograms[1] holds the name of the calling (sub)program and so on. The list of active programs is terminated by an empty string.