SIMOTION G-Code Interpreter Guide
SIMOTION G-Code Interpreter Guide
SIMOTION G-Code
Interpreter
LGCode
Function Manual V3.0
http://support.automation.siemens.com/WW/view/en/109477030
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
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.
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
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
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.
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
• 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.
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.
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\.
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
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.
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]
Error
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
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).
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).
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)
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
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.
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.
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
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.
Startscreen
Support
Overview
Copyright Siemens AG 2016 All rights reserved
Editor
Interpolator
Program
Tool / COSY
Interpreter
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
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)
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__=__
G-Code snippet:
M10 H1=5.0 ;set tool parameter
T1 ;activate tool
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
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.
• 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.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]).
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))
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
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.
Example:
G0 G60 G17 X100.1 Y200.2 Z300.3 M6 M8 M9 R3=37.5 R17=12 R36=2
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
sIpoCfg.sDynamics.sGlobal.r64Accel acceleration
sIpoCfg.sDynamics.sGlobal.r64Decel deceleration
sIpoCfg.sDynamics.sGlobal.r64Jerk jerk
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
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
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².
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
Example:
G1 X300 Y100 F250
G3 X500 Y300 AR=90
Parameter AR is an absolute parameter and specifies the opening angle in
degrees.
Example:
Copyright Siemens AG 2016 All rights reserved
Example:
G0 X300 Y100 F250
G5 X500 Y300 I141.42 J58.58
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.
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;
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.
Example:
G4 F1.25
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
The selection of the working plane specifies the plane in which the arc interpolation
is to be performed. The following settings can be made:
Example:
;Full circle in in Y_Z plane
G0 X0 Y0 Z0
G19
G2 X0 Y0 Z0 I0 J0 K50 F100
M30
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.
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.
• 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
the tool geometry – e.g. milling tool – material will remain in the corner.
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!
Example:
; Original contour
G90 G17 G60
G0 X0 Y0
G91 ; Relative coordinates
G1 Y30 F50
X20 Y20
X20 Y-40
Y-10
X-40
M30
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]
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
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:
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
G1 X100 F400
; Deactivate settable frame
G0 G500 X0 Y0 Z0
M30
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
Example:
G1 G90 X100 Y200 Z300 F250.0
G1 G91 X-10 Y20 Z25
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
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.
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
Example:
T3
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.
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
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
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;
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.
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
Example:
G0 X100 Y100
circforward = 1;
IF circforward = 1
G2 X100 Y100 I100 J0 F250
ELSE
G3 X100 Y100 I100 J0 F250
ENDIF
A count loop is defined with FOR and ENDFOR. The general syntax is:
Copyright Siemens AG 2016 All rights reserved
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
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
Absolute 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 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
G1 X200
G2 X50 Y-50 I0 J-50
myLoopCount = myLoopCount + 1
STOPRE
ENDWHILE
M30
Copyright Siemens AG 2016 All rights reserved
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.
tool sLGCodeIpoToolType
corner BOOL
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
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
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)
GLOBAL:
Global acceleration applies for all motion
GLOBAL:
Global deceleration applies for all motion
commands
r64Accel LREAL Global acceleration
r64Decel LREAL Global deceleration
r64Jerk LREAL Global jerk
The sLGCodeIpoStopDynamicsType structure is relevant for the interruption of a motion via the
stopProgram input.
The sLGCodeIpoAbortDynamicsType structure is relevant for the interruption of a motion via the
reset input or when an error occurs in the sequence.
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).
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;
//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;
//Dynamic adaption
gasGCode[1].sIpoCfg.sDynamics.boDynamicAdaption := FALSE;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//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
PROGRAM pIpoCyclic
// Interpolator Program
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
VAR
FBNcInterpolator : FBLGCodeInterpolator;
END_VAR
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
END_PROGRAM
7 G-Code Interpreter
7.1 Preparations
7.1.1 SIMOTION IT authentification
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
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)
2
n= Handling device number (1..n)
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.
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.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
(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
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.
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
The program is relevant for the interpreter of unit pGCode, its meaning and its
execution level is listed in Table 7-7.
traversing program
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 =>
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
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.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
VAR
boM33Old, boM34Old : BOOL;
boEnableTangentialCtrl : BOOL;
i16TangentialAxisStep : INT;
FBNcTangentialCtrl : FBLGCodeTangentialCtrl;
END_VAR
boM34Old := gasGCode[1].aboMFct[34];
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);
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
gasGCode[1].sControl.sNCInterpolator.b32ErrorId /
FBLGCodeInterpolator.errorId – error number
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
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
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
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:
gasGCode[1].sControl.sNcProgram.u16ErrorLineNumber /
FBLGCodeProgram.errorLineNumber – command line in which the error
occurred
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
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.
The error numbers that occur while interpreting the program are output on the
following variables:
gasGCode[1].sControl.sNCInterpreter.b32ErrorId /
FBLGCodeInterpreter.errorId – error number
70000104 SLOTNUMBER
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;
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
Interpreter
Table 10-5: sLGCodeIprInterfaceNCInterpreterStateType
Name Data type Description
State
eState eLGCodeIprInterpreterStateType Status of the
Interpreter
sgActProgName STRING Name of the currently
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
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
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
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
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
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
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
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
12 Contact
Siemens AG
Industry Sector
I DT MC PMA APC
Frauenauracher Strasse 80
91056 Erlangen, Germany
E-mail: tech.team.motioncontrol@siemens.com
13 History
Table 13-1
Version Date Change
V3.0 2016-05 Release-Version
Copyright Siemens AG 2016 All rights reserved