[go: up one dir, main page]

0% found this document useful (0 votes)
57 views102 pages

SIMOTION G-Code Interpreter Guide

Uploaded by

LIN SEN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views102 pages

SIMOTION G-Code Interpreter Guide

Uploaded by

LIN SEN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 102

Application description Ÿ 2016/05

SIMOTION G-Code
Interpreter
LGCode
Function Manual V3.0

http://support.automation.siemens.com/WW/view/en/109477030
Warranty and liability

Warranty and liability

Note The application examples are not binding and do not claim to be complete
regarding the circuits shown, equipping and any eventuality. The application
examples do not represent customer-specific solutions. They are only intended
to provide support for typical applications. You are responsible for ensuring that
the described products are used correctly. These application examples do not
relieve you of the responsibility to use safe practices in application, installation,
operation and maintenance. When using these application examples, you
recognize that we cannot be made liable for any damage/claims beyond the
liability clause described. We reserve the right to make changes to these
application examples at any time without prior notice.
If there are any variations between the recommendations provided in these
application examples and other Siemens publications, e.g. catalogs, the contents
of the other documents have priority.

We do not accept any liability for the information contained in this document.

Any claims against us – based on whatever legal reason – resulting from the use of
the examples, information, programs, engineering and performance data, etc.
described in this application example, shall be excluded. Such an exclusion shall
not apply in the case of mandatory liability, e.g. under the German Product Liability
Act ("Produkthaftungsgesetz"), in case of intent, gross negligence or injury of life,
 Siemens AG 2016 All rights reserved

body or health, guarantee for the quality of a product, fraudulent concealment of a


deficiency or breach of a condition which goes to the root of the contract
("wesentliche Vertragspflichten"). The damages for a breach of a substantial
contractual obligation are, however, limited to the foreseeable damage, typical for
the type of contract, except in the event of intent or gross negligence or injury to
life, body or health. The above provisions do not imply a change in the burden of
proof to your detriment.

Any form of duplication or distribution of these application examples or excerpts


thereof is prohibited without the express consent of Siemens Industry Sector.

Security Siemens provides products and solutions with industrial security functions that
informati- support the secure operation of plants, solutions, machines, equipment and/or
on networks. They are important components in a holistic industrial security
concept. With this in mind, Siemens products and solutions undergo continuous
development. Siemens recommends strongly that you regularly check for
product updates.
For the secure operation of Siemens products and solutions, it is necessary to
take suitable preventive action (e.g. cell protection concept) and integrate each
component into a holistic, state-of-the-art industrial security concept. Third-party
products that may be in use should also be considered. For more information
about industrial security, visit http://www.siemens.com/industrialsecurity.
To stay informed about product updates as they occur, sign up for a product-
specific newsletter. For more information, visit
http://support.automation.siemens.com.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 2
Table of contents

Table of contents
Warranty and liability ............................................................................................... 2
1 Task................................................................................................................. 6
1.1 Overview ........................................................................................... 6
1.2 Structure of the SIMOTION G-Code Interpreter.................................. 7
From G-Code to motion ..................................................................... 7
1.3 Library LGCode ................................................................................. 8
1.3.1 Units .................................................................................................. 8
2 Preparation of the SIMOTION project .......................................................... 10
2.1 Creating the technology objects ....................................................... 10
2.2 Integrating of the ST library .............................................................. 13
2.3 Creating the global interface variables ............................................. 13
3 Example Project ........................................................................................... 14
3.1 Architecture ..................................................................................... 14
3.2 Overview ......................................................................................... 14
3.2.1 Sequence ........................................................................................ 17
3.2.2 HMI connection................................................................................ 17
3.3 Preparations .................................................................................... 18
3.3.1 G-Code Interpreter .......................................................................... 18
3.4 Operation of the application ............................................................. 19
3.4.1 Overview ......................................................................................... 19
 Siemens AG 2016 All rights reserved

3.4.2 Load program from CF-Card and execute program .......................... 22


3.4.3 Create and store G-Code-Program .................................................. 22
5 Programming in G-Code .............................................................................. 26
5.1 Conventions .................................................................................... 26
5.1.1 General ........................................................................................... 26
5.2 Reserved keywords ......................................................................... 26
5.3 Math functions ................................................................................. 27
5.3.1 Logic operations .............................................................................. 27
5.3.2 Arithmetic operations ....................................................................... 27
5.4 Variables ......................................................................................... 28
5.4.1 Clipboard variables .......................................................................... 28
5.4.2 User-defined variables ..................................................................... 28
5.4.3 External variables ............................................................................ 28
5.5 Motion commands ........................................................................... 29
5.5.1 Rapid traverse (G0) ......................................................................... 29
5.5.2 Linear motion (G1)........................................................................... 30
5.5.3 Circular motion (G2, G3, G5) ........................................................... 31
5.5.4 Automatic contour blending between two linear motions
(G640/G641) ................................................................................... 33
5.5.5 Circular motion with additional motion in the vertical direction .......... 34
5.6 Special commands .......................................................................... 35
5.6.1 Wait time (G4) ................................................................................. 35
5.6.2 Basic work offset (G92).................................................................... 36
5.7 Configuration commands ................................................................. 37
5.7.1 Selecting the working plane (G17, G18, G19) .................................. 37
5.7.2 Tool radius compensation (G40, G41, G42) ..................................... 37
5.7.3 Work offset, frame (G53, G54, G55, G56, G57, G500) ..................... 41
5.7.4 Relative work offset (G52) ............................................................... 42
5.7.5 Blending (G60, G64) ........................................................................ 44
5.7.6 Absolute or incremental dimensions (G90, G91) .............................. 44
5.8 Other commands ............................................................................. 44
5.8.1 Program name (PRG) ...................................................................... 44

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 3
Table of contents

5.8.2 Preprocessing stop (STOPRE) ........................................................ 44


5.8.3 Comments ....................................................................................... 45
5.9 Tool (T) ........................................................................................... 45
5.10 M functions – general ...................................................................... 45
5.10.1 Reserved M functions ...................................................................... 45
5.10.2 User-defined M functions ................................................................. 46
5.11 H parameters - general .................................................................... 47
5.12 Additional functions - general ........................................................... 47
5.12.1 Corner bit ........................................................................................ 47
5.14 Example of a traversing program ..................................................... 51
5.14.1 Scenario 1 ....................................................................................... 51
5.14.2 Scenario 2 ....................................................................................... 51
6 Interpolator ................................................................................................... 54
6.1 FBLGCodeInterpolator function block............................................... 54
6.1.1 Constants ........................................................................................ 54
6.1.2 Schematic LAD representation......................................................... 55
6.1.3 Inputs and outputs of the function block ........................................... 55
6.1.4 Configuration ................................................................................... 57
6.2 Status of the interpolator .................................................................. 62
6.3 Program overview............................................................................ 62
6.4 Configuration of the interpolator ....................................................... 63
6.5 Integrating the function block ........................................................... 63
7 G-Code Interpreter........................................................................................ 65
 Siemens AG 2016 All rights reserved

7.1 Preparations .................................................................................... 65


7.1.1 SIMOTION IT authentification .......................................................... 65
7.1.2 Transferring NC programs to the memory card of the
SIMOTION device ........................................................................... 66
7.1.3 Loading and starting the NC program via the interface ..................... 67
7.2 SIMOTION function blocks............................................................... 67
7.2.1 Task ................................................................................................ 67
7.3 FBLGCodeProgram function block ................................................... 67
7.3.1 Constants ........................................................................................ 68
7.3.2 Schematic LAD representation......................................................... 68
7.3.3 Inputs and outputs of the function block ........................................... 69
7.3.4 Status of the program administration................................................ 70
7.4 FBLGCodeInterpreter function block ................................................ 71
7.4.1 Constants ........................................................................................ 71
7.4.2 Schematic LAD representation......................................................... 71
7.4.3 Inputs and outputs of the function block ........................................... 72
7.4.4 Status of the Interpreter ................................................................... 72
7.5 Integration of the function blocks...................................................... 73
7.5.1 Program overview............................................................................ 73
7.5.2 Calling the function blocks (FBLGCodeProgram and
FBLGCodeInterpreter) ..................................................................... 73
8 Further functions - general .......................................................................... 75
8.1 FBLGCodeTangentialCtrl function block .......................................... 75
8.1.1 Schematic LAD representation......................................................... 75
8.1.2 Inputs and outputs of the function block ........................................... 75
8.1.3 Error numbers ................................................................................. 76
8.1.4 Example .......................................................................................... 77
8.2 Alarm Handler ................................................................................. 79
8.2.1 Importing the text messages into the SIMOTION project .................. 79
8.2.2 Integrating the ST source file ........................................................... 79
8.2.3 FBLGCodeAlarmHandler function block ........................................... 81
8.2.4 Calling the Alarm Handler function block .......................................... 82

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 4
Table of contents

9 Error numbers of the blocks ........................................................................ 83


9.1 Interpolator ...................................................................................... 83
9.2 Interpreter........................................................................................ 89
9.2.1 Errors of the program administration / parser ................................... 89
9.2.2 Errors of the Interpreter.................................................................... 92
10 Description of the interface structure ......................................................... 94
10.1 Purpose of the interface structure .................................................... 94
10.1.1 Interpreter........................................................................................ 94
10.2 Description of the structure elements ............................................... 94
11 References .................................................................................................. 101
12 Contact........................................................................................................ 101
13 History ........................................................................................................ 102
 Siemens AG 2016 All rights reserved

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 5
1 Task
1.1 Overview

1 Task
1.1 Overview
The SIMOTION G-Code Interpreter enables the programming of the technology
object (TO) path interpolation using G-Code. G-Code is a widely-used language
amongst others for the programming of motion. Programming in G-Code is always
advantageous when kinematic systems are to traverse a defined contour.
With the TO path interpolation, SIMOTION provides the option of cartesian
interpolation and is suitable for working with point-shaped tools (glue nozzles, laser
beams, needles, pins, etc. - usually from above). SIMOTION can guarantee a
constant path velocity for such applications.
An overview of the current features can be found in Table 1-1.
Table 1-1: Features of the G-Code Interpreter
Requirement Remarks
2D / 3D axis interpolation Provided by SIMOTION technology object path
interpolation
Tools limited tool length and tool radius compensation

Constant path velocity “Look ahead” of the path object / with up to ten sets
Copyright  Siemens AG 2016 All rights reserved

Linear, circular G1, G2, G3, G5 – see chapter 5.4.2.


interpolation
M-functions / Interface to output data to the PLC program
H-parameter
Clipboard variables Input and output of data by the interpreter –
opportunity to make NC programs more flexible
External variables

Management of user- Arbitrary definition by the user


defines variables / G-
Codes with symbolic
parameters
Mathematical Usage of mathematical expressions within the G-
expressions (math Code, see chapter 5.2.
parser)
Program structure within Usage of loops, control structures, logical operators
the G-Code (IF, ELSE, etc.
FOR, WHILE, GOTO,
GOTOC etc.)
Program administration Loading and storing of G-Code programs on
SIMOTION CF / MMC card
Operation of more than Multi instances of the G-Code interpreter solution
one channel per
controller
Cycle synchronous IPO- and ServoSynchronousTasks, as well as time
coupling of peripheral base tasks in the SIMOTION execution system
devices, several settable
time slices

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 6
1 Task
1.2 Structure of the SIMOTION G-Code Interpreter

1.2 Structure of the SIMOTION G-Code Interpreter


The G-Code Interpreter is based on the SIMOTION ST-library LGCode (see Figure
1-1). G-Codes are files which consist of ASCII characters, in this surrounding
preferably with the ending “.snc”. This code is loaded from the CF / MMC card in
so-called RAM-slots (short slots) in the memory of the SIMOTION and is available
there for the interpretation.
The application comprises function blocks
• for the program administration,
• for interpreting the G-Code
• and to interpolate the motion.
These functions blocks must be integrated into the application, when using the G-
Code Interpreter.

From G-Code to motion


The program block (FB) loads G-Code files into the slots of the controller, the
interpreter (FB) parses and interprets these and writes the commands into the
global motion buffer. The interpolator (FB) reads the commands out of the global
buffer and executes these. Interpreter and interpolator run asynchronously.
Copyright  Siemens AG 2016 All rights reserved

Figure 1-1: Data flow of G-Code program

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 7
1 Task
1.3 Library LGCode

The integration of the G-Code Interpreter in a user program results in the


application structure shown in Figure 1-2 (see below).

Figure 1-2: Application structure G-Code Interpreter


Copyright  Siemens AG 2016 All rights reserved

NOTE The application can be instanced several times (arbitrarily depending on the
controller resources) by simply creating the respective function blocks and
interface variables multiple times - multi channel.

1.3 Library LGCode


1.3.1 Units

Table 1-2 Units of the LGCode library


Unit Use
aVersion Version information
cProtected Global constants that do not require any adaptation
cPublic Global constants that may not be changed by the user or error constants
dProtected Global type definition – for internal use
fInterpolator Storage location of the function block FBLGCodeIpoInterpolator
fInterpreter Function blocks for the G-Code Interpreter (FBLGCodeProgram,
FBLGCodeInterpreter)
fMathAndBoolParser Function for calculating mathematic expressions (String)
fParser Function Block for the parsing functionality Used in FBLGCodeInterpreter

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 8
1 Task
1.3 Library LGCode

Unit Use
fAuxFct Storage location for auxiliary functions
fParser Auxiliary functions blocks for the interpreter
fTangential Auxiliary functions and function blocks for implementing a tangential
control (FBLGCodeTangentialCtrl)
Copyright  Siemens AG 2016 All rights reserved

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 9
2 Preparation of the SIMOTION project
2.1 Creating the technology objects

2 Preparation of the SIMOTION project


When using the example project explained in chapter 3, these steps are already
performed and only serve for a better comprehension. Are there more than one
channel, then a prefix must be chosen for the technology objects. (e.g.
CH_1_Axis1)

2.1 Creating the technology objects


The following technology objects are required for the implementation of the
SIMOTION G-Code Interpreter functionality:
• Two or three path axes (for 2D or 3D applications). In Figure 2-1, these axes
are called AxisA1, AxisA2 and AxisA3. The synchronous operation
functionality can also be activated for these axes.
• A path object that represents the used kinematics (e.g. Cartesian portal). In
Figure 2-1, the path object is called POCartesian.

Figure 2-1: TO interconnection of the path axes


Copyright  Siemens AG 2016 All rights reserved

Path position axis


• Optionally, a positioning axis (AxisPathPosition) can be interconnected to the
path objet (w2) to output the path position – see Figure 2-2. In case this axis is
available, the accumulated path position is output within the
FBLGCodeInterpolator. With every restart of a G-Code program this position is
set back to zero.

Figure 2-2: TO interconnection of the path position output

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 10
2 Preparation of the SIMOTION project
2.1 Creating the technology objects

Extended look ahead


• Optionally, a positioning axis can be created for the extended look ahead in
order to specify the dynamic path response on dynamicsIn of the path object
(AxisDynIn) – see sIpoCfg.boExtendedLookAheadActive.

Figure 2-3: "dynamicsIn" TO interconnection


Copyright  Siemens AG 2016 All rights reserved

Extended arc definition (helix)


• The positioning axis for the output of the path length (AxisPathPosition) must
in addition be used as master for internal curve synchronizations for the
extended arc definition – see sIpoCfg.eCirclePathPlaneType.

• Two cams (Cam_Ext_Circ1 and Cam_Ext_Circ2) must also be created and


provided with a geometry for the master and slave range (definition range,
value range: 0..1).

Figure 2-4: TO cam

• Both cams must be interconnected to each path axis on which the extended
arc definition is to be used – the third path axis in this case (Z coordinate). The
synchronous operation functionality must first be selected on the relevant path
axis.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 11
2 Preparation of the SIMOTION project
2.1 Creating the technology objects

Figure 2-5: Adding a synchronous object to the path axis

• The inserted synchronous object must be configured as a superimposed object


– [Synchronous object].SyncingMotion.motionImpact =
SUPERIMPOSED_MOTION.
Copyright  Siemens AG 2016 All rights reserved

Figure 2-6: Expert list, synchronous object - superimposed

Figure 2-7: Interconnections of the synchronous object

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 12
2 Preparation of the SIMOTION project
2.2 Integrating of the ST library

2.2 Integrating of the ST library


The SIMOTION G-Code Interpreter is provided as a ST-library. The LGCode library contains
besides the interpolator function block also the parser and interpreter blocks. The library is
available in XML format and can be imported under Libraries (right-click à Import object) (see
Figure 2-8).

Figure 2-8: Importing the library


Copyright  Siemens AG 2016 All rights reserved

Figure 2-9: Importing the library

2.3 Creating the global interface variables


A new ST program with the name dGCodeInterface must be created under
Programs. The following global variable structure must be defined within this
source file:

INTERFACE
//------------- Import ---------------------------------------------------------
USELIB LGCode;
//------------- Device global variables ----------------------------------------
VAR_GLOBAL
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// GCode - Interface and control structure
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gasGCode : ARRAY[1..NUMBER_OF_HANDLING_DEVICES] OF sLGCodeIprInterfaceType;
END_VAR
END_INTERFACE

The gasGCode structure is the central interface for the communication of the
blocks with each other. It is configured as an array in order to be able to use
several instances of the G-Code Interpreter.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 13
3 Example Project
3.1 Architecture

3 Example Project
The example project SimGCode provides a testing environment of the G-Code
Interpreter for the user, including an HMI connection (SimGCodeHmi).
The individual function blocks of the library LGCode are intergrated exemplarily
and assigned with variables. Furthermore pre-defined G-Code files are available,
those can be transferred via FTP to the memory card of the SIMOTION controller.
With the HMI these files can be loaded and traversed, see chapter 7.1.2.

3.1 Architecture
The application was created with SIMOTION SCOUT (classic) V4.4 for a
SIMOTION D425-2 hardware platform, the HMI configuration with the TIA Portal
V13 SP1 for a KTP900F comfort panel. The connection between controller and
HMI is done via the device proxy inside the TIA portal.
For the SIMOTION part, perform a download from SIMOTION SCOUT, for
visualization on HMI, perform the download or the start of the simulation / runtime
respectively with the TIA Portal. Details can be found in chapter 11 - \3\ and \4\.

Figure 3-1: SIMOTION SCOUT project with Comfort Panel


Copyright  Siemens AG 2016 All rights reserved

3.2 Overview
Apart from the usage of the library LGCode, there are other standard functionalities
used, e.g. for enabling the axes, for jogging, message handling etc. The following
table gives an overview of the functionalities and the used standard blocks. Further
details concerning the standard applications can be found in the references
(chapter 11). Prefixes of the units within the folders provide information about the
content.
c – constant definitions
d – data definitions – types, structures, variables, FB instances
p – program definitions – configurations and function block calls

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 14
3 Example Project
3.2 Overview

Table 3-1: Used standard functionalities


Function Standard library Folder comment
Path object jogging LJgPth JogPath Function block for incremental /
continuous jogging of the path object,
see \7\
In addition AlarmS handler for the
messages from JoPath function block
OMAC mode and state LPMLV30 OMAC Operation mode manager – here
manager MANUAL (jogging etc.) and
PRODUCTION (run of traversing
program by the interpreter)

G-Code general LGCode GCode dGCode: instancing of the functions


blocks
dGCodeInterface: global interface
variables – see chapter 10
fGCodeAlaramHandler: Alarm handler
– see chapter 8.2
pGCode: configuration and call of the
function blocks (program, interpreter
and interpolator)
Kinematic Simulation LCom KSC Coupling of the path object to the
Copyright  Siemens AG 2016 All rights reserved

Center (KSC) visualization tool KSC per TCP-IP with


