Library Kinematics Transformation: Lkintrans For Simatic
Library Kinematics Transformation: Lkintrans For Simatic
Transformation
Siemens
LKinTrans for SIMATIC Industry
Online
https://support.industry.siemens.com/cs/ww/en/view/109758302 Support
Legal information
Legal information
Use of application examples
Application examples illustrate the solution of automation tasks through an interaction of several
components in the form of text, graphics and/or software modules. The application examples are
a free service by Siemens AG and/or a subsidiary of Siemens AG (“Siemens”). They are non-
binding and make no claim to completeness or functionality regarding configuration and
equipment. The application examples merely offer help with typical tasks; they do not constitute
customer-specific solutions. You yourself are responsible for the proper and safe operation of the
products in accordance with applicable regulations and must also check the function of the
respective application example and customize it for your system.
Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have the
application examples used by technically trained personnel. Any change to the application
examples is your responsibility. Sharing the application examples with third parties or copying the
application examples or excerpts thereof is permitted only in combination with your own products.
The application examples are not required to undergo the customary tests and quality inspections
of a chargeable product; they may have functional and performance defects as well as errors. It is
your responsibility to use them in such a manner that any malfunctions that may occur do not
result in property damage or injury to persons.
Disclaimer of liability
Siemens shall not assume any liability, for any legal reason whatsoever, including, without
limitation, liability for the usability, availability, completeness and freedom from defects of the
application examples as well as for related information, configuration and performance data and
any damage caused thereby. This shall not apply in cases of mandatory liability, for example
under the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss of
life, bodily injury or damage to health, non-compliance with a guarantee, fraudulent
non-disclosure of a defect, or culpable breach of material contractual obligations. Claims for
damages arising from a breach of material contractual obligations shall however be limited to the
Siemens AG 2018 All rights reserved
foreseeable damage typical of the type of agreement, unless liability arises from intent or gross
negligence or is based on loss of life, bodily injury or damage to health. The foregoing provisions
do not imply any change in the burden of proof to your detriment. You shall indemnify Siemens
against existing or future claims of third parties in this connection except where Siemens is
mandatorily liable.
By using the application examples you acknowledge that Siemens cannot be held liable for any
damage beyond the liability provisions described.
Other information
Siemens reserves the right to make changes to the application examples at any time without
notice. In case of discrepancies between the suggestions in the application examples and other
Siemens publications such as catalogs, the content of the other documentation shall have
precedence.
The Siemens terms of use (https://support.industry.siemens.com) shall also apply.
Security information
Siemens provides products and solutions with industrial security functions that support the secure
operation of plants, systems, machines and networks.
In order to protect plants, systems, machines and networks against cyber threats, it is necessary
to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept.
Siemens’ products and solutions constitute one element of such a concept.
Customers are responsible for preventing unauthorized access to their plants, systems, machines
and networks. Such systems, machines and components should only be c onnected to an
enterprise network or the Internet if and to the extent such a connection is necessary and only
when appropriate security measures (e.g. firewalls and/or network segmentation) are in place.
For additional information on industrial security measures that may be implemented, please visit
https://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them more secure.
Siemens strongly recommends that product updates are applied as soon as they are available
and that the latest product versions are used. Use of product versions that are no longer
supported, and failure to apply the latest updates may increase customer’s exposure to cyber
threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed
at: https://www.siemens.com/industrialsecurity.
Table of contents
Legal information ..................................................................................................... 2
1 Introduction .................................................................................................... 4
1.1 Overview ........................................................................................... 4
1.2 Mode of operation.............................................................................. 4
1.3 Components used ............................................................................. 5
2 Engineering .................................................................................................... 6
2.1 Description of interface ...................................................................... 6
2.1.1 Overview ........................................................................................... 6
2.1.2 FB LKinTrans_Main ........................................................................... 6
2.1.3 FB LKinTrans_InvKinTrans ................................................................ 7
2.1.4 FB LKinTrans_FwdKinTrans .............................................................. 8
2.1.5 PLC Tags .......................................................................................... 9
2.1.6 PLC Types ........................................................................................ 9
2.2 Project integration............................................................................ 13
2.2.1 Requirements .................................................................................. 13
2.2.2 Import .............................................................................................. 13
2.2.3 Call and parametrization .................................................................. 13
2.3 User defined kinematics transformation ........................................... 15
2.3.1 Inverse transformation ..................................................................... 15
2.3.2 Forward transformation .................................................................... 16
2.3.3 Use of calculation mode................................................................... 16
Siemens AG 2018 All rights reserved
1 Introduction
1.1 Overview
The SIMATIC Library Kinematics Transformation (LKinTrans) provides an interface
for programming customized kinematics transformations with direct specification of
the Cartesian command values.
The command values of various output axes can be linked to the command values
of various input axes. The output axes are controlled by the library by using the
motion interface functionality of the TO axis. Therefore, no TO Kinematics is
needed for transformation.
LKinTrans_Main
LKinTrans_InvKinTrans
A1 = X + 1
A2 = Y + 2
...
. X = A1 – 1 .
Y = A2 – 2
. ...
.
. .
When enabled, the main function block is cyclically writing into the motion interface
of the output axes by using the MC_MotionInPosition command. The handling of
the motion interface (e.g. enable, cyclic call, disable) is an internal functionality of
the LKinTrans main block; the user does not need to take care of it.
Also, the consistency between forward and inverse transformation can be
monitored in order to ensure a correct result.
2 Engineering
2.1 Description of interface
2.1.1 Overview
2.1.2 FB LKinTrans_Main
In the following, the interface of the LKinTrans_Main FB with its data types and
meaning is shown. The assignment of all IN and IN_OUT parameter is mandatory.
status Word
diagnostics "LKinTrans_typeDiagnostics"
Array["LKINTRANS_AX_LOWER inputAxes Array["LKINTRANS_AX_LOWER
_LIM".."LKINTRANS_IN_AX_ _LIM".."LKINTRANS_IN_AX_
UPPER_LIM"] of DB_ANY UPPER_LIM"] of DB_ANY
Array["LKINTRANS_AX_LOWER outputAxes Array["LKINTRANS_AX_LOWER
_LIM".."LKINTRANS_OUT_AX_ _LIM".."LKINTRANS_OUT_AX_
UPPER_LIM"] of DB_ANY UPPER_LIM"] of DB_ANY
parameter
"LKinTrans_typeParameter" "LKinTrans_typeParameter"
2.1.3 FB LKinTrans_InvKinTrans
In this function block, the user specific inverse kinematics transformation must be
programed. Inverse transformation means to calculate from Cartesian axes values
into joint axes values. The function block LKinTrans_InvKinTrans is called by the
main FB. It is also possible to use it stand alone e.g. for calculation reasons.
2.1.4 FB LKinTrans_FwdKinTrans
In this function block, the user specific forward kinematics transformation must be
programed. Forward transformation means to calculate from joint axes values into
Cartesian axes values. The function block LKinTrans_FwdKinTrans is called by the
main FB. It is also possible to use it stand alone e.g. for calculation reasons.
User constants
The length of input axes array, output axes array and kinematics parameter array is
variable.
NOTE The array length of the input axes array must be at least 3.
NOTE When using a kinematics with less than 3 degrees of freedom, the dimensions
which are not used should not be assigned.
NOTE The coordinate system frame kinFrame has got the same definition as the
kinematics coordinate system (KCS) of the TO Kinematics. The translation (x, y,
z) is done first, the rotation (first a, then b, then c) is done afterwards.
To run the application LKinTrans, a basic TIA Portal V15 project with a S7-1500T
controller and the used number of TO PositioningAxis or TO SynchronousAxis
need to be set up.
2.2.2 Import
The table below lists the steps for integrating the blocks, tags and types of the
LKinTrans library into the TIA Portal project. The folders can be imported by drag
and drop into the corresponding folder in the PLC project tree (see Figure 2-4).
No. Action
1. Copy the folder LKinTrans_Tags with drag & drop into the “PLC tags” in the PLC
2. Copy the folder LKinTrans_Types with drag & drop into the “PLC data types” in the PLC
3. Copy the folder LKinTrans_Blocks with drag & drop into the “Program blocks” in the PLC
4. Now the blocks can be configured and called in the user program
Siemens AG 2018 All rights reserved
Figure 2-4: Integrating the library blocks into the program blocks
It is necessary to create the variables for parameter structure, input axes reference
and output axes reference out of the library types and tags. All other input
parameters are elementary data types. The assignment of the variables can be
done once, e.g. in the OB "Startup". For further information about configuring the
parameter structure, see chapter 2.1.6.
Figure 2-5: Interface variables which rely on library tags and types
NOTE In the standard case, only region three is relevant for the user programming
in which the Cartesian input values are defined into the system that the
transformation is using (example: input values in WCS, kinematics transformation
in KCS).
For the kinematics transformation area, it is possible to program the equations
directly (example 1 in the listed code sequence below), encapsulate the equations
into functions (example 2) or mix both ways.
//--------------------------------------------------------------------------------
// Begin of user area - place transformation equations here
//--------------------------------------------------------------------------------
REGION CALL_INV_TRANS_FC
// call selected transformation ID
// get cartesian positions from variable statCartesianData
// write axes positions into variable statAxesData
CASE #parameter.config.transID OF
ELSE
//ID not defined
#status := #ERR_NO_TRANSFORMATION_SELECTED;
END_CASE;
END_REGION
The next code sequence shows an example use of the calcMode parameter. The
velocity and acceleration values must be assigned in the corresponding calculation
mode; otherwise there might be dynamic issues with the output axes.
END_IF;
END_IF;
2.3.4 Modulo
All input and output axes can be parametrized with modulo. By enabling the
transformation, the settings of all axes are stored in the status structure. The
modulo range does not need to be taken into account while programming the
transformation. This task is done by the main FB.
2.4 Operation
2.4.1 Preconditions
A few preconditions must be met before the user transformation can be enabled.
Also, some preparatory work might be necessary.
Axes state
The following table lists the preconditions of the used input and output axes and
the respective error message if the condition is not fulfilled.
Axes settings
The following settings of the axes are used by the LKinTrans Main FB and may be
set properly according to the used application:
Input axes:
Lower following error limit (for consistency monitoring)
<TOAxis>.FollowingError.minValue
Output axes:
Lower following error limit (for consistency monitoring)
<TOAxis>.FollowingError.minValue
Default velocity, acceleration, deceleration, jerk (for pulling)
<TOAxis>.DynamicDefaults.velocity
<TOAxis>.DynamicDefaults.acceleration
<TOAxis>.DynamicDefaults.deceleration
<TOAxis>.DynamicDefaults.jerk
Maximum velocity, acceleration, deceleration, jerk (for dynamic monitoring
and stopping after error)
<TOAxis>.DynamicLimits.maxVelocity
<TOAxis>.DynamicLimits.maxAcceleration
<TOAxis>.DynamicLimits.maxDeceleration
<TOAxis>.DynamicLimits.maxJerk
Transformation settings
For the transformation, some data might be necessary to set up before activating
the transformation:
Transformation identifier (<parameter>.config.transID)
kinematics parameter (<parameter>.config.kinParamter)
kinematics frame (<parameter>.config.kinFrame)
2.4.2 Enabling
The user transformation is enabled by setting the LKinTrans Main FB input enable
Siemens AG 2018 All rights reserved
= TRUE. Certain steps are done to ensure a safe start up, which are explained in
the following.
-
> followingError.minValue ?
LKinTrans_FwdKinTrans
X = A1 – 1
Y = A2 – 2
...
Redefine the position of the input axes to their command position resulting
from the output axes position (Figure 2-8). MC_Home is used for this.
Pull the output axes to their command position resulting from the input axes
position (Figure 2-9). MC_MoveAbsolute is used for this.
LKinTrans_Main
Command LKinTrans_FwdKinTrans
Actual
X, Y, Z X = A1 – 1
A1, A2, A3
Y = A2 – 2
...
LKinTrans_Main
Siemens AG 2018 All rights reserved
Actual Command
X, Y, Z LKinTrans_InvKinTrans A1, A2, A3
A1 = X + 1
A2 = Y + 2
...
The decision between redefine and pull is done by the FB. Pull is used if at least
one input axis is in use by:
The control panel (statusWord Bit 4)
A synchronous operation (Bit 22)
A path motion (Bit 29)
If no input axis is in use, the input axes are redefined.
In the other case, the output axes are pulled to their respective command position.
An example would be if the path was previously interrupted by MC_GroupInterrupt
command.
For the positioning, the dynamic defaults of the respective axes are used
(<TOAxis>.DynamicDefaults…).
The maximum positioning distance for each axis is limited by the parameter array
<parameter>.monitoring.outputAxesMaxPullDistance. If at least one distance would
be exceeded, the error ERR_PULL_AXIS_DEVIATION is thrown.
Enable successful
If enabling is successful, the status output switches from 16#7000 (no call) to
Siemens AG 2018 All rights reserved
16#7002 (subsequent call), busy and valid are set TRUE. Once the
transformationActive output is TRUE, the FB is in control of the output axes (motion
interface enabled).
In the cyclic processing state, the command values of all input axes are read in and
used as input for the inverse kinematics transformation in function block
LKinTrans_InvKinTrans. The results are used as command values for the motion
interface of the output axes.
Furthermore, the actual values of the output axes are also read in and processed in
the forward transformation, providing the actual Cartesian position of the
kinematics in <parameter>.status.actualCartesianPosition.
NOTE The actual Cartesian position of the kinematics is not represented by the actual
position of the input axes. It is rather determined by the transformed actual
position of the output axes.
LKinTrans_FwdKinTrans
Out_Act
X = A1 – 1
In_Act Y = A2 – 2
...
If the consistency check is enabled, the command output values are used as input
data for the forward transformation. The resulting Cartesian values are compared
to the command input value by value. If at least one deviation is bigger than the
respective following error setting, error ERR_TRANS_CONSISTENCY occurs (See
Figure 2-11).
LKinTrans_Main
Siemens AG 2018 All rights reserved
LKinTrans_InvKinTrans
A1 = X + 1
A2 = Y + 2
...
- > followingError.minValue ?
LKinTrans_FwdKinTrans
X = A1 – 1
Y = A2 – 2
...
2.4.4 Disabling
By setting the input enable = FALSE, the FB is disabled. The FB status switches to
16#7000 (No call). The axes command values are set to the last value at the
motion interface. All output axes are stopped immediately with their particular limit
for deceleration and jerk (<TOAxis>.DynamicLimits.MaxDeceleration and
<TOAxis>.DynamicLimits.MaxJerk).
For more information about stopping behavior when disabling the motion interface,
refer to the MC_MotionInPosition command documentation.
The following table shows the relevant error identifiers. Their range is between
16#8000 and 16#8FFFF. The range reserved for user errors of the kinematics
transformations (sub status of ERR_TRANS_INV and ERR_TRANS_FWD) is
starting at 16#9000.
Additional value
The additional value parameter is relevant for the errors listed in the following table.
Reaction
If an FB error occurs (error = TRUE), the status output shows the error number and
the diagnostic output further information. The motionIn functionality is aborted. All
output axes are immediately stopped with their maximum deceleration and
unlimited jerk, in order to ensure a fast stop. The error reason can be diagnosed in
the status and diagnostics output.
Acknowledgement
A pending error can be acknowledged by setting the enable input to FALSE. The
output signals error and status are reset. However, the error information in the
diagnostic structure is kept until the FB is enabled again.
TO errors are not acknowledged by the FB. This has to be done by the user.
Siemens AG 2018 All rights reserved
3 Application example
3.1 Project configuration
The application example "LKinTrans_Example_V_1_1" shows a basic
implementation of the LKinTrans Library.
From technology side of view, only jogging of the input axes is implemented, which
makes the application very small. It is suitable as a base for testing own user
transformations.
The project contains the following configuration:
CPU 1516T-3 PN/DP, Firmware V2.5
3 Input axes (technology objects Axis_X, Axis_Y, Axis_Z)
3 Output axes (technology objects Axis_A1, Axis_A2, Axis_A3)
Transformation type: Cartesian 3D with gear factor
– parameter[0]: Gear factor between X and A1
– parameter[1]: Gear factor between Y and A2
– parameter[2]: Gear factor between Z and A3
Axis_X
A1 = X * Par[0] Axis_A1
A2 = Y * Par[1]
A3 = Z * Par[2]
Axis_Y Axis_A2
LKinTrans_FwdKinTrans
A list with the relevant OBs is shown in the following. No additional FCs or FBs are
used.
OB Number Content
Reset and enable of Axis_X, Axis_Y and Axis_Z
Jog of Axis_X, Axis_Y and Axis_Z
Two additional data types are defined in order to keep the project organized:
typeAxesControl: Variables for axes functions (enable, reset…)
typeKinTransControl: Variables which are connected to the FB
LKinTrans_Main interface
All relevant variables for axes and LKinTrans control are located in DB
"DataGlobal".
3.2 Operation
After download of the PLC, the application example can be controlled by the
following steps (See Figure 3-2):
1. Open the watch table Control
2. Enable all axes with DataGlobal.axesControl.enableAxes
3. Home output axes DataGlobal.axesControl.homeOutputAxes
4. Enable transformation with DataGlobal.kinTransControl.enable – If enabling
was successful, the status switches to 16#7002.
Siemens AG 2018 All rights reserved
4 Additional information
4.1 Distinction to user defined TO Kinematics
Besides the use of LKinTrans, it is also possible to define a user defined
kinematics on a S7-1500T with the TO kinematics type "User-defined…". The
following table gives a short overview about the functionality of both solutions.
Table 4-1: Distinction between TO Kinematics and LKinTrans user defined transformation
Feature TO Kinematics LKinTrans
Maximum degrees of freedom 4 No limitation
Programming of path movement MC Commands Free specification
Zone monitoring Yes With workaround (See chapter
4.4.2)
Consideration of joint axes limits Yes No
into dynamic planning
NOTE When using a standard kinematics transformation function, the minimum value
for library constant LKINTRANS_KIN_PARA_UPPER_LIM is 13.
LKINTRANS_AX_LOWER_LIM must be set to 1.
The minimum value for LKINTRANS_OUT_AX_UPPER_LIM and
LKINTRANS_IN_AX_UPPER_LIM is 4.
Axes assignment
When using a kinematics frame or a tool frame, it is recommended to connect the
input axis for Orientation A (forth entry of input axes array) to virtual axis, even if it
is not used. Unlike the types offered by TO Kinematics, there is no distinction
between "with orientation" or without.
Siemens AG 2018 All rights reserved
For 2D types, it is not recommended to assign input axis Y (second entry of input
axes array) and output axis A3 (third entry of output axes array).
Inverse transformation
The inverse transformations LKinTrans_<Type>_Inv are used to calculate from
Cartesian values to axes values. All FC have the same interface, descripted in the
following.
Forward transformation
The forward transformations LKinTrans_<Type>_Fwd are used to calculate from
axes values to Cartesian values. All FC have the same interface, descripted in the
following.
"LKinTrans_typeMotionData"
calcMode IN USInt 0: Only Position,
1: Position and Velocity,
2: Position, Velocity, Acceleration
(Note: Only position transformation
is available)
cartesianData OUT Array[*] of Cartesian values
"LKinTrans_typeMotionData"
linkConstellation OUT DWord Link constellation
kinParameter IN_OUT Array[*] of LReal kinematics parameter
Status identifier
The following table shows the meaning of the status parameter.
LKinTrans. It is possible to control the (Cartesian) input axes in any way, for
example:
Single axis commands: use of single axis commands for moving in a single
direction e.g. for jog mode.
TO Kinematics: assignment of the input axes to a kinematics type "Cartesian
portal" for almost the full TO Kinematics functionality.
Motion interface: with using the motion interface of the input axes, it is possible
to move the kinematics independently in any direction.
Camming: For some tasks, it is required to couple the path movement to a
master cycle.
If the Cartesian position source is not TO Kinematics, you can still use the zone
monitoring functionality and the kinematics trace of the TO Kinematics.
For this, it is necessary to define a dummy kinematics object of type "Cartesian
portal" and to connect it with the Cartesian input axes. Then, the dummy
kinematics is used in feedback mode, tracking the movement of the Cartesian
axes. This movement can be recorded with the kinematics trace.
If a collision with a previously defined zone occurs, an error on the dummy
kinematics object is set. However, the movement is not stopped. The user should
respond on a collision with an appropriate reaction on the real kinematics axes.
Axis_X Axis_A1
Axis_Y Axis_A2
Axis_Z Axis_A3
Siemens AG 2018 All rights reserved
Zone monitoring
Kinematics trace
Cartesian portal
Kinematics object
4.4.3 Performance
Performance table
The LKinTrans library might take a lot of performance due to the use of the motion
interface technology. The following table lists the time for one FB call in the OB
"MC-PreServo" with the following configuration:
2 or 3 input axes
1:1 transformation of position, velocity, acceleration (Cartesian portal 3D)
No Frame transformation
2 or 3 output axes
Monitoring active
5 Update notes
5.1 Changelog
From V1.0 to V1.1
The following changes were made with LKinTrans V1.1:
New feature: Position transformation of all TO kinematics V4.0 kinematics
types available
New feature: Input and output axes can now be set as modulo axes
Modification: Names of Library constants changed
Modification: Lower limit of axes array is now variable
Modification: Data type of <LKinTrans_typeParameter>.config.transID changed
from INT to DINT
Modification: Blocks LKinTrans_FwdKinTrans and LKinTrans_InvKinTrans
changed from function to function block
Modification: Names of sub blocks changed; blocks shifted into subfolders
Modification: Extended information for some error identifiers
6 Appendix
6.1 Service and Support
Industry Online Support
Do you have any questions or need assistance?
Siemens Industry Online Support offers round the clock access to our entire
service and support know-how and portfolio.
The Industry Online Support is the central address for information about our
products, solutions and services.
Product information, manuals, downloads, FAQs, application examples and videos
– all information is accessible with just a few mouse clicks at:
https://support.industry.siemens.com
Technical Support
The Technical Support of Siemens Industry provides you fast and competent
support regarding all technical queries with numerous tailor-made offers
– ranging from basic support to individual support contracts. You send queries to
Technical Support via Web form:
www.siemens.com/industry/supportrequest
Siemens AG 2018 All rights reserved
Service offer
Our range of services includes the following:
Plant data services
Spare parts services
Repair services
On-site and maintenance services
Retrofitting and modernization services
Service programs and contracts
You can find detailed information on our range of services in the service catalog:
https://support.industry.siemens.com/cs/sc