library LCom – see \8\
Axis FB LMCBasic MCBasic Basic axis functionalities – here e.g.
axis enable, referencing etc.
In addition AlarmS handler

Table 3-2: SIMOTION units


Folder Unit Program name Meaning
cJogPath - Constants for FBJogPath
dJogPath - Data for FBJogPath including
FB instances
fJogPathAlarm - Alarm handler for FBJogPath
JogPath Handler (AlarmS)
pJogPath pJogPathStartup Defintions / initializations for
(StartupTask) FBJogPath
pJogPathBackground Call of FBJogPath and the
(BackgroundTask) respective alarm handler
dJogPathHmi HMI data for FBJogPath
JogPathHmi pogPathHmi pJogPathHmiCyclic Multiplexer for coupling of
several instances on one HMI
cOmacV30 Constants for OMAC mode
and state manager
dOmacV30 Data for OMAC, including FB
instances

OMAC fOmacV30 Function block mode and


state manager, here mode
PRODUCTION and manual
used
pOmacV30 pOmacModeStateManager Call of function block
(BackgroundTask)

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 15
3 Example Project
3.2 Overview

Folder Unit Program name Meaning


OmacHmi dOmacHmi HMI data for OMAC
pOmacHmi pOmacHmiCyclic Multiplexer for coupling of
several instances on one HMI
dGCode - Data of the G-Code
interpreter, including FB
instances, see chapter 7.5.2
dGCodeInterface - Declaration of interface
variables
- Global interface for
control and state
variables
- M-functions
- H-parameter
GCode - Configuration data
See chapter 10
fGCodeAlarmHandler - Alarm handler for G-Code
interpreter (AlarmS)
pGCode pGCodeStartup Configurations and
(StartupTask) initialization of the G-Code
pGCodeCyclic function blocks
Copyright  Siemens AG 2016 All rights reserved

(BackgroundTask) Call of the function blocks


(program, interpreter, alarm
pGCodeIpoCyclic handler)
(BackgroundTask /
IPOSynchronousTask)
dGCodeHmi - Data for the HMI coupling
pGCodeHmi pGCodeHmi Programs for the preparations
GCodeHmi (BackgroundTaks) of data for the HMI – mainly
G-Code editor
Multiplexer for coupling of
several instances on one HMI
pKSCInterface pComKscCyclic Interface to the simulation tool
KSC (BackgroundTask) KSC (Kinematic simulation
Siehe \8\ center), see chapter 11.

cMCBasic Constants for the MC Basic


axis functions blocks
dMCBasic Data for the MC Basic axis
function block, including FB
instances
MCBasic fMCBasicAlarmHandler Alarm handler for MC Basic
axis function block (AlarmS)
pMCBasic pMCBasicStartup Configuration and initialization
(StartupTask) of MC Basic axis function
pMCBasicBackground block
(BackgroundTask) Call of the axis function block

cGlobal Global constants


Global dGlobal Global type definitions
pGlobal pGlobalStartup Global default values
dGlobalHmi Global HMI data
GlobalHmi
pGlobalHmi pGlobalHmiCyclic Global HMI data
Auxiliary fAux Multiplexer function blocks

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 16
3 Example Project
3.2 Overview

3.2.1 Sequence

The foundation of the sequence is the OMAC mode and state manager (folder
OMAC). The mode or state transition is done via the control variables in Unit
dOmacV30.
Within the transient states (Resetting, Starting, Aborting etc.) the function block
FBOmacModeStateManager (Unit fOmacV30) waits until all present modules
have finished the currently active state. The sequencer of the individual modules
can be found in the respective folders. The coordination of the modules with the
OMAC state machine is achieved with the bit array aboStateComplete / aboError in
unit dOmacV30, see Figure 3-2 and Figure 3-3.

Figure 3-2: Sequence with OMAC mode and state manager

OMAC G-Code MCBasic (Axis FB) Jog Path


PRODUCTION PRODUCTION PRODUCTION PRODUCTION
boStart
RESETTING: wait for SC[1-n] RESETTING: finished à SC RESETTING: finished à SC SC
boStop STARTING: wait for SC[1-n] STARTING: finished à SC STARTING: finished à SC

ABORTING: wait for SC[1-n] ABORTING: finished à SC ABORTING: finished à SC


boInterrupt
STOPPING: wait for SC[1-n] STOPPING: finished à SC STOPPING: finished à SC

MANUAL MANUAL MANUAL MANUAL


Copyright  Siemens AG 2016 All rights reserved

RESETTING: wait for SC[1-n] RESETTING: finished à SC RESETTING: finished à SC RESETTING: finished à SC

STARTING: wait for SC[1-n] STARTING: finished à SC STARTING: finished à SC STARTING: finished à SC

ABORTING: wait for SC[1-n] ABORTING: finished à SC ABORTING: finished à SC ABORTING: finished à SC

STOPPING: wait for SC[1-n] STOPPING: finished à SC STOPPING: finished à SC STOPPING: finished à SC
SC[1] Error [1] SC[2] Error [2] SC[3] Error [3]

State complete (SC)

Error

Figure 3-3: OMAC mode and state manager

3.2.2 HMI connection

The example project is designed for n handling devices working with a single HMI.
The HMI variables are switched via a multiplexer inside the SIMOTION. The HMI

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 17
3 Example Project
3.3 Preparations

variables can also be directly connected to the CPU-variables in case of only one
handling device used.
The variables for switching the active channel (handling device) are located in the
unit dGlobalHmi (folder GlobalHmi/Global).

Table 3-3: Switching of the active channel


Variable Meaning
gu8HmiChNumberActive Active handling channel (device number)
gu8HmiChNumberRequested Requested handling channel (device number)

Depending on which handling device is currently active, the CPU data are copied
to the HMI data and vice versa. Changes on the controller side have a higher
priority than changes on the HMI. The principle mechanism can be seen in
Figure 3-4. The corresponding functions can be found in the folder Auxiliary (sub
folder of Global).

Figure 3-4: HMI switch-over between the channel


Copyright  Siemens AG 2016 All rights reserved

3.3 Preparations
3.3.1 G-Code Interpreter

1. Load the SIMOTION controller with the respective project and start the WinCC
Comfort simulation or runtime
2. Copy the SNC files from the path „Interpreter\GCodeFiles_n 1\“ to the memory
card of the SIMOTION (CF / MMC) – e.g. via FTP -– storage path:
/USER/SIMOTION/HMI/USERFILES/GCodeFiles/
Details can be found in chapter 7.1.

1
n= Handling device number (1..n)

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 18
3 Example Project
3.4 Operation of the application

3.4 Operation of the application


In this description the necessary steps to run and show the application are
explained.

Prerequisite
The following requirements must be fulfilled for the operation of the application:
• The SIMOTION project was loaded to the controller (firmware version 4.4.0.2
or newer).
• All devices are powered on
• The SIMOTION is in operation mode “run” set by the online function of the
SIMOTION SCOUT
• WinCC Comfort V13 SP1 or newer is installed on the PC/PG for the simulation
/ runtime and the visualization is started

NOTE The runtime requires an authorization.


Without authorization an acknowledgeable note is displayed.
Copyright  Siemens AG 2016 All rights reserved

3.4.1 Overview

The provided visualization is based on a Siemens global template and should help
to understand the library LGCode. Also, it could be used as a master copy. Some
features (scrolling, insert/delete line and so forth) are implemented in the
SIMOTION, the accordinG-Code can be found in pGCodeHmi (folder GCOdeHmi).
In general the visualization is accessed to the data structure which is defined in
dGCodeHmi.

Overview and description of the visualization


The HMI-screens are fitted automatically to the variant, which is active on the
SIMOTION.
In the following the HMI-Screens from Figure 3-5 are described:
Startscreen:
Is configurated in WinCC as the start screen and represents the main screen of the
Siemens template.

Support:
Via the support screen it is possible to get more links and screens for common
help.

Overview:
The screen named Overview represents the start screen of LGCode and combines
all important information and control elements.

Editor:
This HMI-screen conduces to check, rework and create G-Code programs.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 19
3 Example Project
3.4 Operation of the application

For a better comfort at creating own programs it is possible to teach the current
TCP-position with the G-commands G0, G1, G2 and G3. There is also the
possibility to insert and delete lines.
The teaching functionality is realized with HMI-Scripting in WinCC (TIA).

Interpolator:
This screen shows all details of the Interpolator. It´s possible to start and stop a G-
Code program which is already interpreted.
Additionally the TCP position in all common coordinate systems are provided.

Program:
On this screen it´s possible to see all stored programs on the CF-/MMC-Card.
These programs can be loaded by a click on the according button in the RAM-Slot
in the SIMOTION. Additionally the programs can be stored via the “store”-button.
This HMI-screen also provides an overview of the status of the program FB.

Interpreter:
On the Interpreter-site you can see all detailed information of the Interpreter-FB,
furthermore it´s possible to see the last active code line, the active code line
Copyright  Siemens AG 2016 All rights reserved

(highlighted bold) and the following code line.

Tools / Cosy:
This site provides a table for the administration of 5 tools. Additionally it´s possible
to configure the coordinate systems (G54, G55, G56, G57)

Diagnostics:
The Diagnostics screen provides a message buffer, where all errors and warning
are stored.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 20
3 Example Project
3.4 Operation of the application

Figure 3-5: Overview HMI-Screens

Startscreen

From every sub


screen

Example Project Support

Support
Overview
Copyright  Siemens AG 2016 All rights reserved

Editor

Interpolator
Program

Tool / COSY
Interpreter

Change language (german/english)

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 21
3 Example Project
3.4 Operation of the application

3.4.2 Load program from CF-Card and execute program

You can load a G-Code-Program directly from the CF-Card and execute the loaded
program.
For that follow the ensuing steps:
Table 3-4: load and execute program
no. Action remark
1. Call up the HMI-Screen „Program“
2. Look for your needed G-Code program by
using the scroll functionality (arrow up and
down)
3. Set desired slot number
4. Click the “load”-button before your desired With this click the file name is copied
program automatically in the field “file name” and the
file will be loaded.
5. Call up the HMI-Screen „Interpreter“
6. Chose OMAC mode „Production“
7. Configure your preferred (RAM-) slot number
Copyright  Siemens AG 2016 All rights reserved

for the interpreter


8. Click on “start” button

3.4.3 Create and store G-Code-Program

In this section two different variants are described, how programs can be created
and stored on the CF-/MMC-Card:
• Variant 1 – via HMI (see Table 3-5)
• Variant 2 – via FTP access and editor (see Table 3-6)

For that follow the ensuing steps:

Table 3-5: Variant 1 – via HMI


no. action remark
1. Call up the HMI-Screen „Program“
2. Choose slot number, where the program form
the storage card should be stored
3. Call up the HMI-Screen „Editor“
4. Write program The teach functionality is only reasonable to
use if the OMAC machine state
Manual/Execute is active.
Overview> Manual > Start
5. Call up the HMI-Screen „Program“
6. Click button “store” for copying the program
from the RAM-Slot in the storage card

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 22
3 Example Project
3.4 Operation of the application

Table 3-6 : Variant 2 – via FTP access and editor


no. action remark
1. Create your G-Code program with your see section 7.1.2
preferred editor or cam system
2. Load the created program via FTP access on see section 7.1.2
the CF-/MMC-card
Copyright  Siemens AG 2016 All rights reserved

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 23
3 Example Project
3.4 Operation of the application

4 Best Practice
4.1 Syntax hints
Construction of G-Commands
For a better readability of the G-Code program and to avoid currently not checked
syntax errors the following structure is recommended:
G__ X__ Y__ Z__ I__ J__ K__ AR=__ CR=__ A__ B__ C__ D__ M__ R__=__

File name and program name


For the browsing function in the Interpreter, the files with the G-Code programs
must be named with the following convention:
File name: ProgramNo0..9.snc
The name of a G-Code program is programmed with PRG, followed by preferred
program name in the first code line.
first G-Code line: PRG program_name_4

M30 at the end


Copyright  Siemens AG 2016 All rights reserved

G-Code programs must always be finished by M30.


Feedrate
At the first use of a motion command (without G0) in a G-Code program the
feedrate must be assigned. An error is caused, if the before mentioned assignment
is missing.
G1 X0 Y0 F150

4.2 Programming hints


Changeable tool radius
The tool radius is changeable from the G-Code program by using clipboard tags /
H-parameter and an assignment in the SIMOTION application. In the following
example it is shown for the M-function ten (M10), the tool parameter one and the
H-parameter 1 (H1). The SIMOTION snippet must be called in a cyclic task.
Example:
SIMOTION snippet:
IF gasGCode[1].aboMFct[10] = TRUE THEN
gasGCode[1].sIpoCfg.asToolParameter.r64Radius[1]
gasGCode[1].ar64HPara[1];
END_IF;

G-Code snippet:
M10 H1=5.0 ;set tool parameter
T1 ;activate tool

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 24
3 Example Project
3.4 Operation of the application

Changeable tool length


In many cases the working height (Z-coordinate) is constant and only different tool
lengths require variability in the Z-height. This can be solved with clipboard tags.

Example:
PRG changeable tool length
;working height + tool offset = 10 + 100.85
%R1 = 110.85
;working height + tool + safety distance = 10 + 100.85 + 5
%R2 = 115.85
G0 X0 Y0 Z=%R2
G1 Z=%R1 F150
...
Copyright  Siemens AG 2016 All rights reserved

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 25
5 Programming in G-Code
5.1 Conventions

5 Programming in G-Code
5.1 Conventions
The following conventions apply when programming:

5.1.1 General

• Per block a maximum of three G-Codes is permitted, one main G-Code (G-
Code for describing a motion) and two configuration G-Codes. The
configuration G-Codes must not be mutually exclusive (e.g.: G17 and G18 in
one block).
• A maximum of three M functions and or three H parameter can be
programmed per block.
• M functions / H parameter can also be programmed as a single block.
• There are no block numbers (e.g. N10). The line number is automatically
stored as block number for each G-Code.
• An end of program is marked by M2 / M30.
• Keywords and parameter are always written in upper-case (e.g. G0, IF, X, Y, Z
Copyright  Siemens AG 2016 All rights reserved

etc.)
• Comments are preceded by a semicolon ";".
• At least one position parameter (X, Y or Z) must be specified in motion
commands. Missing position parameters are assigned to the current position in
absolute mode and a zero in relative mode (incremental).
• G commands can be called alternatively with G1 or G01, for example.
• Constant values can be assigned to the individual parameters. The assignment
is different depending on the type of parameter
• The individual parameters can be assigned values. The assignment is different
depending on the type of parameter
A “=” character between the address designator and the value must be
written, if
– The address designator consists of more than one character (e.g. AR =
100, CR = 75.0)
- The “=”-character can be omitted, if the address designator is a single
character and the value is a simple constant. A leading sign is allowed as
well as delimiter symbols after the address designator (e.g. X 100 F300)
• The “_”-character is used as a merger. If needed to combine letters and
number (e.g. user variable, program name, …), it has to be written like this:
PRG ProgramNo_1
Variable_1 = Variable_2 + 5
• There´re no sub programs available
• Variable designations are case-sensitive.

5.2 Reserved keywords


The following keywords are reserved by the Interpreter and must not be used for
user-defined variables or labels:

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 26
5 Programming in G-Code
5.3 Math functions

• G0, G00, G1, G01, G2, G02, G3, G03, G4, G04, G17, G18, G19, G25, G40,
G41, G42, G53, G54, G55, G56, G57, G500, G60, G64, G640, G641, G90,
G91, G92
• CIP, PSSD_X, PSSD_Y, PSSD_Z, POLY_SSD, PSOC_X, PSOC_Y, PSOC_Z,
POLY_SOC
• X, Y, Z, I, J, K, F, AR, CR, A, B, C, D, T, M, R, S
• IF, ELSE, ENDIF, WHILE, ENDWHILE, GOTO, GOTOC, LABEL, PRINT,
STOPRE, FOR, ENDFOR, CALL, SUB, LOAD
• OR, AND, NOT
• SQR, SIN, COS, ASIN, ACOS, ATAN, SINH, COSH, TAN, EXP, LN, LOG,
SQRT, ABS, SIGN, TRUNC, RANDOM, LOGN, MIN, MAX, MOD

5.3 Math functions


In the following tables are shown the different arithmetic and logic operations.
The “.” is used as decimal mark.
Var = 10.2

5.3.1 Logic operations


Copyright  Siemens AG 2016 All rights reserved

Table 5-1: Logic operations


Operation Syntax
equal =
unequal <>
greater >
smaller <
greater, equal >=
smaller, equal <=
and &
or |
not !

5.3.2 Arithmetic operations

Tabele 5-2: Arithmetic operations


Operation Syntax Example
Addition + counter = counter + 1
Subtraction - counter = counter – 1
Multiplication * No = row * column
Division / row = No / column
Power volume = length^3
^
length = volume^(1/3)
Square SQR() area = SQR(length)
Square root SQRT() length = SQRT(area)

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 27
5 Programming in G-Code
5.4 Variables

Operation Syntax Example


Sin SIN() opposite = hypothenuse * sin(30)
Cosin COS() adjacent = hypothenuse * sin(30)

5.4 Variables
5.4.1 Clipboard variables

Clipboard variables are used for the communication with the PLC part of the
application. 32 DINT and 32 LREAL variables are created in a so-called clipboard
on the controller for this purpose.
Clipboard variables are accessed via a preceding "%" followed by "I" or "R" and a
number. Access can be either read or write.

Example:
G92 X=%I1 Y=%I2 Z=%I3 A0 B0 C=%I4
G1 X=%R1 Y=%R2 Z=%R3 F=%R4
Copyright  Siemens AG 2016 All rights reserved

Note The reading and writing of clipboard variables is performed at the time the
corresponding G-Code line is active in the Interpreter, not the time at which the
G-Code line is interpolated. The clipboard variable therefore precedes the motion
program.
If there must be a chronological relationship between the Interpreter and the
interpolator, a STOPRE command should be used before the statement or the
appropriate H parameters used on the command for the write access, see
Section 5.8.2.
32 Integer and 32 Real parameters can be used ([1] –[32]).

5.4.2 User-defined variables

User-defined variables are valid locally, either for the main program or a
subprogram. The variables are created automatically by assignment and are case-
sensitive, i.e. a distinction is made between upper- and lower-case.
Example:
myLoopCount = 1
myDistance = SQRT(SQR(L1) + SQR(L2))

NOTICE Keywords must not be used as variable names!

5.4.3 External variables

In addition to the clipboard variables, external variables can also exchange data
with the PLC part. Access can be either read or write. These variables begin with a
"%" followed by

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 28
5 Programming in G-Code
5.5 Motion commands

EXB for an 8-bit integer (SINT),


EXI for a 16-bit integer (INT),
EXL for a 32-bit integer (DINT),
EXF for a 32-bit floating-point (REAL) value.

Example
%EXB20 = 254
%EXI20 = 20000
%EXL21 = -32647712
%EXF1 = 12.3562
myVar = %EXF1

Note The reading and writing of external variables is performed at the time the
corresponding G-Code line is active in the Interpreter, not the time at which the
G-Code line is interpolated. The external variable therefore precedes the motion
program.
If there has to be a chronological relationship between the Interpreter and the
interpolator, a STOPRE command should be used before the statement or the
appropriate H parameters used on the command for the write access, see
Section 5.8.2.
Copyright  Siemens AG 2016 All rights reserved

100 external variables each of the EXB, EXI, EXL and EXF type can be used.

5.5 Motion commands


All motion commands have in common that in addition to the command
assignment, each can be assigned a maximum of three M functions and a
maximum of three H parameters, see Section 5.10 and Section 0.
In addition two configuration commands can be defined in the same block, see
Section 5.7. There must not be any other motion command or special commands
(see Section 5.6) in the same block!
Execution of the M functions and H parameter are in opposition to the clipboard
and external variables at the time of the execution in the interpolator.

Example:
G0 G60 G17 X100.1 Y200.2 Z300.3 M6 M8 M9 R3=37.5 R17=12 R36=2

5.5.1 Rapid traverse (G0)

Traversing is linear to the specified target coordinates with the preset rapid
traverse velocity. G0 is modal.

Dynamic response:
The dynamic response for the rapid traverse is set in the configuration data as
follows – the velocity is "G0-specific":

sIpoCfg.sDynamics.sGlobal.sG0.r64Velo velocity

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 29
5 Programming in G-Code
5.5 Motion commands

sIpoCfg.sDynamics.sGlobal.r64Accel acceleration
sIpoCfg.sDynamics.sGlobal.r64Decel deceleration
sIpoCfg.sDynamics.sGlobal.r64Jerk jerk

A jerk-limited motion must be set accordingly in the


sIpoCfg.sDynamics.ePathVeloProfile variable.
The global dynamic responses can also be limited in Cartesian form; the global
settings determine the maximum – parameters only apply for the G0 command:

sIpoCfg.sDynamics.sGlobal.G0.r64MaxCartesianVelo
velocity (X, Y; Z)
sIpoCfg.sDynamics.sGlobal.G0.r64MaxCartesianAccel
acceleration (X, Y; Z)
sIpoCfg.sDynamics.sGlobal.G0.r64MaxCartesianDecel
deceleration (X, Y; Z)

Example:
G0 X100.1 Y200.2 Z300.3
Copyright  Siemens AG 2016 All rights reserved

5.5.2 Linear motion (G1)

Traversing is linear to the target coordinates with the specified feedrate. The
feedrate is an absolute value with the mm/s unit. G1 is modal.

Dynamic response:
If parameter F is omitted, the feedrate of the last motion command is used.
The acceleration (A) and the deceleration (D) can also be specified at the
command (these settings apply without changes also for the following commands)
when the corresponding configuration data is set to "SPECIFIC", otherwise the
global settings apply:

sIpoCfg.sDynamics.sGlobal.eAccelType
Acceleration (command-specific - SPECIFIC or global - GLOBAL)
sIpoCfg.sDynamics.sGlobal.eADecelType
Deceleration (command-specific - SPECIFIC or global - GLOBAL)

sIpoCfg.sDynamics.sGlobal.r64Accel acceleration
sIpoCfg.sDynamics.sGlobal.r64Decel deceleration
sIpoCfg.sDynamics.sGlobal.r64Jerk jerk

A jerk-limited motion must be set accordingly in the


sIpoCfg.sDynamics.ePathVeloProfile variable.

Example:
G1 X12.3 Y-20.5 Z122 F250.0 A1500 D2000
In this example, the maximum velocity is 250 mm/s, the maximum acceleration
1500 mm/s² and the maximum deceleration 2000 mm/s².

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 30
5 Programming in G-Code
5.5 Motion commands

5.5.3 Circular motion (G2, G3, G5)

G2, G3 and G5 are modal. G2 describes a clockwise motion and G3 a


counterclockwise motion. With G5, the direction of motion results from the position
of the intermediate point. G2 and G3 only permit circular motion in a main plane (X-
Y, Z-X or Y-Z plane), a 3D arc definition is also possible using CIP (X_Y_Z).
The dynamic response settings are similar to those of the G1 command (Section
5.5.2).

Specification of end point and circle center point (I, J, K)


Full circles can also be interpolated with this type of arc definition.

Example:
G1 X300 Y100 F250
G3 X500 Y300 I0 J200
Parameters I, J and K are always relative (incremental) related to the start
coordinate and refer to the arc center point. I corresponds to the position of the arc
center point in the x-direction, J in the y-direction and K in the z-direction.
Depending on the main plane, the parameter combinations (I, J) for the x-y plane,
(J, K) for the y-z plane, (K, I) for the z-x plane are permitted.
Copyright  Siemens AG 2016 All rights reserved

Figure 5-1 - Specification of end point and circle center point

Specification of end point and opening angle (AR)


Full circles cannot be interpolated with this type of arc definition.

Example:
G1 X300 Y100 F250
G3 X500 Y300 AR=90
Parameter AR is an absolute parameter and specifies the opening angle in
degrees.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 31
5 Programming in G-Code
5.5 Motion commands

Figure 5-2 - Specification of end point and opening angle (AR)

Specification of end point and arc radius (CR)


Full circles cannot be interpolated with this type of arc definition.

Example:
Copyright  Siemens AG 2016 All rights reserved

G0 X300 Y100 F250


G3 X500 Y300 CR=200
Parameter CR is an absolute parameter and specifies the arc radius.

Figure 5-3 - Specification of end point and arc radius (CR)


R=200

End point and intermediate point (I, J, K)


This is the only arc definition variant that permits motion in all three Cartesian
directions (x, y, z).

Example:
G0 X300 Y100 F250
G5 X500 Y300 I141.42 J58.58

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 32
5 Programming in G-Code
5.5 Motion commands

I, J, K describes the position of the intermediate point in relative coordinates


(increments). It corresponds to the position of the intermediate point in the
x direction, J in the y direction and K in the z direction.

Figure 5-4 - End point and intermediate point (I, J, K)


Copyright  Siemens AG 2016 All rights reserved

5.5.4 Automatic contour blending between two linear motions (G640/G641)

With automatic contour blending, an arc or a polynomial is inserted as additional


segment between two linear motions (in 3D).
The automatic counter blending is activated by a G641 command with radius (CR)
and must be written in its own line.
The following commands for linear movement (G0/G1) will be blended
automatically with the programmed radius. A change of the blending radius can be
performed by calling command G641 again with a changed radius (CR).
A blending will be deactivated by G640 followed by a finishing linear command
(G0/G1), which will be blended last. These commands can be written in their own
line or in one line (see example below).
An initiating command G641 must always be finished by a command G640, in
between only linear commands are permitted.
The blending variant can be set as a global variable in the configuration structure
(sIpoCfg.eTransitionType).
With regard to the M functions and H parameter, the additional segment is included
in the following motion.

• CIRCULAR Automatic insertion of a circular segment


• POLYNOMIAL Automatic insertion of a polynomial segment

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 33
5 Programming in G-Code
5.5 Motion commands

Figure 5-5 Automatic blending


R1 R2

P2 P3

Blending point

P4

Y
X
P1

Example:
G0 X0 Y0 Z0 ;P1
Copyright  Siemens AG 2016 All rights reserved

G641 CR=50.0
G1 Y100 F250.0 ;P2
G641 CR=16.67
G1 X100 ;P3
G640
G1 Y50 ;P4

NOTE When G641 is active, the following programmed point will be blended.

5.5.5 Circular motion with additional motion in the vertical direction

With the G-Code Interpreter, it is possible to move the axis that is not part of the
circular motion in the respective path plane. The following configuration data must
be set together with the additional TO interconnection from Section 2.1:
// Extended circle
sIpoCfg.eCirclePathPlaneType := EXTENDED;
sIpoCfg.aCamExtended[1] := Cam_Ext_Circ_1;
sIpoCfg.aCamExtended[2] := Cam_Ext_Circ_2;

The additional motion of the "free" axis is performed by means of superimposed


synchronous operation parallel to the arc interpolation.
The following examples show a circular motion in the XY plane. During the circular
motion the Z axis is moved from position 200 mm to position 300 mm.

G0 X100 Y100 Z200


G3 X200 Y200 Z300 CR=100 F250.0

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 34
5 Programming in G-Code
5.6 Special commands

NOTICE This functionality is currently only available for Cartesian portals. Keep in
mind, that only the basic motion is output at the path object.
In order to get the sum consisting of basic and superimposed motion, refer
to e.g. [axis].positioningState.commandPosition.

Example:
A helix shall be traversed via the „extended circle definition“. The movement of the
free axis – here the z axis – depends on the geometry of the cam disks.

G0 G17 G60 X100 Y100 Z0


G2 G64 X100 Y100 Z100 I100 J0 F250
G2 X100 Y100 Z200 I100 J0
G2 X100 Y100 Z300 I100 J0
G2 X100 Y100 Z400 I100 J0
G0 G60 X0 Y0
Copyright  Siemens AG 2016 All rights reserved

Figure 5-6: Example extended circle definition

5.6 Special commands


All special commands have in common that in addition to the command
assignment, each can be assigned a maximum of three M functions and a
maximum of three H parameters, see Section 5.10 and Section 0.
In addition two configuration commands can be defined in the same block, see 5.7.
There must not be any motion commands (see Section 5.4.2) or other special
command in the same block!
Execution of the M functions and H parameter are in opposition to the clipboard
and external variables at the time of the execution in the interpolator.

5.6.1 Wait time (G4)

The traversing motion is interrupted by the time specified in parameter F in


seconds.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 35
5 Programming in G-Code
5.6 Special commands

Example:
G4 F1.25

5.6.2 Basic work offset (G92)

The workpiece coordinate system can be offset and rotated around its main axes
with the G92 command. The rotation is sequential.
The basic work offset is independent of the commands of the settable work offset
G54, G55, G56, G57, G53 and G500.
The rotation is only possible around the chosen path plane (e.g. Z for X_Y path
plane), the other rotation parameters are ignored.

X: Offset in x direction
Y: Offset in y direction
Z: Offset in z direction
A: Rotation around the x axis
B: Rotation around the (already rotated) y axis
C: Rotation around the (already rotated) z axis
Copyright  Siemens AG 2016 All rights reserved

Example:
G92 X100 Y100 Z300 A0 B0 C45

Figure 5-7: Rotation order

CAUTION Rotation can be effectless


The rotation is only possible around the chosen path plane (e.g. Z
for X_Y path plane), the other rotation parameters are ignored.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 36
5 Programming in G-Code
5.7 Configuration commands

5.7 Configuration commands


A maximum of three configuration commands can be assigned in the same block.
In addition, up to three M functions and/or H parameter are supported; see Section
5.10 and Section 0.
Execution of the M functions and H parameter are in opposition to the clipboard
and external variables at the time of the execution in the interpolator.

5.7.1 Selecting the working plane (G17, G18, G19)

The selection of the working plane specifies the plane in which the arc interpolation
is to be performed. The following settings can be made:

G17: X-Y plane


G18: Z-X plane
G19: Y-Z plane

Figure 5-8: Working plane


Copyright  Siemens AG 2016 All rights reserved

Example:
;Full circle in in Y_Z plane
G0 X0 Y0 Z0
G19
G2 X0 Y0 Z0 I0 J0 K50 F100
M30

5.7.2 Tool radius compensation (G40, G41, G42)

The compensation supports the user when creating a program, for example, for a
milled part in which the tool paths are compensated by the tool radius. The
workpiece dimensions can therefore be taken directly from the construction
drawing – the controller compensates the traversing path.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 37
5 Programming in G-Code
5.7 Configuration commands

Figure 5-9: Tool radius compensation - traversing path


Copyright  Siemens AG 2016 All rights reserved

Only the radius of the selected tool is taken into account for the compensation, not
the tool length, etc.
The tool radius compensation is assigned to the preset radius when a tool is
selected, see Section 5.9.

sIpoCfg.sToolParameter[n].sgName tool name


sIpoCfg.sToolParameter[n].r64Radius tool radius

The compensation is then activated by setting the machining direction (G41/G42).


The compensation is deactivated with the G40 command.

• G41 – activate the tool radius compensation in the machining direction to the
left of the workpiece
• G42 – activate the tool radius compensation in the machining direction to the
right of the workpiece
• G40 – deactivate the tool radius compensation

Behavior at outside contours


The configuration variable sIpoCfg.eToolRadiusCompensationTransitionType
determines how an outside corner is traversed, with an arc or straight-lined.
• ARC transition with arc
• INTERPOLATION_POINT transition with interpolation point

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 38
5 Programming in G-Code
5.7 Configuration commands

Figure 5-10: Outside contour

Behavior at inside contours


When programming inside contours, there is no automatic rounding done. Due to
Copyright  Siemens AG 2016 All rights reserved

the tool geometry – e.g. milling tool – material will remain in the corner.

Figure 5-11: Inside cotour

Note A change of the machining plane (G17, G18, G19), a change of the work offset
(G92, G54, G55, G56, G57) as well as a STOPRE motion command are not
permitted when the tool radius compensation is active!
The tool radius compensation doesn’t provide any collision monitoring!

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 39
5 Programming in G-Code
5.7 Configuration commands

Example:
; Original contour
G90 G17 G60
G0 X0 Y0
G91 ; Relative coordinates
G1 Y30 F50
X20 Y20
X20 Y-40
Y-10
X-40

; Tool radius compensation to the left


G90
G0 X0 Y0
T1 G41 ; Tool 1, activate tool radius compensation left
Copyright  Siemens AG 2016 All rights reserved

G91 ; Relative coordinates


G1 Y30 F50
X20 Y20
X20 Y-40
Y-10
X-40
G40

; Tool radius compensation to the right


G90
G0 X0 Y0
T1 G42 ; Tool 1, activate tool radius compensation right
G91 ; Relative coordinates
G1 Y30 F50
X20 Y20
X20 Y-40
Y-10
X-40
G40

M30

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 40
5 Programming in G-Code
5.7 Configuration commands

Figure 5-12: Tool radius compensation - example


Copyright  Siemens AG 2016 All rights reserved

5.7.3 Work offset, frame (G53, G54, G55, G56, G57, G500)

The workpiece zero in relation to the zero point of the basic offset (G92) is set up
via the settable work offset. In this way, it is possible to call zero points program-
wide via G command, e.g. for different machines.
Only one frame together with the basic offset (G92) can be active at one time.
The offset/rotation of the workpiece coordinate system is additive and independent
of the basic offset G92, the rotation is sequential.
The definition of the respective offset/rotation is performed by means of the
configuration structure:
sIpoCfg.asFrame[54] 2nd settable frame
sIpoCfg.asFrame[55] 3rd settable frame
sIpoCfg.asFrame[56] 4th settable frame
sIpoCfg.asFrame[57] 5th settable frame

// Translation
sIpoCfg.asFrame[n].ar64Trans[1/2/3]
// Rotation
sIpoCfg.asFrame[n].ar64Rot[1/2/3]

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 41
5 Programming in G-Code
5.7 Configuration commands

Figure 5-13: Rotation order

NOTICE Rotation could be ignored!


The rotation is only possible around the chosen path plane (e.g. Z for X_Y path
plane), the other rotation parameters are ignored.
Copyright  Siemens AG 2016 All rights reserved

The respective settable work offset is selected via the G54, G55, G56 or G57
command; a frame active at this time is automatically deselected.
The offset/rotation is permanently reset by setting the G500 command (has no
effect on the basic frame G92).
The G53 command only deactivates the settable frame for the following traversing
block, thereafter the previously selected frame is active again.

Example
G0 X0 Y0 Z0
; activate 2. Frame
G00 G54 X0 Y0 Z0
G1 X100 F400
; deactivate Frame
G0 G500 X0 Y0 Z0

5.7.4 Relative work offset (G52)

The workpiece zero in relation to the zero point of the basic offset G92 and the
settable work offset G54…G57 is set up via G52. In this way, it is possible to call
zero points program-wide via G command, e.g. for manufacturing the same part
several times in one step and one program.
The offset/rotation of the G52 coordinate system is additive and independent of the
basic offset G92 and the settable work offset G54…G57, the rotation is sequential.
The definition of the respective offset/rotation is performed by G52 command in the
G-Code program:

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 42
5 Programming in G-Code
5.7 Configuration commands

Figure 5-14: G52 frame offset

0
10
0Y
10
2X
G5
Copyright  Siemens AG 2016 All rights reserved

Example
G92 X100 Y100 Z300 A0 B0 C0
G54
G00 X0 Y0 Z0
; Set relative offset/rotation
G52 X100 Y100
G0 X0 Y0 Z300
LABEL myPart
G1 X… Y… Z… F…
G1 X… Y… Z…
.
.
.
; Set relative offset/rotation
G52 X100
Counter = Counter + 1
GOTOC myPart Counter <= 2
; Reset relative offset/rotation
G52

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 43
5 Programming in G-Code
5.8 Other commands

G1 X100 F400
; Deactivate settable frame
G0 G500 X0 Y0 Z0
M30

5.7.5 Blending (G60, G64)

G60 deactivates the velocity blending. Motion therefore always stops at the end of
a motion command.
With G64, the velocity blending is active. The velocity profile for the motion is
calculated for all commands, and traversing is performed with constant velocity if
possible.

Example
G60
G1 X100 Y200 Z300 F250.0
G64
G1 X100 Y100 Z200
G3 X200 Y200 AR=90 Velocity blending active
Copyright  Siemens AG 2016 All rights reserved

5.7.6 Absolute or incremental dimensions (G90, G91)

When G90 is programmed, the position parameters X, Y and Z are interpreted as


absolute values as of the relevant line in the traversing program. With G91, the
position parameters are interpreted as relative values (incremental).

Example:
G1 G90 X100 Y200 Z300 F250.0
G1 G91 X-10 Y20 Z25

5.8 Other commands


Assignments of M functions and H parameters are not supported within the other
commands.

5.8.1 Program name (PRG)

A global name for a program can be specified with this command. This name is
visible in the gasGCode[1].sControl.sNCInterpreter.sgActProgName PLC variable
when interpreting the program.

Example:
PRG myProgram

5.8.2 Preprocessing stop (STOPRE)

The STOPRE command stops the block advance of the Interpreter until the
preprocessing motion buffer of the interpolator has been processed or the state of
the gasGCode[1].sNCIpoBuffer.eNCBufferState buffer is EMPTY.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 44
5 Programming in G-Code
5.9 Tool (T)

With the aid of this command, a chronological relationship between the reading
and writing of clipboard and external variables and the interpolation of the
traversing program can be established, see section 5.45.4.2.

Example:
STOPRE

5.8.3 Comments

Comments are preceded by a semicolon ";". Multi-line comments are not possible.

Example:
G0 X100 Y200 Z300 ;Approach start position

5.9 Tool (T)


The associated tool radius and length is activated when a tool is selected [1 -
LGCODE_IPO_NUMBER_OF_TOOLS]. A tool must be selected in order to use the
tool radius compensation (G41, G42). The tool command can be called within a
motion command, a special command or a configuration command or in an
individual line. With T0 the active tool is deselected.
Copyright  Siemens AG 2016 All rights reserved

sIpoCfg.sToolParameter[n].sgName tool name


sIpoCfg.sToolParameter[n].r64Radius tool radius
sIpoCfg.sToolParameter[n].r64Lenth tool length

Example:
T3

5.10 M functions – general


Generally, M functions are the connection between the PLC and the G-Code.

5.10.1 Reserved M functions

M0, M1, M2, M17, M30


M0 interrupts the traversing program; the user must then restart the program so
that the execution is continued in the next line.
M1 behaves similar to M0, but the function can be selected and deselected via
parameter:
sIpoCfg.boEnableM1

M2 / M30 mark the end of a main program. At an M2 or M30 in the main program,
the Interpreter changes its status from RUNNING to DONE.

M17 is not treated special.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 45
5 Programming in G-Code
5.10 M functions – general

5.10.2 User-defined M functions

In addition to the reserved M function, up to three user-defined M functions in the


range [0..LGCODE_IPO_MAX_NUMBER_OF_M_FCT] (0-99) can be triggered
within a motion command, special command or configuration command. An M
function can also be alone in a command line; a combination with H parameters is
possible.
An M function can be present at the start or end of a block for a cycle or during a
motion. The traversing program can also be interrupted by an M function until the
appropriate M function is reset in the PLC part. M functions are visible in the
gaboMFct[n] global PLC variables.

Variants of the user-defined M functions


The parameterization of the respective M function is performed in the configuration
structure:

sIpoCfg.aeMFunctionType[n]

• SET_BEFORE_AND_RESET_AFTER_ONE_CYCLE
the associated M bit is set before the motion and automatically reset after one
cycle
Copyright  Siemens AG 2016 All rights reserved

• SET_BEFORE_AND_RESET_AFTER
the associated M bit is set before the motion and automatically reset at the end
of the motion
• SET_BEFORE_AND_NO_RESET
the associated M bit is set before the motion and not automatically reset
(performed by the user)
• SET_BEFORE_AND_NO_RESET_AND_WAIT_FOR_ACKNOWLEDGE
the associated M bit is set before the motion and not automatically reset; the
program waits with the processing until the M bit has been reset by the user
(M function requiring acknowledgement)
• SET_AFTER_AND_RESET_AFTER_ONE_CYCLE
the associated M bit is set at the end of the motion and automatically reset
after one cycle
• SET_AFTER_AND_NO_RESET
the associated M bit is set at the end of the motion and not automatically reset
(performed by the user)
• SET_AFTER_AND_NO_RESET_AND_WAIT_FOR_ACKNOWLEDGE
the associated M bit is set at the end of the motion and not automatically reset;
the program waits with the processing until the M bit has been reset by the
user (M function requiring acknowledgement)

Example:
G1 G64 X100 Y100 Z200 F200 M23 M75 M89
Y150 M12
M14
G2 X150 Y200 I50 J0 K0 M7 M19
G1 X200 M12

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 46
5 Programming in G-Code
5.11 H parameters - general

5.11 H parameters - general


H-parameters are used to transfer floating point values from the G-Code to the
PLC.
Up to three H parameters in the range
[1..LGCODE_IPO_MAX_NUMBER_OF_H_PARA] (1-32) can be triggered within a
motion command, special command or configuration command. An H parameter
can also be alone in a command line; a combination with M functions is possible.
In contrast to the clipboard and external variables (see Section · ), the H
parameters are output at the time the interpolator executes the relevant command
line.
H parameters are visible in the gar64HPara[n] global PLC variables.
The H parameter number and value must be defined in the command line of the G-
Code for the output of the H parameter.

Example:
G1 G64 X100 Y100 Z200 F200 M5 H13=45.67 H24=12
H2=42 M6
M7 H3=1.23
Copyright  Siemens AG 2016 All rights reserved

X200

5.12 Additional functions - general


5.12.1 Corner bit

If a G1 command is followed by a further G1 command (no G0), a defined output


can be set during the transition from the first linear motion to the next. The
activation and deactivation position of this output (corner) can be parameterized, as
well as the maximum angle between the two straight lines for which the
functionality is still taken into account - decisive is always the small angle.
The maximum ON duration of the output results from the length of the straight-line
sections. The function is activated via the sIpoCfg.sCorner.boEnable variable.

The corner bit function is illustrated in the following example, the maximum angle
will be selected as <= 90° in the working plane, the ON length before the corner
is to be 150 mm and the OFF length after the corner 100 mm:

// Corner bit
sIpoCfg.sCorner.boEnable := TRUE;
sIpoCfg.sCorner.r64ActivationLengthBeforeCorner := 150.0;
sIpoCfg.sCorner.r64ActivationLengthAfterCorner := 100.0;
sIpoCfg.sCorner.r64MaxAngleDeg := 90.0;

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 47
5 Programming in G-Code
5.12 Additional functions - general

Figure 5-15: Corner bit example


Copyright  Siemens AG 2016 All rights reserved

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 48
5 Programming in G-Code
5.12 Additional functions - general

5.13 Program flow


Assignments of M functions and H parameters are not supported within the
program flow commands, each command needs an individual block. Furthermore
no G commands are allowed in the same block.

5.13.1 LABEL

The keyword LABEL and a following identifier define a jump label in the traversing
program. This jump label can be used for jumps with GOTO or GOTOC. Labels
must be unique.

Example:
LABEL myLabel

5.13.2 GOTO

A jump is made immediately to the specified label with the GOTO command and
the traversing program continued below this label.

Example:
Copyright  Siemens AG 2016 All rights reserved

GOTO myLabel

5.13.3 GOTOC

A jump is made to the specified label with the GOTOC command if the following
condition is true. If the condition is not satisfied, the program is continued with the
next line.

Example:
GOTOC myLabel myLoopCount >= 5

Note A jump with GOTO and GOTOC is possible against as well as with the
processing sequence in the traversing.

5.13.4 WHILE, ENDWHILE

WHILE and ENDWHILE enclose a loop environment that is run through as long as
the condition behind WHILE is satisfied. Therefore an endless loop is possible.

Example:
G0 X100 Y100 Z200
myLoopCount = 1
WHILE myLoopCount <=5
G2 X50 Y50 I50 J0 K0 F100
myLoopCount = myLoopCount + 1
ENDWHILE

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 49
5 Programming in G-Code
5.12 Additional functions - general

5.13.5 IF, ELSE, ENDIF

The IF statement enables conditional branches within a traversing program. If the


condition after IF is true, the following commands are executed. Otherwise the
ELSE branch is executed, if existing.

Example:
G0 X100 Y100
circforward = 1;
IF circforward = 1
G2 X100 Y100 I100 J0 F250
ELSE
G3 X100 Y100 I100 J0 F250
ENDIF

5.13.6 FOR, ENDFOR

A count loop is defined with FOR and ENDFOR. The general syntax is:
Copyright  Siemens AG 2016 All rights reserved

FOR assignment: Increment: End value


Statements
ENDFOR
For an FOR loop there is created a user variable. It is possible to manipulate this
variable within the FOR loop. Start value, increment and quantity could be
programmed directly by numbers or by user variables (no external and Clipboard
variables). The values can be both, positive and negative.

Example 1:
; Draw two full circles
G0 X100 Y100
FOR i=1:1:2
G2 X100 Y100 I100 J0 F250
ENDFOR

Example 2:
; Draw 20 full circles
G0 X100 Y100
quantity = 20
increment = 1
startvalue= 1

FOR i= startvalue:increment:quantity
G2 X100 Y100 I100 J0 F250
ENDFOR

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 50
5 Programming in G-Code
5.14 Example of a traversing program

5.14 Example of a traversing program


5.14.1 Scenario 1

A rectangle with rounded corners shall be traversed.

PRG Rounded_Rectangle
;Demo program
G90 G17 G60
G0 Z100
X200 Y0 Z3
G92 X0 Y0 Z0 A0 B0 C0
G1 Z0 F300
G64 X750
G3 X1000 Y250 CR=250
Copyright  Siemens AG 2016 All rights reserved

G1 Y650
G3 X850 Y800 CR=150
G1 X100
G3 X0 Y700 CR=100
G1 Y200
G3 X200 Y0 CR=200
STOPRE
G1 G60 Z2
G0 Z150
M30

5.14.2 Scenario 2

Adhesive is to be applied to a rectangular contour with rounded corners. Two parts


are on the work table. At the start of the traversing program, a clipboard variable
decides which part is present.

Absolute programming
myLoopCount=1
%I1=1
WHILE myLoopCount <=6
IF %I1=1
G92 X0 Y0 Z0 A0 B0 C0

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 51
5 Programming in G-Code
5.14 Example of a traversing program

%I1=2
ELSE
G92 X-450 Y0 Z0 A0 B0 C0
%I1=1
ENDIF
G0 G90 G60 X-100 Y-100 Z-100
Y-150 Z-120
G1 G64 Y-250 F250.0
G2 X-150 Y-300 I-50 J0
G1 X-350
G2 X-400 Y-250 I0 J50
G1 Y-150
G2 X-350 Y-100 I50 J0
G1 X-150
G2 X-100 Y-150 I0 J-50
Copyright  Siemens AG 2016 All rights reserved

myLoopCount=myLoopCount+1
STOPRE
ENDWHILE
M30

Relative programming
myLoopCount=1
%I1=1
WHILE myLoopCount <=6
IF %I1=1
G92 X0 Y0 Z0 A0 B0 C0
%I1=2
ELSE
G92 X-450 Y0 Z0 A0 B0 C0
%I1=1
ENDIF
G0 G90 G60 X-100 Y-100 Z-100
Y-150 Z-120
G1 G91 G64 Y-100 F250.0
G2 X-50 Y-50 I-50 J0
G1 X-200
G2 X-50 Y50 I0 J50
G1 Y100
G2 X50 Y50 I50 J0

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 52
5 Programming in G-Code
5.14 Example of a traversing program

G1 X200
G2 X50 Y-50 I0 J-50
myLoopCount = myLoopCount + 1
STOPRE
ENDWHILE
M30
Copyright  Siemens AG 2016 All rights reserved

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 53
6 Interpolator
6.1 FBLGCodeInterpolator function block

6 Interpolator
6.1 FBLGCodeInterpolator function block
The global motion buffer is processed by the FBLGCodeInterpolator block which is
in the LGCode library. The motion control is started, stopped, continued or
cancelled with this block.

6.1.1 Constants

The public constants (cPublic unit) that can be changed by the user are described
in the following. Generally, the default settings have been selected sensibly so that
they should only be changed for a good reason.

Table 6-1 Constants of the LGCode library used by the interpolator


Name Description Default setting
LGCODE_IPO_MAX_NUMBER_ Size of the global command buffer 50
OF_NC_SETS
LGCODE_IPO_MAX_NUMBER_ Number of M functions 100 (0-99)
OF_MFCT
Copyright  Siemens AG 2016 All rights reserved

LGCODE_IPO_MAX_NUMBER Number of H parameters 32 (1-32)


_OF_H_PARA
LGCODE_IPO_MAX_NUMBER_ Size of the preprocessor buffer 50
OF_PRE_PROCESS_BUFFER (internal)
LGCODE_IPO_MAX_NUMBER_ Size of the auxiliary buffer (internal) 20
OF
_AUX_BUFFER_ENTRIES
LGCODE_IPO_NUMBER_OF Number of tools for the tool radius 5
_TOOLS compensation
LGCODE_IPO_NUMBER_OF Size of the error buffer 5
_ERROR_BUFFER
LGCODE_IPO_MAX_NUMBER_ Maximum number of commands that 5
OF_PREPROCESSED_CMDS must be present in the preprocessor
buffer before the processing is started
(exception: STOPRE or end of
program)
LGCODE_IPO_MIN_NUMBER_ Minimum number of commands to 2
OF_PREPROCESSED_CMDS which the preprocessor can be emptied
LGCODE_IPO_LENGTH_OF_ Length of the path position output array 100
PATH_POSITION_ARRAY (state.sPathPositionArray)

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 54
6 Interpolator
6.1 FBLGCodeInterpolator function block

6.1.2 Schematic LAD representation

Figure 6-1: Schematic LAD representation


FBLGCodeInterpolator

BOOL startProgram busy BOOL


BOOL stopProgram done BOOL
BOOL reset resetActive BOOL
eLGCodeIpoInter
polationMode interpolationMode error BOOL
BOOL nextStep errorId DWORD
LREAL veloOverride errorInformation DINT[3]
state sLGCodeIpoStateType
actBlock DINT
actPathPlane EnumPathPlane
eLGCodeIpoProgramState
programState Type
M0Active BOOL
M1Active BOOL
MAckNumberActive DINT[3]
waitTimeActive BOOL
actPositionWCS LREAL[3]
actPositionUCS LREAL[3]
actFrame sLGCodeIpoFrameType
Copyright  Siemens AG 2016 All rights reserved

tool sLGCodeIpoToolType
corner BOOL

sLGCodeIpoBufferType partProgram sLGCodeIpoBufferType


BOOL[..] M_Fct BOOL[..]
LREAL[..] H_Para LREAL[..]
sLGCodeIpoConfig sLGCodeIpoConfig
configData
DataType DataType

6.1.3 Inputs and outputs of the function block

Table 6-2 FBLGCodeInterpolator input/output parameters


Name P type 1) Data type Description
startProgram IN BOOL Starts or continues the traversing
program in the command buffer
stopProgram IN BOOL Stops or interrupts the processing,
continuation is possible. An active
wait time (G4) is terminated
automatically after execution.
reset IN BOOL Stops and cancels the program
processing, continuation is not
possible, only a restart
interpolationMode IN eLGCodeIpoInter Selection of the single step mode:
polationMode - CONTINUOUS –
continuous procession ot
the NC program
- SINGLE_STEP – only one
command is processed,
step forward once by
input nextStep

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 55
6 Interpolator
6.1 FBLGCodeInterpolator function block

1)
Name P type Data type Description
- SINGLE_STEP_MOTION –
only after a motion
command (G0, G1, G2,
G3 etc.) the sequence is
stopped and the
interpolator waits for
input nextStep to
continue
nextStep IN BOOL Single step mode – next step
veloOverride IN LREAL Velocity override (0-200%).
Changes are accepted
immediately

partProgram IN/OUT sLGCodeIpoBufferType Global command buffer which


contains the motion commands to
be processed by the interpolator
M_Fct IN/OUT BOOL[..] Array with M functions
H_Para IN/OUT LREAL[..] Array with H parameters
configData IN/OUT sLGCodeIpoConfigDataType Configuration parameters
Copyright  Siemens AG 2016 All rights reserved

busy OUT BOOL Block active and being processed


done OUT BOOL Traversing program processing
completed (M2 / M30)
Active as long as startprogram is
present, but at least for one cycle
resetActive OUT BOOL A reset to stop and cancel the
traversing program or to clear
errors is active
error OUT BOOL TRUE: Error has occurred
errorId OUT DWORD Error number (hexadecimal)
errorInformation OUT DINT[3] Additional information about the
errorId
state OUT sLGCodeIpoStateType Status structure
actBlock OUT DINT Current command (line number)
actPathPlane OUT EnumPathPlane Actual path plane (G17 = X_Y,
G18 = Y_Z, G19 Z_X)
programState OUT eLGCodeIpoProgramStateType Status of the block (see Table 6-
12)
M0Active OUT BOOL Traversing program stopped after
an M0 function – continue with
startProgram
M1Active OUT BOOL Traversing program stopped after
an M1 function – continue with
startProgram
(note sIpoCfg.boEnableM1)
MAckNumberActive OUT DINT[3] M function(s) requiring
acknowledgment is/are active.
Continue by resetting the
appropriate bit in the M_Fct array
waitTimeActive OUT BOOL Wait time (G4) is active
actPositionWCS OUT LREAL[3] Actual position in world

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 56
6 Interpolator
6.1 FBLGCodeInterpolator function block

1)
Name P type Data type Description
coordinates (taking the work offset
into account)
actPositionUCS OUT LREAL[3] Actual position in user coordinates
(without offset)
actFrame OUT sLGCodeIpoFrameType Currently effective work offset
(G92 + G54/G55/G56/G57)
tool OUT sLGCodeIpoToolType Selected tool for the tool radius
compensation (G41/G42)
corner OUT BOOL Corner bit, see Section 5.12.1
1)
Parameter types: IN = input parameter, OUT = output parameter,
IN/OUT = in-out parameter

6.1.4 Configuration

The configuration of the interpolator block is performed with the sLGCodeIpoConfigDataType –


(sIpoCfg) structure.

Table 6-3: sLGCodeIpoConfigDataType


Name Data type Description
Copyright  Siemens AG 2016 All rights reserved

path _pathObjectType Instance of the path object


dynInAxis posAxis Master axis (interconnected internally
with the dynamicsIn of the path object)

Operation of the TO path interpolation


without dynamic response planning and
dynamic response adaptation
aCamExtended ARRAY[1..2] of camType Array of cams for extended arc
definition, synchronous operations
sDynamics sLGCodeIpoDynamicsType Structure for the dynamic response
specification
ePathCartesianKinematics EnumPathCartesianKine Programming in the plane or in space
maticsType - _3D – three-dimensional space
- _2D – two-dimensional path
plane
(X_Y, Z_X, Y_Z)
r64RadiusTolerance LREAL Permissible deviation of the radii R1
and R2 for an arc definition (G2, G3
with specification of the end point and
arc center point)
eTransitionVelocityMode EnumPathTransition Specifies the transition velocity for the
VelocityMode geometric blending.
- LOW_VELOCITY - the transition
geometry is executed with the
lower path velocity of the
previous and the following
motion
- HIGH_VELOCITY - the
transition geometry is
executed with the higher path
velocity of the previous and
the following motion

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 57
6 Interpolator
6.1 FBLGCodeInterpolator function block

Name Data type Description


The parameter is used during the
automatic blending using the G641
command
eBlendingMode EnumPathBlendingMode Specifies the blending.
- INACTIVE – there is no blending
- ACTIVE_WITH_DYNAMIC_
ADAPTION - the current
motion is blended with
consideration of the dynamic
axis response
- ACTIVE_WITHOUT_DYNAMIC
_
ADAPTION - the blending is
performed without
consideration of the dynamic
axis response
eCirclePathPlaneType eLGCodeIpoCirclePath Arc definition
PlaneType - STANDARD: Arcs are defined in
the active path plane
- EXTENDED: The "free"
coordinate for the arc can also
be positioned (with the aid of a
Copyright  Siemens AG 2016 All rights reserved

superimposed camming)
eTransistionType eLGCodeIpoPathTransition Specifies the transition geometry for the
Type automatic blending (G641)
- CIRCULAR – arc transition
segment (smooth velocity)
- POLYNOMIAL – polynomial
transition segment (smooth
velocity and acceleration)
eAutoInsertBlendingMode eLGCodeIpoAutoInsert Blending variant
BlendingModeType - SYSTEM – the system-side
option of the automatic
blending is used
(transitionType); can only be
used with restrictions and
therefore currently cannot be
selected
- GENERAL – applicative
algorithm for blending; general
application
sCornerBit sLGCodeIpoCornerType Structure for "corner bit"
eToolRadiusCompensation eLGCodeIpoToolRadius Behavior of the tool radius
TransitionType CompensationTransition compensation for outside contours
Type - ARC – transition with arc
- INTERPOLATION_POINT –
transition with interpolation
point
boEnableM1 BOOL Enables/disables the stopping of the
traversing program after an M1
command
- TRUE – M1 is considered
- FALSE – M1 is ignored
boExtendedLookAhead BOOL Uses the extended "look ahead" by
Active means of dynamicsIn (dynInAxis)

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 58
6 Interpolator
6.1 FBLGCodeInterpolator function block

Name Data type Description


Operation of the TO path interpolation
without dynamic response planning and
dynamic response adaptation
aeMFunctionType ARRAY [1 .. Parameterization of the "free" M
LGCODE_IPO_MAX_NUMB functions, see chapter 5.10.2
ER_OF_MFCT] OF
eLGCodeIpoMFunctionType

asFrame ARRAY[54..57] OF Configuration of the settable work


sLGCodeIpoFrameType offsets G54-G57 (translation and
rotation), see Section 0
sToolParameter ARRAY[1.. Tool parameters (TOOL1-TOOLn), e.g.
LGCODE_IPO_NUMBER_ for the tool radius compensation
OF_TOOLS]OF
sLGCodeIpoToolParameter
Type

Table 6-4: sLGCodeIpoDynamicsType


Name Data type Description
sGlobal sLGCodeIpoGlobalDynamicsType Global dynamic response settings
Copyright  Siemens AG 2016 All rights reserved

sStop sLGCodeIpoStopDynamicsType Dynamic response settings for


stopping
sAbort sLGCodeIpoAbortDynamicsType Dynamic response settings for
aborting
sContinue sLGCodeIpoContinueDynamicsType Dynamic responses for continuing
an aborted program
ePathVeloProfile EnumPathVelocityProfile Velocity profile for the path:
- TRAPEZOIDAL:
No jerk limitation
- SMOOTH:
Jerk limitation
boDynamicAdation BOOL Dynamic response adaptation for
consideration of the axis limits
- TRUE:
Dynamic response
adaptation is activated
- FALSE:
Dynamic response
adaptation is deactivated

Table 6-5: sLGCodeIpoGlobalDynamicsType


Name Data type Description
sG0 sLGCodeIpoG0DynamicsType Setting for the dynamic response of the rapid
traverse
eAccelType eLGCodeIpoAccelType SPECIFIC:
The acceleration is specified on the motion
command

GLOBAL:
Global acceleration applies for all motion

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 59
6 Interpolator
6.1 FBLGCodeInterpolator function block

Name Data type Description


commands
eDecelType eLGCodeIpoAccelType SPECIFIC:
The deceleration is specified on the motion
command

GLOBAL:
Global deceleration applies for all motion
commands
r64Accel LREAL Global acceleration
r64Decel LREAL Global deceleration
r64Jerk LREAL Global jerk

Table 6-6: sLGCodeIpoG0DynamicsType


Name Data type Description
r64Velo LREAL Rapid traverse velocity
r64MaxCartesianVelo ARRAY[1..3]OF LREAL Index:
1: Maximum velocity in the X direction
2: Maximum velocity in the Y direction
Copyright  Siemens AG 2016 All rights reserved

3: Maximum velocity in the Z direction

r64MaxCartesianAccel ARRAY[1..3]OF LREAL Index:


1: Maximum acceleration in the X direction
2: Maximum acceleration in the Y direction
3: Maximum acceleration in the Z direction

r64MaxCartesianDecel ARRAY[1..3]OF LREAL Index:


1: Maximum deceleration in the X direction
2: Maximum deceleration in the Y direction
3: Maximum deceleration in the Z direction

The sLGCodeIpoStopDynamicsType structure is relevant for the interruption of a motion via the
stopProgram input.

Table 6-7: sLGCodeIpoStopDynamicsType


Name Data type Description
r64Decel LREAL -1: Use global setting
>0: Specific deceleration
r64Jerk LREAL -1: Use global setting
>0: Specific jerk

The sLGCodeIpoAbortDynamicsType structure is relevant for the interruption of a motion via the
reset input or when an error occurs in the sequence.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 60
6 Interpolator
6.1 FBLGCodeInterpolator function block

Table 6-8: sLGCodeIpoAbortDynamicsType – reset input / error


Name Data type Description
r64Decel LREAL -1: Use global setting
>0: Specific deceleration
r64Jerk LREAL -1: Use global setting
>0: Specific jerk

The sLGCodeIpoContinueDynamicsType structure is relevant for the continuation of a motion


after an interruption (stopProgram).

Table 6-9: sLGCodeIpoContinueDynamicsType


Name Data type Description
eType EnumContinueDynamicType Settings for the continuation of the motion after an
interruption
- INTERRUPTED_COMMAND: The motion
is continued with the stop dynamic
response
- SPECIFIC: The motion is continued with
the specific dynamic response(not
available for operation with master axis –
Copyright  Siemens AG 2016 All rights reserved

dnyInAxis)
r64Accel LREAL -1: Use global setting
>0: Specific acceleration
r64Decel LREAL -1: Use global setting
>0: Specific deceleration
r64Jerk LREAL -1: Use global setting
>0: Specific jerk

The sLGCodeIpoFrameType structure is relevant for the configuration of the settable work
offsets (G54 – G57).

Tabelle 6-10: sLGCodeIpoFrameType


Name Datentyp Beschreibung
ar64Trans ARRAY[1..3] OF LREAL Translation (X, Y; Z)
ar64Rot ARRAY[1..3] OF LREAL Rotation (X, Y; Z)

The sLGCodeIpoToolParameterType structure is relevant for the tool radius compensation.

Table 6-11: sLGCodeIpoToolParameterType


Name Data type Description
sgName STRING Definition of the tool name
r64Radius LREAL Definition of the tool radius for the tool radius
compensation, see Section 5.7.1.
r64Length LREAL Definition of the tool length

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 61
6 Interpolator
6.2 Status of the interpolator

6.2 Status of the interpolator


The status of the interpolator is output at programState or at the structure
gasGCode[1].sControl.sNCInterpolator.eState. The following status outputs are
possible:

Table 6-12 Status of the interpolator


Status Description
IDLE The interpolator is not being used
RUNNING The interpolator is processing commands present in the
preprocessing. When the end of the program is reached
(M2 / M30), the block will be switched to the DONE status
STOPPING The interpolator is on the stop ramp (input stopProgram =
TRUE)
STOPPED A traversing program has been interrupted
CONTINUING The processing of the traversing program will be
continued after a stop followed by an automatic switch to
the RUNNING state
ABORTING_BY_RESET The processing of the traversing program will be aborted
due to reset = TRUE. This state is active as long as the
Copyright  Siemens AG 2016 All rights reserved

stop ramp is being processed, followed by a switch to the


ABORTED state
ABORTING_BY_ERROR The processing of the traversing program will be aborted
due to an error. This state is active as long as the stop
ramp is being processed, followed by a switch to the
ABORTED state
ABORTED If the traversing program has been aborted by a reset, this
state is active for one cycle. For an abort due to an error,
the state is active until the reset input is set, followed by a
switch to the IDLE state
DONE If the processing of the commands is completed (M2 /
M30), the block switches to the DONE state as long as the
startProgram input is FALSE, but at least for one cycle.
This is followed by an automatic switch to the IDLE state
ERROR An error occurred while executing a motion command

6.3 Program overview


The relevant programs for the interpolator inside the unit pGCode, their meaning
and their execution level are listed in Table 6-13.

Table 6-13: Overview of the programs


Program name Description Execution level
pStartUp Variable initialization for the StartupTask
interpolator
pIpoCyclic Interpolator block for processing IPOSynchronousTask or
motion commands and triggering BackgroundTask
M functions

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 62
6 Interpolator
6.4 Configuration of the interpolator

6.4 Configuration of the interpolator


A program is required in the StartupTask which sets the defaults for the
interpolator.

PROGRAM pStartUp
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//Interpolator configuration
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//Master axis for the path Object (used for extended look ahead)
gasGCode[1].sIpoCfg.dynInAxis := AxisDynIn;

//Path object
gasGCode[1].sIpoCfg.path := POCartesian;

//Max. path acceleration / deceleration


gasGCode[1].sIpoCfg.sDynamics.sGlobal.r64Accel := 4000.0;
gasGCode[1].sIpoCfg.sDynamics.sGlobal.r64Decel := 4000.0;

//Max. path jerk


gasGCode[1].sIpoCfg.sDynamics.sGlobal.r64Jerk := 100000.0;

//Velocity G0
gasGCode[1].sIpoCfg.sDynamics.sGlobal.sG0.r64Velo := 1300.0;

gasGCode[1].sIpoCfg.sDynamics.sGlobal.sG0.r64MaxCartesianVelo[1] := 950.0;
Copyright  Siemens AG 2016 All rights reserved

gasGCode[1].sIpoCfg.sDynamics.sGlobal.sG0.r64MaxCartesianVelo[2] := 950.0;
gasGCode[1].sIpoCfg.sDynamics.sGlobal.sG0.r64MaxCartesianVelo[3] := 300.0;

//Velocity profile: TRAPEZOIDAL/SMOOTH


gasGCode[1].sIpoCfg.sDynamics.ePathVeloProfile := SMOOTH;

//Use M1 to interrupt program


gasGCode[1].sIpoCfg.boEnableM1 := TRUE;

//Dynamic adaption
gasGCode[1].sIpoCfg.sDynamics.boDynamicAdaption := FALSE;

// Auto geometry blending transition type (G641)


gasGCode[1].sIpoCfg.sAutoGeometryBlendingParameter.eTransitionType:= POLYNOMIAL;

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//M-Function Configuration
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//Behaviour for each M-Function
//(some examples)
gasGCode[1].sIpoCfg.eMFunctionType[2] := SET_BEFORE_AND_RESET_AFTER_ONE_CYCLE;
gasGCode[1].sIpoCfg.eMFunctionType[3] := SET_AFTER_AND_RESET_AFTER_ONE_CYCLE;
gasGCode[1].sIpoCfg.eMFunctionType[4] :=
SET_BEFORE_AND_NO_RESET_AND_WAIT_FOR_ACKNOWLEDGE;
gasGCode[1].sIpoCfg.eMFunctionType[5] := SET_BEFORE_AND_NO_RESET;
//...
END_PROGRAM

6.5 Integrating the function block


The LGCode library contains the FBLGCodeInterpolator interpolator block in the
fInterpolator source file. This block processes the motion commands of the
traversing program and triggers M functions. If the M function is to be output at a
precise time in the IPO cycle, the block must be executed in an
IPOsynchronousTask. If the triggering of the M functions is not time-critical, it can
also be called in the BackgroundTask. The block is integrated as follows.

PROGRAM pIpoCyclic
// Interpolator Program
//+++++++++++++++++++++++++++++++++++++++++++++++++++++

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 63
6 Interpolator
6.5 Integrating the function block

VAR
FBNcInterpolator : FBLGCodeInterpolator;
END_VAR

//take override from HMI


gr64VeloOverride := USINT_TO_LREAL(gsHmiOverride);

FBNcInterpolator (
startProgram := gasHmiInterpolator[1].sControl.boStartProgram
,stopProgram := gasHmiInterpolator[1].sControl.boStopProgram
,reset := gasHmiInterpolator[1].sControl.boReset
,interpolationMode := gasHmiInterpolator[1].sControl.eInterpolationMode
,nextStep := gasHmiInterpolator[1].sControl.boExecuteNextStep
,veloOverride := gr64VeloOverride //Global override variable
,partProgram := gasGCode[1].sNCIpoBuffer
,M_Fct := gasGCode[1].aboMFct
,H_Para := gasGCode[1].ar64HPara
,configData := gasGCode[1].sIpoCfg
,actBlock => gasHmiInterpolator[1].sControl.sNCInterpolator.i32ActBlock
,actPathPlane => gasHmiInterpolator[1].sState.eActPathPlane
,programState => gasHmiInterpolator [1].sControl.sNCInterpolator.eState
,M0Active => gasHmiInterpolator [1].sControl.sNCInterpolator.boM0Active
,M1Active => gasHmiInterpolator [1].sControl.sNCInterpolator.boM1Active
,MAckNumberActive => gasHmiInterpolator[1].sControl.sNCInterpolator.ai32MAckNumberActive
,waitTimeActive => gasHmiInterpolator[1].sControl.sNCInterpolator.boWaitTimeActive
,actPositionWCS => gasHmiInterpolator[1].sControl.sNCInterpolator.ar64ActPositionWCS
,actPositionUCS => gasHmiInterpolator[1].sControl.sNCInterpolator.ar64ActPositionUCS
,actFrame => gasHmiInterpolator[1].sControl.sNCInterpolator.sActFrame
,tool => gasHmiInterpolator[1].sControl.sNCInterpolator.sTool
,busy => gasHmiInterpolator[1].sState.boBusy
,done => gasHmiInterpolator[1].sState.boDone
,error => gasHmiInterpolator[1].sControl.sNCInterpolator.boError
Copyright  Siemens AG 2016 All rights reserved

,errorId => gasHmiInterpolator[1].sControl.sNCInterpolator.b32ErrorId


,errorInformation => gasHmiInterpolator[1].sControl.sNCInterpolator.ai32ErrorInformation
,state => gasHmiInterpolator[1].sControl.sNCInterpolator.sState
);

END_PROGRAM

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 64
7 G-Code Interpreter
7.1 Preparations

7 G-Code Interpreter
7.1 Preparations
7.1.1 SIMOTION IT authentification

As of SIMOTION V4.4, access to the SIMOTION IT Web server is protected by a


multi-level security concept.
As delivered, the security level of the controller is selected as low. During the first
commissioning, a user password authentication with normal access rights must be
performed. Without this authentication, access to the Web server (incl. FTP) is no
longer possible after a project download. In this case, the access level must be
restored, e.g. by deleting the memory card – see the SIMOTION documentation
SIMOTION IT Diagnostics and Configuration.
The authentication can be performed with a Web browser by specifying the
SIMOTION IP address, e.g. 169.254.11.22.
1. Call of the Manage Config > SIMOTION IT > Users & Passwords page.
Add a user with Administrator group. As soon as the user is saved, the
Web server switches to the Security Level normal state because the user
database now contains a valid entry, see the SIMOTION documentation
Copyright  Siemens AG 2016 All rights reserved

SIMOTION IT Diagnostics and Configuration.

Figure 7-1: Performing the authentication

2. Additionally it is possible to register the user directly in the xml-file on the


storage card (CF card)
/USER/SIMOTION/HMICFG/UserDataBase/UserDataBase.xml

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 65
7 G-Code Interpreter
7.1 Preparations

7.1.2 Transferring NC programs to the memory card of the SIMOTION


device

G-Code programs are stored on the CF / MMC card of the SIMOTION controller. A
G-Code program can be transferred to the memory card using the FTP client.
FileZilla is available as FTP client. Notepad++ and its integrated FTP client are also
an easy-to-use option. The advantage of Notepad++ is that the source code of the
G-Code program can be transmitted and edited in the tool. The "SNC.xml" file in
Notepad++ can be imported for the syntax highlighting in Notepad++. The
programs can be downloaded from the following links.

http://www.filezilla.de
http://notepad-plus-plus.org

The NC programs must be stored in the


/USER/SIMOTION/HMI/USERFILES/GCodeFiles_n 2/
folder on the CF / MMC card. The IP address of the SIMOTION device (e.g.
169.254.11.22) must be specified in the FTP client. User name and password are
both preset to "simotion" (up to SIMOTION V4.3) or must be set in accordance with
the authentication – see section 7.1.1. The view in Notepad++ is shown in Figure
Copyright  Siemens AG 2016 All rights reserved

7-2. The FTP client can be activated via the Plugins menu command. Figure 7-3
shows the view in FileZilla.

NOTICE Browsing with the Interpreter is not possible if other file names than
“ProgramNoXX.snc”, are used – (see Figure 7-2)

Figure 7-2: View in Notepad++

2
n= Handling device number (1..n)

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 66
7 G-Code Interpreter
7.2 SIMOTION function blocks

Figure 7-3: View in FileZilla


Copyright  Siemens AG 2016 All rights reserved

7.1.3 Loading and starting the NC program via the interface

After the program has been stored on the memory card, it can be started by the
SIMOTION application. The function blocks FBLGCodeProgram and
FBLGCodeInterpreter are used for this purpose.

7.2 SIMOTION function blocks


7.2.1 Task

The LGCode library provides two function blocks for the control of the Basic G-
Code Interpreter (unit fInterpreter). The FBLGCodeProgram function block controls
the program administration. The FBLGCodeInterpreter function block controls the
Interpreter. It is used to start and cancel traversing programs.
The parsing of the G-Code files is also done by the interpreter.

7.3 FBLGCodeProgram function block


The program administration (FBLGCodeProgram) automatically creates files from
ProgramNo1.snc to ProgramNo[LGCODE_PRG_NUMBER_OF_
FILES].snc when started for the first time. The files offer storage space on the CF-
/MMC-card for G-Code programs.
By default, the program names of these files are set to <ProgramNoXX.snc>. In
case G-Code programs are transferred via FTP to the card, it is recommended, to
use the before mentioned file names, otherwise a browsing is not possible. If no
browsing is necessary, also different file names can be used.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 67
7 G-Code Interpreter
7.3 FBLGCodeProgram function block

7.3.1 Constants

The public constants (cPublic unit) that can be changed by the user are described
in the following. Generally, the default settings have been selected sensibly so that
they should only be changed for a good reason.

Table 7-1 Constants of the LGCode library used by the program administration and parser
Name Description Default setting
LGCODE_PRG_NUMBER_OF_ Maximum number of ASCII lines for 1000
ASCII_LINES each file
LGCODE_PRG_LENGTH_OF_ Maximum length of individual ASCII line 80
ASCII_LINE_STRING
LGCODE_PRG_NUMBER_OF_ Maximum number of files 10
FILES
LGCODE_PRG_LENGTH_OF_ Maximum length of file name 46
FILE_NAME_STRING
LGCODE_PRG_LENGHT_OF_ Maximum length of file path string 200
FILE_PATH_STRING
LGCODE_PRG_FILE_PATH Storage location of ASCII-(G-Code) ‘GCodeFiles_n\’
files on CF / MMC card n= Handling device
/USER/SIMOTION/HMI/USERFILES/ number (1..n)
Copyright  Siemens AG 2016 All rights reserved

LGCODE_PRG_NUMBER_OF_ Maximum number of slots 10


SLOTS

7.3.2 Schematic LAD representation

Figure 7-4: Schematic LAD representation


FBLGCodeProgram

BOOL executeCardToSlot ready BOOL


BOOL executeSlotToCard busy BOOL
BOOL executeDeleteFileOnCard done BOOL
BOOL executeClearSlot error BOOL
BOOL executeParseSlot errorId DWORD
BOOL executeBrowseFolder errorAdditionalId DWORD
BOOL reset errorLineNumber UINT
eLGCodeIprFileState
UINT slotNumber fileState Type
STRING fileName programName String
UINT filePath programList String[]
errorStringDetail String[]

sLGCodeIprInterface gCodeInterface sLGCodeIprInterface


Type Type

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 68
7 G-Code Interpreter
7.3 FBLGCodeProgram function block

7.3.3 Inputs and outputs of the function block

Table 7-2 FBLGCodeProgram input/output parameters


Name P type Data type Description
1)

executeCardTo IN BOOL Loads the program specified at


Slot fileName from the CF / MMC
card to the RAM slot of the
Interpreter specified at
slotNumber
executeSlotTo IN BOOL Saves the program stored in the
Card slotNumber RAM slot on the CF
/ MMC card under the file name
specified in fileName
executeDelete IN BOOL Deletes the program with the
FileOnCard fileName from the CF / MMC
card of the controller
executeClearSlot IN BOOL Clear the RAM slot defined in
slotNumber
executeParseSlot IN BOOL Parse the RAM slot defined in
slotNumber (also syntax check)
executeBrowse IN BOOL Browses the file system. The
Copyright  Siemens AG 2016 All rights reserved

Folder programs available on the CF /


MMC card are displayed in
gasGCode[1].sStorageInfo.asgF
iles, and in addition also in the
FB output programList
reset IN BOOL Resets the block when an error
occurs
slotNumber IN UINT Specifies the RAM slot for
loading, saving and starting
programs
fileName IN STRING[LGCODE_PRG_LENGTH_ File name for loading and
OF_FILE_NAME_STRING] saving the program
filePath IN STRING[LGCODE_PRG_LENGTH_ Path of the data on the CF /
OF_FILE_PATH_STRING] MMC card
Default: ‘GCodeFiles_n\’
Complete path:
\USER\SIMOTION\HMI\USERFI
LES\GCodeFiles_n\
n= Handling device number
(1..n)

gCodeInterface IN/OUT sLGCodeIprInterfaceType G-Code Interface structure

ready OUT BOOL The block is ready for a new


action
busy OUT BOOL The block is processing the last
job
done OUT BOOL The block has processed its last
job
error OUT BOOL An error occurred while
processing a job
errorId OUT DWORD Specifies the error number

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 69
7 G-Code Interpreter
7.3 FBLGCodeProgram function block

Name P type Data type Description


1)

(hexadecimal)
errorAdditionalId OUT DWORD Specifies the additional error
number (hexadecimal) – used
e.g. for Parser errors
errorLineNumber OUT UINT Line number where an error
occurred
fileState OUT eLGCodeIprFileStateType State of the current file
- EXISTING: File exists on
the CF / MMC card
- NOT_EXISTING: File
does not exist on the
CF / MMC card
programName OUT String Displays the program name. If
no program name is stored,
"default" is displayed. The
program name is specified in
the G-Code by the PRG
command
programList OUT ARRAY[1..LGCODE_PRG_ Output of the programs stored
NUMBER_OF_FILES] of on the CF / MMC card (see also
Copyright  Siemens AG 2016 All rights reserved

sLGCodeProgramListType executeBrowsePrograms)
errorStringDetail OUT STRING[LGCODE_PRG_LENGTH_ String output of the error
OF_DIAGNOSTIC_STRING] information
1)
Parameter types: IN = input parameter, OUT = output parameter,
IN/OUT = in-out parameter

7.3.4 Status of the program administration

The status of the program administration is output at


gasGCode[1].sControl.sNcProgram.eState. The following status outputs are
possible:

Table 7-3 Status of the program administration / parser - eLGCodeIprProgramStateType


Status Description
INACTIVE The program administration is currently not being
used
DONE The block has processed the assigned job
ERROR An error occurred while processing a job
BUSY_PARSE_SLOT A traversing program is being compiled
BUSY_LOAD_CARD_TO_SLOT A traversing program is being loaded from the CF /
MMC card
BUSY_STORE_SLOT_TO_CARD A traversing program is being stored on the CF /
MMC card
BUSY_DELETE_FILE_ON_CARD A traversing program is being deleted from the CF /
MMC card
BUSY_BROWSE_FOLDER The CF / MMC card is being browsed for traversing
programs in the respective folder
BUSY_CLEAR_SLOT The respective RAM slot is being cleared

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 70
7 G-Code Interpreter
7.4 FBLGCodeInterpreter function block

7.4 FBLGCodeInterpreter function block


7.4.1 Constants

The public constants (cPublic unit) that can be changed by the user are described
in the following. Generally, the default settings have been selected sensibly so that
they should only be changed for a good reason.

Table 7-4 Constants of the LGCode library used by the interpreter


Name Description Default setting
LGCODE_IPR_NUMBER_OF_USE Number of User Variables 50
R_VAR
LGCODE_IPR_NUMBER_OF_ Number of Clipboard Variables 32
CLIPBOARD_VAR
LGCODE_IPR_NUMBER_OF_ Number of External Variables 100
EXT_VAR
LGCODE_IPR_NUMBER_OF_ Number of Labels 50
LABELS
LGCODE_IPR_NUMBER_OF_ Number of token per block 50
LINE_TOKEN
Copyright  Siemens AG 2016 All rights reserved

LGCODE_IPR_LENGTH_OF_ Lenght (string) per token 10


TOKEN
LGCODE_IPR_STACK_DEPTH Depth of stack 15

7.4.2 Schematic LAD representation

Figure 7-5: Schematic LAD representation


FBLGCodeInterpreter

BOOL executeProgram ready BOOL


BOOL reset busy BOOL
UINT slotNumber done BOOL
eLGCodeIpoProgram
StateType interpolatorProgramState error BOOL
errorId DWORD
errorParser BOOL
errorIdParser DWORD
errorLineNumber UINT
resetActive BOOL
actIprBlock DINT

sLGCodeIprInterface gCodeInterface sLGCodeIprInterface


Type Type

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 71
7 G-Code Interpreter
7.4 FBLGCodeInterpreter function block

7.4.3 Inputs and outputs of the function block

Table 7-5 FBLGCodeInterpreter input/output parameters


Name P type Data type Description
1)

executeProgram IN BOOL Starts the parsing and


interpreting of the program at
slotNumber in the RAM
reset IN BOOL Aborts the parsing and
interpreting of the program
slotNumber IN UINT Specifies the RAM slot for the
respective program

gCodeInterface IN/OUT sLGCodeIprInterfaceType G-Code interface structure

ready OUT BOOL The function block is ready for a


new action
busy OUT BOOL The function block is processing
the last job
done OUT BOOL The function block has
Copyright  Siemens AG 2016 All rights reserved

processed its last job


error OUT BOOL An error occurred while
processing a job
errorId OUT DWORD Specifies the error number
(hexadecimal)
errorParser OUT BOOL An error occurred during parsing
of the G-Code line
errorIdParser OUT DWORD Error ID of the parser
errorLineNumber OUT UINT Line number at which the parser
error occured
actIprBlock OUT DINT Displays the current interpreted
G-Code line (line number in the
traversing program)
1)
Parameter types: IN = input parameter, OUT = output parameter,
IN/OUT = in-out parameter

Note The actIprBlock output of the FBLGCodeInterpreter shows which traversing


block (corresponding to the line number) of the Interpreter is being processed.

7.4.4 Status of the Interpreter

The status of the Interpreter is output at


gasGCode[1].sControl.sNCInterpreter.eState. The following status outputs are
possible:

Table 7-6 Status of the Interpreter


Status Description
INACTIVE The Interpreter is currently not being used
DONE The Interpreter has completely interpreted a traversing

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 72
7 G-Code Interpreter
7.5 Integration of the function blocks

Status Description
program and reached the end of the program
ERROR An error occurred while interpreting a traversing program
RUNNING_CONTINUOUSLY A traversing program is being processed continuously
STOPPED A traversing program has been aborted

7.5 Integration of the function blocks


7.5.1 Program overview

The program is relevant for the interpreter of unit pGCode, its meaning and its
execution level is listed in Table 7-7.

Table 7-7: Overview of the programs


Program name Description Execution level
pCyclicControl Interface blocks for the program BackgroundTask
administration, interpreting and for
starting and stopping of a
Copyright  Siemens AG 2016 All rights reserved

traversing program

7.5.2 Calling the function blocks (FBLGCodeProgram and


FBLGCodeInterpreter)

The FBLGCodeProgram function block is the interface to the program


administration, the FBLGCodeInterpreter function block controls the interpreter.
Both function blocks can be called in the BackGroundTask. In the following source
code example, the inputs and outputs of the function blocks have been assigned to
HMI variables.

PROGRAM pCyclicControl

VAR
FBNcProgram : FBLGCodeProgram;
FBNcInterpreter : FBLGCodeInterpreter;
END_VAR

FBNcProgram (
executeCardToSlot := gasHmiProgram [1].sControl.boExecuteCardToSlot
,executeSlotToCard := gasHmiProgram [1].sControl.boExecuteSlotToCard
,executeDeleteFileOnCard:= gasHmiProgram [1].sControl.boExecuteDeleteFileOnCard
,executeClearSlot := gasHmiProgram [1].sControl.boExecuteClearSlot
,executeParseSlot := gasHmiProgram [1].sControl.boExecuteParseSlot
,executeBrowseFolder := gasHmiProgram [1].sControl.boExecuteBrowseFolder
,reset := gasHmiProgram [1].sControl.boReset
,slotNumber := UINT_TO_USINT(gasHmiProgram [1].sControl.u16SlotNumber)
,fileName := gasHmiProgram [1].sControl.sgFileName
,filePath := CONCAT(CONCAT(LGCODE_PRG_FILE_PATH, DINT_TO_STRING(in
:= 1)) , '\')
,gCodeInterface := gasGCode[1]
,ready => gasHmiProgram [1].sState.boReady
,busy => gasHmiProgram [1].sState.boBusy
,done => gasHmiProgram [1].sState.boDone
,error => gasHmiProgram [1].sState.boError
,errorId => gasHmiProgram [1].sState.b32ErrorID
//,errorAdditionalId =>

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 73
7 G-Code Interpreter
7.5 Integration of the function blocks

,errorLineNumber => gasHmiProgram [1].sState.u16ErrorLineNumber


// ,fileState =>
,programName => gasHmiProgram [1].sState.sgProgramName
// ,programList =>
// ,errorStringDetail =>
);

gsHmiProgram.sState.i32FileState := ENUM_TO_DINT(FBNcProgram.fileState);

FBNcInterpreter (
executeProgram := gasHmiInterpreter[1].sControl.boExecuteProgram
,reset := gasHmiInterpreter[1].sControl.boReset
,slotNumber := gasHmiInterpreter[1].sControl.u16SlotNumber
,interpolatorProgramState := FBNcInterpolator[1].programState
,gCodeInterface := gasGCode[1]
,ready => gasHmiInterpreter[1].sState.boReady
,busy => gasHmiInterpreter[1].sState.boBusy
,done => gasHmiInterpreter[1].sState.boDone
,error => gasHmiInterpreter[1].sState.boError
,errorId => gasHmiInterpreter[1].sState.b32ErrorId
,errorLineNumber => gasHmiInterpreter[1].sState.u16ErrorLineNumber
// ,errorParser =>
// ,errorIdParser =>
// ,resetActive =>
,actIprBlock => gasHmiInterpreter[1].sState.i32ActBlock
);

END_PROGRAM
Copyright  Siemens AG 2016 All rights reserved

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 74
8 Further functions - general
8.1 FBLGCodeTangentialCtrl function block

8 Further functions - general


8.1 FBLGCodeTangentialCtrl function block
The FBLGCodeTangentialCtr function block is for the tangential control of an
additional positioning axis in the project (library LGCode). Depending on the
selected path plane, the relevant axis is controlled tangentially in coupled motion
using the [Positioning axis].defaultmotionIn.position/velocity/acceleration motion
interface. The motion is executed uncoupled from the FBLGCodeInterpolator, a
link to the G-Code program can be established, for example, through M functions.

8.1.1 Schematic LAD representation

Figure 8-1: Schematic LAD representation


FBLGCodeTangentialCtrl

BOOL enable busy BOOL


_PathObjectType pathObject active BOOL
PosAxis axis commandAborted BOOL
Copyright  Siemens AG 2016 All rights reserved

EnumPathPlane pathPlane error BOOL


LREAL startPos errorId DWORD
LREAL offset errorInfo DINT

8.1.2 Inputs and outputs of the function block

Table 8-1 FBLGCodeTangentialCtrlinput/output parameters


1)
Name P type Data type Description
enable IN BOOL TRUE: Block is processed
FALSE: Block is not processed, a
motion is stopped
pathObject IN _PathObjectType Reference of the path object for the
calculation of the tangential angle
axis IN posAxis Tangential axis
pathPlane IN EnumPathPlane Currently active path plane on the
path object
- X_Y
- Y_Z
- Z_X
startPos IN LREAL Start position of the tangential axis
offset IN LREAL Additive angular offset

busy OUT BOOL Block active and being processed


active OUT BOOL Calculation and motion interface on
the tangential axis are active
commandAborted OUT BOOL The motion interface on the tangential
axis has been deactivated by a
substitutional command from outside
the block

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 75
8 Further functions - general
8.1 FBLGCodeTangentialCtrl function block

1)
Name P type Data type Description
error OUT BOOL TRUE: Error has occurred
errorId OUT DWORD Error number (hexadecimal)
errorInfo OUT DINT Additional information about the
errorId
1)
Parameter types: IN = input parameter, OUT = output parameter,
IN/OUT = in-out parameter

8.1.3 Error numbers

The error numbers can be taken from the cPublic unit:

Table 8-2 FBLGCodeTangentialCtrl error numbers


Error number Short text Description
00020001 LGCODE_TANG_CTRL_ERR_ Missing TO interconnection
MISSING_TO
00020002 LGCODE_TANG_CTRL_ Invalid path plane
INVALID_PATH_PLANE
Copyright  Siemens AG 2016 All rights reserved

00020003 LGCODE_TANG_CTRL_ERR_ Error on the motion interface of


MOTION_IF the tangential axis

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 76
8 Further functions - general
8.1 FBLGCodeTangentialCtrl function block

8.1.4 Example

Diagram
Figure 8-2
Copyright  Siemens AG 2016 All rights reserved

G-Code
G90 G17 G60
G0 Z100
X200 Y0 Z3
G92 X0 Y0 Z0 A0 B0 C0
G1 Z0 F200
M33 ; enable tangential control
G1 G64 X750
G3 X1000 Y250 CR=250
G1 Y650
G3 X850 Y800 CR=150
G1 X100
G3 X0 Y700 CR=100
G1 Y200
G3 X200 Y0 CR=200
M34 ; disable tangential control
G0 G60 Z100
M30

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 77
8 Further functions - general
8.1 FBLGCodeTangentialCtrl function block

Configuration – e.g. StartupTask


gasGCode[1].sIpoCfg.eMFunctionType[33] :=
SET_BEFORE_AND_NO_RESET_AND_WAIT_FOR_ACKNOWLEDGE;
gasGCode[1].sIpoCfg.eMFunctionType[34] :=
SET_BEFORE_AND_NO_RESET_AND_WAIT_FOR_ACKNOWLEDGE;

Cyclic program, e.g. IPOSynchronousTask


The motion to the start position in this example is performed with the axis FB.

VAR
boM33Old, boM34Old : BOOL;
boEnableTangentialCtrl : BOOL;
i16TangentialAxisStep : INT;
FBNcTangentialCtrl : FBLGCodeTangentialCtrl;
END_VAR

//Disable tangential movement with M34


IF (gasGCode[1].aboMFct[34] AND NOT boM34Old) THEN
i16TangentialAxisStep := 20;
// Enable tangential movement with M33
ELSIF (gasGCode[1].aboMFct[33] AND NOT boM33Old) THEN
i16TangentialAxisStep := 10;
END_IF;
boM33Old := gasGCode[1].aboMFct[33];
Copyright  Siemens AG 2016 All rights reserved

boM34Old := gasGCode[1].aboMFct[34];

IF (NOT FBNcInterpolator.busy) THEN


gasGCode[1].aboMFct[33] := FALSE;
gasGCode[1].aboMFct[34] := FALSE;
boEnableTangentialCtrl := FALSE;
gasAxisControl[AX_W1].boExecutePos := FALSE;
boEnableTangentialCtrl := FALSE;
i16TangentialAxisStep := 0;
END_IF;

CASE i16TangentialAxisStep OF
10: // Move tangential axis to start position
gasAxisControl[AX_W1].sAxisData.sPosData.boPosAbsolute := TRUE;
gasAxisControl[AX_W1].sAxisData.sPosData.r32Position := 0.0;
gasAxisControl[AX_W1].boExecutePos := TRUE;
// Enable tangential control
IF (gaFBAxis[AX_W1].axisInPosition) THEN
gasAxisControl[AX_W1].boExecutePos := FALSE;
boEnableTangentialCtrl := TRUE;
i16TangentialAxisStep := 15;
END_IF;
15: // Wait until tangential control is active
IF (FBNcTangentialCtrl.active) THEN
gasGCode[1].aboMFct[33] := FALSE;
i16TangentialAxisStep := 100;
END_IF;
20: // Disable tangential control
boEnableTangentialCtrl := FALSE;
IF (NOT FBNcTangentialCtrl.active) THEN
gasGCode[1].aboMFct[34] := FALSE;
i16TangentialAxisStep := 100;
END_IF;
END_CASE;

FBNcTangentialCtrl(
enable := boEnableTangentialCtrl
,pathObject := gasGCode[1].sIpoCfg.path
,axis := AxisW1
,pathPlane := X_Y
,startPos := 0.0
,offset := 0.0);

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 78
8 Further functions - general
8.2 Alarm Handler

8.2 Alarm Handler


8.2.1 Importing the text messages into the SIMOTION project

The "AlarmS.txt" file is imported via the project tree in SCOUT in the following
steps:
• Right-click the project à"Language-dependent texts".
• Select "Alarm_S" in the following screen form and click Import.
• The alarm messages are imported after selecting the "
AlarmS_LGCode.txt" file (see Figure 8-3).
Figure 8-3: Importing the AlarmS messages
Copyright  Siemens AG 2016 All rights reserved

8.2.2 Integrating the ST source file

The ST source file is integrated via the project navigator:


• Right-click PROGRAMS à Import external source à ST source file.
• The import is started after selecting the "fLGCodeAlarmHandler.st" file
(Figure 8-4). The FBSNcAlarmHandler function block is provided in this
source file, which outputs the AlarmS messages.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 79
8 Further functions - general
8.2 Alarm Handler

Figure 8-4: Importing the "fSNcAlarmHandler.st" ST source file


Copyright  Siemens AG 2016 All rights reserved

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 80
8 Further functions - general
8.2 Alarm Handler

8.2.3 FBLGCodeAlarmHandler function block

Schematic LAD representation


Figure 8-5: Schematic LAD representation
FBLGCodeAlarmHandler

BOOL enable errorActive BOOL


BOOL acknowledge errorHistory sLGCodeErrorHistoryType
USINT chNumber

sLGCodeIprInterfaceType gCodeInterface sLGCodeIprInterfaceType

Inputs and outputs of the function block


Table 8-3 FBLGCodeAlarmHandler Input/output parameters
Name P type Data type Description
1)

enable IN BOOL Block is processed


acknowledge IN BOOL Acknowledges pending errors
Copyright  Siemens AG 2016 All rights reserved

chNumber IN USINT Handling device number


gCodeInterface IN/OUT sLGCodeIprInterfaceType Global interface structure, contains
- NCProgram
- NCInterpreter
- NCInterpolator
errorActive OUT BOOL At least one error pending on one of
the functionalities
errorHistory OUT sLGCodeErrorHistoryType Error history with time stamp, error ID
and error source
1)
Parameter types: IN = input parameter, OUT = output parameter,
IN/OUT = in-out parameter

Tabelle 8-4: sLGCodeErrorHistoryType


Name Data type Description
dtTimeStamp DT Time stamp – date and
time
b32ErrorId DWORD Error ID
eAlarmSource eLGCodeAlarmSource Alarm source:
1- Program
2- Interpreter
3- Interpolator
4- Programm
Additional
5- Interpreter
Additional

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 81
8 Further functions - general
8.2 Alarm Handler

8.2.4 Calling the Alarm Handler function block

The instance of the FBLGCodeAlarmHandler function block must be called in a


program assigned to the BackgroundTask. Pending alarms are acknowledged by
the "acknowledge" input which can be assigned as follows:

FBNcAlarmHandler (enable := TRUE


,acknowledge := gboAckErrors
,chNumber := 1
,gCodeInterface := gasGCode[1]);
Copyright  Siemens AG 2016 All rights reserved

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 82
9 Error numbers of the blocks
9.1 Interpolator

9 Error numbers of the blocks


9.1 Interpolator
The error numbers that occur while executing the program with the function block
FBLGCodeInterpolation are output on the following variables.

gasGCode[1].sControl.sNCInterpolator.b32ErrorId /
FBLGCodeInterpolator.errorId – error number

The interpolator state gasGCode[1].sControl.sNCInterpolator.eState also changes


to ERROR.
Error numbers are output in hexadecimal format.

Table 9-1 Error numbers of FBNcInterpolator


Error number Constant Description
00000001 LGCODE_IPO_ERROR_START_ Start during a reset
DURING_RESET
Copyright  Siemens AG 2016 All rights reserved

00000002 LGCODE_IPO_ERROR_INVALID_ Invalid pointer to global


RETRIEVE_POINTER command buffer
(RetrievePointer)
00000100 LGCODE_IPO_ERROR_TO_NOT_ Technology object hasn’t been
ASSIGNED assigned – see
errorInformation[1]:
- 1: Path object
- 2: Path axis a1
- 3: Path axis a2
- 4: Path axis a3
- 5: DynamicsIn axis
- 6: Axis w2
- 7: aCamExtended[1] /
[2]
00000101 LGCODE_IPO_ERROR_NUMBER_ Command buffer too small
OF_CMD_BUFFER_TOO_SMALL (command buffer smaller than
the command queue from the
path object)
00000102 LGCODE_IPO_CMD_BUFFER_LESS_ Command buffer smaller than
OR_EQUAL_AUX_BUFFER the auxiliary buffer
00000103 LGCODE_IPO_ERROR_PATH_ Path object configured
OBJECT_WRONG_CONFIGURATION incorrectly
00000110 LGCODE_IPO_ERROR_REDEFINE_ Error while redefining the
MASTER position of the master axis
00000111 LGCODE_IPO_ERROR_ENABLE_ Error while activating the
MASTER master axis
00000120 LGCODE_IPO_ERROR_REDEFINE_ Error while redefining the path
PATH_POSITION position axis
00000121 LGCODE_IPO_ERROR_ENABLE_ Error while enabling the path
PATH_POSITION position axis
00000200 LGCODE_IPO_INVALID_CIRCLE_ Invalid arc definition
COORDINATES

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 83
9 Error numbers of the blocks
9.1 Interpolator

Error number Constant Description


00000201 LGCODE_IPO_ERROR_FCT_NOT_ Command not permitted
ALLOWED
00000202 LGCODE_IPO_ERROR_PATH_ Error while issuing the path
COMMAND command
00000203 LGCODE_IPO_ERROR_MASTER_ Error while issuing a command
COMMAND to the master axis
00000204 LGCODE_IPO_ERROR_RESET_PATH_ Error while resetting the path
OBJECT_BUFFER object buffer
00000205 LGCODE_IPO_ERROR_CANCEL_ Error while canceling a path
PATH_OBJECT_COMMAND command
00000206 LGCODE_IPO_ERROR_RESET_PATH_ Error during path object
OBJECT "Reset"
00000207 LGCODE_IPO_ERROR_RESET_PATH_ Error while resetting the path
OBJECT_ERROR object errors
00000208 LGCODE_IPO_ERROR_AUTOMATIC_ Error during automatic blending
BLENDING
00000209 LGCODE_IPO_ERROR_CUTTER_ Tool radius compensation error
PATH_COMPENSATION
0000020A LGCODE_IPO_ERROR_TOOL Tool error
Copyright  Siemens AG 2016 All rights reserved

00000210 LGCODE_IPO_INVALID_CORNER_BIT_ Invalid corner bit parameter


PARAMETER
00000220 LGCODE_IPO_ERROR_SUPER_SYNC_ Superimposed synchronous
MOTION operation error
00000230 LGCODE_IPO_ERROR_AXIS_NOT_ Axis not enabled
ENABLED
00000300 LGCODE_IPO_ERR_CONTINUE_ Error while continuing the
MOTION motion
00000301 LGCODE_IPO_ERR_INTERRUPT_ Error interrupt motion
MOTION
00000302 LGCODE_IPO_ERR_INTERRUPT_ Error while stopping the motion
MOTION
00000303 LGCODE_IPO_ERR_ABORT_ Error while canceling the
MOTION motion
00000400 LGCODE_IPO_ERROR_INTERNAL Internal error
00000500 LGCODE_IPO_ERROR_SYNTAX Syntax error

Details on the errors can be found in the


gasGCode[1].sControl.sNCInterpolator.ai32ErrorInformation array.

Table 9-2 Additional information on errors of the interpolator


Array No. Constant Description
index
[1] n - Return value of the internal system function /
function (FC)

[2] 1 LGCODE_IPO_INFO_ Incorrectly configured path object


INVALID_POSITION_ Check the following configuration data on
INDICATION the path object: [Path
object].DecodingConfig.positionIndication =

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 84
9 Error numbers of the blocks
9.1 Interpolator

Array No. Constant Description


index
NON_INCREMENT_BASED
2 LGCODE_IPO_INFO_ Error while buffering the command ID
BUFFER_CMD_ID
3 LGCODE_IPO_INFO_ Error while issuing the command
EXECUTE_CMD
4 LGCODE_IPO_INFO_ Error while determining the command state
GET_STATE_OF_CMD
5 LGCODE_IPO_INFO_ Error while determining the state of the
GET_MOTION_ motion buffer
BUFFER_STATE
6 LGCODE_IPO_INFO_ Command aborted
CMD_ABORTED
7 LGCODE_IPO_INFO_ Error while transferring the superimposed
TRANSFER_ position back to the basic coordinates
SUPERIMPOSED_
POSITION
8 LGCODE_IPO_INFO_ Command does not exist in the command
CMD_NOT_EXISTENT buffer
9 LGCODE_IPO_INFO_ Invalid parameter
Copyright  Siemens AG 2016 All rights reserved

INVALID_PARAMETER
10 LGCODE_IPO_INFO_ Invalid radius
INVALID_RADIUS
11 LGCODE_IPO_INFO_ Same start and end point
EQUAL_START_AND_
END_POINT
12 LGCODE_IPO_INFO_ Negative angle not permitted
NEGATIVE_ANGLE_
NOT_ALLOWED
13 LGCODE_IPO_INFO_ Full circle not permitted
FULL_CIRCLE_NOT_
ALLOWED
14 LGCODE_IPO_INFO_ Invalid circle center point
INVALID_MIDDLE_
POINT
15 LGCODE_IPO_INFO_ Invalid circle transition point
INVALID_INTERMEDIATE
_POINT
16 LGCODE_IPO_INFO_ Error while deleting the command ID
DELETE_CMD_ID
17 LGCODE_IPO_INFO_ Error while calculating the linear length
CALC_LINEAR_PATH_
LENGTH
18 LGCODE_IPO_INFO_ Error while calculating the arc length
CALC_CIRCULAR_PATH_
LENGTH
19 LGCODE_IPO_INFO_ Error while calculating the polynomial length
CALC_POLYNOMIAL_
PATH_LENGTH
20 LGCODE_IPO_INFO_ Error in the first linear section of the
FIRST_LINEAR_AUTO_ automatic blending
BLENDING

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 85
9 Error numbers of the blocks
9.1 Interpolator

Array No. Constant Description


index
21 LGCODE_IPO_INFO_ Error in the second blended section of the
SECOND_ROUNDING_ automatic blending
AUTO_BLENDING
22 LGCODE_IPO_INFO_ Error in the third linear section of the
THIRD_LINEAR_ automatic blending
AUTO_BLENDING
23 LGCODE_IPO_INFO_NO_ Automatic system blending not permitted in
SYSTEM_AUTO_ conjunction with master axis
BLENDING_WITH_
MASTER_AXIS
24 LGCODE_IPO_INFO_G_ G function not permitted
FUNCTION_NOT_
ALLOWED
25 LGCODE_IPO_INFO_ Radius too large
RADIUS_TOO_LARGE
26 LGCODE_IPO_INFO_ Invalid blending radius
INVALID_BLENDING_
RADIUS
27 LGCODE_IPO_INFO_ Consecutive points are the same at
EQUAL_CONSECUTIVE_ geometric blending
Copyright  Siemens AG 2016 All rights reserved

POINTS
28 LGCODE_IPO_INFO_ Consecutive directions are the same (0°) at
EQUAL_CONSECUTIVE_ geometric blending
DIRECTIONS
29 LGCODE_IPO_INFO_ Consecutive directions in opposite direction
REVERSAL_ (180°) at geometric blending
CONSECUTIVE_
DIRECTIONS
30 LGCODE_IPO_INFO_END End of program not permitted in this state
_OF_PROGRAM_NOT_
PERMITTED
31 LGCODE_IPO_INFO_ Faulty enumeration
INVALID_ENUMERATION
32 LGCODE_IPO_INFO_ Invalid G-Code combination
INVALID_G_CODE_
COMBINATION
33 LGCODE_IPO_INFO_ Invalid tool number for the tool radius
INVALID_TOOL_NUMBER compensation
34 LGCODE_IPO_INFO_ Invalid tool radius for the tool radius
INVALID_TOOL_RADIUS compensation
35 LGCODE_IPO_INFO_ STOPRE not permitted in this state
STOPRE_NOT_
ALLOWED
36 LGCODE_IPO_INFO_ Function not permitted with system blending
NOT_ALLOWED_WITH_
SYSTEM_AUTO_
BLENDING
37 LGCODE_IPO_INFO_ Change of the path plane not permitted in
PATH_PLANE_CHANGE_ this state
NOT_ALLOWED
38 LGCODE_IPO_INFO_ Change of the work offset not permitted in
CHANGE_OF_FRAME_ this state
NOT_ALLOWED

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 86
9 Error numbers of the blocks
9.1 Interpolator

Array No. Constant Description


index
39 LGCODE_IPO_INFO_ Change of the tool not permitted in this state
CHANGE_OF_TOOL_
NOT_ALLOWED
40 LGCODE_IPO_INFO_ Polynomial with specification of the
POLYNOMIAL_WITH_ coefficients not permitted in this state
COEFFICIENTS_NOT_
ALLOWED
41 LGCODE_IPO_INFO_ Incorrect axis type
WRONG_AXIS_TYPE
42 LGCODE_IPO_INFO_ Synchronous object missing
FOLLOWING_OBJECT_
MISSING
43 LGCODE_IPO_INFO_ Error while scaling the cam
CAM_SCALE
44 LGCODE_IPO_INFO_ Cam offset error
CAM_OFFSET
45 LGCODE_IPO_INFO_ Circular length zero error
CIRCULAR_LENGTH_
ZERO
Copyright  Siemens AG 2016 All rights reserved

46 LGCODE_IPO_INFO_NO_ No specific continue dynamic response


SPECIFIC_CONTINUE_ permitted during operation with master axis
DYNAMICS_WITH_
MASTER_AXIS
47 LGCODE_IPO_INFO_ Tool radius compensation – error start point
LINEAR_CURRENT_ shift current linear command
START_SHIFT
48 LGCODE_IPO_INFO_ Tool radius compensation – error end point
LINEAR_CURRENT_ shift current linear command
END_SHIFT
49 LGCODE_IPO_INFO_ Tool radius compensation – error start point
LINEAR_NEXT_START_ shift next linear command
SHIFT
50 LGCODE_IPO_INFO_ Tool radius compensation – error start point
LINEAR_NEXT_END_ shift next linear command
SHIFT
51 LGCODE_IPO_INFO_ Tool radius compensation – error start point
CIRCULAR_CURRENT_ shift current circular command
START_SHIFT
52 LGCODE_IPO_INFO_ Tool radius compensation – error end point
CIRCULAR_CURRENT_ shift current circular command
END_SHIFT
53 LGCODE_IPO_INFO_ Tool radius compensation – error start point
CIRCULAR_NEXT_ shift next circular command
START_SHIFT
54 LGCODE_IPO_INFO_ Tool radius compensation – error start point
CIRCULAR_NEXT_ shift next circular command
END_SHIFT
55 LGCODE_IPO_INFO_ Tool radius compensation – error start point
POLYNOMIAL_ shift current polynomial command
CURRENT_START_SHIFT
56 LGCODE_IPO_INFO_ Tool radius compensation – error end point
POLYNOMIAL_ shift current polynomial command
CURRENT_END_SHIFT

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 87
9 Error numbers of the blocks
9.1 Interpolator

Array No. Constant Description


index
57 LGCODE_IPO_INFO_ Tool radius compensation – error start point
POLYNOMIAL_NEXT_ shift next polynomial command
START_SHIFT
58 LGCODE_IPO_INFO_ Tool radius compensation – error start point
POLYNOMIAL_NEXT_ shift next circ polynomial command
END_SHIFT
59 LGCODE_IPO_INFO_ Tool radius compensation – error calculate
CALC_CIRC_CENTER_ circle center current command
CURRENT_CMD
60 LGCODE_IPO_INFO_ Tool radius compensation – error calculate
CALC_CIRC_CENTER_ circle center next command
NEXT_CMD
61 LGCODE_IPO_INFO_ Tool radius compensation – error start point
CALC_END_POINT_ shift linear command
SHIFT_LINEAR_CMD
62 LGCODE_IPO_INFO_ Tool radius compensation – error end point
CALC_END_POINT_ shift circular command
SHIFT_CIRCULAR_CMD
63 LGCODE_IPO_INFO_ Tool radius compensation – error calculate
CALC_CIRC_CENTER_ circle center shift
Copyright  Siemens AG 2016 All rights reserved

SHIFT
64 LGCODE_IPO_INFO_ Tool radius compensation – error
CHANGED_RADIUS_ compensated radius current command
CURRENT_CIRCLE_ smaller than zero
SMALLER_THAN_ZERO
65 LGCODE_IPO_INFO_ Tool radius compensation – error
CHANGED_RADIUS_ compensated radius next command smaller
NEXT_CIRCLE_ than zero
SMALLER_THAN_ZERO
66 LGCODE_IPO_INFO_ Tool radius compensation – error during
CALC_ANGLE_ calculation of angle between two vectors
BETWEEN_VECTORS_
FAILED
67 LGCODE_IPO_INFO_ Tool radius compensation – error negative
LONG_RUN_RADIUS_ radius not permitted
NOT_ALLOWED
68 LGCODE_IPO_INFO_ Tool radius compensation – error full circle
CIRCLE_AFTER_FULL_ after full circle not permitted
CIRCLE_NOT_
PERMITTED
90 LGCODE_IPO_INFO_ Functionality not supported
FUNCTION_NOT_
AVAILABLE

[3] 1 LGCODE_IPO_INFO_ Error source: Path object


PATH_OBJECT
2 LGCODE_IPO_INFO_ Error source: Master axis
MASTER
3 LGCODE_IPO_INFO_ Error source: Path position axis
PATH_POSITION
4 LGCODE_IPO_INFO_ Error source: Superimposed camming
SUPER_SYNC_MOTION

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 88
9 Error numbers of the blocks
9.2 Interpreter

Array No. Constant Description


index
5 LGCODE_IPO_INFO_ Error source: FCLGCodeCalcOverPosition
CALC_CIRCLE_OVER_
POSITION
6 LGCODE_IPO_INFO_ Error source: FCLGCodeCalcMiddlePoint
CALC_CIRCLE_MIDDLE_
POINT
7 LGCODE_IPO_INFO_ Error source:
CALC_SHORTEND_ FCLGCodeCalcShortendVectorLength
VECTOR_LENGTH
8 LGCODE_IPO_INFO_ Error source:
CALC_AUTO_BLENDING FCLGCodeCalcAutomaticBlendingOver
_OVER_POSITION Position
9 LGCODE_IPO_INFO_ Error source:
CALC_CUTTER_PATH_ FCLGCodeCalcCutterPathCompensation
COMPENSATION_ Coordinates
COORD
10 LGCODE_IPO_INFO_ Error source: FCLGCodeLineLineIntersect
CALC_LINE_LINE_
INTERSECTION
Copyright  Siemens AG 2016 All rights reserved

11 LGCODE_IPO_INFO_ Error source: FCLGCodeLineCricleIntersect


CALC_LINE_CIRCLE_
INTERSECTION
12 LGCODE_IPO_INFO_ Error source:
CALC_CIRCLE_CIRCLE_ FCLGCodeCircleCircleIntersect
INTERSECTION
13 LCGOCE_IPO_INFO_ Error source:
CALC_ANGLE_ FCLGCodeCalcAngleBetweenVectors
BETWEEN_VECTORS
14 LGCODE_IPO_PRE_ Error source: Preprocessing
PROCESS
15 LGCODE_IPO_STEP_ Error source: Auto blending first step
FIRST
16 LGCODE_IPO_STEP_ Error source: Auto blending second step
SECOND

9.2 Interpreter
9.2.1 Errors of the program administration / parser

The error numbers that occur during program administration and parsing of the
program can be evaluated using the following variables:
gasGCode[1].sControl.sNcProgram.b32ErrorID /
FBLGCodeProgram.errorId – error number

gasGCode[1].sControl.sNcProgram.b32AdditionalErrorID /
FBLGCodeProgram.errorAdditionalID – additional error number parser

In case of a parser error, the respective line number is displayed using the
following variables:

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 89
9 Error numbers of the blocks
9.2 Interpreter

gasGCode[1].sControl.sNcProgram.u16ErrorLineNumber /
FBLGCodeProgram.errorLineNumber – command line in which the error
occurred

The state gasGCode[1].sControl.sNcProgram.eState also changes to ERROR.


Error numbers are output in hexadecimal format.

Table 9-3 Error numbers of the program administration / parser


Error number Constant Description

Program
LGCODE_PRG_ERR_FILE_ File path too long
FFFF_0001 PATH_TOO_LONG
LGCODE_PRG_ERR_INVALID_ Invalid slot number
FFFF_0002 SLOT_NUMBER
FFFF_0002 LGCODE_PRG_ERR_NC_PARSER Error during parsing of the file
LGCODE_PRG_ERR_COMMAND_ Command cannot be executed
FFFF_8002 CANNOT_BE_EXECUTED
LGCODE_PRG_ERR_COMMAND_ Command buffer full
FFFF_8003 BUFFER_FULL
Copyright  Siemens AG 2016 All rights reserved

LGCODE_PRG_ERR_SLOT_ slot access denied


FFFF_8004 ACCESS_DENIED
LGCODE_PRG_ERR_WHEN_ Error when writing file
FFFF_8005 WRITING
LGCODE_PRG_ERR_WHILE_ Error while writing file
FFFF_8006 WRTING
LGCODE_PRG_ERR_FILE_IS_ Error file is already opened
FFFF_8008 OPEN
LGCODE_PRG_ERR_INTERNAL_ Internal error
FFFF_8009 ERROR
LGCODE_PRG_ERR_FILE_NOT_ File not found
FFFF_800A FOUND
LGCODE_PRG_ERR_FILE_ File already exists
FFFF_800B ALREADY_EXISTS
LGCODE_PRG_ERR_MAXIMUM_ Maximum number of opened
NUMBER_OF_OPEN_FILES_ files exceeded
FFFF_800C EXCEEDED
LGCODE_PRG_ERR_INVALID_ Invalid file handle
FFFF_800D FILE_HANDLE
LGCODE_PRG_ERR_INVALID_ Invalid file name
FFFF_800E FILE_NAME
LGCODE_PRG_ERR_NO_ No memory for file available
MEMORY_SPACE_AVAILABLE_
FFFF_800F FOR_FILE
LGCODE_PRG_ERR_FILE_ File access denied
FFFF_8010 ACCES_WAS_DENIED
LGCODE_PRG_ERR_FILE_DATA_ File not read in full
FFFF_8011 NOT_READ_IN_FULL
LGCODE_PRG_ERR_DATA_NOT_ File not written, not enough
WRITTEN_NOT_ENOUGH_ bytes
FFFF_8012 BYTES_AVAILABLE

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 90
9 Error numbers of the blocks
9.2 Interpreter

Error number Constant Description


LGCODE_PRG_ERR_CR_LF_NOT_ CR/LF not found during reading
FFFF_8013 FOUND_DURING_READING
LGCODE_PRG_ERR_FILE_HANDLE File handle already assigned
FFFF_8014 _ALREADY_ASSIGNED
LGCODE_PRG_ERR_INVALID_FB_ Invalid FB state
FFFF_FFFF STATE
Parser
00010001 LGCODE_PARSER_ERR_
INTERNAL Internal parser error
00010201 LGCODE_PARSER_ERR_
EMPTY_CODE_LINE Empty code line
00010202 LGCODE_PARSER_ERR_
OVERFULL_CODE_LINE Code line exceeds length
00010203 LGCODE_PARSER_ERR_
SYNTAX_UNKNOWN unkonwn syntax
00010204 LGCODE_PARSER_ERR_
SYNTAX_MULTI_G Multiple G-Codes in one set
00010205 LGCODE_PARSER_ERR_
SYNTAX_MULTI_XYZ Multiple coordinates in one set
Copyright  Siemens AG 2016 All rights reserved

00010206 LGCODE_PARSER_ERR_
SYNTAX_PARA_XYZ Syntax error in coordinates
00010207 LGCODE_PARSER_ERR_
SYNTAX_MULTI_PARA multiple parameter in one set
00010208 LGCODE_PARSER_ERR_ Syntax error in one or more
SYNTAX_PARA parameters
00010209 LGCODE_PARSER_ERR_
SYNTAX_MULTI_SETNUMBER Multiple set numbers
00010210 LGCODE_PARSER_ERR_
SYNTAX_SETNUMBER Syntax error in set number
00010211 LGCODE_PARSER_ERR_
SYNTAX_M_FUNCTION Syntax error in m function
00010212 LGCODE_PARSER_ERR_
SYNTAX_H_PARAMETER Syntax error in H parameter
00010213 LGCODE_PARSER_ERR_
PARAMETER_OVERFLOW Parameter overflow
00010214 LGCODE_PARSER_ERR_WRONG_
CLIPBOARD_NO Invalid number of clipboard tag
00010215 LGCODE_PARSER_ERR_SYNTAX_ syntax error - clipboard tags
CLIPBOARD
00010216 LGCODE_PARSER_ERR_MISSING_ Missing M2 / M30 at the end of
M2_M30 main program
00010217 LGCODE_PARSER_ERR_SYNTAX_ Syntax error in math expression
MATH_EXPRESSION
00010218 LGCODE_PARSER_ERR_SYNTAX_ User Variable can´t be created
SET_VARIABLE
00010219 LGCODE_PARSER_ERR_NO_OF_V Number of user-defined
ARIABLE_OVERFLOW variables exceeded.
Increase the regarding constant.
00010220 LGCODE_PARSER_ERR_SYNTAX_ Syntax error label definition
LABEL
00010221 LGCODE_PARSER_ERR_NO_OF_L Number of labels exceeded.
ABELS_OVERFLOW Increase the regarding constant.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 91
9 Error numbers of the blocks
9.2 Interpreter

Error number Constant Description


00010222 LGCODE_PARSER_ERR_LABEL_ Jump to undefined label
UNDEFINED
00010223 LGCODE_PARSER_ERR_LABEL_ Label is already defined. Labels
NOT_UNIQUE must be unique.
00010224 LGCODE_PARSER_ERR_FOR Forbidden parameter or sign in
BIDDEN_PARAMETER_IN_CND condition.
00010225 LGCODE_PARSER_ERR_SYNTAX_ Syntax error in condition
CONDITION
00010226 LGCODE_PARSER_ERR_SYNTAX_ Syntaxfehler bei STOPRE
STOPRE
00010227 LGCODE_PARSER_ERR_SYNTAX_ Syntax error - PRG
PRG
00010228 LGCODE_PARSER_ERR_INVALID_ Invalid line number was chosen.
LINE_NUMBER
00010229 LGCODE_PARSER_ERR_SYNTAX_ Syntax error - GOTO
GOTO
00010230 LGCODE_PARSER_ERR_MISSING_ Missing motion command.
MOTION_CMD
00010231 LGCODE_PARSER_ERR_SYNTAX_ wrong parameter programmed
WRONG_PARA_IN_LINE
00010232 LGCODE_PARSER_ERR_SYNTAX_ There aren´t programmed all
MISSING_PARA needed parameters.
00010233 LGCODE_PARSER_ERR_JUMP_IN Forbidden jump in loop or
Copyright  Siemens AG 2016 All rights reserved

TO_LOOP branch. (e.g.: FOR, IF,…)


00010234 LGCODE_PARSER_ERR_SYNTAX_ Syntax error - FOR
FOR
00010235 LGCODE_PARSER_ERR_SYNTAX_ Syntax error - ENDFOR
ENDFOR
00010236 LGCODE_PARSER_ERR_SYNTAX_ Syntax error - IF
IF
00010237 LGCODE_PARSER_ERR_SYNTAX_ Missing ELSE or ENDIF
MISSING_ELSE_ENDIF
00010238 LGCODE_PARSER_ERR_SYNTAX_ Syntax error - WHILE
WHILE
00010239 LGCODE_PARSER_ERR_SYNTAX_ Syntax error - ENDWHILE
ENDWHILE
00010240 LGCODE_PARSER_ERR_STACK_ Overflow loop stack
OVERFLOW
00010241 LGCODE_PARSER_ERR_UNKOWN Verwendung von nicht
_USER_VARIABLE zugewiesenen User Variablen.
00010242 LGCODE_PARSER_ERR_SLOT_IS_ Slot ist leer
EMPTY
00010243 LGCODE_PARSER_ERR_STACK_E Keine Einträge im
MPTY Schleifenstack.

9.2.2 Errors of the Interpreter

The error numbers that occur while interpreting the program are output on the
following variables:
gasGCode[1].sControl.sNCInterpreter.b32ErrorId /
FBLGCodeInterpreter.errorId – error number

In case of a parser error the following variable provides more information


FBLGCodeProgram.errorIdParser – additional error Id from parser, see
chapter 9.2.1.

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 92
9 Error numbers of the blocks
9.2 Interpreter

The Interpreter state gasGCode[1].sControl.sNCInterpreter.eState also changes to


ERROR.
Error numbers are output in hexadecimal format.

Table 9-4 Error numbers of the Interpreter


Error number Short text Description

70000001 LGCODE_IPR_ERR_NOT_READY Function block not ready


70000002 LGCODE_IPR_ERR_TIMEOUT Request time out
Function block is in the
LGCODE_IPR_ERR_WRONG_ wrong state for that
70000003 STATE request
LGCODE_IPR_ERR_EXECUTE_ Execute during reset
70000100 DURING_RESET
LGCODE_IPR_ERR_NC_BUFFER_ Buffer is not ready
70000101 NOT_READY
70000102 LGCODE_IPR_ERR_NC_PARSER Error at parser
70000103 LGCODE_IPR_ERR_INVALID_ASCII Invalid G-Code line
LGCODE_IPR_ERR_INVALID_ Invalid slot number
Copyright  Siemens AG 2016 All rights reserved

70000104 SLOTNUMBER

LGCODE_IPR_ERR_NC_ Error at Interpolator


70000105 INTERPOLATOR function block
LGCODE_IPR_ERR_SLOT_ slot access denied
70000106 ACCESS_DENIED

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 93
10 Description of the interface structure
10.1 Purpose of the interface structure

10 Description of the interface structure


10.1 Purpose of the interface structure
10.1.1 Interpreter

The dgCodeInterface source file contains the central interface structure which is
accessed by all blocks of the G-Code Interpreter. The global structure is declared
as follows:
gasGCode : ARRAY[1..NUMBER_OF_HANDLING_DEVICES] OF
sLGCodeIprInterfaceType;

Arbitrarily numbers of Interpreters per controller are supported, by changing the


constant NUMBER_OF_HANDLING_DEVICES (unit cGlobal) the interface
structure is instanced multiple times accordingly.

10.2 Description of the structure elements


Table 10-1: sLGCodeIprInterfaceType
Name Data type Description
Copyright  Siemens AG 2016 All rights reserved

asSlot ARRAY[1..LGCODE_MAX_ Array of ASCII slots


NUMBER_ASCII_SLOTS] OF
sLGCodeIprInterfaceSlotType
sState sLGCodeIprInterfaceStateType Structure with status information of
the G-Code Interpreter (program,
interpreter and interpolator)
sClipBoard sLGCodeIprInterface Predefined variables that can be
ParameterType read from the Interpreter and
written, and evaluated in the user
program
sExtVar sLGCodeIprInterfaceExtVarType Predefined variables that can be
read from the Interpreter and
written, and evaluated in the user
program (in preparation)
sStorageInfo sLGCodeIprStorageInfoType Information about the traversing
programs stored on the CF / MMC
card after browsing
sNCIpoBuffer sLGCodeIpoBufferType Global motion command buffer
sInfo sLGCodeIprInterfaceInfoType General information of constants

ASCII program slots


Table 10-2: sLGCodeIprInterfaceAsciiProgType
Name Data type Description
asgLine ARRAY [1 .. The lines of the traversing
LGCODE_IPR_NUMBER_OF_ program for editing or
ASCII_LINES] OF STRING displaying. The length is set
via the
LGCODE_PRG_NUMBER_
OF_ASCII_LINES
constant. Default is 1000.
u32NumberOfLines UDINT Number of valid lines in the

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 94
10 Description of the interface structure
10.2 Description of the structure elements

Name Data type Description


traversing program
sgProgramName STRING Displays the program name
sgFileName STRING[LGCODE_PRG_LENGTH File name
_OF_FILE_NAME_STRING]

State structures
Table 10-3: sLGCodeIprInterfaceStateType
Name Data type Description
sNcProgram sLGCodeIprInterfaceNCProgramStateType Status of the
program
sNCInterpreter sLGCodeIprInterfaceNCInterpreterStateType Status of the
Interpreter
sNCInterpolator sLGCodeIprInterfaceNCInterpolatorStateType Status of the
interpolator

Program
Table 10-4: sLGCodeIprInterfaceNCProgramStateType
Copyright  Siemens AG 2016 All rights reserved

Name Data type Description


State
eState eLGCodeIprProgramStateType Status of the program
administration / parser
eFileState eLGCodeIprFileStateType Status of a file
sgFileName STRING[LGCODE_PRG_LENGTH File name of the
_OF_FILE_NAME_STRING] program
sgProgName STRING Displays the program
name
u16ErrorLineNumber UINT Displays the program
line in which an error
occurred while
compiling
boError BOOL Error occurred at
function block
b32ErrorId DWORD Error ID at function
block
b32AdditionalErrorID DWORD Additional error
number of a pending
error

Interpreter
Table 10-5: sLGCodeIprInterfaceNCInterpreterStateType
Name Data type Description
State
eState eLGCodeIprInterpreterStateType Status of the
Interpreter
sgActProgName STRING Name of the currently

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 95
10 Description of the interface structure
10.2 Description of the structure elements

Name Data type Description


interpreted program
sgPrompt STRING Output line of the
PRINT command
b32ErrorID DWORD Error number for
pending error
i32ActSlotNumber DINT Slot number of the
currently processed
program
i32ActBlock DINT Currently interpreted
block number

Interpolator
Table 10-6: sLGCodeIprInterfaceNCInterpolatorStateType
Name Data type Description
State
i32ActBlock DINT Block number of the block
currently processed by the
interpolator
Copyright  Siemens AG 2016 All rights reserved

eActPathPlane EnumPathPlane Current path plane (X_Y, Y_Z,


Z_X)
eState eLGCodeIpoProgramStateType Status of the interpolator (see
Table 6-12)
boM0Active BOOL An M0 is active
boM1Active BOOL An M1 is active
ai32MAckNumber ARRAY [1..3] OF DINT Number of the active M
Active function requiring
acknowledgement
boWaitTimeActive BOOL A G4 (wait time) is active
ar64ActPositionWCS ARRAY[1..3] OF LREAL Actual position in world
coordinates (without work
offset)
ar64ActPositionUCS ARRAY[1..3] OF LREAL Actual position in user
coordinates (taking all work
offsets into account)
sActFrame sLGCodeIpoFrameType Displays the current
coordinate system offset
(combination of all active work
offsets)
i16ToolNumber INT Selected tool for the tool
radius compensation
(G41/G42)
r64ToolRadius LREAL Selected tool radius
(G41/G42)
boError BOOL Displays a pending error
b32ErrorId DWORD Error number for pending
error
ai32ErrorInformation DINT[3] Additional information about
b32ErrorId
sState sLGCodeIpoStateType Status structure

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 96
10 Description of the interface structure
10.2 Description of the structure elements

Frame
Table 10-7: sLGCodeIpoFrameType
Name Data type Description
ar64Trans ARRAY[1..3] OF LREAL Offset of the coordinate
system
ar64Rot ARRAY[1..3] OF LREAL Rotation of the coordinate
system

Interpolator state
Table 10-8: sLGCodeIpoStateType
Name Data type Description
u16ErrorHistoryPointer UINT Pointer to the last entry in
the error history
(asErrorHistory)
asErrorHistory sLGCodeIpoErrorHistory Error history
3
Type [n ]
Copyright  Siemens AG 2016 All rights reserved

eFBState eLGCodeIpoFBStateType State of the FB (internal


only)
sIntState sLGCodeIpoInternalState Internal substates
sIntPointer sLGCodeIpoInternalPointer Internal command pointers
Type
r64PathPosition LREAL current summarized path
position
r64BufferedPathLength LREAL Buffered path length
u16RetrieveSet UINT Pointer to the global NC
command buffer
u16ActiveSet UINT Pointer to the command

The following table contains the error history in which significant states of the
interpolator are saved at the time the error occurs.

Error history
Table 10-9: sLGCodeIpoErrorHistoryType
Name Data type Description
b32ErrorId DWORD Error number
i32Blocknumber DINT NC block number
u16NCSet UINT Internal command numbers
ai32Information ARRAY [1..3] OF DINT Additional information about
the error number
i32SourceCode DINT Source code line number at
LineNumber which the error was thrown
– for internal usage only

3
Array size: 1.. LNCIPO_NUMBER_OF_ERROR_BUFFER

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 97
10 Description of the interface structure
10.2 Description of the structure elements

Name Data type Description


eFBState eLGCodeIpoFBStateType State of the FB
sIntState sLGCodeIpoInternalState Internal substates
sIntPointer sLGCodeIpoInternalPointer Internal command pointers
Type
dtTimeStamp DT Time stamp

Clipboard
Table 10-10: sLGCodeIprInterfaceParameterType
Name Data type Description
ai32Long ARRAY [1 .. LGCODE_IPR_ Storage location for integer
NUMBER_OF_ clipboard variables
CLIPBOARD_VAR] OF DINT
ar64LReal ARRAY [1 .. LGCODE_IPR_ Storage location for real clipboard
NUMBER_OF_ variables
CLIPBOARD_VAR] OF LREAL

External variable
Table 10-11: sLGCodeIprInterfaceExtVarType
Copyright  Siemens AG 2016 All rights reserved

Name Data type Description


ai8ExtByte ARRAY[1..LGCODE_IPR_ Storage location for EXB
NUMBER_OF_EXT_VAR] OF parameters
SINT
ai16ExtInt ARRAY[1..LGCODE_IPR_ Storage location for EXI
NUMBER_OF_EXT_VAR] OF parameters
INT
ai32ExtLong ARRAY [1..LGCODE_IPR_ Storage location for EXL
NUMBER_OF_EXT_VAR] OF parameters
DINT
ar32ExtReal ARRAY[1..LGCODE_IPR_ Storage location for EXR
NUMBER_OF_EXT_VAR] OF parameters
REAL

Storage information
Table 10-12: sLGCodeIprStorageInfoType
Name Data type Description
asgFiles ARRAY[1..LGCODE_PRG_ List of the files stored on the
NUMBER_OF_FILES] OF CF / MMC card
String
au16Index ARRAY[1..LGCODE_PRG_ Numbers of the file names
NUMBER_OF_FILES] OF in the asgFile according to
UNIT the order on the CF / MMC
card
u16NumberOfFiles UNIT Number of files on the CF /
MMC card

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 98
10 Description of the interface structure
10.2 Description of the structure elements

NC buffer
Table 10-13: sLGCodeIpoBufferType
Name Data type Description
sActualSet sLGCodeIpoCodeType Displays the data of the
current traversing block
asNCSet ARRAY[1..LGCODE_IPO_ Motion command buffer
MAX_NUMBER_OF_NC_ (preprocessing)
SETS] OF
sLGCodeIpoCodeType
u16NumberBufferedNCSets UINT Number of currently
buffered motion commands
u16AddPointer UINT Pointer to the buffer
location where the
Interpreter will write next
u16RetrievePointer UINT Pointer to the buffer
location which the
interpolator will process
next
eNCBufferState eLGCodeIpoBufferStateType Status of the buffer
Copyright  Siemens AG 2016 All rights reserved

G-Code structure
Table 10-14: sLGCodeIpoCodeType
Name Data type Description
Skip BOOL Reserve – presently not
used
STOPRE BOOL Preprocessing stop
N DINT Line number
G ARRAY[1..3] OF INT G-Codes
X LREAL Position value X
Y LREAL Position value Y
Z LREAL Position value Z
I LREAL Arc parameter I
J LREAL Arc parameter J
K LREAL Arc parameter K
AR LREAL Arc parameter AR
CR LREAL Arc parameter CR /
blending radius
F LREAL Feedrate or wait time (for
G4)
O LREAL Rotation around the X axis
B LREAL Rotation around the already
rotated Y axis
C LREAL Rotation around the already
rotated Z axis
PolyCoeff ARRAY[1..4] OF Polynomial coefficients
StructPathVector (SOC) / starting point and
end point data (SSD)
Components: X, Y, Z

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 99
10 Description of the interface structure
10.2 Description of the structure elements

Name Data type Description


M ARRAY[1..3] OF INT M functions of the block
H ARRAY[1..3] OF H parameters of the block
sLGCodeHParameterType
eState eLGCodeIpoBlockStateType Status of the block
aParameterValid ARRAY [1..4] OF BOOL Validity of X, Y, Z and F
(modal parameters)

Info
Table 10-15: sLGCodeIprInterfaceInfoType
Name Data type Description
u16MaxNumberOfAsciiLines UINT Number of ASCII lines
u8LengthOfStringInAsciiLine USINT Maximum character
length in ASCII line
u8NumberOfClipBoardVar USINT Number of clipboard
variables
u8NumberOfExtVar USINT Number of external
variables
u16NumberOfNcSets UINT Number of NC blocks
Copyright  Siemens AG 2016 All rights reserved

u16NumberOfPreprocessed UINT Maximum number of


Cmds commands available from
the preprocessor
sgInterfaceVersion STRING[20] Version of the interpreter
sgInterpolatorVersion STRING[20] Version of the interpolator
u8MaxNumberOfFilesInList USINT Number of files on the CF
card / MMC
u8LengthOfStringInFileList USINT Max. length of the file
name

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 100
11 References

11 References
Table 11-1
Topic Title
\1\ Siemens Industry http://support.automation.siemens.com
Online Support
\2\ Download page of http://support.automation.siemens.com/WW/view/en/109477030
the article
\3\ Projekt ins SIMOTION documentation
SIMIOTION 1_Engineering_system_handling/ SCOUT_Getting_Started_D435-
Zielsystem laden 2.pdf – chapter 6 - Download the project to the target system
\4\ SIMOTION SCOUT SIMOTION documentation
TIA Geräte-Proxy 1_Engineering_system_handling/ SCOUTDeviceProxy_DE.pdf
\5\ SIMOTION Motion SIMOTION documentation
Control - TO 2_Description_of_system_and_functions / Path_TechnologyFct.pdf
Bahninterpolation
\6\ OMAC – mode and Folder: Used_Standards/OMACV30_LPML
state manager
\7\ LJgPth – jog path Folder: Used_Standards/JogPath_LJgPth
\8\ KSC – Kinematic Folder: Used_Standards/KSC_Interface
Simulation Center Used_Standards/Communication_LCom
Copyright  Siemens AG 2016 All rights reserved

\9\ MCBasic – basic Folder: Used_Standards/AxisFB_LMCBasic


axis functions

12 Contact
Siemens AG
Industry Sector
I DT MC PMA APC
Frauenauracher Strasse 80
91056 Erlangen, Germany
E-mail: tech.team.motioncontrol@siemens.com

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 101
13 History

13 History
Table 13-1
Version Date Change
V3.0 2016-05 Release-Version
Copyright  Siemens AG 2016 All rights reserved

SIMOTION G-Code Interpreter


Entry ID: 109477030, V3.0, 2016/05 102

You might also like