De MC Smo PRG en 01 v4 3 1 CNRSZR
De MC Smo PRG en 01 v4 3 1 CNRSZR
com
Siemens AG
DEUTSCHLAND
Industry Sector
90475 NÜRNBERG
Gleiwitzer Str. 555
er
di
nc
. ke
lo
gl
u
@
Siemens Certified Service Technician Level 1
(inkl. SPS-Techniker entspr. VDMA/ZVEI)
ca
(MC-SMO-PRG)
ne
r.s
SIMOTION Programming
SITRAIN:
ez
er
@
gm
ai
Training for Industry
l.c
siemens.com/sitrain
om
1 SIMOTION - System Overview
Fundamentals of programming
2
with Structured Text
om
SITRAIN
Training for Industry 4 Programming motions of axes
l.c
5 Libraries in SIMOTION
SIMOTION
Programming Course
ai
6 The execution system in SIMOTION
MC-SMO-PRG course
gm 7 Gearing in SIMOTION
@
8 Creating cams
er
9 Camming in SIMOTION
ez
10 Exercises
r.s
Name:
11 Solutions
Course from: to:
ne
Course leader:
Appendix 1: Communication
12
Course location: with SIMOTION
ca
This document was created for training purposes. SIEMENS Appendix 2: Supplementary technology
does not guarantee the content. 13
The reproduction, transmission, or use of this document or its objects/Fixed gear
content is not permitted without express written authority.
Offenders will be liable for damages.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_01.1
@
Contents Page
om
Machine functions are mechanical components
"mechanically" defined Flexible machine functions
Electronics
Coupling Mechanical system
l.c
Gearing
Cam
controller
ai
Line shafts
Cam
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_01.2
Software
concepts with central drive technology. Machine functions are implemented by means of
distributed drive technology. Individual movements are coordinated and
synchronized by the higher-level control.
Functions which were previous sly implemented with hardware are now
integrated into the software. Changing machine requirements such as format
r.s
software.
SIMATIC and As technology leader, Siemens offers manufacturers of machines and production
SIMOTION plants a system platform providing automation without system interruptions. The
associated wide-ranging services portfolio extends from application consultancy
by competent specialists – with well-founded sector experience – up to
commissioning and maintenance by our service specialists.
om
of the speed setpoint via PROFIBUS or
PROFINET
Other tasks
Processing peripheral (I/O) signals
Closed loop control tasks (e.g. closed loop
temperature control, etc.)
l.c
Data processing
Tasks of a drive
Converting the speed setpoint into the actual
I/O speed
ai
Closed-loop speed and current control
of a drive comprises
- Rectifier/inverter
- Motor
SIMOTION
Siemens AG 2013. All rights reserved.
Drives
gm
Date:
File:
- Encoder system
can also be operated independent of an MC
control system
10.01.2013
MC-SMO-PRG_01.3
SITRAIN Training for
Automation and drive technology
@
MC control For SIEMENS control systems, the total motion functionality is split up into the
actual Motion Control system and the drive system.
The MC control has the task of processing the specified (motion) program.
Within the motion program, both positioning commands can be issued to
er
supplied from the drive system (closed-loop position control). From the resulting
following error, by multiplying with the Kv factor, a new speed setpoint (axis
velocity) is calculated and transferred to the drive.
The speed setpoint can be transferred to the drive system either digitally via
r.s
Drive system The task of the drive system is to convert the received speed information into an
actual motor speed. A speed and current controller are integrated in the drive
system for this very purpose.
The motor moves the axis which is traversed to the required target position with
ca
om
SIMATIC - automates SIMOTION - the motion SINUMERIK – brings
everything for you and that control system machine tools up to speed.
worldwide.
Specifically for machine Specifically for turning,
Powerful control that can be solutions where there are milling, drilling –
universally used – high demands on the numerical control at its
l.c
functionality can be T-CPU motion control best.
extended by motion control
ai
SINAMICS
MICROMASTER
SIMODRIVE
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Drive technology
Date:
File:
10.01.2013
MC-SMO-PRG_01.4
MASTERDRIVES
SIMATIC SIMATIC is the tried and proven basis automation system for solutions in all
sectors of industrial automation.
It consists of standard hardware and software components and offers a wide
range of possibilities for customized expansions. For SIMATIC S7, motion
ez
SINUMERIK SINUMERIK control systems are specially designed for machine tools, handling
systems and special-purpose machines.
SINUMERIK offers the optimum solution for every task in the machine tool
sector, using CNC control and drives.
ne
SIMOTION In addition to SIMATIC and SINUMERIK, there is also SIMOTION, the motion
control system for applications with complex motion control which integrates
motion control and simple control functionality in one unit.
ca
Technology CPU The technology CPUs 315/317T -2DP and 317TF -2DP (fail-safe control) are
located between the SIMATIC and SIMOTION pillars.
Motion control
Positioning
Synchronous
operation
+ SIMOTION
om
The fusion of:
Technology functions Motion control
Temperature controller Technology functions
Pressure Logic
l.c
controller
Integrated
+ system solutions for
machine construction
ai
Logic functionality
AND, OR
Multipliers
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_01.5
SITRAIN Training for
Automation and drive technology
@
SIMOTION SIMOTION offers an optimized system platform for automation and drive
solutions with the focus on motion control applications and technological tasks.
This is achieved through the new universal motion control system.
SIMOTION is an integrated motion control system which has been conceived
er
With respect to the hardware, this new approach means that the controller must
be capable of processing motion functions. On the other hand, a drive system
must be able to perform automation tasks.
On the software side, the fusion of automation functions and motion functions
ne
makes for simpler engineering. This starts with the configuration and continues
through parameter assignment and programming.
The integration with SIMATIC brings additional advantages as both systems are
often operated in one installation. The two systems can be configured and
programmed on a standard engineering interface.
ca
om
programming
Different
l.c
Runtime system hardware platforms:
Synchronous operation Controller in the S7 design
Positioning Industrial PC
... Drive
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_01.6
SITRAIN Training for
Automation and drive technology
@
Overview SIMOTION offers an optimized system platform for automation solutions for
machines where motion control applications and technology tasks are in the
forefront.
The motion control system consists of the engineering system SCOUT, the
er
motion control technology packages and a common runtime system for the
various SIMOTION platforms.
SCOUT engineering The SCOUT engineering system is used fomr configuring, programming
ez
system and setting parameters; it is the same system for all hardware platforms.
Technology Technology packages contain the software functions that are required for
packages automation in a wide range of different sectors. They expand the basic
functionality of the SIMOTION devices to suit individual requirements.
Technology packages can be added according to the machine requirements
(e.g. synchronous operation, cam).
ne
• SIMOTION C - Controller-based
• SIMOTION P - PC-based
• SIMOTION D - Drive-based
SIMOTION Tailored
SIMOTION
user Function SIMOTION
program libraries
application
om
Motion
control Additional DCC User program
technology technology blocks
l.c
Basis function- packages
ality acc. to packages
IEC 61131-3 + Function libraries
SIMOTION kernel
ai
(operating system, I/O handling, communication…) + Technology packages
+ Basis functionality
SIMOTION
Drives
Date:
File:
components
10.01.2013
MC-SMO-PRG_01.7
SITRAIN Training for
Automation and drive technology
@
System architecture The most outstanding feature of the new automation approach is its system
architecture. This forms the basis for ongoing system development. The system
architecture of SIMOTION especially supports concepts – such as
decentralization, different target platforms and distributed intelligence.
er
The software is modular and can be flexibly adapted to the widest range of
requirements.
Basis functionality The basis functionality of the device (SIMOTION kernel) includes functions for
ez
command set plus system functions for controlling various components, such as
inputs and outputs.
Technology The SIMOTION kernel can be expanded by loading technology packages. Using
packages additional language commands, the technology packages can be accessed in
ne
the same way as the SIMOTION kernel from the user program.
Function The libraries contain standard functions for frequently performed tasks.
libraries In addition to the standard functions supplied, users can also create their own
blocks and store them in a library.
ca
From Version 4.0, the following libraries have also been integrated as function
blocks in the system (TP "Cam"), and can now be directly inserted into the user
program from the command library:
• Standard functions, for instance PID controllers, driver blocks for special
I/O modules
• Blocks in conformance with PLCopen to control axes (single and
multi-axis blocks)
om
Adder Temperature
Actual value Position- Gearing 2D/3D linear object control
processing controlled interpolation
Camming Controller Controller
Speed traversing Circular
Synchroni- object optimization
setpoint Referen- interpolation
zation/de- Formula
l.c
Output cam cing synchroni- Polynomial object
functions Leading zation interpolation
Fixed gear
Measuring axis Various
function Sensor
input kinematics
ai
License TP "Cam" License
not required required
License License
TP "Path" not required required
SIMOTION
Siemens AG 2013. All rights reserved.
TP "Cam_ext" (extended)
gm
Date:
File:
10.01.2013
MC-SMO-PRG_01.8
License
not required "TControl"
TP "CAM" The "Cam" technology package provides all object types and system commands
to control speed, positioning and synchronous axes.
In addition to the functionality for the individual axes, TP "Cam" contains the
ez
"Measuring input", "Output cam" and "Cam track" functions (from V3.2 and
higher) as well as the function blocks in conformance with PLCOpen.
TP "PATH" The "PATH" technology package provides path functionality. The following are
supported: 2D/3D linear, circular and polynomial interpolation. In addition,
r.s
TP "CAM_EXT" Supplementary technology functions are available with Version 3.2 and higher.
• Adder: With adder objects up to four input vectors can be added to one
ne
output vector.
• Formula: With formula objects, you can apply mathematical operations to
scalar (LREAL, DINT) and motion vectors.
• Controller: Using the controller object, according to a PID algorithm, scaler
ca
TP "TControl" The basis of the temperature controller is a DPID controller which has special
functions (threshold monitoring, adaptation of controller parameters, etc.) for
easy adaptation to applications (plastics machines).
SITRAIN Training for MC-SMO-PRG
Automation and Drive Technology Page 8 SIMOTION – An Overview
SIMOTION SCOUT Engineering Tools
om
LAD/FBD
Axis configuration
DCC
l.c
CamEdit
ai
commissioning
SIMOTION
Siemens AG 2013. All rights reserved.
Date:
File:
gm 10.01.2013
MC-SMO-PRG_01.9
SITRAIN Training for
Automation and drive technology
@
Engineering system The SCOUT Project navigator is the common framework for all tools of the.
SCOUT engineering system. This workbench is also the navigation center for the
individual engineering steps. It is used to create and manage SIMOTION
projects and provides a uniform and integrated view of all data and programs.
er
The essential new feature is the graphic programming of the motion sequence
using Motion Control Chart (MCC). From SCOUT V4.1, there is also the optional
DCC programming language (Drive Control Chart) to create continuous, closed-
loop control related circuit diagrams to control drives.
ez
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_01.10
SITRAIN Training for
Automation and drive technology
@
Overview SIEMENS offers a range of task-oriented programming languages for
SIMOTION that allow the user to focus on the actual task at hand. SIMOTION's
modular design makes it possible to create modular blocks in different
languages according to the individual task requirements.
er
MCC MCC is a graphic language for creating operational sequences. In particular, this
language offers entry-level users support for quick and transparent creation of
sequential program sequences in MotionTasks.
ez
Any additional ST code can be integrated in the MMC program via the "ST
Zoom" command.
LAD/FBD These programming languages are unparalleled for programming binary signal
r.s
gating. In addition to the wide range of options in the area of binary signal gating
(edge evaluation, flip-flops, etc.), it integrates many other function such as IEC-
compliant counter and timer blocks.
Almost all system functions can be directly called and tested in a network.
ne
process sequences.
DCC The Drive Control Chart (DCC) option is a modular, scalable programming
language based on the STEP 7 package CFC (Continuous Function Chart), to
develop continuous open-loop or closed-loop control solutions for controlling
drives.
om
• MCC contains graphic commands for:
• Axis movements
• Processing I/O signals
• Control structures for branches and
repeat operations
l.c
• Comparable with S7 Graph from STEP 7
Advantages of MCC
• Motion sequences can be simply and
ai
transparently generated
• Even entry-level programmers can attain
results quickly
SIMOTION
Siemens AG 2013. All rights reserved.
gm
• In addition to the fast generation, MCC also provides support
Date:
File:
10.01.2013
MC-SMO-PRG_01.11
SITRAIN Training for
Automation and drive technology
@
Properties MCC is a new graphic programming language, designed to significantly simplify
of MCC the automation of production machines.
Many production machines are very complex. They require a control system
(SIMOTION) that is capable of handling motion control and technologies with a
er
with all of the descriptive symbols you will need to define your automation task
quickly and efficiently.
In addition, MCC offers many ways to structure large automation tasks.
Using MCC, programs, function blocks and functions can be generated in
r.s
Advantages of MCC As a graphic programming language, MCC helps you to formulate process and
motion sequences easily by creating a sequence of graphic MCC commands.
The characteristics of every MCC command can be parameterized individually.
ne
om
• Motion control functionality can be best integrated
using the function block from the PLCOpen
library
• Identical to SIMATIC LAD/FBD
l.c
Advantages:
• Binary logic operations can be simply formulated,
for instance, interlocking conditions
ai
• Easy to understand and program
• Simple testing and commissioning of programs
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_01.12
SITRAIN Training for
Automation and drive technology
@
LAD LAD stands for ladder diagram. LAD is a graphic programming language. The
syntax for the instructions is similar to a circuit diagram. LAD enables simple
tracking of the signal flow between conductor rails via inputs, outputs and
operations.
er
FBD FBD stands for function block diagram. FBD is a graphics-based programming
language that uses the same type of boxes used in boolean algebra to represent
logic (compatible to IEC 61131-3). In addition, complex functions (e.g. mathe-
matical functions) can be represented directly in conjunction with the logic
boxes.
ne
Just like LAD, FBD provides all of the elements that are required for creating
PLC tasks.
Advantages and The programming languages are admirably suited to implement open-loop
limits control tasks using binary operands; for instance, interlocking conditions.
ca
Programming closed-loop control tasks with analog variables, for instance the
speed of a drive or the temperature of a heating boiler etc. is a tedious
procedure in LAD/FBD networks.
DCC is an expansion to process analog variables. Using the DCC editor, analog
variables can be processed and interconnected in a similar way to binary
variables in LAD/FBD.
However, having said this, LAD/FBD is especially useful as many service
personnel feel very comfortable with LAD/FBD programming.
om
high-level language, such as operators,
expressions, control instructions, etc.
• Motion control functionality is integrated
by means of system functions and
function blocks
l.c
• Identical to SIMATIC S7 SCL
Advantages:
• Formulation and creation of blocks with
ai
complex algorithms:
• Closed-loop control tasks
• Data processing tasks
SIMOTION
•
•
Process optimization
Mathematical/statistical evaluation
om
• Interconnections are possible:
- to I/Os of other blocks
- between I/Os of the I/O list
- also to I/Os of blocks in
other charts
• Sources and targets are managed in
l.c
the sheet bar
• Can be used in SIMOTION and
SINAMICS
ai
Advantages
• Well-established programming tool for
motion control tasks!
• Fast generation, testing and
commissioning
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_01.14
SITRAIN Training for
Automation and drive technology
@
Overview, DCC DCC (Drive Control Chart) offers a modular, scalable technology option, which
has chiefly been developed for drive-related, continuous open-loop and closed-
loop control tasks. The DCC technology option for SIMOTION controllers and
SINAMICS drives can be configured graphically using the Drive Control Chart
er
Using the DCC Editor, charts are subsequently created, in which blocks are
inserted from the library, parameterized and interconnected. The charts are then
compiled and an intermediate code generated; this is then loaded into the
SIMOTION and/or the drive unit using SCOUT /STARTER.
ca
Advantage kDCC can be used from very simple up to extremely complex applications.
Communication between the blocks can be configured in a user-friendly fashion
using a straightforward interconnection system. It is not necessary to manually
handle and manage the machine resources.
Comprehensive test tools with simple display, diagnostics and trace functions
ensure fast testing and in turn fast commissioning of the user program.
om
l.c
ai
• Can only be used in "MotionTasks" • Only suitable in cyclic tasks:
and event-controlled tasks • Alternative to creation in MCC
SIMOTION
• Program creation in MCC
MC-SMO-PRG_01.15
SITRAIN Training for
Automation and drive technology
@
Sequential With sequential programming, the entire program is separated into individual
programming steps with associated function calls. When one command can switch to the next
is defined in the dialogs for the individual commands.
If the next command is only enabled when the job has been completed, then this
er
After the function call is issued, the program advances to the next command
without waiting for the job to be terminated. During the subsequent cycles of the
program section, the user program can track the job processing status via the
associated output parameters of the function block, so that the next job can be
started upon successful termination of the current one.
RUN
BackgroundTask BackgroundTask
om
MotionTasks MotionTask1 MotionTask2 MotionTask32
l.c
TimerInterruptTasks TimerIntTask1 TimerIntTask2 TimerIntTask5
ai
InterruptTasks UserIntTask1 UserIntTask2 SystemIntTasks
SIMOTION
Siemens AG 2013. All rights reserved.
Run Stop
Date:
File:
gm ShutdownTask
10.01.2013
MC-SMO-PRG_01.16
SITRAIN Training for
Automation and drive technology
@
StartupTask/ The StartupTask is executed once at the transition from STOP or STOP U
ShutdownTask operating mode to RUN operating mode. It serves the purpose of initialization.
The ShutdownTask is called at the transition from RUN to STOP or STOP U.
er
BackgroundTask This task is called cyclically. When the programs in this task have been
processed, the task is automatically restarted. This task implements the
conventional interlock functions of a PLC.
ez
MotionTasks MotionTasks are tasks that are started by the user program and are processed
only once. These tasks are assigned to programs; execution is then sequential.
One such program is, for example, motion control of an axis. The axis moves to
a target position and waits for an Enable signal before traversing to the next
target position.
r.s
. . . Synchronous- The tasks are started synchronously with the specified system cycle clock
tasks (position control cycle clock, IPO cycle clock, IPO_2 cycle clock) before the
technology package. In these tasks, you can implement time-critical functions
that correlate closely with the timing of the motion control of the axes.
ne
TimerInterruptTasks The TimerInterrupt Tasks are started and processed at fixed intervals and can
be used to implement control or monitoring tasks that need a fixed time
reference.
UserInterruptTasks These are event-triggered and processed only once. They can be used to
respond to user-defined events.
FaultTasks These are triggered by system events such as faults and alarms and
(Systeminter.Tasks) processed only once. Different tasks are available for the various error events.
SITRAIN Training for MC-SMO-PRG
Automation and Drive Technology Page 16 SIMOTION – An Overview
The Various Hardware Platforms (1)
SIMOTION C230-2 / C240 / C240 PN
• SIMATIC S7-300 mechanical design
• Drive link analog (4 channels onboard, not C240 PN)
or via PROFIBUS-DP or 3 x PROFINET
(only C240 PN)
• Interfaces 2 x PROFIBUS-DP,
om
1 x Ethernet (100 MBit/s)
l.c
Embedded Standard 2009
• Processor: Intel Pentium 2 GHz /
Intel Core2 Solo 1.2 GHz,
ai
• Memory: 2 GB RAM, 40 GB HD /
2 GB RAM, 4 GB CF card
• Drive link: PROFIBUS-DP or PROFINET /
• Interfaces
SIMOTION
Siemens AG 2013. All rights reserved.
3 x PROFINET
gm
1 x COM, 4 USB, 2 x Ethernet /
1 x Ethernet, 4 x USB
Date:
File:
10.01.2013
MC-SMO-PRG_01.17
SITRAIN Training for
Automation and drive technology
@
What is The C2xx is a motion control module for controlling servo drives via
SIMOTION C? PROFIBUS DP (PROFINET for C240 PN) and four onboard drive interfaces
(only C230-2 and C240).
The SIMOTION C is a powerful module for the independent single-axis
er
positioning or for axis group motions. It supports operation of both rotary and
linear axes.
The engineering system is used for the configuration, parameterization,
commissioning, programming and diagnostics of the SIMOTION C.
ez
What is SIMOTION P is a PC-based motion control system. Control, motion control and
SIMOTION P? HMI functions run concurrently on this PC.
For the P350-3, the drive coupling and the connection of distributed I/Os can be
r.s
om
• Drive link Three PROFIBUS master systems:
one internal, two external
• Interfaces: 2 x PROFIBUS DP Antriebs-
2 x Ethernet (100 MBit/s) Steuerung
3 x PROFINET (only Dx45-2 PN/DP)
l.c
SIMOTION D410/410-2
• Comprises two systems:
• Processor for motion control
ai
• Processor for drive control D4x5/-2
• Design SINAMICS drive system
• Drive link Two PROFIBUS master systems:
• Interfaces :
SIMOTION
one internal, one external
1 x PROFIBUS-DP
or 1 x PROFINET
performance for motion control tasks are required in combination with high-
speed I/Os. SIMOTION D is offered in the performance variants: D425/-2 (low-
end performance range), D435/-2 (medium performance range), D445/-2 (high-
end performance range) and D455-2 (top performance range).
ez
As of V4.1, the D410 single-axis system is available for the modular expansion
of SIMOTION D systems. As of V4.3 the innovated System D410-2 with a multi-
axes option is available.
r.s
ne
ca
om
Shared communication:
PROFIBUS, PROFINET, Ethernet
T-CPU
l.c
C230-2/C240
P350-3/P320
D4xx
ai
Shared use of
distributed I/Os and
SIMOTION
drives via PROFIBUS
and PROFINET
Industrial Ethernet Fast Industrial Ethernet that can be used for the following purposes:
ne
PROFINET PROFINET is the innovative and open Industrial Ethernet standard (IEC 61158)
for industrial automation. With PROFINET, devices can be linked up from the
field level through to the management/supervisory level.
With PROFINET, drives can be controlled isochronously via a network and
communication that is not critical from a time perspective (e.g. TCP/IP) can be
established between automation components.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_01.20
SITRAIN Training for
Automation and drive technology
@
SIMOTION The SIMOTION printed documentation consists of individual documentation
documentation packages included in more than 50 SIMOTION documents and other documents
(e.g. SINAMICS).
The documentation packages are organized according to their functionality and
er
the handling of the SIMOTION SCOUT engineering system and of the CamTool .
• 2_Description_of_system_and function describes the technical
operational sequences for the SIMOTION system and explains the technology
objects.
• 3_Programming: describes the three programming languages
r.s
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.1
SITRAIN Training for
Automation and Drives
@
Contents Page
Integration of ST in SCOUT .............................................................................................................. 3
Generating an ST source file ............................................................................................................ 4
er
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.2
SITRAIN Training for
Automation and Drives
@
Contents Page
Access to individual bits with the "Permit language extensions" compiler option .............................. 27
Control statements: IF and CASE ..................................................................................................... 28
er
Comments in ST .............................................................................................................................. 32
Controlling compilation with the preprocessor ................................................................................... 33
Example of how to use the preprocessor .......................................................................................... 34
Testing ST programs ........................................................................................................................ 35
r.s
om
Editor
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Symbol browser
Date:
File:
10.01.2013
MC-SMO-PROG_02.3
SITRAIN Training for
Automation and Drives
@
ST programming The ST programming environment essentially consists of the editor, the
environment compiler, and the integrated test functions:
• ST editor
er
Programs are created with a user-friendly text editor. You can use this editor
to create programs consisting of functions (FC), function blocks (FB), and
user-defined data types (UDT).
• ST compiler
ez
• ST test functions
ST programs are tested with the "Program status" function. It is particularly
useful for locating logical programming errors in running programs.
The symbol browser can also be used to observe and change the content of
ne
External editor An external ST editor can also be integrated into the SIMOTION SCOUT
Workbench.
1. To do this, open the "Settings" dialog by selecting Options -> Settings
from the menu and go to the "External ST editor" tab.
2. Check the "Use external ST editor" box and enter the path and the required
program.
Enter name
(max. 128 characters)
om
l.c
ai
Double-click
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.4
SITRAIN Training for
Automation and Drives
@
Inserting an ST
source file ST source files are assigned to the SIMOTION device on which they are to run.
1. Open the appropriate SIMOTION device in the project navigator.
er
4. Enter a name of your choosing for the ST source file on the "General" tab.
Names for program source files must satisfy the rules for identifiers:
They are made up of letters (A … Z, a … z), numbers (0 … 9), or single
underscores (_) in any order, whereby the first character must be a letter
r.s
or underscore.
Names are not case-sensitive. They start with a letter or an underscore and
can contain up to 128 characters.
5. If applicable, select the "Compiler" tab so that you can make the local
ne
Permit program
status
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.5
SITRAIN Training for
Automation and Drives
@
Compiler The following settings can be made on the "Compiler" tab:
• Use global settings: The selected global settings are applied.
The global settings can be selected under the menu command:
Options -> Settings -> Compiler.
er
Once the "global setting" has been deselected, the relevant option can
be selected locally, i.e. specifically for the source file.
• Selective linking: Unused code is removed from the executable program.
ez
the block status later on. In this case, additional program code is generated
to enable variables (including local variables)
to be monitored.
• Permit language extensions: Language elements are permitted that do not
comply with IEC 61131-3.
ne
• Only create program instance data once: The local variables of a program
are only stored once in the user memory of the unit. The setting is required
when a further program is to be called within a program.
• Issue warnings: In addition to error messages, the compiler can issue
ca
warnings. You can set the scope of the warning messages to be issued.
• Permit forward declarations: When calling a block, the compiler must not
yet have compiled that block; it must only know the signature (name,
parameters, etc.).
• Permit OPC-XML: Symbol information about the unit variables of the
interface section is loaded to the target system.
om
l.c
ai
•
SIMOTION
Command library
The following settings can be made on the "ST editor" tab in the "Settings"
ST editor settings dialog:
• Display line numbers: If active, the line numbers are displayed.
• Replace tabs with blanks: Tab entries are replaced with the
r.s
om
Restrictions Keywords
No umlauts (blue)
Not case-sensitive
Must not start with a digit
Should not start with an Constants:
underscore (reserved for (pink)
l.c
SIEMENS)
Must not be the same as
"keywords"
Keywords
ai
Have a fixed meaning
Are displayed in blue
Comments:
•
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.7
(green)
Identifier (name) A user-defined name (identifier) for a data type, a variable, or a block can
consist of letters (no umlauts), digits, and the underscore character. The
ez
Syntax coloring
• Blue: Keywords
• Green: Comments
• Black: The names of technology objects, variables, and blocks, as well
as user code
• Pink: Constants
INTERFACE
Connection to
other units
END_INTERFACE and to the
execution system
om
IMPLEMENTATION
END_FUNCTION
l.c
FUNCTION_BLOCK homing
END_FUNCTION_BLOCK
...
ai
PROGRAM Truing
END_PROGRAM
SIMOTION
END_IMPLEMENTATION
are also called sections. Specific keywords are used to mark the start and end of
each logical section of an ST source file.
UNIT name The name of the unit can be specified but does not have to be; if it is, it must
ez
appear at the start of the ST source file. If the name is used, it must match the
name of the ST source file entered under the settings in the corresponding
dialog.
r.s
INTERFACE Obligatory part of a unit. The interface section contains statements for importing
and exporting data (data types, variables, function blocks, functions, and
programs). Technology packages, libraries, and the INTERFACE component of
other units can also be loaded.
ne
IMPLEMENTATION Obligatory component of a unit. As well as the declaration of private data types
and variables, it contains the executable sections or POUs (program
organization units).
POUs are the executable source file sections, e.g.: functions, expressions,
ca
The POU called must always be in a unit upstream of the calling block.
UNIT example
INTERFACE
// Specification of imports Import of:
USEPACKAGE CAM; • Technology packages
USELIB Lib_1, Lib_2; • Libraries
om
USES control, diagnostics; • Units
l.c
VAR_GLOBAL • Data types
set, actual: LREAL;
END_VAR
Export of:
ai
// Specification of public blocks
PROGRAM display; • Programs (necessary for
task assignment)
FUNCTION adder;
• Function blocks
END_INTERFACE
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.9
• Functions
other units.
makes the system functions and variables required for compiling the ST source
file available.
Units The USES unit_name-list keyword is used to reference other units so that their
exported components such as variables, data types, etc. can be imported
(importing unit).
ne
Export Data and code blocks can be exported here. The following are permitted at
variable and type declarations:
• TYPE for the full declaration of user-defined data types
ca
Note Follow the sequence specified above when making specifications in the
interface section. Otherwise, error-free compilation of the ST source file will not
be possible.
om
END_TYPE
• Variables
VAR_GLOBAL
State: Mode := active;
END_VAR
l.c
PROGRAM display
Declaration part
. . .
END_PROGRAM
ai
FUNCTION adder : LREAL
Statement part
. . .
END_FUNCTION
SIMOTION
. . .
END_IMPLEMENTATION
Declaration The following variable and type declarations are permitted within the declaration
section section:
• TYPE for the declaration of user-defined data types
ez
Functions (FC) FCs are parameterizable POUs that can be called from programs and function
blocks. FCs do not have a "memory", i.e. they are not able to "remember"
information from one call to another.
FC variables are only ever temporary; they are initialized on every call.
ne
Expression Expressions are a special type of function declaration with a BOOL data type
return value. The WAITFORCONDITION function is used so that a MotionTask
can wait specifically for a programmable event or condition. The command
ca
suspends the task that called it until the condition (expression) is true.
Function block FBs are parameterizable POUs which can be called from programs and other
(FB) FBs. Unlike FCs, FBs have a "memory", i.e. they are able to "remember"
information in static variables from one call to another.
Programs Programs are called by the operating system on the target device based on their
task configuration. More FBs and FCs can be be called within a program.
om
Motor: STRUCT
Setpoint_speed : Speed; - Fields
Actual_speed : Speed; - Enumerators
Enable: BOOL;
Fault: BOOL; • TO/system data types
END_STRUCT;
Meas_values: ARRAY[1..NUM] OF REAL;
State: (active, passive);
l.c
XYZ_Achse: posAxis; Global variables:
END_TYPE
• VAR_GLOBAL
VAR_GLOBAL
• VAR_GLOBAL CONSTANT
FullBottles: INT := 123;
ai
EmptyBottles: INT; • VAR_GLOBAL RETAIN
END_VAR
VAR_GLOBAL RETAIN
SIMOTION
OperatingRuntime: UINT;
END_VAR
• POU
The data types created can be used again in the same or subsequent
declaration section. Moreover, UDTs can be nested at will. Predefined UDTs
ez
Variables A variable defines a memory space with variable content. A variable consists of
r.s
an identifier that can be selected at will (e.g. myVar1), the specification of a data
type (e.g. INT), and any applicable modifiers (e.g. CONSTANT, RETAIN), which
define access or how the content responds in the event of a POWER OFF.
The following types of variable can be declared within an interface and
implementation section:
ne
• Global variables (VAR_GLOBAL) are variables which support read and write
access from the user program. When
the controller shuts down, the content of the variables is lost. Global
variables can be initialized during declaration.
• Global "read-only" variables (VAR_GLOBAL CONSTANT) only support
ca
om
NumTests: INT := 5; • Variable declarations:
Guard: State;
END_VAR • VAR (static variables)
VAR_TEMP • VAR_TEMP (temporary variables)
IntermResult: REAL; • VAR CONSTANT (constants)
END_VAR
l.c
VAR CONSTANT • Static and temporary variables
Pi: REAL := 3.14;
END_VAR can be initialized; constants
must be initialized.
;
ai
IntermResult:= NumTests * Pi;
SIMOTION
END_PROGRAM
types defined here can only be used for subsequent variable declarations
VAR within the PROGRAM.
The VAR keyword is used to declare variables of any data type in a program.
ez
Local variables (VAR) of a program are simatic when used in cyclic tasks. In
sequential tasks, they are temporary; i.e. they are reinitialized every time the
task (e.g. MotionTask_1) starts.
In these variables, a program that is running in a cyclic task can remember
information from cycle to cycle (memory).
r.s
VAR_TEMP
The keyword VAR_TEMP is@ used to declare temporary variables in a
program. Temporary program variables are local user variables which are
reinitialized every time the program is called.
Temporary variables are used to save intermediate results which are produced
ne
at the start of program execution, for example, and processed further later in
the same program cycle.
VAR CONSTANT Constants are data with a fixed value. This value cannot change at program
runtime. Constants are declared in the same way as variables.
ca
Initialization All local variables of a program can be initialized during declaration. Constants
must be initialized during declaration. If an initialization value is not declared for
a variable, it is pre-assigned the value "0".
om
END_INTERFACE END_INTERFACE
Unit variable
(interface part)
IMPLEMENTATION IMPLEMENTATION
Validity
VAR_GLOBAL VAR_GLOBAL
l.c
(implemen-
tation part)
END_PROGRAM END_PROGRAM
Validity
ai
PROGRAM test_n PROGRAM test_n
Local variable
Validity
SIMOTION
END_PROGRAM
END_IMPLEMENTATION
10.01.2013
MC-SMO-PROG_02.13
SITRAIN Training for
Automation and Drives
@
Global device Global device user variables are created with the symbol browser:
variables For this purpose, the "Global device variables" entry must be selected in the
project window underneath the required SIMOTION device. The required
variables can then be created in the symbol browser window with identifier, data
er
Global unit Global unit variables can be declared in the interface or implementation part
variables of the unit.
In the case of declaration in the interface part, the variables become exportable
r.s
variables which can also be used in POUs of other units. These variables (with
the exception of CONSTANT) can be monitored and controlled in the symbol
browser. They can also be accessed from OCM devices.
In the case of declaration in the implementation part, the global variables can
only be used in the POU of the unit concerned (they are the private property of
ne
the unit, as it were). Although these variables can be monitored in the symbol
browser, they cannot be accessed from OCM devices.
Variables can also be saved as data sets on an MMC or CF card and reloaded.
Values of retain unit variables (VAR_GLOBAL RETAIN) are not saved. The
system supports the following functions for saving and reloading values:
ca
Local variables Local variables can only be used in the associated POU in which they were
declared. These variables can neither be monitored in the symbol browser nor
accessed from OCM devices. Local variables are the private property of the
corresponding POU, as it were.
om
IMPLEMENTATION
VAR_GLOBAL RETAIN Initialization on
MyCounter: INT;
END_VAR "OVERALL RESET" or "Download"
Initialization on
VAR_GLOBAL
"Power On" and "OVERALL RESET"
l.c
MyValue: LREAL;
END_VAR (also on STOP -> RUN as of V4.2)
PROGRAM MyProgram
VAR // static Initialization on start of task,
Counter: INT; e.g. transition: STOP -> RUN
END_VAR
ai
VAR_TEMP // temporary
Initialization on program
IntermediateValue : REAL; call or function block call
END_VAR
SIMOTION
. . .
END_PROGRAM
END_IMPLEMENTATION
These variables retain their values even after the controller shuts down.
VAR_GLOBAL In other words, after a controller restart, the original value is retained. The
RETAIN initialization values are restored when an OVERALL RESET (switch position:
MRES) is performed and, dependent upon the settings made under Options ->
ez
These variables usually retain their contents when the controller is set to STOP
r.s
VAR_GLOBAL
operating mode due to an error, for example, and then reset to RUN. They
"lose" their contents when the controller is shut down and when an overall reset is
performed. When the controller is powered up or an overall reset is performed, the
contents of the variables are set to the initialization values. This also happens when
a project is downloaded (dependent upon the settings made under Options ->
ne
In programs, these variables are static in nature, i.e. they are only reset to the
ca
VAR initialization values if the task in which the program is running is restarted. In FBs,
these variables are part of the instance data area, i.e. initialization depends upon
the variable type (VAR_GLOBAL RETAIN, etc.) under which the associated FB
instance was declared.
These variables are temporary in nature, i.e. their contents are reset to the
VAR_TEMP initialization values every time the program or the FB/FC (in the case of FC this
corresponds to the type: VAR) is called.
r
om
• Field (ARRAY)
l.c
• Character string (STRING)
Compound
• Structure (STRUCT)
(derived)
data types • Enumerators (ENUM)
ai
• TO (Technology Objects)
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.15
SITRAIN Training for
Automation and Drives
@
Overview Solutions for automation tasks provided by computer systems are based on
algorithms which process the process data captured by sensors and output new
manipulated variable values to the actuators. Programs are ultimately
formulations of algorithms based on certain representations of data or data
er
structures.
Elementary The elementary data types are the smallest elements of any programming
data types
system. The selection of elementary data types in a programming system says
ez
data types
elementary and higher structures. Elementary structures are the tiny elements
which are used to build compound data types.
In SIMOTION, the compound data types declared by the user are supplemented
by dedicated data types provided by the corresponding technology packages
ca
and by the system for handling the supported objects (driveAxis, posAxis, etc.).
om
DWORD 32 16#0 to 16#FFFFFFFF
SINT 8 -128 to 127
USINT 8 0 to 255
INT 16 -32768 to 32767
UINT 16 0 to 65635
DINT 32 -2147483648 to 2147483647
0 to 4294967295
l.c
UDINT 32
REAL 32 -3.040282E38 to 3.040282E38
LREAL 64 -2.225073E308 to 2.225073E308
TIME 32 TIME#49d_17h_2m_47S_295mS
DATE 32 DATE#2200-12-31
ai
TIME_OF_DAY 32 TIME_OF_DAY#23:59:59.999
DATE_AND_TIME 64 DT#2200-12-31-23:59:59.999
SIMOTION
Siemens AG 2013. All rights reserved.
gm
* BOOL type operands only occupy 1 bit if they are defined as inputs or outputs in the I/O list;
if they are defined as variables in the memory, they occupy 1 byte (8 bits).
Date:
File:
10.01.2013
MC-SMO-PROG_02.16
SITRAIN Training for
Automation and Drives
@
BOOL, BYTE, BOOL data type variables consist of one bit; BYTE, WORD, DWORD data type
WORD, DWORD variables are sequences of 8, 16, and 32 bits respectively. The individual bits
are not processed in these data types.
er
SINT, INT, DINT... Variables of these data types represent integers for performing corresponding
arithmetic operations (counter instructions).
SIMOTION supports both signed integers such as SINT, INT, and DINT and
the corresponding unsigned data types: USINT, UINT, and UDINT.
ez
REAL, LREAL These are numeric data types with decimal places. In addition to counting
operations, they can be used for extended mathematical operations and
functions (such as the trigonometric functions sin, cos, etc.).
r.s
TIME, DATE, etc. These data types are used to manage time stamps in the user program of a
SIMOTION device.
ne
ca
om
TYPE
a : ARRAY[1..6] OF REAL; // 1-dim. array (6 columns)
matrix : ARRAY[1..4] OF a; // 2-dim. array (4 rows with 6 columns)
END_TYPE
l.c
VAR
a_1 : a; // Variable of 1-dim. array data type
b_1 : a := [1,2,3,3(4)]; // Variable with initialization
m_1, m_2 : matrix; // 2-dim. array
END_VAR
ai
m_1[4][6] := 9.0; // Write to row 4, column 6
m_1 := m_2; // Assignment of a complete array
SIMOTION
m_1[4] := a_1;
IF m_1 = m_2 THEN ...
10.01.2013
MC-SMO-PROG_02.17
SITRAIN Training for
Automation and Drives
@
ARRAYs The ARRAY data type is a field from a fixed number of components of the same
data type. An array can be multidimensional (number of indices).
The index specification describes the limits of the array:
• The array limits specify the minimum and maximum value for the index.
er
They can be defined by SINT, USINT, INT, UINT, or DINT data type
constants or initialization expressions.
• The array limits must be separated by two periods.
ez
column number.
• The higher-dimensional ARRAY type is an expansion of the two-dimensional
ARRAY type that includes additional dimensions.
ca
Note If array limits are violated during runtime, a processing error occurs in the
program.
• Example assignments:
om
AxisName1 := 'Transporter';
• Comparison operations:
IF AxisName1 = AxisName2 THEN.. (<, >, <=, =<, =>, >=, = , <>)
• String functions (Command library "Character strings"):
CONCAT (attaches two strings together) LEN (returns the length)
l.c
DELETE (deletes sub character string) LEFT (returns the left character string)
FIND (returns the pos. of a character string) MID (returns character string from string)
REPLACE (first character string in string) RIGHT (returns right character string)
• Assignments to BYTE type variables
ai
byteVar := string20[5];
string20[10] := byteVar;
SIMOTION
• Conversions from and to DINT/UDINT/REAL/LREAL
myString := REAL_TO_STRING(myReal);
myLReal := STRING_TO_LREAL(myString);
• As printable characters (ASCII code $20 to $7E, $80 to $FF), except the
dollar sign (ASCII code $24) and apostrophe (ASCII code $27), as these
have a special function within the string
• Using the two-digit hexadecimal ASCII code of the corresponding character
preceded by a dollar sign ($).
r.s
accessed.
Operations String variables are used to assign constant character strings (e.g. 'Fueller_rot')
or other string variables. Comparison functions are also available
ca
om
TYPE // UDT definition
Motor : STRUCT
Setpoint_speed : REAL := 10.0;
Actual_speed : REAL;
Enable : BOOL;
l.c
Fault : BOOL;
END_STRUCT;
END_TYPE
VAR
ai
Motor_1 : Motor; // Variables of data type Motor
Motor_2 : Motor := (setpoint_speed:= 100.0, fault:= TRUE)
END_VAR
SIMOTION
Motor_1.setpoint_speed := 100.0; //
Motor_1 := Motor_2;
IF Motor_1 = Motor_2 THEN ...
MC-SMO-PROG_02.19
SITRAIN Training for
Automation and Drives
@
Structure The derived data type STRUCT, or structure, encompasses an area of a fixed
number of components in the TYPE/END_TYPE construct; the data types of
these components can vary:
The following are permitted as data types:
er
• TO data types
• System data types
If you wish, you can define initialization values when declaring the data type
and/or when creating variables (as of V4.0).
r.s
Note The following data specifications cannot be used directly within a component
declaration:
• STRUCT data type specifications
• Enumerator data type specifications
ne
In this case, a UDT (user-defined data type) must be declared with the
required data type first. This UDT can then be used for component declaration.
kA component of the structure is addressed using the following syntax:
Access
ca
• StructureName.ComponentName
A period must be inserted as a separator between StructureName and
ComponentName. In the user program, the entire structure can of course be
accessed for assignments.
As of V4.0, the "Comparator at equal to" = and "Comparator at not equal to" <>
operations are supported for STRUCT variables of the same type.
Enumerator: 1 OPENING
1 1
• Limited number of
identifiers (names) 0 1 2
2 1
• Declaration and access: OPEN
3
CLOSED CLOSING
om
State graph for a guard
TYPE
GuardState :(CLOSED := -1, OPENING := 2, OPEN, CLOSING);
END_TYPE
l.c
VAR
myGuard : GuardState; // GuardState type variables
myDINT : DINT; // DINT type variables
END_VAR
ai
myGuard := CLOSED; // Access to myGuard
myGuard := GuardState#OPEN;
IF myGuard = OPEN THEN ... // Comparison operation(=, <>)
SIMOTION
myDINT := ENUM_TO_DINT(GuardState#OPEN);
Date:
File:
10.01.2013
MC-SMO-PROG_02.20
SITRAIN Training for
Automation and Drives
@
Enumerator For the enumerator data types, a limited number of identifiers or names are
assigned to the data type to be defined in the TYPE/END_TYPE construct.
Internally, DINT data type numbers are assigned to the individual values (e.g.
OPEN, CLOSED, etc.) which can accept an enumerator data type.
er
As of V4.0, the individual names can be initialized with DINT type values during
declaration. In the absence of initialization, the number 0 is assigned to the first
name, the number 1 to the second name, etc. Once a name is initialized with a
value, when the next name is initialized, it is assigned the same value
ez
Variables and Once the Identifier data type has been declared, enumerator data type variables
r.s
operations can be declared. In the statement part, you can assign only elements from the
list of defined identifiers (enumerator elements) to these variables.
To integrate the data type into this assignment, you can prefix the enumerator
element with the identifier of the enumerator data type and the character "#".
ne
In addition to the ":=" assignment, the comparison operations "=", "<>", "<=",
">=", "<", and ">" are also supported at possible operations for an enumerator
data type.
Note Both the operating system and the technology packages often use predefined
ca
om
VAR
myAxis : posAxis; // Variable for axis
myPos : LREAL; // Variable for position of axis
retVal : DINT; // Variable for return value of TO function
END_VAR
l.c
myAxis := Axis_1; // The name "Axis_1" was defined when the axis
// was configured
// Axis is enabled.
retVal := _enableAxis(axis := myAxis);
ai
// Axis is positioned.
retVal := _pos(axis := myAxis, position := 100);
SIMOTION
Siemens AG 2013. All rights reserved.
// Scan the position
gm
myPos := myAxis.positioningState.actualPosition;
Date:
File:
10.01.2013
MC-SMO-PROG_02.21
SITRAIN Training for
Automation and Drives
@
Technology objects TOs incorporate fixed structures and functions provided by the individual
(TO) technology packages. For variables of a TO to be declared, the corresponding
technology package must be loaded in the interface part.
SIMOTION provides the following TOs:
er
The data types for technology objects are dependent on the technology package
downloaded. The elements of technology objects can be accessed in the same way
ne
Inheritance can also be used between TOs. Inheritance for axes means that all of
the data types, system variables, and functions of the driveAxis TO are fully included
in the posAxis TO. In turn, posAxis is fully included in the followingAxis TO.
ca
VAR
minHeight: REAL:= 2.2;
Height : REAL;
Length : REAL;
Write access Width : REAL;
Read access
om
END_VAR
VAR_TEMP
Area: REAL;
Volume: REAL;
END_VAR
;
l.c
Area: = Length * Width;
Volume: = Area * Height;
;
IF volume < 5.0 THEN
Control structure
Length:= 2.5; // Comment
ai
Width:= 2.0;
END_IF;
END_PROGRAM
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.22
SITRAIN Training for
Automation and Drives
@
Statement part The actions to be executed with the data introduced in the declaration part and
the global data are described in the statement part of a block. Normally, the
statements are executed in the order in which they are listed in the program text.
The assignment operator ".=" is used to assign new values to both local and
er
global variables. The old value of the variables is lost when you do this.
In the case of "read" access, the variable always appears on the right of the
assignment operator (":-") in the expression. In the case of write access, the
operand appears on the left of the assignment operator.
ez
Local and global variables can be accessed in both read and write mode. In
other words, the variable can appear both on the immediate right of the
assignment operator ":=" (read access) and on the immediate left of the
assignment operator (write access).
r.s
Value assignments:
• Example: A := B + C;
Expression
Control statements:
om
• IF statement: IF E1 THEN ... ELSIF ... ELSE ... END_IF
l.c
...
ai
MyRetVal := test(-2.4);
SIMOTION
Siemens AG 2013. All rights reserved.
gm
position := 100,
commandId := _getCommandId());
Date:
File:
10.01.2013
MC-SMO-PROG_02.23
SITRAIN Training for
Automation and Drives
@
Value assignments The ".=" assignment operator is used to assign new values to variables. The old
value of the variables is lost when you do this.
Control Control statements are used to modify the sequential order in which statements
er
Loop statements (FOR, WHILE, and REPEAT statement) are used to execute
statements repeatedly.
Jump statements (CONTINUE, EXIT, and GOTO statement) are used to
interrupt the sequential order in which commands are processed and jump to a
point at which the process should be resumed.
r.s
Calls to FC, FB In accordance with the principle of structured programming, other POUs can be
system functions called from within a POU. POUs that can be called are:
• Other functions and function blocks created in ST or in MCC by the user
ne
Operators
om
• Assignment operator: :=
• Arithmetic operators *, /, MOD, DIV, +, -, **
• Relational operators <, >, <=, >=, =, <>
• Logic operators NOT, AND, XOR, OR
l.c
• Bit sequence operators NOT, AND, XOR, OR
Operands
• Constants 30.0, 1234
ai
• Extended variables %IB5, Status, Motor.Current,
Func(A:=ON)
SIMOTION
• Expression in (...)
Date:
File:
10.01.2013
MC-SMO-PROG_02.24
SITRAIN Training for
Automation and Drives
@
Expressions Expressions consist of operands, operators, and round brackets. Within an
expression, the operators (e.g. +, -, *, /, etc.), i.e. the active components, are
linked with the passive elements such as constants, variables, and function
values to generate a new value.
er
purposes.
Expressions consist of operators and operands. Most operators in ST link two
Operators and operands (e.g. A + B) and a re, therefore, known as binary operators. The
operands others just work with a single operand and are, therefore, known as unary
r.s
operators.
The result of an expression can be:
om
- Components Struct_1.comp1 := Struct_2.comp1;
• Arrays
- Entire array Array_1 := Array_2;
- Components Array_1[Index_1] := Array_2[5];
l.c
Access to process image
- Absolute access Value := %IB5; %Q5.2 := TRUE;
ai
- Symbolic: VAR
MyInput AT %IB5 : SINT;
END_VAR
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Value := MyInput;
Date:
File:
10.01.2013
MC-SMO-PROG_02.25
SITRAIN Training for
Automation and Drives
@
Principle Value assignments replace the instantaneous value of a variable with a new
value specified via an expression. This expression can also contain function
(FC) identifiers which are called by the expression and for their part return
corresponding values.
er
Value assignments A compound variable represents the entire type (the entire structure, the
ez
with compound entire array) or a component of the compound variable. Therefore, assignments
variables to a compound variable can be made in two ways. You can:
• Assign the content of another complete compound variable (structure, array)
to each compound variable (structure, field).
r.s
PIB66
"User-defined Process images PIB67
om
of the inputs
process images" IB0 PIB4095 (C240)
Symbolic only for: Refresh
depending on PIB4095 (P350)
• IPOSynchronousTask IB . . . Any PIB16383 (D4x5)
• TimerInterruptTask selected task
• BackgroundTask
l.c
"Absolute identifier" Process image Output
%Q1.3 output Refresh
PQB0
%QB63 %QB0
%QW0 BackgroundTask PQB63
%QB63 64 bytes PQB64
ai
"User-defined Process images
PQB66
process images" PQB67
of the outputs
Symbolic only for: QB0 Refresh PIB4095 (C240)
SIMOTION
• IPOSynchronousTask
• TimerInterruptTask
• BackgroundTask
10.01.2013
depending on
selected task
MC-SMO-PROG_02.26
PIB4095 (P350)
PIB16383 (D4x5)
clock.
During the StartupTask, access to the I/O variables is restricted. Otherwise, in
the RUN operating state and in the ShutdownTask, I/O variables can be
accessed without restriction.
r.s
Access via Process images are areas of the RAM in the SIMOTION device in which a
process images subset of the I/O address area is mirrored.
The system automatically mirrors the first 64 bytes of the I/O address area to the
process images of the BackgroundTask. With user-defined process images, the
ne
size depends on the number and size of the I/O variables that have been set up.
The process images of the inputs are updated before the associated task is
called. After processing of the task, the process image output is sent to the I/Os.
The process image is, therefore, consistent for the entire cycle of the associated
task.
ca
om
MyResult := _getbit(in:= MyAnyBit, // Read out bit status
n:= BitNo); // Without language extension
l.c
MyAnyBit := _setbit(in:= MyAnyBit, // Set bit
n:= BitNo, // Without language extension
value:= TRUE);
ai
MyAnybit := _togglebit(in:= MyAnyBit, // Toggle bit
n:= BitNo); // Without language extension
SIMOTION
MyAnyBit.5 := MyAnyBit.5 XOR TRUE;
10.01.2013
MC-SMO-PROG_02.27
SITRAIN Training for
Automation and Drives
@
Access to As of SCOUT V4.1 the compiler option "Permit language extension" provides a
individual bits user-friendly means of accessing the individual bits of a BYTE, WORD, or
DWORD data type variable. It enables individual bits in a BYTE, WORD, or
DWORD to be accessed in the same way as in SIMATIC S7. This type of
er
• IF MCC
IF
IF height
height << 55 THEN
THEN
;; //
// Statements
Statements
ELSIF
ELSIF height
height >> minHeight
minHeight THEN
THEN
om
;; // Statements
// Statements
ELSE
ELSE
;; //
// Statements
Statements
END_IF;
END_IF;
l.c
• CASE
CASE
CASE condition
condition OF
OF
1: ; // Statements
ai
1: ; // Statements
2,3:
2,3: ;; //
// Statements
Statements
44 .. 10: ; // Statements
.. 10: ; // Statements
SIMOTION
ELSE
ELSE ;;
END_CASE;
END_CASE;
1. If the value of the first expression is TRUE, the statement part after
THEN is executed; otherwise, the expressions are evaluated in the ELSIF
branches.
2. If none of the Boolean expressions in the ELSIF branches is TRUE, the
r.s
CASE branch The CASE statement is used to select 1 of n program parts. The selection is
determined by a selector (an expression evaluated as an INT type variable).
A list of constants is available for selection, a program part being assigned to
each value or group of values.
ca
• FOR
FOR
FOR loop
loop :=
:= 11 TO
TO height
height BY
BY 22 DO
DO
;; // Statements
// Statements
END_FOR;
END_FOR;
om
• WHILE
WHILE
WHILE condition
condition DO
DO
;; //
// Statements
Statements
END_WHILE;
END_WHILE;
l.c
• REPEAT
REPEAT
REPEAT
ai
;; //
// Statements
Statements
condition := n+1;
condition := n+1;
UNTIL
UNTIL condition
condition == 13
SIMOTION
END_REPEAT;
END_REPEAT;
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.29
SITRAIN Training for
Automation and Drives
@
Overview ST and of course MCC provide the control structures FOR, WHILE, and
REPEAT for repeating statement sequences.
er
incremented (or reduced for a negative step width) by the specified value with
each loop cycle. The FOR_loop is exited, i.e. execution resumes with the
statement after END_FOR, when the control variable reaches the full-scale
value.
The FOR statement is used whenever a statement sequence is to be looped
r.s
through for a fixed, known number of cycles. If the number of cycles is not
known, use the WHILE or REPEAT statement.
REPEAT statement REPEAT statements repeat statement sequences between REPEAT and UNTIL
until a particular condition is fulfilled and the action is aborted. This abort
condition is formed according to the rules of a logical expression.
The condition is evaluated after every completed execution of the statement
sequence. This means that the sequence is executed at least once, even if the
abort condition has been fulfilled from the start.
WHILE
WHILE TRUE
TRUE DO
• EXIT DO
;; //
// Statements
Statements
IF
IF %I1.1
%I1.1 == TRUE
TRUE THEN
THEN
om
EXIT;
EXIT;
END_IF;
END_IF;
END_WHILE;
END_WHILE;
l.c
• RETURN FUNCTION
FUNCTION example:
example: VOID
VOID
//
// Statements
Statements
IF
IF %I1.1
%I1.1 == TRUE
TRUE THEN
THEN
RETURN;
RETURN;
ai
END_IF;
END_IF;
END_FUNCTION
END_FUNCTION
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.30
SITRAIN Training for
Automation and Drives
@
EXIT An EXIT statement is used to exit a loop (FOR, WHILE, or REPEAT loop) at any
point regardless of whether or not the abort condition has been fulfilled.
This statement has the effect of jumping directly out of the loop immediately
surrounding the EXIT statement. Program execution is resumed at the end of
er
RETURN A return statement exits the POU (FB, FC, program) currently being processed
and returns to the calling POU or operating system when a program is exited.
ez
om
IF
IF %I0.0
%I0.0 THEN
THEN
GOTO
GOTO MyLabel;
MyLabel;
END_IF;
END_IF;
test
test :=
:= NumTest;
NumTest;
MyLabel:
MyLabel:
;; //
// Statements
Statements
l.c
• WAITFORCONDITION
//
// Call
Call with
with expression
expression
ai
WAITFORCONDITION
WAITFORCONDITION myExpression
myExpression WITH
WITH TRUE
TRUE DO
DO
//
// Execution
Execution with
with priority,
priority,
//
// at
at least
least one
one statement,
statement, e.g.:
e.g.:
%Q0.0 := TRUE;
%Q0.0 := TRUE;
SIMOTION
END_WAITFORCONDITION;
END_WAITFORCONDITION;
//
// ...
...
EXPRESSION An expression is a special type of function declaration with a BOOL data type
ne
return value. When the expression is declared, the data type of the return value
is not specified explicitly.
An expression can only be declared in the implementation section of a unit.
Optionally, local (temporary) variables can be declared. Other declarations (e.g.
input parameters, constants) are not permitted.
ca
The local variables of the expression, unit variables, global device variables, I/O
variables, and the process image can be accessed in the statement section.
In the statement section, a BOOL data type expression must be assigned to the
expression designation. Function calls or loops are not permitted.
The expression is called by the operating system in the IPO cycle clock. If the
return value is "true", the task switches back to the "RUNNING" state.
• Line comment
// Can look like this
x := 3;
om
// extend over several lines in this
// format. => ASCII character set
• Block comment
l.c
(*
Block comments look like this. They are used
to comment out entire blocks.
####
ai
######
#
*)
SIMOTION
x := 3;
Comments In ST programs, you can insert line comments to describe program sections
in ST or command lines, for example.
If a comment extends over several lines, you can use block comments, which
are written in an ST unit specially created for them. You can use block
ez
Comments In MCC, you can enter short comments immediately next to a command.
r.s
in MCC Spanning three short lines, they refer, for example, to the addressed inputs,
outputs, axis names, or machine modules.
In addition, you can add a longer comment to each command. Comments in
MCC are indicated by a mark at the command and are included on program
printouts.
ne
om
e.g. somewhere in an ST source file:
{
#define <identifier> <text>
. . .
}
l.c
// Here the name <identifier> is replaced by the name <text> in
// subsequent lines of the program before the actual compilation
// takes place.
ai
#undefine <identifier>
. . .
}
SIMOTION
// stops here.
Date:
File:
10.01.2013
MC-SMO-PROG_02.33
SITRAIN Training for
Automation and Drives
@
Preprocessor The preprocessor prepares an ST source file for compilation. For example,
character strings can be defined as replacement texts for identifiers, or sections
of the source program can be hidden/shown for compilation. This provides a
means of including additional lines of code in a program for supplementary
er
Controlling the Statements sent to the preprocessor to start or end replacement rules
preprocessor are called pragmas. The preprocessor can be controlled with the following
pragmas.
r.s
#ifdef or #ifndef. The following program lines (until the next pragma
containing #endif) are compiled by the compiler, if the preceding query with
#ifdef or #ifndef was not fulfilled.
• #endif Concludes variant formation with #ifdef or #ifndef.
Note The #define pragma can also be used to replace names in the interface part of
an ST source file, for example. This interface part can then be imported into any
other ST source file, MCC chart, or LAD/FBD program with the USES
statement.
om
END_INTERFACE
IMPLEMENTATION
FUNCTION f : INT
VAR_INPUT
i : INT;
END_VAR
f := i;
END_FUNCTION
FUNCTION_BLOCK fb1
l.c
VAR_INPUT
i_var : INT;
END_VAR
VAR_OUTPUT
o_var : INT;
END_VAR
my_define := i_var; // After preprocessor: g_var := i_var
ai
{
#undef my_define
}
o_var := my_call +1; // After preprocessor: o_var := f(g_var) + 1;
my_define := i_var; // After preprocessor my_define not replaced.
SIMOTION
END_FUNCTION_BLOCK
END_IMPLEMENTATION
Date:
File:
10.01.2013
MC-SMO-PROG_02.34
SITRAIN Training for
Automation and Drives
@
Overview In the interface part of the ST source file shown, after the declaration of the
global variables g_var, the following pragmas:
• #define my_define g_var
• #define my_call f(my_define)
er
my_define := i_var;
is replaced by the statement:
g_var := i_var;
and the statement:
o_var := my_call +1;
r.s
by the statement
o_var l:= f(g_var) +1;
After the pragma:g
#undefomy_define
ne
• Program status
om
variables
• Use breakpoints
l.c
• Trace tool
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.35
SITRAIN Training for
Automation and Drives
@
Overview Syntax errors are detected and displayed by the ST compiler during the
compilation procedure. Runtime errors during execution of the program are
indicated by system alarms or cause the system to switch to STOP mode; you
can find program logic errors using the ST test functions, e.g. using the symbol
er
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.36
SITRAIN Training for
Automation and Drives
@
Overview Various SIMOTION device modes are available for program testing. How to
select the mode of a SIMOTION device:
1. Highlight the SIMOTION device in the project navigator.
2. Select Test mode from the context menu.
er
Operating modes The following operating modes are available for selection:
• Process mode: Program execution on the SIMOTION device is optimized for
maximum performance. The following diagnostic functions are available:
- Monitor variables in the symbol browser
r.s
- Program status
- Trace tool with measurement functions for drives and function generator
Only 1 ST source file and 1 trace can be activated in this mode.
• Test mode: The same diagnostic functions are available as for process
ne
You must observe the appropriate safety regulations. Use the debug mode only with
the life-sign monitoring function activated with a suitably short monitoring time!
Program status
Stop Force
monitoring update
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.37
SITRAIN Training for
Automation and Drives
@
Overview With the "Program status" function, you can select a range within the code of an
ST source file to monitor. You can also use this function to monitor local
variables (within a function, for example).
The "Program status" function shows the following variables:
er
Using Program If you are using the "Program status" function, the "Permit program status"
status option must be checked to compile the ST source file in the Properties dialog of
the ST source file.
If you want to monitor more than one ST source file at the same time (up to 4 ST
source files can be monitored at the same time), the Test mode option must be
ne
om
l.c
Select
unit
ai
Status value
Global variables
of the unit
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.38
SITRAIN Training for
Automation and Drives
@
Overview The symbol browser shows the names, data types, and values of unit variables,
i.e. of global variables that have been declared in the interface or
implementation section of a unit. The contents of the variables can be monitored
and – if necessary – modified (Modify variables function).
er
However, the variable values of a unit can only be viewed or edited with the
symbol browser if the associated program has been downloaded to the target
system and a connection to the target system has been established.
ez
Using the For the following functions, a connection to the target system must be
symbol browser established and the associated program must have been downloaded to the
target system.
1. Select the required ST source file in the project navigator (e.g. ST_1).
r.s
currently in progress.
- Enter a value in the "Control value" column, check the box in this column
and click the "Immediate control" button. The value entered is written to
the variable.
Note The symbol browser can also be used to monitor and control the I/O variables,
global device variables, and static variables of a program (select the execution
system and the task in the symbol browser).
om
Insert
watch table
l.c
Right mouse
ai
click
Unit/TO
variables
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.39
SITRAIN Training for
Automation and Drives
@
Overview With the symbol browser, you can only monitor variables belonging to one
object (device-, I/O-, and unit-specific) within a project, and with the "Program
status" test function, you can only monitor variables in a user-definable range
within the program.
er
Watch tables, on the other hand, let you monitor selected variables from any
source or object as a group. In offline mode, you can monitor and control the
data type of the variables; in online mode, you can monitor and control their
content.
ez
table. A watch table with this name is then created in the "Monitor" folder.
3. In the project navigator, click the object (ADDRESS LIST, GLOBAL DEVICE
VARIABLES, unit) containing the variables you want to add to the watch
table. The corresponding table of variables then appears in the symbol
browser.
ne
4. In the table of variables, click the first entry to select the whole row. Right-
click to display the associated context menu and select "Move variable to
watch table".
In the next menu that is displayed, select the corresponding watch table
ca
om
Support for split window
(e.g. so that declaration and code can be
displayed separately)
Sequence generator
Generation of simple number sequences
l.c
based on a specific pattern (<Ctrl> <Alt> F7)
Autocomplete
Select via <Ctrl> <Space>
ai
Select column Generate Select column Generate
by column sequence by column sequence
•
<Alt> mouse <Ctrl> <Shift> F7
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
<Alt> mouse
10.01.2013
MC-SMO-PROG_02.40
<Ctrl> <Shift> F7
• Copying/cutting/pasting/deleting
• Changing the view (show/hide line numbers, folding active, display
pairs of brackets, indent help, split wimndow, etc.)
• Bookmarks (insert/remove bookmaerk, go to bookmark, etc.)
ez
As of V4.2, the ST editor window can be split into two segments, creating two
Splitting the views of the same ST source file so that the declaration and the code can be viewed
editor window at the same time, for example, or different code positions can be compared more
easily.
The split can be activated/deactivated either with the ST source file -> Split
ne
window command or via the context menu. The split itself is not saved when the
source file is closed. ST source files are always opened in an entire window (i.e. one
that is split).
Wkhen the status function is activated, i.e. when the block is being monitored,
the editor window cannot be split.
ca
Sequence generator You can generate simple series of integer numbers (sequences) that follow a
specific pattern in the ST editor. This can be useful, for example, for the
initialization of an array. All the numbers selected in the ST editor are interpreted
as being possible elements. The initial elements from which the series is
calculated must represent integer values.
om
Procedure
1. Select debug mode
2. Specify the "debug task group"
l.c
3. Set breakpoints
4. Specify the call path
5. Activate breakpoints
ai
6. Use "Variable status" to monitor contents of local variables
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.41
SITRAIN Training for
Automation and Drives
@
Overview You can set breakpoints within a POU of a program source (e.g. ST source file,
MCC chart, LAD/FBD program). On reaching an activated breakpoint, the task
in which the POU with the breakpoint is called is stopped. If the breakpoint that
initiated the stopping of the tasks is located in a program or function block, the
er
values of the static variables for this POU are displayed in the "Variable status"
tab of the detail display.
Temporary variables (including in-out parameters for function blocks) are not
displayed. You can monitor static variables of other POUs or unit variables in
ez
2. Specify the tasks of the "debug task group", i.e. the tasks that are to be
stopped when a breakpoint is reached.
3. Set your breakpoints in the ST source file at lines with statements.
4. Specify the call path.
ne
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.42
SITRAIN Training for
Automation and Drives
@
Overview During program execution, all tasks in the assigned "debug task group" are
stopped when an activated breakpoint is reached.
Procedure Once you have switched the corresponding SIMOTION device to debug mode,
er
Note The "debug task group" can only be changed if no breakpoints are active.
2. Set
om
breakpoints
l.c
Inactive
breakpoint
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.43
SITRAIN Training for
Automation and Drives
@
Setting Breakpoints can only be set in an ST source file if the following conditions
breakpoints are met:
• The ST source file is open
• The required SIMOTION device has been switched to debug mode
er
Note You can use other diagnostic functions such as "Status program" and the
"Breakpoints" function together in one ST source file. However, the line
highlighted in the ST source file for program testing must not contain a
breakpoint.
ne
ca
om
Edit
call path
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.44
SITRAIN Training for
Automation and Drives
@
Specifying the Once you have set the breakpoint in the ST source file, you can specify the
call path call path for the breakpoints. Proceed as follows:
1. Place the cursor on a line in the ST source file at which a breakpoint is set.
er
2. Click the "Edit call path" button on the "Breakpoints" toolbar. In the "Call
path/Breakpoint" window, the selected code position is displayed (with the
name of the ST source file, line number, name of the POU).
3. If the code position is called from several tasks:
ez
- Select the required task. The task must be in the debug task group.
4. Select the code position to be called (in the calling POU). The following
options are available for selection:
- The calling code positions within the selected task (with the name of the
r.s
All displayed code positions are selected. Moreover, all code positions
(up to the top level of the hierarchy) are selected from which the
displayed code positions are called.
5. If the breakpoint is only to be activated after the code position has been
reached several times, select the number of times.
ca
Note You can view the call path associated with the selected task with the "Display
call stack" function. Place the cursor on the line of the ST source file with the
breakpoint and click the "Display call stack" button.
Continue
Activate
breakpoint
Debug
om
Activate/deactivate table
all breakpoints
Debug table
l.c
Active
breakpoints
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.45
SITRAIN Training for
Automation and Drives
@
Activating Breakpoints must be activated if they are to have an effect on program
breakpoints execution.
To activate/deactivate a single breakpoint, proceed as follows:
er
1. Place the cursor on a line of the ST source file at which a breakpoint is set.
2. Click the "Activate/deactivate breakpoints" button on the "Breakpoints"
toolbar (keyboard shortcut F4).
To deactivate a breakpoint click the "Activate/deactivate breakpoint" button
ez
again.
To activate/deactivate all breakpoints, proceed as follows:
1. Click the "Activate all breakpoints" button on the "Breakpoints" toolbar.
2. To deactivate all breakpoints, click the "Deactivate all breakpoints" button
r.s
again.
On reaching an activated breakpoint, the tasks that are assigned to the debug
task group are stopped.
ne
Note Breakpoints can also be activated and deactivated in the debug table. Select the
SIMOTION device in the project navigator and select the "Debug table" context
ca
menu.
In the window that opens, execute the action below, depending on which
breakpoints you wish to activate or deactivate:
• Single breakpoints: Check or clear the corresponding checkbox.
• All breakpoints: Click the corresponding button.
Call- Stack
anzeigen
om
breakpoint, this statement
has not yet been processed
l.c
Call- Stack
ai
Variable status
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.46
SITRAIN Training for
Automation and Drives
@
Monitoring The instantaneous content of the local variables can be monitored on the
variables "Variable status" tab in the detail window.
Program call For a program call, the following variables are displayed:
er
monitored.
FB call
• Input parameters (VAR_INPUT)
• Output parameters (VAR_ OUTPUT)
• Static variables (VAR)
r.s
The instantleous values of global "unit variables" must be monitored via the
ne
Note
"symbol browser window".
ca
om
Program execution
stops at breakpoint
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.47
Status Variable
om
l.c
ai
Signal selection for trace
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.48
SITRAIN Training for
Automation and Drives
@
Device trace With the "device trace", you can record and save signal charts of inputs and
outputs and the contents of variables in a SIMOTION or SINAMICS device. The
tool is used, for example, for implementing and documenting the optimization of
axes.
er
You can set the trace length, select the traced variables, define trigger
conditions, parameterize offsets, and switch between different graph types and
scales.
The device trace can be called via the menu command: Target system -> Trace.
ez
The only available description of the trace tool appears in the online help.
System trace As of V4.2, a system trace is also supported. It can be used to record up to
(new as of V4.2) 128 signals from multiple SIMOTION controllers networked via PROFINET IO
r.s
om
Event selection for TO Recorded data
trace for TO trace
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_02.49
SITRAIN Training for
Automation and Drives
@
TO trace In SIMOTION, technology objects can be affected by changes to configuration
data and system variables, or by commands during runtime. The TO trace (a
new function as of V4.2) maps how a technology object is affected by these
changes and commands.
er
It can be used to record and display the last n actions affecting a technology
object in chronological order.
The TO trace is used for TO diagnostics and provides information in a snapshot.
It is TO-specific, i.e. it has to be confirmed individually for each technology
ez
object.
Call
There are three ways of calling the TO trace. With the device selected, the TO
trace can be called either with the menu command Target system ->
Technology object trace or by selecting the corresponding command from the
device context menu. The third option is to use the corresponding button on the
ne
toolbar.
Parameterization All the technoology objects created in the project are displayed under the
"Technology objects" setting.
ca
To select a line, click any cell within it. The settings for a line are displayed
under the technology objects. The settings for a TO can be changed using the
button on the left.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_03.1
SITRAIN Training for
Automation and Drives
@
Contents Page
Blocks for structured programming .................................................................................................. 2
Properties of functions ...................................................................................................................... 3
er
om
for flexibility of application Valves
l.c
ON VAR_OUTPUT BOOL
.
(libraries): .
.
.
• Blocks can be called an Motor_1(
Start :=%I0.0,
unlimited number of times Stop :=%I0.1);
ai
ON := Start AND NOT _Stop;
• Restrictions: %Q4.0:=Motor_1.ON;
• No access to global
operands
SIMOTION
• Communication only via
parameter list
SIMOTION supports this concept of modularization with its block model. Blocks
Structured are assigned to the sub-tasks that are isolated when the complete task is
programming divided into smaller components. These blocks contain the necessary algorithms
and data for solving the sub-task.
ez
SIMOTION blocks such as functions (eFC) and function blocks (FB) are
parameterizable - they allow you to implement the concepts of structured
programming. This means:
• Blocks for solving sub-tasks implement their own data management
r.s
of one another
• Parameters can make the blocks flexible. For example, you can create a
drilling cycle where the coordinates and depth of the drill hole are passed as
parameters
• Blocks can be called any number of times at different locations with different
parameter sets, i.e. can be reused to suit your requirements
• "Reusable" blocks for special tasks can be provided in precompiled libraries
om
execution ...
variables only
• Only one output parameter Result := Add(
RET_VAL OP_1 := Value_1
OP_2 := Value_2,
• Avoid access to global ); ...
variables and absolute Add := OP_1 + OP_2;
l.c
operands
END_FUNCTION
• Return an identical result
with the same input
parameters
ai
Expand the command set of the
processor
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_03.3
SITRAIN Training for
Automation and Drives
@
General Functions represent parameterizable blocks without memory. In SIMOTION, functions
can have any number of input parameters, but they should only return one result in
the return value.
A calling block (a program, for example), can transfer input values to a function via
er
input parameters. The input values (actual values) are evaluated by the function and
the result is transferred to the calling block via the return value. If multiple items of
individual information are to be returned, then a corresponding data structure must be
declared as the return value.
ez
Similarly, a calling block can transfer information to the function called via in-out
parameters. Unlike input parameters, in-out parameters are also able to send back
results to the calling block.
r.s
om
END_STRUCT; by blocks belonging to
END_TYPE
other units)
FUNCTION MyFC;
• IMPLEMENTATION part
END_INTERFACE (for functions that are only used
within the unit)
IMPLEMENTATION
l.c
FUNCTION MyFC: SumMeanType • Function name + data type of the
VAR_INPUT return value (or VOID)
MeasVal: MeasValType;
. . . • Type, parameter, and variable
END_VAR declarations
ai
VAR_INOUT
. . . • Statement part
END_VAR
; • Assignment of the return value
SIMOTION
MyFC := . . .;
END_FUNCTION
END_IMPLEMENTATION
the implementation part. However, the FC must be defined before the blocks
(program, FB, FC) in which it is called.
Defining a function A function is defined via the keyword FUNCTION in the implementation part of
ez
Declarations for The operands of a function include input/in-out parameters (formal parameters)
input/in-out which are also visible from "outside". A block which calls a function must supply
ne
parameters and the input/in-out parameters with actual operands of the same data type the
return value function is called. Similar to the procedure with input/in-out parameters, the return
value of a function must be returned to the calling block upon completion of
function execution.
Blocks which call functions must, therefore, know about the syntax of the data
ca
types for the function's input parameters and return value. If custom data types
such as structures are used for the function's input parameters and/or return
value, their type (TYPE ... END_TYPE) must be declared outside the function.
If a function is to be called by blocks belonging to other ST units, the data type
for the input parameters and return value must be declared in the interface part of
the ST source file. If the functions are only used internally, declaration in the
implementation part is sufficient.
om
END_VAR • VAR_INPUT (input parameters)
VAR_IN_OUT • VAR_INOUT (in-out parameters)
. . .
END_VAR • Variable declarations:
VAR • VAR (temporary variables)
l.c
IntermSum: REAL; • VAR CONSTANT (constants)
Index: INT := 0;
END_VAR
• Input parameters and variables can
VAR CONSTANT be initialized
Pi: REAL := 3.14;
ai
END_VAR • In-out parameters cannot be
initialized
MyFC := ...;
• Assignment of the return value
SIMOTION
END_FUNCTION
User-defined Custom data types can be declared in a function. Unlike the declarations in the
er
data types interface or implementation part, the data types declared here can only be used
internally.
Input parameters (formal parameter) are some of the local operands of a function.
Input parameters The formal input parameters (name and data type) of a function are declared within
ez
the block VAR_INPUT ... END_VAR. The values of the actual operands can be
accessed within the function in the statement part under the names of the input
parameters .
The formal in-out parameters of a function (name and data type) are declared within
r.s
completion of the function. The next time the function is called, all variables are
reinitialized.
VAR_INPUT
Meas_val_1 : REAL;
Meas_val_2 : REAL;
Meas_val_3 : REAL;
END_VAR
Write
om
access VAR
IntermResult: REAL; Read access
END_VAR
;
;
;
l.c
IntermResult := Meas_val_1 + Meas_val_2;
Assignment of
the function IntermResult := IntermResult + Meas_val_3;
return value
ai
MeanValue := IntermResult / 3;
END_FUNCTION
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_03.6
SITRAIN Training for
Automation and Drives
@
Statement part The actual calculation is performed within the statement part. You can use the
same syntax to access the input/in-out parameters and local variables of a
function.
In the case of "read" access, the operand always appears to the right of the
er
assignment operator (":=") in the expression. In the case of write access, the
operand appears on the left of the assignment operator.
Local variables and in-out parameters of a function can be accessed in both
read and write mode. In other words, the variable/in-out parameter can appear
ez
both on the immediate right of the assignment operator ":=" (read access) and
on the immediate left of the assignment operator (write access).
Just like constants (VAR CONSTANT), the input parameters of a function can
only be accessed in read mode. In other words, they are only permitted to
r.s
Return value The purpose of the function's return value is to return the result of its execution
to the calling block. The return value is assigned by assigning the required result
to the "function name".
ne
ca
PROGRAM Main
VAR
myMeasVal: REAL := 5;
myRetVal: REAL; Function
END_VAR name
om
Return myMeasVal:= 25.3; Actual parameters
value of the FC call
myRetVal:= MeanValue(
Meas_val_1 := 3.5, Parameter list
l.c
Meas_val_2 := myMeasVal,
Meas_val_3 := 5.35 );
ai
.
. Formal input
.
parameters
SIMOTION
Siemens AG 2013. All rights reserved.
END_PROGRAM
gm
Date:
File:
10.01.2013
MC-SMO-PRG_03.7
of the FC
Parameter passing When functions are called, data exchange takes place between the calling block
and the called block. The parameters to be transferred must be specified in the
parameter list in the call.
The formal parameters are then replaced by actual parameters during function
ca
PROGRAM Main
VAR
_MccRetDINT: DINT;
myByte: BYTE;
END_VAR
om
Function
name _starttask(MotionTask_1);
_MccRetDINT := _enableAxis(
Leading axis,
ALL, Actual parameters
ACTIVE,
of the FC call
l.c
Return INACTIVE,
WHEN_COMMAND_DONE, (parameter list)
value _getCommandId(),
INACTIVE);
myByte := ROL(myByte,1);
ai
SIMOTION
Siemens AG 2013. All rights reserved.
.
.
END_PROGRAM
gm
Date:
File:
10.01.2013
MC-SMO-PRG_03.8
SITRAIN Training for
Automation and Drives
@
Short form of a As an exception, when some functions are called, it is necessary to use the
FC call short form of parameter transfer if this is explicitly requested by the
documentation. This is the case, for example, for all task control commands
(see Chapter 5). The short form of the system function call must also be used
er
correct sequence.
Generally it is possible to use the short form of parameter transfer with all
system functions. However, for reasons of transparency and flexibility, it is
advisable to always use the long form with value assignment as described on
the previous page.
r.s
ne
ca
om
specification of limits for VAR
i : DINT;
index, e.g. IntermSum : LREAL;
END_VAR
ArrayName : ARRAY[…] OF TypeName
• Access to length and limits of FOR i := _firstIndexOf(in := MeasVal) TO
_lastIndexOf(in := MeasVal) DO
array via: IntermSum := IntermSum + MeasVal[i];
l.c
END_FOR;
_firstIndexOf(in := ArrayName) MeanValue := IntermSum/_lengthIndexOf(in:= MeasVal);
_lastIndexOf(in := ArrayName) END_FUNCTION
_lengthIndexOf(in := ArrayName)
Return value type is DINT
ai
• Access to occupied memory
via:
SIMOTION
_sizeOf(in := ArrayName)
Evaluation When the function or an instance of the function block is called, arrays of any
length of the declared data type can be transferred. In this case, both the
reference (pointer) to the array specified in the actual parameter and the index
limits are included when the parameters are transferred.
ez
Within the function or function block, you can use the following functions to
access the index limits transferred additionally:
• _firstIndexOf (in := ArrayName)
Returns the lower index limit of the array transferred
r.s
om
temporary but also Program M_on VAR_OUTPUT BOOL
Speed VAR_OUTPUT INT
static variables execution
...
• Call with separate data area ...
(instantiation) Motor_1(
• "Data encapsulation" Start :=%I0.0,
...
Stop :=%I0.1);
l.c
M_on := Start AND NOT Stop;
Application (in %Q8.0 := Motor_1.M_on; ...
%QW2 := Motor_1.Speed;
cyclic tasks):
END_FUNCTION_BLOCK
• Timer and counter functions
ai
• Actuating process units with
internal states
SIMOTION
• Furnaces, drives,
valves, etc.
"Memory" The programmer can declare static variables in the declaration part of a function
block, where the function block can store information which is retained from one
call to the next.
r.s
This possibility to store information from call to call is one of the features that
differentiates a function block from a function.
Application Using this "memory", a function block can implement timer or counter functions,
for example, or actuate process units such as machining stations, drives,
ne
furnaces, etc.
In cyclic runtime environments such as TimerInterruptTasks and
BackgroundTask, function blocks are particularly suitable for actuating process
units which have responses that depend on internal states, such as machining
step, speed, temperature, etc., in addition to external influences.
ca
When actuating such units, in general the internal states of the process unit are
mapped to the static variables of the function block.
om
END_STRUCT; called by blocks stored in other
END_TYPE units)
FUNCTION_BLOCK Motor; • IMPLEMENTATION part
END_INTERFACE (for function blocks which are only
used within the unit)
IMPLEMENTATION
l.c
FUNCTION_BLOCK Motor • FB name
VAR_INPUT
Execute: BOOL; • Type, parameter and variable
MyPosSpeed: PosSpeedType; declarations
END_VAR
ai
;
;
;
• Statement part
SIMOTION
END_FUNCTION_BLOCK
END_IMPLEMENTATION
Data types for The operands of a function block include input, output, and in-out parameters
input, output, and (formal parameters) which are also visible from "outside". A block which calls
in-out parameters this function block must supply the input and in-out parameters with actual
ne
operands when the FB is called. It also has to clear the output parameters after
execution of the function block.
Blocksel which call functions must, therefore, know about the syntax of the data
types for the function's input, output, and in-out parameters. If custom data types
ca
such as structures are used for these parameters, their type (TYPE ...
END_TYPE) must be declared outside the function block.
om
END_VAR
VAR_OUTPUT • VAR_OUTPUT (output parameters)
Motor_ON: BOOL;
Setpoint: INT;
• VAR_IN_OUT (in-out parameters)
END_VAR
VAR_IN_OUT
• Variable declarations:
E_STOP: BOOL; • VAR (static variables)
l.c
END_VAR
• VAR_TEMP (temporary variables)
VAR
AxisPos: LREAL := 50.0; • VAR CONSTANT (constants)
END_VAR
VAR_TEMP
• Input parameters output parameters,
ai
IntermPos: LREAL;
END_VAR and all variables can be initialized
VAR CONSTANT
Pi: REAL := 3.14; • In-out parameters cannot be
SIMOTION
END_VAR
;
END_FUNCTION_BLOCK
MC-SMO-PRG_03.12
SITRAIN Training for
Automation and Drives
@
Declaration part The declaration part of a function block is subdivided into various blocks, each of
which is identified by a separate pair of keywords. Each block is given a
declaration list for data of the same kind, e.g. local type declarations, input,
output, and in-out parameters as well as static and temporary variables and
er
constants. Each type of block may only appear once; the blocks may appear in
any order.
User-defined Custom data types can be declared in functions - just like in any other POU.
ez
data types Unlike declarations in the interface or implementation part, the data types
declared here can only be used internally, i.e. only for declaring local variables
or constants.
Input, output, and Input parameters (formal parameters) are some of the local operands of a
r.s
in-out parameters function. The formal parameters (name and data type) of an FB are declared
within the block VAR_INPUT ... END_VAR. The values of the actual operands
can be accessed within the FB in the statement part under the names of the
parameters.
ne
Static variables Static variables are variables which are declared within the block and can only
be used within the statement part of the block.
The local variables (VAR ... END_VAR) are static in FBs, i.e. the value stored in
the variable is retained. The next time the FB is called, the stored values can be
ca
accessed again.
Temporary All local variables (VAR_TEMP ... END_VAR) are temporary in FBs, i.e. the
variables value stored in the variable is not retained after completion of the FB. The next
time the FB is called, all temporary variables are reinitialized.
Initialization Input and output parameters as well as all local variables of an FB can be
initialized during declaration. In-out parameters cannot be initialized.
Parameters are the channels Name Var.type Data type Initial value
for information transfer: Start VAR_INPUT BOOL FALSE
Stop VAR_INPUT BOOL TRUE
• Input parameter: Speed VAR_INPUT INT 50
Caller -> Block Motor_ON VAR_OUTPUT BOOL FALSE
• Output parameter: Setpoint VAR_OUTPUT INT 10
om
Block -> Caller E_STOP VAR_IN_OUT BOOL
... VAR ... ... ...
• In-out parameter:
... VAR_TEMP .. ... ...
Caller <-> Block
l.c
"envelope":: Motor
EN ENO
• Parameters are like "local"
Start Output
variables in the statement part Input Motor_ON
Stop para-
ai
• The call interface is language- parameters Setpoint meters
Speed
neutral
• Different languages In-out
E_STOP
SIMOTION
can be mixed
gm
Date:
File:
10.01.2013
MC-SMO-PRG_03.13
SITRAIN Training for
Automation and Drives
@
Overview Parameters are channels for information transfer between the block calling and
the block called. The symbolic names, data types, and if applicable the initial
values of the parameters are defined in the declaration part.
er
Declaration type The type of the parameter indicates the direction of data transfer:
VAR_INPUT Input parameters (FB): For transferring information from the calling block to the
called block. Within the called block, only read access is permitted to input
parameters.
ez
VAR_OUTPUT Output parameters (FB, FC): For transferring information (results) from the
called block to the calling block.
VAR_IN_OUT In-out parameters (FB, FC): In-out parameters are for transferring information in
both directions. Both read and write access is possible to input/output
r.s
parameters.
Parameter transfer When the FBs are instantiated, a memory cell is provided in the instance data
area for each input parameter and output parameter of the function block. This
memory cell is used for storing the actual operand. In-out parameters are only
ne
provided with a memory cell to store the pointer to the actual operand.
When the FB instance is called (in LAD, FBD) the actual operands of the input
parameters are copied to the respective memory cells of the FB instance area.
Similarly, after the block is called (at least in LAD and FBD) the values of the
output parameters are copied to the actual operands created (transfer "by
ca
om
Setpoint: INT;
• Read and write access to
END_VAR output and in-out parameters
VAR_IN_OUT
E_STOP: BOOL;
• Read and write access for all local
END_VAR variables (VAR and VAR_TEMP)
VAR_TEMP • Read-only access to constants
MotorOnAux : BOOL;
l.c
END_VAR (VAR CONSTANT)
MotorOnAux := Start AND NOT Stop;
Motor_ON := Motor_ON OR MotorOnAux;
Motor_ON := Motor_ON AND NOT E_STOP;
IF Speed > 3000 AND Motor_ON THEN
ai
Motor_ON := FALSE;
E_STOP := TRUE;
Setpoint := 0;
SIMOTION
END_IF;
END_FUNCTION_BLOCK
Access to Access to the input parameters of a function block is read-only, i.e. the
parameters parameter must always be written to the right of the assignment operator
ez
Memory A function block can retain information from call to call in both static variables
and output parameters because:
ne
• Both static variables and output parameters are stored in the instance
data area of an FB and, therefore, retain their contents from one call to the
next.
• Both static variables and output parameters can be accessed in the
statement part of an FB in read and write mode.
• It is not possible to change static variables or output parameters from
ca
om
...
PROGRAM MyProgram
VAR Instance area for Motor_2
E_STOP: BOOL; Start
Start BOOL
BOOL FALSE
FALSE
Motor_1: Motor; Stop
Stop BOOL
BOOL FALSE
FALSE
Motor_2: Motor; Speed
Speed INT
INT 00
Motor_3: Motor; Motor_ON
Motor_ON BOOL
BOOL FALSE;
FALSE;
l.c
END_VAR Setpoint
Setpoint INT
INT 00
E_STOP
E_STOP "Pointer"0h
"Pointer" 0h
Motor_1( Drive_2
...
...
Start:= %I0.0,
Stop:= %I0.1,
Speed:= 200, Instance area for Motor_3
ai
E_STOP:= E_STOP); Start BOOL FALSE
Start BOOL FALSE
; Stop
Stop BOOL
BOOL FALSE
FALSE
: Speed
Speed INT
INT 00
Motor_ON
Motor_ON BOOL
BOOL FALSE;
FALSE;
%Q4.0:= Motor_1.Motor_ON;
SIMOTION
END_PROGRAM
10.01.2013
MC-SMO-PRG_03.15
INT
INT
"Pointer"
00
"Pointer"0h
0h
Drive_3
Instantiation Creating an FB instance, i.e. assigning a dedicated memory area to an FB, can
r.s
you want to actuate several process units of the same type (e.g. drives,
valves, etc.), you can use multiple instances of an FB.
The status data of the individual process units is mapped to the static
variables/output parameters of the FB.
ca
PROGRAM MyProgram
VAR
E_STOP: BOOL;
FB instance name
Motor_1: Motor;
om
Motor_2: Motor;
Motor_3: Motor;
END_VAR
Assigning the input and
Motor_1( in-out parameters in
Start:= %I0.0, the parameter list
Stop:= %I0.1,
Speed:= 200,
E_STOP:= E_STOP); Copying the output
l.c
%Q4.0:= Motor_1.Motor_ON;
parameters to the
; actual parameters
Motor_2(
Start:= %I1.0,
ai
Stop:= %I1.1,
Speed:= -400, <InstanceName.OutputParameter>
E_STOP:= E_STOP);
%Q4.1:= Motor_2.Motor_ON;
SIMOTION
END_FUNCTION_BLOCK
Input and in-out In ST, an actual parameter can be specified for each input parameter and must
parameters be specified for each in-output parameter when an instance is called.
If no actual operand is specified for an input parameter, the value of the last FB
instance call/the initialization value is used for FB execution.
ez
For all in-out parameters, ST - and of course all other compilers (LAD, CSF,
MCC) - forces the formal parameter to be supplied with a variable. Due to the
parameter transfer mechanism for in-out parameters, the assigned variable
must be directly readable and writable.
r.s
Output The FB instance returns the results of the call in output parameters. Output
parameters parameters cannot be specified in the parameter list in an FB instance call. After
the call, output parameters can be only be "cleared" (i.e. assigned to one of the
calling block's variables, for example) via explicit access to the private data area
ne
of the FB instance.
The output parameter of the FB instance is accessed by specifying the instance
name and - separated by a period - the name of the formal output parameter,
e.g.:
• %Q4.0:= Motor_1.Motor_ON
ca
PROGRAM MyProgram
VAR
E_STOP: BOOL;
Motor_1: Motor;
om
Motor_2: Motor;
Motor_3: Motor;
END_VAR
Motor_1(
Start := %I0.0, FB instance call with specification
Stop := %I0.1,
Speed := 200, of output parameters
l.c
E_STOP := E_STOP,
Motor_ON => %Q4.0);
Motor_2.Start := %I1.0;
ai
Motor_2.Speed := 400;
Motor_2( E_STOP := E_STOP);
%Q4.1:= Motor_2.Motor_ON; Read and write access to input
parameters outside of the
SIMOTION
END_FUNCTION_BLOCK
10.01.2013
MC-SMO-PRG_03.17
SITRAIN Training for
Automation and Drives
@
Extended call Activating the compiler option "Permit language extensions" makes the following
and access additional call and access options available to the ST programmer:
options
• Clearing of output parameters in the parameter list
er
The actual operation to copy the values of the output parameters from the
instance data area of the FB is performed immediately after termination of
FB execution.
• Read and write access to input parameters
In addition to the assignment of an actual operand to the input parameter
r.s
when an FB is called, this compiler option also supports read and write
access to the FB's input parameters in the associated instance data area
outside of the FB.
The input parameters are accessed in the same way as the output
parameters - by specifying the instance name and the parameter name.
ne
ca
om
PROGRAM MyCyclicProg;
important; called POUs must
be compiled before the call END_INTERFACE
l.c
TYPE/END_TYPE section of the VAR_INPUT
. . .
interface or implementation part END_VAR
• The POU can be used now; the . . .
END_FUNCTION
implementation will follow later
ai
PROGRAM MyCylicProg
• This is being achieved with a . . .
two-phase compiler myOpMode(. . .);
. . .
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
END_PROGRAM
END_IMPLEMENTATION
10.01.2013
MC-SMO-PRG_03.18
SITRAIN Training for
Automation and Drives
@
Overview When creating the source file, you should always pay attention to the order of
the source file modules. A module that is to be called must always precede the
calling module so that the former is recognized by the latter. For example,
variables must be declared before they are used, functions must be defined
er
before they are called, and function blocks must be defined prior to instance
declaration.
Forward declaration If the "Permit forward declarations" compiler option is activated, the program
ez
organization units (POUs) can be used for the following purposes in a source
file, before the corresponding POUs have been fully defined:
• Instance declaration of a function block
• Call of a function
r.s
Example Then, in an ST source file, once the prototype of an FB has been declared, an
instance of the FB can be declared; the FB is not implemented until
subsequently in the implementation part of the ST source file.
Note With MCC or LAD/FBD language, using (i.e. declaring) FB instances or calling
FCs and programs without explicit forward declaration is always possible.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
Command library
gm
Date:
File:
10.01.2013
MC-SMO-PRG_03.19
SITRAIN Training for
Automation and Drives
@
Overview ST provides a range of standard functions and function blocks for solving
common tasks. These standard functions and function blocks can be moved to
an ST source file using a drag and drop operation in the project navigator (select
command library).
er
Alarms & messages These functions send configured messages (e.g. error messages) to the display
devices that are logged on or check their status. Both messages that do not
require acknowledgment and messages that require acknowledgment can be
ez
sent. The state of a message and its acknowledgment state can also be
checked.
Drives This function is used to read and write drive parameters as well as to read out
the latest fault buffer entry in the drive.
r.s
Bit string Bit string functions are used to manipulate sequences of bits by means of
functions shifting (SHL, SHR) or rotation (ROL, ROR). There are also functions to read or
write individuals bits within a BYTE, WORD, or DWORD variable.
ne
Communication This group contains functions for data exchange between devices using the
Ethernet protocols UDP and TCP/IP, as well as functions for data transfer on
PROFIBUS.
ca
Data type When you link two operands in an operation or perform a value assignment,
conversion you must take data type compatibility into account. SIMOTION provides the
functions necessary for the explicit conversion of data types.
Logic This group contains functions for logic or bit-by-bit operations between
corresponding operands.
om
EXP(..), LOG(..), ..
Bit string standard functions SHL( ), ROR( ), ...
_getBit(..), _setBit(..)
Conversion INT_TO_DINT(..),
USINT_TO_BYTE (..), ...
l.c
Functions for task _restarttaskId(...),
handling _getStateOfTaskId(...), ...
ai
Communication _xsend(..),_xreceive (..),
_udpSend(..),_udpReceive(..),
...
TO-specific functions _enableaxis)..),_move(..),
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
_pos(..),...
10.01.2013
MC-SMO-PRG_03.20
SITRAIN Training for
Automation and Drives
@
Mathematical These are the functions for more complex mathematical operations. They go
functions beyond the scope of the commands supported by the ST language. Simple
mathematical functions can be performed using the operators +, -, *, /, **.
er
I/O These are primarily function blocks for accessing I/O modules such as CP or
FM modules.
PLCopen These are all of the function blocks conforming to PLCopen. These blocks have
ez
been designed for moving axes from a cyclic user program that is executed in
the BackgroundTask, for example.
Task handling Task control commands are used to manipulate the execution system (to start or
r.s
stop individual tasks, for example). In addition, the current state of tasks
(RUNNING, STOPPED, etc.) and information about task runtimes can be
obtained.
TO-specific TO functions are commands that execute specific actions at a technology object,
ne
functions such as axes, output cams, measuring inputs, etc. Before technology functions
can be called in a user program, the corresponding technology package must be
integrated into the associated ST source file with the USEPACKAGE statement.
Other system This group contains various functions such as querying the states of DP slaves
ca
Character strings These functions are used to edit STRING type variables.
LAD/FBD These groups contain special operations for use in LAD/FBD programs.
elements
om
Counters CTU(...), CTD(...), CTUD(...)
l.c
RTC(...)
PLCopen _MC_Power(), _MC_Home(),
_MC_MoveAbsolute(),
_MC_MoveRelative(),
ai
_MC_MoveAdditive(),
_MC_MoveSuperImposed(),
_MC_Stop(), . . .
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_03.21
SITRAIN Training for
Automation and Drives
@
Overview Unlike system functions, system function blocks must be instantiated. First, a
variable of the function block type must be declared. This instance can then be
called.
er
Edge The R_TRIG system function block detects a rising edge, F_TRIG detects a falling
evaluation edge.
Counters ST provides a range of system s function blocks for counters. In total, three types
r.s
• RTC: RTC is used to set and read out the controller's real-time clock.
ST also provides a range of IEC-compliant timers:
Timers • eTP: Time pulse
• TON: Switch-on delay
ca
PLCopen This library contains the single-axis and multi-axis blocks conforming to
PLCopen. It also features an integrated block for implementing JOG mode for
axes.
om
Drive axis driveAxis
Position axis posAxis
Following axis followingAxis
Following object followingObjectType
Cam camType
l.c
External encoders encoderType
Measuring input measuringInputType
Output Cam outputCamType
ai
Temperature Controller temperatureControllerType
AnyObject anyObject
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_03.22
SITRAIN Training for
Automation and Drives
@
General Within library blocks such as FCs or FBs, the technology objects of a project can
only be accessed via input parameters of the "Technology object" type.
In this case, the requisite input parameters must be declared in the declaration
part of the FC or FB.
er
Properties The data types of technology objects are determined by the technology package
loaded. The elements (e.g. system variables) of technology objects can be
accessed via TO data type input parameters.
ez
Inheritance can also be used between data types. Inheritance for axes means
that all of the data types, system variables, and functions of the "driveAxis" TO
are fully included in the "posAxis" TO. In turn, "posAxis" is fully included in the
"followingAxis" TO.
r.s
om
END_VAR
VAR_OUTPUT
myActPos : LREAL; // Variable for actual position of axis
END_VAR
VAR
retVal : DINT; // Variable for return value of TO function
l.c
END_VAR
retVal := _enableAxis(axis := myAxis); // Axis is enabled.
ai
position := myPos);
myActPos := myAxis.positioningState.actualPosition;
// Scanning position using system var access
SIMOTION
END_FUNCTION_BLOCK
system function.
After positioning, the current position of the axis is stored by means of structure
access.
ez
Note The above FB, however, is not programmed in a "watertight" manner. Since the
input parameters do not necessarily have to be assigned when the FB is called, the
input parameter "myAxis" will not necessarily point to a valid Axis TO.
Therefore, in an FB which is@ provided for general use, e.g. via a library, it is
r.s
always advisable to check whether the input parameters which are to be used to
access technology objects really do point to valid TOs.
ne
ca
om
drv_axis1 := pos_axis1;
any_obj1 := drv_axis1;
l.c
drv_axis1 : driveAxis;
pos_axis1 : posAxis;
any_obj1 : ANYOBJECT;
END_VAR
pos_axis1 := ANYOBJECT_TO_OBJECT(drv_axis1);
ai
pos_axis1 := ANYOBJECT_TO_OBJECT(any_obj1);
Testing a TO reference
SIMOTION
Siemens AG 2013. All rights reserved.
gm
• With input parameters in FC, FB; after an explicit type transformation:
IF pos_axis1 <> TO#NIL THEN . . . // cast was successful
Date:
File:
10.01.2013
MC-SMO-PRG_03.24
SITRAIN Training for
Automation and Drives
@
Transformation of The TO data types driveAxis, posAxis, and followingAxis have a hierarchically
TO data types structured functionality.
A position axis (posAxis data type) contains the functionality of a drive axis
(driveAxis data type). A following axis (followingAxis data type) contains the
er
functionality of a position axis (posAxis data type) and, therefore, also of a drive
axis (driveAxis data type).
SIMOTION only supports type conversion within these hierarchical data types
as well as with the general TO data type ANYOBJECT. Other type conversions
ez
lower down the hierarchy) must point to a TO instance that is at least as high up
the hierarchy as the TO data type of the target variable.
Otherwise, the target variable of the value
• TO#NIL
is assigned. This value can be evaluated in an IF statement, for example, with
the comparison operator "=".
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.1
SITRAIN Training for
Automation and Drives
@
Contents Page
SIMOTION - Axes - Drives ............................................................................................................... 2
Technology objects (TO) in SIMOTION ........................................................................................... 3
Creating and configuring an axis ....................................................................................................... 4
er
om
Synchronous operation
Communication via Message frames, e.g. speed setpoint, encoder actual value, control word, status word
PROFIBUS/PROFINET
Drive objects
l.c
Speed control Drive 1 Drive 1 Drive 3
Current control
Power module Speed control Speed control Speed control
Motor
ai
Encoder
M Motor M M
Encoder
SIMOTION
Siemens AG 2013. All rights reserved.
~
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.2
~
SINAMICS
~
Controller The controller handles the execution of the specified (motion) program and
controls the I/Os of the entire machine.
In the interpolator, the motion commands are converted into information about
ez
Drive system The drive system converts this information into a speed setting. The motor runs
at this speed to traverse the axis in the specified time/at the specified velocity
and reach the required target position.
ne
om
System tions ration
variable data Alarms Configu-
Alarms
ration
data
Encoder System
func-
System tions Axis
Configu- variable System
System Alarms
l.c
ration func- func-
data tions System tions
variable
Alarms
Measuring Configu-
input ration
ai
data
System Alarms
variable Output
cam System
func-
SIMOTION
Siemens AG 2013. All rights reserved.
gm
System
variable
Date:
File:
Alarms
10.01.2013
MC-SMO-PROG_04.3
tions
error, etc.
Default values and settings can also be read/specified via system variables.
• System functions: The user program uses system functions to access the
functionality for actuating the associated "physical" object. An axis TO, for
example, will provide powerful system functions for positioning, homing,
ne
Using
parameter
screens
om
l.c
ai
Using
expert list
SIMOTION
Siemens AG 2013. All rights reserved.
Date:
File:
gm 10.01.2013
MC-SMO-PROG_04.4
SITRAIN Training for
Automation and Drives
@
Configuration You will need to work through several steps before you can use the technology
of TOs objects.
First, an instance of the technology object is created by means of configuration.
A TO is configured with the SCOUT engineering system. Appropriate wizards
er
It is, therefore, not possible to change properties such as drive axis, position
axis, etc., later. To convert a driveAxis TO to a posAxis TO, the original drive TO
must be deleted and a new posAxis TO inserted.
Configuration data generally determines the static properties of a TO. Certain
properties determined by the configuration can also be changed during runtime.
ne
Expert list In addition to accessing the configuration data and system variables via the
wizards and parameter screens, you can also access the data directly via an
expert list. The expert list for an object is opened via the context menu (Expert
ca
-> Expert list command). Select the object in the project navigator first.
om
l.c
TO- Config- read data
myKv := Axis_1.activeconfigdata.typeofaxis.numberofdatasets.
dataset_1.controllerstruct.pv_controller.kv;
ai
TO- Config- overwrite data
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Axis_1.setconfigdata.typeofaxis.numberofdatasets.dataset_1.
controllerstruct.pv_controller.kv := 100;
Date:
File:
10.01.2013
MC-SMO-PROG_04.5
SITRAIN Training for
Automation and Drives
@
Configuration data Configuration data defines the principal functionality of a TO. It is generally set
using the SCOUT engineering system during object configuration and remains
fixed during runtime.
Part of this configuration data can, however, be modified while the program is
er
The change does not take effect until the technology object is restarted.
• Can be modified online, effective immediately: Configuration data of this
type can be changed by variable access from the user program. The change is
effective immediately.
ne
Online mode supports both read and write access to configuration data. For
Online access read access, activeconfigdata must be added to the name of the
configuration data; for write access, setconfigdata must be added.
Example:
ca
om
Collecting and activating changes
l.c
activationModeChangedConfigData
ai
ACTIVATE_CHANGED_CONFIG_DATA
SIMOTION
Siemens AG 2013. All rights reserved.
gm
COLLECT_CHANGED_CONFIG_DATA
Date:
File:
10.01.2013
MC-SMO-PROG_04.6
SITRAIN Training for
Automation and Drives
@
Effectiveness The "effectiveness" of changes can be controlled with a system variable. The
technology object system variable activationModeChangedConfigData defines
when the changes made to the configuration data are to be activated.
• When the system variable activationModeChangedConfigData is set to
er
ACTIVATE_CHANGED_CONFIG_DATA,
the modified data becomes effective immediately. If the system variable is
set to this value, data collected up to this point is also activated.
ez
ACTIVATE_CHANGED_CONFIG_DATA.
resetAxisConfigDataBuffer()).
Note Once the modified configuration data item is written, it will take some time for
the change to take effect, even if the setting activationModeChangedConfigData
= ACTIVATE_CHANGED_CONFIG_DATA is used. Timeouts are likely to occur
ca
Effectiveness
1. Activate precontrol
om
l.c
3. Control
restartActivation
ai
2. activateRestart
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.7
SITRAIN Training for
Automation and Drives
@
Restarting the TO To integrate configuration data that requires a TO restart, you must reset the
technology object. The procedure depends on the
Restart.restartActivationSetting configuration data item of the TO.
er
If
• Restart.restartActivationSetting RestartInfo = RESTART_BY_COMMAND,
the TO can only be restarted with the corresponding system function (e.g.
resetAxis()). The activateRestart parameter of the corresponding call must be
ez
set to ACTIVATE_RESTART.
If
• Restart.restartActivationSetting =
RESTART_BY_SYSVAR_AND_COMMAND,
r.s
Note A RESTART can also be activated from within SIMOTION SCOUT by pressing
ca
om
Enable / disable axis _enable / _disable
Move axis _move
Position axis to target position _pos
Stop axis motion _stop / _stopEmergency
Continue axis motion _continue
l.c
Home axis _homing
ai
SIMOTION
Command library
_enableAxis / This function switches the enable signals on the axis. The states of the
er
_disableAxis drive and power enable signals can be accessed using the system variables
actorMonitoring.driveState (DRIVE) and actorMonitoring.power (POWER).
The position controller enable must be set for position axes. Its state can be
checked with servoMonitoring.controlState. The position controller enable is
ez
ignored for drive axes These commandse cannot be executed in the StartUpTask
of a program.
_move The axis is accelerated or decelerated to the programmed velocity. If no time limit
has been programmed (parameter 'moveTimeOutType
r.s
_pos This function moves the axis to the programmed target position with a definable
velocity profileg. The dynamic parameters can be specified in the command.
ne
This colmmand stops all motion or the specified motion (basic motion or
_stop/ superimposed motion). The stop command affects only single axis motion and
_stopemergency cannot be used for synchronous operation motion.
ca
Function for homing an axis. An axis has the 'referenced' or 'homed' status when
_homing the controller coordinate system is aligned with the axis system. The status can
be read from the 'positioningState.homed' system variable.
om
velocity, // velocity: when direct
positiveacceltype, // direct, userdefault
positiveaccel, // accel., only when direct
negativeacceltype, // direct, userdefault
negativeaccel, // accel., only when direct
positiveaccelstartjerktype, // direct, userdefault
positiveaccelstartjerk, // jerk, only when direct Dynamic
l.c
positiveaccelendjerktype, // direct, userdefault response
positiveaccelendjerk, // jerk, only when direct
negativeaccelstartjerktype, // direct, userdefault
negativeaccelstartjerk, // jerk, only when direct
ai
negativeaccelendjerktype, // direct, userdefault
negativeaccelendjerk, // jerk, only when direct
velocityprofile, // trapezoidal, smooth
mergemode, // substitute, attach, Execution
SIMOTION
blendingmode,
nextcommand,
commandid);
10.01.2013
MC-SMO-PROG_04.9
control
Identification
job, it then executes it. In the event of an error while a job is being processed
(with the result that the job can no longer be executed correctly and completed),
the TO sets an alarm message with the corresponding error response as set in
the parameters.
ez
Return value In the return value for the system call, the addressed TO indicates whether it is
accepting the job or rejecting it (in the latter case giving the reasons why). All
motion commands normally return a double-precision integer (DINT).
r.s
The calling program can tell from this value whether the job has been accepted
(return value = 0) or rejected (return value <> 0). In the online help for the
_move() command, the possible return values are listed with a corresponding
description.
ne
Input parameters The input parameters of the TO system function call can be divided into the
following groups:
• mandatory: These parameters must be specified with the call. This group
includes the TO instance, the target position, etc.
• optional predefined: These parameters can be specified in the call but do not
ca
have to be.
If they are not specified in the call, a system default setting is activated,
e.g. IMMEDIATELY for command advance conditions.
• optionalUserDefault: These parameters can also be specified in the call but
do not have to be.
If they are not specified in the call, a user-defined default (dialog: Default)
is activated.
MotionTask 1
motion buffer for axis 2
start
om
Pos(Achse1) buffer for sequential movement IPO
(basic coordinate system) (Basis)
+ Position
control
buffer for superimposed movement IPO
(superimposed coordinate system)
(überlagernd)
l.c
enable/ disable commands
superimposedMotion.position
ai
end buffer for emergency stop
und stop / continue commands
positioningState.commandPosition
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.10
SITRAIN Training for
Automation and Drives
@
General Commands can be issued from all user tasks of the system. The execution time of
a command on the technology object is the only factor that determines the
effectiveness of the command.
er
Since a technology object does not have a task context, the priority of the task
which issued the command is of no significance for command execution. If
commands are issued from multiple tasks, the user program must ensure
consistency as regards the order in whichm they are executed.
ez
Command buffers
Each axis has a command buffer so ethat multiple commands can be issued to one
axis TO. This buffer consists of ifour command-group-specific sub-buffers. Each
sub-buffer can buffer one cosmmand from one of the following command groups.
r.s
The interpolators on the axis reads the command out of the command buffers (in
the IPO cycle clock) and processes them. Commands from different command
ca
RetVal := _pos(
axis := . . ., // Axis
. . ., //
blendingMode:=ACTIVE, // Select: Blending
. . ., //
mergeMode:=NEXT_MOTION ); // Select: Transition behavior
om
IMMEDIATELY NEXT_MOTION
Replace current motion immediately: Attach and clear buffer:
l.c
SEQUENTIAL SUPERIMPOSED_MOTION_MERGE
ai
Attach: Superimpose:
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.11
SITRAIN Training for
Automation and Drives
@
Transition behavior If a motion command is issued from a program when traversing is
Merge_mode active, how to proceed with the motion command issued is selected by setting
the mergemode parameter accordingly:
• Replace (IMMEDIATELY): The motion specified in the issued command
er
om
_pos (.. position:= 100,.., _pos (.. position:= 200,..,
velocity:= 20,..) velocity:= 40,..)
40
20
l.c
100 200
Profile without
blending
_pos (.. position:= 100,.., _pos (.. position:= 200,..,
ai
velocity:= 20,..) velocity:= 10,..)
20
SIMOTION
10
10.01.2013
MC-SMO-PROG_04.12
200
Blending takes place between two positioning commands. The set velocity
specified in the commands for each motion is never violated. The previous
positioning motion is performed at the velocity specified in the command up to
ez
Exception: If the velocity of the new positioning motion is less than the set
velocity of the previous motion and both motions have the same sign, then the
r.s
velocity of the previous positioning motion is reduced to the velocity of the new
Precondition
motion up to the target position .
'blending' must be known to the interpolator or motion control system at the start
of deceleration in the previous command.
If the blending command is not detected by the motion control system until later,
blending is delayed accordingly.
ca
om
Basic
coordinate
Sum
+ coordinate
l.c
Superimposed
coordinate
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.13
SITRAIN Training for
Automation and Drives
@
Superimposed Superimposed motion can be specified by setting the mergeMode parameter
motion to SUPERIMPOSED_MOTION_MERGE. Superimposed motions are
independent motions which can be executed in parallel to a basic motion. One
superimposed motion aborts another; superimposed motions can be stopped
er
Coordinate system With a position axis, superimposed motions are performed in an additive
coordinate system. The superimposed motion is performed in a superimposed
ez
Note Only one superimposed motion can be active on an axis at a given time, e.g.
superimposed positioning motion or superimposed synchronous operation.
ca
Resulting motion
Basic motion
om
Superimposed motion
with: TRANSFER_STANDSTILL
l.c
Basic motion: target position 100 mm, superimposed motion: 30 mm, was started twice
Feedback from the coordinate system, configurable in:
ai
• TypeOfAxis.decodingConfig TransferSuperimposedPosition:
TRANSFER_RESET (_resetAxis() only)
TRANSFER_ MERGE (positioning motion with mergemode = IMMEDIATELY and
SIMOTION
TRANSFER_STANDSTILL
gm
(standstill, positioning motion with mergemode =
IMMEDIATELY and _resetAxis())
Date:
File:
10.01.2013
MC-SMO-PROG_04.14
SITRAIN Training for
Automation and Drives
@
Display The position and dynamic values for the basic and superimposed coordinate
systems are displayed in the system variables for motionStateData.
Sum coordinates:
er
coordinate system Superimposed basic coordinate is set in the following axis configuration data:
The time of feedback of the @superimposed coordinate to the axis coordinate or
TypeOfAxis.decoduingConfig.transferSuperimposedPosition
om
Immediately: At start of deceleration
IMMEDIATELY phase:
AT_DECELERATION_START
Set
At end of setpoint
l.c
After entry in the command queue:
interpolation:
WHEN_BUFFER_READY Actual
WHEN_INTERPOLATION_
DONE Set
ai
Actual
AT_MOTION_START WHEN_MOTION_DONE
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.15
SITRAIN Training for
Automation and Drives
@
Program For synchronizing program execution and command execution in technological
advance objects, you can use the "next_command" parameter to specify when you want
program execution to resume after the command has been issued.
This makes it possible to wait for partial or complete execution of the motion
er
concerned.
The following settings are available for selection:
• IMMEDIATELY
ez
• WHEN_BUFFER_READY
• AT_MOTION_START
• WHEN_ACCELERATION_DONE
• AT_DECELERATION_START
r.s
• WHEN_INTERPOLATION_DONE
• WHEN_MOTION_DONE
ne
ca
om
myID := _getCommandId(); // Assignment of a free number
RetVal := _pos(
axis := . . ., // Axis
. . ., //
commandId:=myID); // Identification of the command
l.c
or, if tracking commands is not important
RetVal := _pos(
ai
axis := . . ., // Axis
. . ., //
// commandID - comment it out, it is an optional parameter
SIMOTION
);
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.16
SITRAIN Training for
Automation and Drives
@
Command All motion commands have a command ID parameter. In conjunction with
identification system functions, this parameter is used to indicate the status of a command.
The status of a command can also be checked in other parts of the program.
At the start of the TechnologicalFaultTask, this command identification is also
er
specified in the start information of the command which caused the fault.
SystemID_high.
om
RetVal := _pos(
axis := ..., // Axis
. . ., //
commandID := myID); // Identification of the command
l.c
RetVal :=_getStateOfAxisCommand (
axis:= // Axis
commandId:= myID); // Specification of number
ai
RetVal: ACTIVE: Command is being executed.
NOT_EXISTENT: CommandId not known or command already completed.
WAITING: Command is decoded, execution has not yet started.
SIMOTION
ABORTED:
Date:
File:
10.01.2013
MC-SMO-PROG_04.17
SITRAIN Training for
Automation and Drives
@
_getstateof This function returns the execution state of a motion command. The return
Axiscommand() value is a structure of the type StructRetCommandState with the following
elements:
• functionResult: DINT, for status see online help for _move
er
• commandIDstate:
- ACTIVE: Command is being executed.
- NOT_EXISTENT: CommandId not known or command already
ez
completed.
- WAITING: Command is decoded, execution has not yet started.
- WAITING_FOR_SYNC_START: Command is decoded, waiting for a
synchronous start.
r.s
Note Unless provision has been made elsewhere in the user program, the technology
ne
object only buffers the CommandId until the command has been executed or
aborted for other reasons. After this, the CommandId is deleted in the
technology object (so the value NOT_EXISTENT will always be returned when
the execution state is checked).
To check the status of a specific command after it has been completed
ca
om
axis := . . ., // Specification of axis TO
commandId := myID,
deleteCommandIdWithReset:= ..);
l.c
commandId := myID); // Identification of the command
RetVal :=_getstateofAxisCommand (
axis := . . ., // Axis
ai
commandId := myID); // Specification of number
SIMOTION
axis := . . .,
gm
removeMode := SPECIFIC_ID, // Specific ID or all IDs
commandId := myID);
Date:
File:
10.01.2013
MC-SMO-PROG_04.18
SITRAIN Training for
Automation and Drives
@
CommandId To determine the status of a specific command once it has been executed, you
buffer must buffer the corresponding CommandId in the technology object.
Within each TO there is a buffer for long-term storage of the CommandIds. The
size of this buffer can be specified using the configuration data item:
er
• <TO>.TypeOfAxis.DecodingConfig.NumberOfMaxBufferedCommandid
ez
reset.
The command completion status (e.g. EXECUTED or ABORTED) then remains
available even after the command has been executed.
ne
CommandIds and their command status are no longer available once the
command has been completed.
om
RetVal := _pos(
axis := axis_blue, // Axis
. . .,
commandId := myID); // Specify CommandId
myStateofMotion:= _getMotionStateofAxisCommand(
l.c
axis := Axis_1, // Axis
commandId := myID); // Specify CommandId
ai
BUFFERED: Command is in the command queue
IN_EXECUTION: Command is being executed
IN_ACCELERATION: In acceleration phase
IN_CONSTANT_MOTION: In constant motion phase
SIMOTION
IN_DECELERATION:
AXIS_HOMED:
INTERPOLATION_DONE:
Date:
File:
10.01.2013
MC-SMO-PROG_04.19
SITRAIN Training for
Automation and Drives
@
_getMotionstate This function returns the current phase of a command execution. The return
ofAxisCommand() value is a structure of the type StructRetMotionCommandState with the
following elements:
• functionResult: DINT, for status see online help for _move()
er
• motionCommandIdState:
- NOT_EXISTENT: CommandId not known or command already
completed.
ez
Note The last two return values are only available if the CommandId is explicitly
buffered inside the TO.
om
l.c
ai
motioncommand IN_MOTION END_OF_INTERPOLATION MOTION_DONE
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.20
SITRAIN Training for
Automation and Drives
@
MotionStateData The status of a motion command and the corresponding motion can be
monitored with the TO system variable motionStateData. motionStateData is
structured as follows:
• motionStateData
er
RetVal := _stop(
axis := . . ., // Axis
. . ., //
stopMode := STOP_AND_ABORT, // Stop behavior
stopSpecifcation := ALL_AXIS_MOTION, // Basic or superimposed
stopId := _getcommandid()); // Command ID
om
stopMode:
STOP_AND_ABORT Normal stop with abort
STOP_WITHOUT_ABORT Normal stop without abort
l.c
stopSpecification:
All_AXIS_MOTION Effective on all active motions
BASIC_MOTION Is effective on the basic motion of the axis
ai
SUPERIMPOSED_MOTION Is effective on the superimposed motion of the axis
SPECIFIC_AXIS_MOTION Is effective on a specified motion of the axis
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.21
SITRAIN Training for
Automation and Drives
@
Stop axis The command stops the axis moving. It can be used for both positioning and
Normal stop drive motions.
With a normal stop, the motion is decelerated along the parameterized
deceleration ramp.
er
The function resumes all motion or some motion of the specified axis if it was
_continue() stopped with _stop() and STOP_WITHOUT_ABORT in the stopMode parameter.
ne
The motion or part motion that is continued with the command is specified at the
continuespecification parameter:
RetVal := _stopEmergency(
axis := . . ., // Axis
. . ., //
stopDriveMode := STOP_IN_DEFINED_TIME, // Stop behavior
stopTime := 1.0); // Default time
om
stopDriveMode:
STOP_IN_DEFINED_TIME Stop axis with a time-defined ramp
STOP_WITH_MAXIMAL_DECELERATION Stop axis with maximum deceleration
l.c
STOP_WITH_COMMAND_VALUE_ZERO Stop axis with setpoint zero
STOP_WITH_DYNAMIC_PARAMETER Stop axis with dynamic parameters
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.22
SITRAIN Training for
Automation and Drives
@
Emergency stop This function stops the axis with a programmable stop mode. If a motion
command is active, it is aborted and cannot be continued with a _continue()-
command. The axis is not switched to follow-up mode. It remains in position
control. The axis is blocked for further motion commands; the state can be
er
Parameter Quick stop within defined period: The motion is stopped by the interpolator
based on the instantaneous set position within the parameterized time frame
ez
This type of quick stop should only be used for axes that run without precontrol,
i.e. conventionally with following error. With this type of stop, initially, the set
position of the interpolator is counted back by the (following error) distance
resulting from the instantaneous velocity and the time constant
dynamicData.positionTimeConstant. Based on the set position counted back,
ne
the interpolator decelerates the axis along the emergency stop ramp.
In this case, the emergency stop ramp must be dimensioned like the actual
braking ramp of the axis at speed setpoint 0. This is the only way to ensure that
the axis stops with velocity setpoint 0.
ca
RetVal := _continue(
axis := . . ., // Axis
continueSpecification := BASIC_MOTION, // Basic or superimp,..
continueId := _getcommandid(), // Command ID
nextCommand:=IMMEDIATELY, //
commandId:= . . .,
om
);
l.c
continueSpecification:
All_AXIS_MOTION Effective on all active motions
BASIC_MOTION Is effective on the basic motion of the axis
SUPERIMPOSED_MOTION Is effective on the superimposed motion of the axis
ai
SPECIFIC_AXIS_MOTION Is effective on a specified motion of the axis
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.23
SITRAIN Training for
Automation and Drives
@
Resume a stopped
motion command This function continues the entire motion or a partial motion of the specified axis,if it
was stopped with the _stop() command using STOP_WITHOUT_ABORT in the
'stopMode' parameter.
er
RetVal := _redefinePosition(
axis := . . ., // Axis
redefineSpecification := COMMAND_VALUE, // Setpoint, act. value,..
redefineMode:=ABSOLUTE, // Absolute, relative
position:=0.0, // Offset
velocity:=0.0, // Dynamic data only
om
acceleration:=0.0, // relevant for virtual
nextCommand:=IMMEDIATELY, // axis
commandId:= . . .,
);
l.c
redefineSpecification:
COMMAND_VALUE // Set position is set or offset to position
ACTUAL_VALUE // Actual position is set or offset to position
VIRTUAL_AXIS // Position and dynamic data for a virtual axis are set,
ai
// become effective next time the virtual axis is started
redefineMode:
ABSOLUTE
SIMOTION
Siemens AG 2013. All rights reserved.
gm
// Actual or set position set to absolute value RELATIVE
// Actual or set position offset by position
Date:
File:
10.01.2013
MC-SMO-PROG_04.24
SITRAIN Training for
Automation and Drives
@
Coordinate system: The _redinePosition() function sets the coordinate system of an axis to
set/offset a new value. The position value can be defined as an absolute value or
as a relative position offset. The setpoint or the actual value can be set to a
defined position. The other value is adjusted taking the current following error
er
into account.
The setting of the coordinate system only affects the programmed axis
positions. The software limit switches, whmich are defined by homing, stay in
their original positions.
ez
With a virtual axis, the setpoints for ievelocity and acceleration can be set in
addition to the set position. The values for position, velocity, and acceleration
are used as starting values for s the next motion command, i.e. they are
included when starting a motion command at the virtual axis.
r.s
RetVal := _resetAxis(
axis := . . ., // Axis
userDefaultData := ..., // Reset user data?
activateRestart := ..., // Restart TO?
nextCommand:=, // Synchronous, asynchronous?
commandId:= . . .,
om
);
usedefaultData:
l.c
ACTIVATE_CONFIGURATION_DATA Set user default values to the configured values
DO_NOT_CHANGE No resetting of the user default values
activateRestart:
NO_RESTART_ACTIVATION Do not execute a technology object restart
ai
ACTIVATE_RESTART Execute a technology object restart
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.25
SITRAIN Training for
Automation and Drives
@
Reset axis The _resetAxis() command places the axis in a defined initial state. The
following actions are carried out with the axis in this state:
• All active motions are stopped with the emergency stop ramp.
er
• Commands in the motion buffer and commands pending at the motion buffer
are deleted; synchronous commands are aborted. The Command aborted
technology alarm is suppressed.
• Optionally, the axis can be restarted using a function parameter in the
ez
command.
• The command is executed synchronously as normal.
• The command can also be executed asynchronously (as of V3.1).
• Pending errors on the axis are reset. The command is terminated with a
r.s
Restart When restart is activated on the technology object with the activateRestart
parameter, the technology object performs a restart.
• An active motion on the axis is aborted without error messages or similar.
ca
• The actual value system of the axis and, thus, the homing status, are reset.
• All commands on the axis are aborted.
• All connections to other technology objects are terminated and re-
established.
• The _resetAxis() command stops any synchronous operation command that
is in effect on this axis. The synchronous operation TO on the synchronous
axis is not reset.
RetVal := _resetAxisError(
axis := . . ., // Axis
errorResetMode := ..., // All errors, spec. error?
errorNumber := ..., // Error number
nextCommand:=, //
commandId:= . . .,
om
);
errorResetMode:
l.c
ALL_ERRORS Reset all errors
SPECIFIC_ERROR Reset selected error
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_04.26
SITRAIN Training for
Automation and Drives
@
Acknowledge error The _resetAxisError() function resets a specified error or all errors on the axis.
The command is terminated with a negative acknowledgment if any errors occur
that must not be acknowledged at this point.
er
error status The _getAxisErrorNumberState() command mis used to read the status of
a specific error on the axis. The function returns the status (pending, not
pending) of the error specified with the error number (DINT) in its return value.
r.s
ne
ca
MyRetStructRetGetToError := _getAxisErrorState
axis := . . . // Axis
);
om
StructRetGetToError:
StructRetGetToError STRUCT
functionResult; // (DINT) Result of call
errorState; // Yes or No
numberOfErrors; // Number of errors
error1; // Error number 1. Error
l.c
error1Parameter1 // Add. info. 1 for error 1
error1Parameter2 // Add. info. 2 for error 1
...
error1Parameter5 // Add. info. 5 for error 1
...
ai
Error8 // Add. info. 1 for error 8
error8Parameter1 // Add. info. 2 for error 8
...
SIMOTION
error8Parameter5
END_STRUCT
MC-SMO-PROG_04.27
SITRAIN Training for
Automation and Drives
@
Read out error The _getAxisErrorState() function is used to read out the status of up to eight
on axis TO alarms on an axis TO. The function returns whether any alarms are pending on
the axis in the errorState return value and if so how many in numberOfErrors.
Additional information is also returned for these alarms. The additional
er
om
forceControlMode := INACTIVE, // ACTIVE, INACTIVE
STWBitSet := . . ., // Bits (UINT) für STW1
movingMode := DO_NOT_CHANGE // POSITION_Controlled, SPEED_Co…
);
l.c
enableMode:
ALL // position controller and drive + power is enabled
DO_NOT_CHANGE // no changes
DRIVE // switch only drive enable
POWER // switch on power enable
ai
BY_STW_BIT // the bits in "STWBitSet" are set according to the PROFIdrive-state machine
STATE_MACHINE_CONTROL_BY_APPLICATION // the bits in "STWBitSet" are set
servoControlMode:
ACTIVE
INACTIVE
SIMOTION
Siemens AG 2013. All rights reserved.
gm
// set value path between IPO and position controller is enabled
// set value path between IPO and position controller is disabled
Date:
File:
10.01.2013
MC-SMO-PROG_04.28
SITRAIN Training for
Automation and Drives
@
Switch axis This function switches the axis enables. If not all enables are set, the axis will
enables switch to the following-up mode. The following enable modes can be set. via the
"enableMode" parameter:
ALL: Enable drive and power. This is necessary for a movement initiated by a
er
TO movement command. .
DO_NOT_CHANGE: the current specified setting for the enable mode are not
changed. The axis will remain in the following-up mode, if not all enable signals
are applied.
ez
DRIVE: The drive enable is switched on, the power enable state is not changed.
POWER: The power enable state is switched on, the drive enable state is not
changed.
BY_STW_BIT: the bits specified in 'STWBitSet' are set according to the
r.s
ServoControlMode Via the "sevoControlMode" parameter the passing of the setpoint value from the
interpolator to the position controller can be enabled /disabled.
ACTIVE: The passing of the setpoint value from the interpolator to the position
controller is enabled. This setting is also necessary for a peed controlled
movement of an electrical axis.
INACTIVE: The passing of the setpoint value is disabled. The axis can only be
moved via the sepoint superimposition "servosettings.additionalSetPointValue",
e.g. generated by the internal function generator.
RetVal := _disableAxis(
axis := . . ., // Axis
enableMode:= ALL // All, DRIVE, POWER, BY_STW_BIT,
servoControlMode := ACTIVE, // ACTIVE, INACTIVE
servoCommandToActualMode:=INACTIVE,// ACTIVE, INACTIVE
nextCommand := . . ., // IMMEDIATELY, WHEN_COMMAND_DONE
om
commandId := . . ., //
forceControlMode := INACTIVE, // ACTIVE, INACTIVE
) );
servoCommandToActualMode
l.c
ACTIVE // following-up mode is activated, the axis can be moved externally
INACTIVE // following-up is deactivated, the movement of the axis is controlled by the
// position controller
forceControlMode
ai
INACTIVE // force / pressure controller is deactivated
ACTIVE // force / pressure controller is activated
movingMode:
POSITION_CONTROLLED
SPEED_CONTROLLED
DO_NOT_CHANGE
SIMOTION
Siemens AG 2013. All rights reserved.
gm
// for position –and speed controlled movement
// only for speed controlled movement, also works when the encoder fails
// no changes
Date:
File:
10.01.2013
MC-SMO-PROG_04.29
SITRAIN Training for
Automation and Drives
@
Following-up mode The axis can be switched to the following-up mode by the parameter
"servoCommandToActualMode" :
ACTIVE: Following-up mode is active. No motion commands are executed, the
movement of the axis is not controlled by SIMOTION. An axis has to be
er
In the following-up mode the command position is set equal to the actual
position of the axis, i.e. the command position will follow the actual position.
INACTIVE: The standard control mode is active, the movement of the axis is
controlled by SIMOTION. The internal mechanism in the following-up mode
r.s
ensures, that an axis can be switched without any jump on the output of the
position controller from the following-up mode to the standard control mode. If
not all enable signals are applied, the axis will remain in the following-up mode.
Force / pressure Only for axis with a configured forse- or pressure controller:
ne
movingMode An axis can be enabled for position- and speed controlled movements or only for
ca
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_05.1
SITRAIN Training for
Automation and Drives
@
Contents Page
Libraries in "CAM" ............................................................................................................................ 2
The PLCopen function library ........................................................................................................... 3
er
om
• Basic control (continuous PID,
PI step controller, pulse width modulation)
• Integration: Communication
processors CP340, CP341
• Integration: Serial interface module
l.c
ET200S
• Integration of FM350-1, FM350-2, FM352
• Control of SIMODRIVE POSMO A
ai
FBs areare designed solely for use in
cyclic tasks (BackgroundTask,
TimerInterruptTask, etc.)
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_05.2
SITRAIN Training for
Automation and Drives
@
Libraries As of V4.0, the "MotLib" and "SysLib" function libraries, which were shipped on a
separate CD in previous versions, are included in the CAM technology package.
Drag-and-drop operations can now be used to move the corresponding library
blocks directly from the command library to the user program like other system
er
functions.
PLCopen This file contains the PLCopen-compliant motion control blocks and an
additional block for implementing JOG traversing for axes. As well as the single
ez
axis blocks, the library also contains the multi-axis blocks for gearing and
camming.
The blocks in the motion control library contain blocks for controlling speed-
controlled axes, position axes, and following axes. The function blocks (FBs)
have been designed by PLCopen for compliance with the language elements for
r.s
Controller + I/Os In addition to the conventional closed-loop control blocks, in particular, this block
+ Drives contains blocks for the integration of various modules (ASI, Ident systems, CP
modules) and drives (SIMODRIVE POSMO A) in a SIMOTION overall system.
Documentation A description of the library blocks is included in the SIMOTION SCOUT online
ca
help.
om
• _MC_MoveSuperImposed (Position axis superimposed)
• _MC_VelocityProfile (traverses an axis along a velocity profile)
• _MC_ReadActualPosition (Read out actual position)
• _MC_ReadStatus (Read out axis status information)
• _MC_Reset (Reset an axis to the basic state)
• _MC_ReadParameter (Read axis parameter)
l.c
• _MC_ReadBoolParameter (Read parameter of type BOOL)
• _MC_WriteParameter (Write axis parameter)
• _MC_WriteBoolParameter (Write parameter of type BOOL)
Multi-axis blocks compliant with PLCopen
• _MC_CamIn (start camming operation between master and following axis)
ai
• _MC_CamIn (stop camming operation between master and following axis)
• _MC_GearIn (start gearing)
• _MC_GearOut (terminate gearing)
SIMOTION
• _MC_Phasing (incorporate additional phase)
JOG block
• _MC_Jog
The function blocks for triggering motion control jobs are integrated in the user
program in the usual way. If a single block is to address multiple axes in a
program, for example (e.g. axis enables with the "MC_Power" block), a separate
FB instance must be created for each axis as follows:
ez
_MC_Power
Axis_Ref Axis Status BOOL
BOOL Enable Busy BOOL
_MC_EnableMode Mode Active BOOL
om
_MC_StopMode Stop mode Error BOOL
_MC_ Disablemode Disable mode ErrorID WORD
WORD STWBitSet StatusMode BOOL
l.c
Enable: TRUE = Set axis enable Disable mode
FALSE = Reset axis enable ALL (remove position controller + drive enable)
Mode: ALL (position controller + drive) DRIVE (drive enable retained)
DRIVE (drive enable) BY_STW_BIT (remove bits)
ai
BY_STW_BIT (define bits) Status: TRUE = Axis is enabled
Stop mode FALSE = Axis is not enabled
WITH_COMMAND_VALUE_ZERO StatusMode
WITH_MAXIMAL_DECELERATION
SIMOTION
IN_DEFINED_TIME
DISABLE_DRIVE_IMMEDIATELY
Date:
File:
10.01.2013
MC-SMO-PRG_05.4
SITRAIN Training for
Automation and Drives
@
Description The function block _MC_Power enables or disables an axis or an external
encoder. The enable is controlled statically with the input enable =TRUE from
the user program. A falling edge at the enable input removes the enable.
In addition, the mode parameter can be used to specify whether just the drive
er
enable (DRIVE), the position controller and the drive enable, or the individual
bits of the control word are switched to PROFIdrive.
As of V4.2, the block has been expanded with the addition of the STWBitSet
ez
being disabled. In this case, the stop mode is activated on a falling edge at the
enable input. The stop@ modes are identical to those of the _stopEmergency
system function.
The status output indicates whether the axis is also enabled according to the
ne
enables specified in mode (status = TRUE) or not (status = FALSE). The busy
parameter indicates whether or not the FB is currently in progress. The active
parameter indicates whether or not a motion control job is currently in progress
at the TO.
The error parameter indicates an error. TRUE means that an error has occurred
ca
during the initialization of the function block. The function block is terminated.
The error description can be read at the errorId output.
_MC_MoveRelative
Axis_Ref Axis Done BOOL
BOOL Execute Busy BOOL
LREAL
om
Distance Active BOOL
LREAL Velocity CommandAborted BOOL
LREAL Acceleration Error BOOL
LREAL Deceleration ErrorID WORD
LREAL Jerk
l.c
Enable: The traversing block FB is sent to CommandAborted
the TO on a rising edge Indicates that processing of the job has been
ai
Done: TRUE = Motion completed aborted (e.g. due to an overriding command)
successfully Error: Error in block (e.g. job rejected by TO,
Busy: TRUE = FB started error during parameter assignment)
Active: TRUE = Job currently being
SIMOTION
processed at TO
10.01.2013
MC-SMO-PRG_05.5
SITRAIN Training for
Automation and Drives
@
Description The function block _MC_MoveRelative positions an axis relative to the actual
position of the axis. The processing of the FB starts on a rising edge at the
execute input. If the axis is already in motion when the job is started, the job in
progress is overridden and the position that is present in the system at the start
er
and which depends on the set interpolation cycle clock, must be taken into
account.
The dynamic parameters velocity, acceleration, deceleration, and jerk define the
dynamic response of the motion procedure. If a value greater than zero is
specified, this value is used. If -1.0 is specified, the value that was preset in the
r.s
_MC_Jog
om
BOOL CommandAborted BOOL
BOOL ModeInc Error BOOL
LREAL Increment ErrorID DWORD
LREAL Velocity
LREAL Acceleration
LREAL Deceleration
LREAL Jerk
l.c
Enable: Block enable
Forward: Start/stop motion in positive direction
ai
Backward: Start/stop motion in negative direction
ModeInc: Operating mode: FALSE (continuous mode), TRUE (incremental mode)
Increment: Specification of path (only relevant if modeInc = TRUE)
SIMOTION
...
When incremental jogging is selected, the axis is stopped by the function block
after traversing the parameterized distance. If the axis is stopped before
completing the parameterized distance due to a negative edge, the remaining
distance is completed when traversing is restarted. Therefore, when incremental
ez
In incremental mode, done signals that the specified distance has been
completed successfully. In continuous mode, the done output is set to TRUE
once the axis has stopped. The busy parameter indicates whether or not the FB
is currently being processed. The active parameter indicates whether or not a
motion control job is currently active at the TO.
ne
The commandAborted parameter indicates that the job that was active originally
has been aborted (e.g. error at TO, override by other MC command, etc.). The
error parameter signals a synchronous error (e.g. error during parameterization,
job rejected by TO, etc.).
In both cases, a detailed error specification is returned at the errorId output.
ca
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_05.7
SITRAIN Training for
Automation and Drives
@
Creating User libraries are created in exactly the same way as programs. However,
libraries you do not need to insert hardware in the project. The name must be unique
throughout the project.
In the Properties dialog box for the library, you need to specify which SIMOTION
er
devices and which technology packages you want the library to be executable
for. When you compile the library, the data required in the kernel is generated
for each device you have specified.
A library has the property "original name". When the library is created, this name
ez
is taken automatically from the name you specified. The library can still be
identified by this original name even after the library name has been changed.
If the configured SIMOTION devices and their technology packages do not
Note match the properties specified in the library, an error is output when the project
r.s
4. If necessary, make the settings for the local compiler on the "Compiler" tab
5. Click "OK" to confirm your settings. The library is inserted in the
. project navigator.
om
• Old task control commands (e.g. _StartMotionTask(..), etc.)
• Old commands for runtime measurement of tasks
(e.g. _getMaximalTaskRunTime(..), etc.)
• Old commands for message programming (e.g. _alarms(..), etc.)
l.c
• System functions of SIMOTION devices, if the library is compiled
independently of the device
Prohibited variable accesses:
• I/O variables
ai
• Global device variables
• Instances of technology objects and their system variables
SIMOTION
•
independently of the device
Date:
File:
10.01.2013
MC-SMO-PRG_05.8
SITRAIN Training for
Automation and Drives
@
General Libraries usually provide you with user-defined data types, functions, and
function blocks for use by all SIMOTION device blocks within a project. Libraries
can be created in all programming languages. Conversely, blocks from libraries
can be used in all program sources (e.g. ST, MCC, LAD/FBD sources).
er
There are no test functions (functions, function blocks) for ST, LAD/FBD, or
MCC charts available in the LIBRARY folder. Accordingly, the blocks are usually
first created and tested within the PROGRAMS folder and then copied to the
library.
ez
The library with the individual ST source files/LAD programs/MCC charts and
the ST source files/LAD/FBD programs/MCC charts called by the blocks from
the library must use the same technology packages. If they do not, during
compilation and when carrying out the consistency check, an error message will
be generated and the project cannot be downloaded to the target system. In this
r.s
case, the technology package for the library has to be selected again on the
"TPs/TOs" tab in the Properties dialog and the library has to be compiled again.
Restrictions In libraries, all ST/LAD/FBD/MCC commands with certain restrictions (e.g. "old"
task control commands, commands for task runtime measurement, and
ne
om
XML export
l.c
ai
SIMOTION
XML import
1. In the project navigator window select the desired library and open the
short cut menu.
2. In the short cut menu select the entry "Expert -> Save project and export
object". The browser for the target direcmtory is opened.
ez
3. Select the directory for the XMLe data export and confirm your settings
via the "OK" button. The data export is istarted. Export information is displayed in
the detailed window of the SIMOsTION SCOUT screen.
r.s
Note If you export in XML format, the libraries or sources are exported in an
encrypted form. When importing the encrypted XML files, the know-how
protection, including log in and password, is retained.
Libraries which were exported in the XML format can also be imported in
XML import an arbitrary SIMOTION project.
ne
1. Select the "LIBRARIES" folder and open the short cut menu.
2. Select the "Import object" entry. A browser dialog is opened.
3. Navigate to the desired XML file of the exported library and confirm
the settings via the OK button.
ca
The library is imported into the project and stored under the "LIBRARIES"
folder.
om
1. Open library
3. Object properties:
Select target devices
l.c
2. Copy + paste or
export, import xml
4. Save and compile
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_05.10
SITRAIN Training for
Automation and Drives
@
Library In the highest hierarchy of the project navigator, SIMOTION SCOUT supports
an option to create/save user and standard libraries for user-defined data
types, UNIT variables, functions (FC), and function blocks (FB) in the
"LIBRARY" folder. This folder can contain any number of libraries.
er
compile it.
3. In the source project, select the required library and copy it to the
clipboard using the menu co mmand: Edit -> Copy.
In the target project, select the LIBRARIES folder and paste the copied library
to the target folder by with the menu command: Edit -> Paste.
4. Then select the library you have inserted in the destination folder and
ne
library is compiled. Now you can use its blocks, etc., in the programs contained
in the project.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_06.1
SITRAIN Training for
Automation and Drives
@
Contents Page
Automating technical processes ....................................................................................................... 2
The SIMOTION execution system .................................................................................................... 3
er
om
l.c
ai
SIMOTION
Machine/Plant
MC-SMO-PROG_06.2
SITRAIN Training for
Automation and Drives
@
Parallel processes In the automation of machines and other technical processes, it is often
necessary to monitor or control multiple part processes such as the motions of
machine axes at the same time. This is because most technical processes can
be split into multiple linked part processes that are executed at the same time.
er
Multitasking = To maintain a clear overview, complex automation tasks are usually, in practice,
split into smaller function elements, which are then assigned to individual tasks.
Tasks, then, contain complete program units (POUs) and their associated data.
Tasks can be started and executed independently of each other, but must be
coordinated and communicate with to fulfill their common purpose.
r.s
Realtime If a process is to run continuously, the PLC’s associated execution system must
ensure that all necessary tasks are completed within the specified time.
Control systems used for automating technical processes always have their own
ne
om
Servo level Pr
io
rit
y
IPO level
§
l.c
Timer level
ai
Interrupt level
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_06.3
SITRAIN Training for
Automation and Drives
@
Execution system The execution system of SIMOTION consists of individual execution levels,
which define the chronological sequence of programs in the execution system.
Each execution level contains one or more tasks for this purpose.
A task provides the execution framework for the user programs. One or a
er
are executed.
This execution system and the e sxecution levels contained therein allow motion
control tasks to be processed together with logic functions on one control
Motion control platform.
Time-controlled execu tion levels such as the IPO level and the TimerInterrupt
r.s
and logic
level usually provide the starting point for implementing motion control tasks and
technology functionsu.
Fast responsesg to process signals are covered by a ProcessInterrupt level. The
requirements of logic switching functions, as typically implemented by a PLC,
are usuaolly met by the round robin level.
ne
the tasks.
om Priority
Temp. control
T4 DccAux task
Event-driven T5 DccAux task
execution levels Avera
SystemInterrupt ge
SystemInterrupt tasks
tasks
l.c
Wait For Condition
TimerInterrupt
TimerInterrupttasks
tasks
ai
UserInterrupt tasks
SIMOTION
Siemens AG 2013. All rights reserved.
BackgroundTask
System startup
gm
Date:
File:
10.01.2013
MotionTasks
MotionTasks
System stop
MC-SMO-PROG_06.4
SITRAIN Training for
Automation and Drives
@
Priorities The execution system structures the chronological execution of programs in
SIMOTION. Tasks and the programs assigned to them are started and
executed at a certain time. If several tasks are to be started and executed at the
same time, the task priority determines which task will be executed first.
er
Servo task This task for axis position control has the hieghest priority. It is called and
processed at fixed intervals defined during system clock configuration.
As of V4.0 the user can assign custom prmograms to this execution level. In
ez
IPOTask The interpolation leve l has the next highest priority. In IPO-synchronous
tasks, you can implemenut time-critical functions that have a direct effect on the
functions of a telchnology object. The user program is executed before system
ne
IPO_2Task
Ask well as the interpolation level there is a second interpolation level
(IPOSynchronousTask_2 or DCC time slice T3). While the IPO level is intended
for automating highly dynamic axes, the IPO2 level can be used for controlling
axes with less dynamic characteristics (auxiliary axes).
om Priority
Temp. control
T4 DccAux task
T5 DccAux task
Avera
SystemInterrupt ge
Event-driven SystemInterrupt tasks
tasks
l.c
execution levels
Wait For Condition
TimerInterrupt
TimerInterrupttasks
tasks
ai
UserInterrupt tasks
SIMOTION
Siemens AG 2013. All rights reserved.
Background Task
System startup
gm
Date:
File:
10.01.2013
MotionTasks
MotionTasks
System stop
MC-SMO-PROG_06.5
SITRAIN Training for
Automation and Drives
@
Temperature For temperature control in connection with the associated technology package,
control execution levels are available for actual value acquisition, control, and pulse
width modulation of the output signals.
er
T4 DccAux task/ As of V4.1, blocks assigned to runtime group (time slice) T4/T5 are processed
T5 DccAux_2 task at this level. The time frames for these tasks are set when configuring the
system clocks.
ez
Freely executing The BackgroundTask and the 32 MotionTasks share the lowest priority
execution level on what is known as the round robin level. Within this level, an additional time
slice multiplex method ensures that they are assigned free computing time.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_06.6
SITRAIN Training for
Automation and Drives
@
Servo_fast/IPO_fast As of V4.2, you can operate synchronous devices (drive, measuring input, or
output cam output, I/Os) on the fast bus system (PROFINET) via Servo_fast.
Servo_fast always finishes during the first send clock of the fast bus system with
this type of arrangement. This makes it possible to operate two bus systems in
er
different application cycle clocks. An assigned position control cycle clock and
IPO cycle clock are available for each of the two application cycle clocks.
A second position control cycle clock is only necessary in applications with
special requirements, e.g.:
ez
• For fast I/O processing via PROFINET IO (for particularly short sampling
times and response times)
• If, in addition to the electric axes (e.g. servo drives), hydraulic axes
with particularly high-performance pressure/position control are implemented
r.s
Since most electric servo axes are operated with DSC (Dynamic Servo Control),
the part of the position controller that acts dynamically in the drive runs at the
clock rate of the speed control circuit (i.e. usually 125 μs on SINAMICS S120).
As a result, a split at servo level is usually reserved for hydraulic drives, so that
ca
Note For V4.3, only the SIMOTION modules SIMOTION D435-2 DP/PN, D445-2
DP/PN and SIMOTION D455-2 DP/PN support the second position control cycle
clock.
om
DP Sl. Sl. Sl. Acycl. Sl. Sl. Sl.
GC Res. GC
communication ... 1 2 3 part 1 2 3 ...
T dx
l.c
Drives Ts
Ta Sl: Slave communication (bidirectional)
ai
GC: Global control message frame
Actual values T a: Time of actual value acquisition
T s: Time of setpoint transfer Setpoints
T dx: Sum of transfer times for all slaves
SIMOTION
Siemens AG 2013. All rights reserved.
T dp:
PCT:
BT:
DP cycle time
gm
Position controller
BackgroundTask
Date:
File:
10.01.2013
MC-SMO-PROG_06.7
SITRAIN Training for
Automation and Drives
@
Isochronous mode If high-precision positioning must be performed on PROFIBUS DP, this requires
short, reproducible (i.e. of the same length) cycles with defined actual value
acquisition, position control, and setpoint output.
With SIMOTION, the equidistant (isochronous) DP bus cycles and
er
DP cycle time Cyclic data exchange with the slaves is carried out in this time frame. This time
frame depends on the number of slaves, the data to be transferred, the baud
rate, and additional factors. In addition to pure data exchange, sufficient time
r.s
must be provided for the position control to allow calculation of new speed
setpoints for the drives.
T dx The time duration that is necessary for data exchange to be performed with the
configured slaves is specified in this parameter. This time is calculated internally
ne
There is an assurance that data can be exchanged with all the slaves during this
time duration. After this time has expired, the position controller starts
processing the data.
ca
Global control SIMOTION outputs the global control message frame at the beginning of each
cycle for the purpose of synchronizing the drives with SIMOTION.
Ta Describes the length of time which expires before the GC message frame is
broadcast for the drives to save their actual values to. This ensures that all
actual values are acquired at the same time.
Ts Describes the length of time which expires after the GC message frame is
broadcast for the drives to accept the transferred setpoints.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_06.8
SITRAIN Training for
Automation and Drives
@
Bus cycle clock Specifies the basic clock cycle and is generally grayed out. Is only displayed if an
isochronous bus has been parameterized for the interface. The basic/bus cycle clock
(DP cycle clock or PN cycle clock) is used as a basis for setting further tasks.
er
The integer ratio between the position control cycle clock and the bus cycle clock is
Servo/T1 (DCC) set here. In this clock cycle, the blmocks in DCC charts, those of time slice T1, the
user programs of the ServoSynchronousTask and, among others, the position control
of the axes are perocessed. Generally, factor 1 is applied. If a different ratio is
ez
selected, it must aliso be entered in the HW Config for the drive as the "master
application cycsle". This setting is used for life-sign monitoring.
IPO/T2 (DCC) The integer ratio between @the IPO cycle clock and the position control cycle clock is
r.s
set here. By default, the DCC blocks of time slot 2, the programs of the
IPOSynchronousTask , and motion control (i.e. calculation of the position setpoints for
positioun axes) are processed in the IPO cycle clock.
IPO_2/T3 (DCC) The ratio betgween the IPO_2 and IPO cycle clocks is set here. The DCC blocks in
ne
time slice T3, the programs of IPOSynchronousTask, and motion control for axes with
less dynamic characteristics (auxiliary axes) are processed in this task.
The intervals for DCC time slices T4 and T5 are set here.
ca
DxxAux/DccAux_2
TControl Use this arrow to open the configuration of the system tasks for the TControl
technology package. The cycle clock ratios for the temperature channels task in
Copy aserynchr. relation to the position control cycle clock are set in this dialog.
cyclic I/O data
As of V4.2, you can select when the asynchronous cyclic I/O data should be
copied. The copy operation can be performed in either the IPO cycle clock or the
IPO_2 cycle clock.
om
IPOSynchronousTask T2/T3 2 +1(fast)
DccAuxTask T4/T5 2
TimerInterruptTask 5
l.c
TimeFaultBackgroundTask 1
TechnologicalFaultTask 1
PeripheralFaultTask 1
ai
ExecutionFaultTask 1
Event-controlled user UserInterruptTask 2
SIMOTION
Round robin level
Date:
File:
10.01.2013
MC-SMO-PROG_06.9
1
32 (as of V4.0)
BackgroundTask This task is called cyclically. When the programs in this task have been
processed, the task is automatically restarted. This task implements the
conventional interlock functions of a PLC.
ez
MotionTasks MotionTasks are tasks that are started from within a cyclic user program, for
example, and are then processed only once.
ServoSynchronous This task is processed in synchronism with the servo task. In this task, fast
task terminal-to-terminal responses can be programmed, for example.
r.s
IPOSynchronous These tasks are started synchronously with the specified system cycle clock
tasks (IPO cycle clock, IPO_2 cycle clock) before the technology package. They can
be used to implement time-critical functions for starting and stopping axes, for
example.
ne
T4/T5 DccAux task The blocks of DCC charts that are assigned to time slices T4 and/or T5 are
processed in these tasks.
TimerInterruptTasks TimerInterrupt Tasks are started and processed at fixed intervals and can be
ca
used to implement control tasks that need a fixed time reference, for example.
For temperature control using the associated technology package, additional
tasks are available.
UserInterruptTasks These are event-triggered and processed only once. They can be used to
respond to user-defined events.
SystemInterrupt These are triggered by system events such as faults and alarms and
tasks processed only once.
om
2. Select task
l.c
3. Select program
ai
4. Assign program
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_06.10
SITRAIN Training for
Automation and Drives
@
Execution levels tree The execution levels tree is displayed in the left-hand section of the execution
system. The available execution levels/tasks are displayed as fixed entries. The
OperationLevel folder contains the tasks that are available in RUN. To open the
OperationLevel folder, click the plus sign in front of it.
er
The list below each execution level or task name shows the configured tasks
and the programs assigned to them. After you have assigned programs to tasks,
they are displayed in the execution levels tree.
ez
Click the "Select tasks" entry to display a list of all configurable tasks in the right-
hand section. Check the box next to the task you want to display in the
execution levels tree. The right-hand section contains an overview of all
execution levels and tasks.
r.s
Assignment of 1. Open the execution system dialog by double-clicking the "execution system"
programs icon.
2. Select the required task. Make sure that the "Use task in execution system"
option is selected.
3. Click the "Program assignment" tab. In the "Programs" list box on the left-
ne
hand side, select the program you wish to assign to the task.
4. Click "Assign >>". The assigned program is displayed in the list box on the
right and in the execution levels tree. The "Programs" list box on the left still
displays the program; the number of assignments that have been made is
displayed in brackets after the program.
ca
Note With DCC, blocks are assigned to time slices T1 through T5 and thus to the
corresponding tasks within the DCC editor.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_06.11
SITRAIN Training for
Automation and Drives
@
Task runtimes The statuses and runtimes of the individual tasks can be read out using the
device diagnostics of the control system.
Call Via the device (for example D425-2) -> Target device -> device diagnostics, you
er
Overview Task name, task status, actual, miniemum, maximum and the average value
task runtimes are displayed for each taski in the overview.
The task status can also be read sout using the system function
(_getStateOfTask) and processed in the user program.
r.s
ne
ca
om
System variables of the SIMOTION device
• TaskRuntime
• EffectiveTaskRuntime
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_06.12
SITRAIN Training for
Automation and Drives
@
System variables The task runtimes can also be read out via the associated system variables of
the SIMOTION device. For this functionality, measurement of the task runtime
must first be activated via the following system variable:
• TaskRunTimeMonitoring = active
er
Then the task runtimes are provided by the system in the associated system
variables.
The task runtimes alone, i.e. the runtime excluding interruptions by higher-
ez
TaskRunTime
priority levels, are displayed in this system variable.
Effective The task runtimes including inte srruptions by higher-priority levels are
TaskRunTime displayed in this system variable. The following always applies:
r.s
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_06.13
SITRAIN Training for
Automation and Drives
@
Overview The "SIMOTION Task Trace" supports you when troubleshooting in the
SIMOTION multitasking environment. The SIMOTION Task Trace records the
sequence of individual tasks, identifies user events that you can generate via a
program command, and displays these graphically. This makes the interaction
er
between programs and tasks easily traceable, thereby affording better control
over them.
Task Trace - The SIMOTION Task Trace includes two main components:
ez
structure • The SIMOTION Task Tracer, which writes the task change and events to a
buffer on the target device
• The SIMOTION Task Profiler, an application for displaying the recorded data
SIMOTION IT DIAG (standard web pages) is used to configure the SIMOTION
r.s
Task Tracer. The recording data is saved as a JEN file on the memory card of
the target device.
If you start the Task Profiler via the device diagnostics, the trace data is
automatically read from the memory card via the online connection and
displayed. Alternatively, you can also save the JEN file from the target device to
ne
the file system of the PC using the SIMOTION standard web pages and then
open the file in the SIMOTION Task Profiler.
Start task trace Start the Task Profiler in the device diagnostics as described below: Switch to
the "Task Manager" tab. The following options are available:
ca
Click the "Display" button. The Task Profiler starts. In addition, the trace file is
loaded from the memory card of the target device and opened in a new tab in
the Task Profiler. If you click the button again, the same file is read again.
Click the "Create snapshot" button. The setting that you have made using IT-
Diag is reset to the default state. The settings made using the SIMOTION.ini file
are retained. The Task Trace is started, written to the memory card, and then
the Task Profiler started. If you click the button again, a new recording is started.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_06.14
SITRAIN Training for
Automation and Drives
@
Configuration SIMOTION IT DIAG (standard web pages) is used to configure the SIMOTION
Task Tracer. The recording data is saved as a JEN file on the memory card of
the target device. If you start the Task Profiler via the device diagnostics, the
trace data is automatically read from the memory card via the online connection
er
and displayed. Alternatively, you can also save the JEN file from the target
device to the file system of the PC using the SIMOTION standard web pages
and then open the file in the SIMOTION Task Profiler.
ez
Note The button "Get Trace File" offers a further possibility to upload and store a
Trace file, from the SIMOTION memory card to the PG/PC. Afterwards the trace
file could be opened and displayed via the trace profiler.
The trace profiler could also be opened using the Windows start menu:
r.s
om
_taskTraceStart() : UDINT Starts the task trace recording
l.c
_taskTraceUserEvent(UDINT) : This function stores an event with the
UDINT event number (freely selectable ID
between 0 and 255) in the buffer of the
SIMOTION Task Tracers
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_06.15
SITRAIN Training for
Automation and Drives
@
Control The Task Tracer could be configured using either the tool "SIMOTION IT DIAG"
(standard web pages of the target system) or via system functions which were
called in the user program.
er
Note The data of the task tracer, which was stopped by _taskTraceWriteOut() are
stored in a JEN File (ttrace.jen) on the memory card of the target system. This
JEN file is stored in following directory:
ez
/USER/SIMOTION/HMI/SYSLOG/TASKTRACE/DIAG
r.s
ne
ca
Commands for kernel versions <= V3.0 Commands as of kernel versions V3.1
Example: Example:
_startTask ( // Only short form _startTaskId (
om
name : Task_Name // MotionTasks only id : StructTaskId // MotionTasks only
) : VOID ) : DWORD
Assignment: Assignment:
<name>: MotionTask_1, ... <id>: _task.MotionTask_1
• Only "constants" permitted for <name> e.g. • MotionTask identified via its "Id"
l.c
MotionTask_1, etc., no variables possible • Variables can be used
for <name> • Can be used in libraries
• Cannot be used in libraries • Can be called in LAD/FBD
• Cannot be called in LAD/FBD • Both call variants possible
ai
• Only short form of call permitted
Determination of "Id":
• _task.MotionTask_1
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
• _getTaskId(Task_Name)
10.01.2013
MC-SMO-PROG_06.16
SITRAIN Training for
Automation and Drives
@
Special features There are generally two groups of functions for processing tasks in SIMOTION.
The differences between them are to be found in how tasks are defined:
The task is defined with a unique TaskId:
These functions are available in SIMOTION Kernel V3.1 and higher and can be
er
used in libraries.
You can obtain the TaskId for a task in the folloewing two ways:
• As the task.name variable, where namme designates the task as defined
in the execution system (e.g. _task.MotionTask_1)
ez
Command Description
_getMaximalTaskIdRunTime(taskId): TIME Returns the maximum runtime of the task since the last
transition from STOP to RUN, including all interruptions by
_getMaximalTaskRunTime(name): TIME
higher-priority tasks.
om
_getMinimalTaskIdRunTime(taskId): TIME Returns the minimum runtime of the task since the last
transition from STOP to RUN, including all interruptions by
_getMinimalTaskRunTime(name): TIME
higher-priority tasks.
_getCurrentTaskIdRunTime(taskId): TIME Returns the runtime of the task from the previous cycle,
including all interruptions by higher-priority tasks.
_getCurrentTaskRunTime(name): TIME
l.c
_getAverageTaskIdRunTime(taskId): TIME This command returns an average runtime of the task
from the last 10 cycles, including all interruptions by
_getAverageTaskRunTime(name): TIME
higher-priority tasks.
ai
The function is applicable to MotionTasks,
_retriggerTaskControlTime(name): DWORD
BackgroundTask, TimerInterruptTasks,
UserInterruptTasks, SystemInterruptTasks.
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_06.17
SITRAIN Training for
Automation and Drives
@
Special features The commands for runtime measurement are permissible for all tasks.
Measurement is not supported by the IPOsynchronousTask and the
ShutDownTask. For calls involving tasks which do not support measurement, 0
is returned as the measured value.
er
The commands may only be called in the short form, i.e. with a complete listing
of all parameter values, but without specification of the formal parameters.
r.s
ne
ca
om
_resetTaskId(taskId) : DWORD Resets a MotionTask to the original state
_resetTask(name) : VOID TASK_STATE_STOPPED.
_restartTaskId(taskId) : DWORD Resets a MotionTask to the original state TASK_STATE_STOPPED
and restarts it; the startup code (initialization of variables) is
_restartTask(name) : VOID executed.
_suspendTaskId(taskId) : DWORD The relevant task is suspended; for cyclic tasks, time monitoring is
suspended.
l.c
_suspendTask(name) : VOID Cannot be used for IPOsynchronousTask, StartupTask, and
ShutdownTask.
_resumeTaskId(taskId) : DWORD The relevant task is resumed; time monitoring is resumed.
Cannot be used for IPOsynchronousTask, StartupTask, and
_resumeTask(name) : VOID ShutdownTask.
ai
_getStateOfTaskId(taskId) : DWORD Returns the state of the relevant task.
_getStateOfTask(name) : DWORD
_disableScheduler() : DINT Prevents scheduling of all user tasks except ServoSynchTask,
_enableScheduler() : DINT
SIMOTION
Siemens AG 2013. All rights reserved.
gm
IPOsynchTask, and IPOsynchTask_2
Re-enables scheduling of user tasks
Date:
File:
10.01.2013
MC-SMO-PROG_06.18
SITRAIN Training for
Automation and Drives
@
Controlling Various commands are available for controlling tasks. The parameter name
tasks represents the task name as indicated in the execution system (e.g.
"MotionTask_1", "IPOsynchronousTask", "StartupTask", "BackgroundTask",
etc.).
er
The commands may only be called in the short form, i.e. with a complete listing
of all parameter values, but without specification of the formal parameters.
_getStateOfTaskId
Determine task BOOL EN ENO BOOL
state StructTaskId id OUT DWORD
om
Return value "OUT" indicates ORing of the following states:
• 16#0000:
Specified task does not exist (TASK_STATE_INVALID)
• 16#0001:
Transition from RUN to STOP (TASK_STATE_STOP_PENDING)
l.c
• 16#0002:
Task stopped (TASK_STATE_STOPPED)
• 16#0004:
Task running (TASK_STATE_RUNNING)
• 16#0010:
Task waiting (TASK_STATE_WAITING)
• 16#0020:
Task suspended (TASK_STATE_SUSPENDED)
ai
• 16#0040:
TimerInterruptTask waiting for next cycle
(TASK_STATE_WAIT_NEXT_CYCLE)
• 16#0080 UserInterruptTask or SystemInterruptTask waiting for
next event (TASK_STATE_WAIT_NEXT_INTERRUPT)
SIMOTION
Siemens AG 2013. All rights reserved.
gm
• 16#0100 Task locked by _disableScheduler (TASK_STATE_LOCKED)
Date:
File:
10.01.2013
MC-SMO-PROG_06.19
SITRAIN Training for
Automation and Drives
@
Task states This functions returns the state of the relevant task. It can be used for all tasks
except StartupTask and ShutdownTask.
This function requires the task name as an input parameter and returns a value
of data type DWORD, from which the task state can be derived.
er
• WAITFORCONDITION
TS TS • _waitTime() TS
_INVALID _WAITING _RUNNING
(16#0000) (16#0010) Condition fulfilled (16#0004) _
r es
e
om
d tT
kI as
T as kI
nd d
pe d
us kI
_s
_restartTaskId
as
MT completed
T
me
t
su TS_STOP
up
e
_r
rr
_PENDING
TS_
te
d
(16#0001)
te
in
SUSPENDED
l.c
le
xt
(16#0020)
mp
Ne
Co
TS
ai
_WAIT_NEXT TS
TS _CYCLE TS
_STOPPED
_LOCKED (16#0040) _WAIT_NEXT
(16#0002)
(16#0100) _INTERRUPT
SIMOTION
_disableScheduler
_enableScheduler
10.01.2013
MC-SMO-PROG_06.20
SITRAIN Training for
Automation and Drives
@
TS_INVALID The task does not exist in the execution system. It is not used in the execution
system’s parameterization.
TS_STOP_PENDIING Task has received signal to stop; however, it is in a state between RUNNING
er
TS_STOPPED The task has been stopped due to the following actions:
• The _resetTaskId() function has been camlled
ez
• _waitTime()g
• WAITFORCoONDITION...
TS_SUSPENDED
ca
om
TSI#taskId Task that caused the error
(system error tasks)
TSI#interruptId Event that triggered the call
comparison operation, e.g.
TSI#alarmNumber Alarm number of triggering TO TSI#taskId = _task.MotionTask_1
l.c
TSI#toInst Instance of triggering TO
TSI#commandIdlow ID of causing command
(low word)
TSI#commandIdhigh ID of causing command
ai
(high word)
TSI#executionFaultType Type of processing error
. . . ...
SIMOTION
Siemens AG 2013. All rights reserved.
Date:
File:
gm 10.01.2013
MC-SMO-PROG_06.21
SITRAIN Training for
Automation and Drives
@
TaskStartInfo Important information about starting the task is stored in the TaskStartInfo for
each task, e.g.:
• Start time of task
• For the TechnologicalFaultTask: the triggering instance of the technology
er
and the type of error (divide by zero, invalid floating-point number, etc.)
Within a task, its TaskStartInfo can be queried with the following system
variable:
• TSI#<info> (<info> is the information to be queried)
r.s
The content and scope of the TaskStartInfo and the associated system variables
depend on the relevant task.
ne
ca
IMPLEMENTATION
EXPRESSION myExpression // Declaration of an EXPRESSION
myExpression := IOfeedCam; // always with retVal equals BOOL
om
END_EXPRESSION
// feeder is assigned to MotionTask_1
PROGRAM feeder
VAR
retVal : DINT ;
END_VAR ;
; // further commands
l.c
WAITFORCONDITION myExpression WITH TRUE DO
retVal := _pos(axis := Achse_1,
positioningMode := RELATIVE,
position := 500,
velocityType := DIRECT,
ai
velocity:= 300,
mergeMode:= IMMEDIATELY,
nextCommand := WHEN_MOTION_DONE);
END_WAITFORCONDITION;
SIMOTION
;
END_PROGRAM
END_IMPLEMENTATION
Date:
File:
10.01.2013
MC-SMO-PROG_06.22
SITRAIN Training for
Automation and Drives
@
Properties You can use the WAITFORCONDITION statement to wait for a programmable
event or condition in a MotionTask. The statement suspends execution of the calling
MotionTask until the condition is true. In the mean time the MotionTask is witched to
the task state TASK_STATE_WAITING.
er
The evaluation of the Expression is performed by the system an the end of the
IPO Task. If the expression evaluates to TRUE, the MotionTask is switched from the
task state TASK_STATE_WAITIN to TmASK_STATE_RUNNING, i.e. it is
competing with the other tasks in that state to be dispatched to the processors.
ez
task in the round-robin execution level, as well as before the UserInterruptTasks and
TimerInterruptTasks.
This increased task pr iority applies to all statements between the
WAITFORCONDITuION command and the END_WAITFORCONDITION command.
The lEND_WAITFORCONDITION command ends the increased task priority.
ne
• The MotionTask waiting for the event is switched to the task state
TASK_STATE_WAITING, i.e. the MotionTask does not consume any
processor load. Only a small amount of processor load is required by the
system to evaluate the EXPRESSION.
• Due to the increase of the execution priority, the MotionTask will be the next
task which is dispatched to the processor when the EXPRESSION returns
with TRUE. So in maximum one has a delay of one IPO cycle until the
response, e.g. start or stop of axis motion will be effective.
om
• TYPE
VAR_INPUT
myInput : BOOL; • VAR und VAR_CONSTANT
. . . • VAR_INPUT und VAR_IN_OUT
END_VAR In the instruction part access is permitted to the
VAR_INOUT following variables:
. . .
END_VAR • local variables and parameters
l.c
; • Unit variables
myExpression := . . .; • global device variables
END_EXPRESSION • IO variables and process image variables
An expression of type BOOL must be assigned
PROGRAM feeder to the "Expression name" (return value)
ai
. . .
WAITFORCONDITION myExpression(…)
Instructions between WAITFORCONDITION
WITH TRUE DO
and END_WAITFORCONDITION are executed
; // Instructions with high priority with a higher priority to avoid task switches
SIMOTION
END_WAITFORCONDITION;
END_IMPLEMENTATION
10.01.2013
MC-SMO-PROG_06.23
SITRAIN Training for
Automation and Drives
@
Expression For the use of the WAITFORCONITION instruction the declaration of a so-
called "Expression" is necessary. An "Expression" is a special case of a function
declaration. The data type of the return value is always defined as BOOL, it is
not specified explicitly in the declaration.
er
• Local constants
• User-defined data types (UDT)
• Input and in-out parameters (as of Version V4.1 of the SIMOTION kernel)
The following can be accessed in the statement section:
r.s
Execution system
om
IMPLEMENTATION IMPLEMENTATION
MotionTask 2
PROGRAM motion2 //Motion Task2
PROGRAM motion1 //Motion Task1
WHILE TRUE DO
IF _testAndSetSemaphore(mysema) IF _testAndSetSemaphore(mysema)
THEN THEN
my_struc.a := a;
l.c
my_var_a := my_struc.a;
my_var_b := my_struc.b; my_struc.b := b;
_releaseSemaphore (mySema); _releaseSemaphore (mySema);
MotionTask 1
END_IF; END_IF;
END_WHILE;
END_PROGRAM
ai
END_PROGRAM
END_IMPLEMENTATION
SIMOTION
Siemens AG 2013. All rights reserved.
Date:
File:
gm 10.01.2013
END_IMPLEMENTATION
MC-SMO-PROG_06.24
SITRAIN Training for
Automation and Drives
@
Inconsistent All accesses to variables of elementary data types are managed consistently by
access the system. The system makes sure that changes cannot be made to these
variables while they are being processed.
However, where access to global compound variables is concerned (derived
er
data types STRUCT, ARRAY), users are responsible for ensuring data
consistency. Inconsistencies can occur when several tasks access the same
variables (symbolic I/O variables, system variables of SIMOTION devices and
technology objects, global device variables and unit variables).
ez
1. If its original content is 0, the value TRUE is returned. The semaphore was
free and access is, therefore, permitted.
If its original content is 1, the value FALSE is returned. The semaphore is not
free and access is, therefore, not permitted.
Release Following consistent access, a set semaphore can be released again (i.e. its
content reset to 0) with the _releaseSemaphore() system function.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.1
SITRAIN Training for
Automation and Drives
@
Contents Page
How synchronous operation is structured in SIMOTION ................................................................... 3
Camming in SIMOTION ..................................................................................................................... 4
er
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.2
SITRAIN Training for
Automation and Drives
@
Contents Page
Leading synchronization, changing the leading axis velocity (2) ....................................................... 27
Synchronization without overshoot (engagement) ............................................................................. 28
er
Master value
• Position axis External
• Following axis encoder
• Ext. encoder Virtual
• Virtual axis axis
Slave value
om
Leading
Synchro-
axis
nous
operation
Settings TO
l.c
• Master value Master value
• Gear ratio
• Synchronization and
desynchronization profile
ai
Buffer IPO Servo
• Limitations of use
SIMOTION
• Monitoring functions
Date:
File:
10.01.2013
MC-SMO-PRG_07.3
SITRAIN Training for
Automation and Drives
@
How synchronous The "Synchronous operation" technology object is used to connect two
operation is or more axes to create a synchronous group.
structured A leading axis (master) generates a master value, which is processed by the
synchronous object according to specific criteria (gear ratio, scaling, cam, etc.)
er
value.
The master and slave values arse coupled without physical conversion in the
relevant parameterized units. If the leading axis is a linear axis (unit mm), for
example, and the following axis is a rotary axis (unit degrees), then with a
r.s
Mechanical Mechanically, the suynchronous object represents the gear with driving gear/
model driven gear or, inl conjunction with the "Cam" TO, the cam gear with the
mechanical cam and sensor system. The model also includes a coupling for
ne
Coupling via The geaelr functionality is characterized by a constant ratio between master
gear value source and following axis. The ratio can either be programmed as a
rational gear factor or using a numerator/denominator ratio.
ca
The slave value is calculated from the programmed gear factor and the master
value and transferred to the gear axis. A following axis can be interconnected
with more than one master value by means of the synchronous object, but only
one of these is evaluated. At runtime, you can switch over the master setpoint in
the user program.
When you select the gearing, you differentiate between absolute and relative
synchronous operation. You can also select from different types of
synchronization/desynchronization profile (related to master value or time).
Master value
• Position axis External
• Following axis encoder
• Ext. encoder Virtual
• Virtual axis Cam_1
axis
om
Slave value
Leading Cam_2
axis TO Synchro-
nous
operation Cam_3
Settings
• Master value
TO
l.c
• Cam
• Scalings Master value
• Synchronization and
desynchronization profile
ai
Buffer IPO Servo
SIMOTION
• Monitoring functions
synchronous operation, a following axis does not receive its position setpoints
from one synchronous operation TO but from two, i.e. the basic synchronous
operation TO and a superimposed synchronous operation TO.
Several cams can be used in camming. You can switch from one cam to
another in the user program during runtime.
r.s
• The synchronous object and the following axis are permanently assigned to
one other in the configuration
• The master value object (position axis, virtual axis, following axis or external
encoder) can be interconnected with several synchronous objects
ca
om
Synchronous operation
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.5
SITRAIN Training for
Automation and Drives
@
Create synchronous If the "synchronous operation" technology is selected when creating an axis in
object SIMOTION SCOUT, SIMOTION SCOUT will automatically create a
synchronous object belonging to the axis.
The synchronous object appears in the project navigator underneath the
er
Assignments Master value and cam assignments are indmicated in the SIMOTION
ez
used
• The link to the synchr@onous object is displayed underneath the
"master values" (axes, external encoder)
These assignments are made in the "Interconnections" dialog (see next slide).
ne
ca
om
• Setpoint coupling
• Actual value coupling
with extrapolation
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.6
SITRAIN Training for
Automation and Drives
@
Interconnections Assignments between the synchronous object and possible leading axes and
cams are made in the "Interconnections" dialog. This dialog opens when you
double-click Interconnections under the <AxisName>_SYNCHRONOUS
OPERATION object in the project navigator.
er
In this dialog, the possible master values and cams are assigned to the
synchronous object of the following axis. The currently used master value/active
cam is defined during runtime using the appropriate functions.
ez
Setpoint and actual With real axes, you can also choose between setpoint and actual value
value coupling coupling. External encoders only support actual value coupling, virtual axes only
support setpoint coupling.
With actual value coupling, the reference value for the actual value coupling
r.s
Notes Gearing or camming with a following axis is only possible if at least one master
value has been assigned to the associated synchronous object
ne
Expert list You can access all configuration data and system variables of the synchronous
object via the expert list. You can open the expert list by selecting Expert ->
Expert list from the synchronous object's context menu.
ca
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.7
SITRAIN Training for
Automation and Drives
@
Configuration The most important configuration settings for synchronous operation can be
made in this dialog.
Abs. synchr. with For absolute synchronization, if "Yes" is set the jerk is taken into account.
consideration of jerk If "No" is set, the set jerk will be ignored in spite of velocity profile = SMOOTH
ez
Adaptation of Adaptation to the leading axis dynamic response in the synchronous position
r.s
Overdrive Overdrive factor for the adapted dynamic response values to compensate
factor a remaining path difference (syncingMotion.overdriveFactor) The value is
ne
specified in percent (%). Reference to the current master value velocity for the
start of synchronization.
Tolerance for Tolerance window for aborting synchronization for direction reversal of the
direction reversal master values (syncingMotion.masterReversionTolerance). Position value in the
ca
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.8
SITRAIN Training for
Automation and Drives
@
Setting default Default settings for synchronous operation are made in the "Default" dialog. In
parameters this dialog, parameters (defaults) for calling synchronous operation functions
are set. However, these parameters are only evaluated if no special settings
have been made in the associated function calls for synchronization/
er
Gearing
on
Specification of master
and following axes
om
Specification of direction
and gear ratio
Select:
l.c
• Absolute or
• Relative
gearing
ai
Settings for transition
behavior and program
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.9
advance
Here you select the following axis for synchronization. All axes of the device for
er
Following axis
which the synchronous operation functionality has been configured as well as
all variables of the MCC chart with data type "followingAxis" are available for
selection.
ez
Here you select the axis or external encoder which supplies the master value
Leading axis in the synchronous relationship. You can choose from all position axes,
following axes, and external encoders as well as from all variables of the MCC
chart with data type: posAxis, followingAxis, or externalEncoderType.
r.s
ratio
as a nominator/denominator pair or as a floating-point number.
Nominator/ Here you select the type of synchronous operation. SIMOTION diff
denominator
Check this box to reset the master value of the synchronous operationrentiates
ca
om
Slave value Slave value
l.c
g g
ai
Slave value = g x master value + φ
SIMOTION
(can be specified in system function call
"Synchronize")
Absolute With absolute gearing, i.e. "Gearing takes place relative to axis zero"
gearing (gearingType = ABSOLUTE), the master values and slave values are
ez
interpreted as absolute. This means that any offset between master value and
slave value existing prior to synchronization is compensated.
After completion of the synchronization procedure, both the velocities and the
positions of the leading axis and the following axis are identical (φ = 0) or a
r.s
defined phase relationship (φ <> 0) has been established between the positions
of leading axis and following axis.
A phase (φ ) can be specified if: "Start of synchronization: at leading axis with
offset" or "Synchronize immediately with offset" is selected.
ne
Relative With relative gearing, i.e. "Gearing takes place relative to start position"
gearing (gearingType = RELATIVE), a synchronization profile is calculated so that only
the velocities of the leading axis and the following axis are adapted in
accordance with the gear ratio.
An offset existing before synchronization or additional phase (φ' ) resulting from
ca
Selection of synchroni-
zation reference:
• Leading axis
om
• Time
l.c
Settings for transition
behavior and program
ai
advance
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.11
SITRAIN Training for
Automation and Drives
@
Programming On the "Synchronization" tab of the MCC command "Gearing ON", you can
gearing make settings for the synchronization reference as well for synchronization
positions and lengths.
er
At leading axis position: Synchronization starts once the leading axis has
reached a specific position. Select "Gearing takes place relative to axis zero" for
absolute position synchronous operation (φ = 0). An additional phase offset
(φ <>0) is not possible.
r.s
At leading axis position with offset: Synchronization starts once the leading axis
has reached a specific position.
Select "Gearing takes place relative to axis zero" for absolute position
synchronous operation. In this case, an additional phase offset (φ) can be
specified between leading axis and following axis.
ne
Leading axis
velocity
om
Position
Leading axis
Position
l.c
Following axis Leading axis position
Start End
Synchronization length
ai
Leading-axis-related synchronization profile
• Specification of synchronization position -> Start and end positions are clearly defined,
and synchronization length dynamic parameters are not effective
SIMOTION
Siemens AG 2013. All rights reserved.
gm
• SIMOTION uses the positions of the following axis and the ratio of the velocities of the following
and leading axes at the start and the end to calculate the synchronization profile
Date:
File:
10.01.2013
MC-SMO-PRG_07.12
SITRAIN Training for
Automation and Drives
@
Synchronization The profile for synchronization can reference the leading axis or time. In ST and
reference LAD, the profile can be selected using the function parameter
syncProfileReference.
• Leading axis (syncProfileReference = relate_sync_profile_to_leading_value)
er
Master-value-related
With master-value-related synchroinization, a start value or an end value for
ez
The synchronization profile between start and end is specified as a cubic spline
(SyncingMotion.VelocityMode = CONTINUOUS):
y = a0 + a1*x + a2 * xu 2 + a3 * x3 (y: following axis position, x: leading axis position)
The coefficients la0 ... a3 are calculated using the 4 conditions for the positions of
ne
the following axis and the inclines (ratio of the velocities of the following and
leading axes = gear ratio) at the start and at the end of the profile.
Setting the lparameters in this way ensures that the synchronous operation TO has
synchronized the leading axis and the following axis at a specific position, but
without consideration of the dynamic parameters from the "Dynamic response" tab.
ca
If any limits (velocity, acceleration, etc.) are exceeded during synchronization, they
are not applied until the TO of the following axis.
Note Setting SyncingMotion.VelocityMode = NON_CONTINUOUS calculates a non-
continuous synchronization profile. In this case, a straight line joins the start and end
point.
Following axis
Synch. position
om
l.c
Leading axis
ai
Synchronize before synchronization position
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Synchronize symmetrically
Synchronize from synchronization position
Date:
File:
10.01.2013
MC-SMO-PRG_07.13
SITRAIN Training for
Automation and Drives
@
Reference point of The "Reference point of leading axis" (syncPosition-Reference) parameter is
leading axis position used to manipulate the position of the synchronization point during
synchronization:
Synchronize from synchronization position (syncPositionReference =
er
aborted with the error melssage "50007: Error occurred while activating/
deactivating the synchronous operation" if the leading axis reversed during
leading axis synchronization. Asg of V4.0, a tolerance window can be defined
for aborting the synchoronization procedure if the master value was reversed
(syncinlgMotion.masterReversionTolerance).
ca
Leading axis
Retain system behavior (SYSTEM_DEFINED): Following
axis
(as originally in versions <= 3.0)
om
Leading axis
Shortest path (SHORTEST_WAY) Following
axis
l.c
Positive direction (POSITIVE_DIRECTION)
ai
Maintain direction of the following axis (SAME_DIRECTION)
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.14
SITRAIN Training for
Automation and Drives
@
Functionality Depending on the difference between the leading axis and the following axis,
many machines require synchronization related to the positive direction, negative
direction, or shortest path. This function is relevant, for example, for modulo axes,
for which synchronization is possible in both directions. With non-modulo axes,
er
SYSTEM_DEFINED Retain present system behavior (as in <= V3.0). In case of a moving slave axis, a
check is made to determine whether the direction of motion can be retained.
r.s
SAME_DIRECTION The same direction of motion of the following axis at the synchronization point is
also retained for the synchronization phase (same direction of motion). As such, it
also depends on the master direction of motion.
ne
SHORTEST_WAY Synchronize to the "shortest way", regardless of which direction of motion results
in the synchronization phase.
om
gearingnumerator, // Gear ratio numerator
gearingdenominator, // Gear ratio denominator
synchronizingmode, // Synchr., lead. axis pos.?, immediate?..
syncpositionreference, // Before, after, symmetrical?
syncprofilereference, // Leading-axis-related or time-related
synclengthtype, // Type "Synch.length": direct,...?
synclength, //Synchronization length
l.c
syncpositionmastertype, // Type "Lead. axis pos.": direct, user-def.?
syncpositionmaster, // Leading axis position
syncpositionslavetype, // Type "Slave offset": direct,...?
syncpositionslave, // "Offset in slave direction"
velocitytype, // Type "Veloc.": direct, user-def.?
ai
velocity, // Velocity: Only if direct
. . ., // Remaining dynamic parameters
mergemode, // Substitute, attach, etc.?
nextcommand, // Wait for ... ?
SIMOTION
Commandid,
gm
synchronizingDirection);// Specific. of synchronization direction
// (V3.1 specifically for rotary axes)
Date:
File:
10.01.2013
MC-SMO-PRG_07.15
SITRAIN Training for
Automation and Drives
@
_enablegearing The _enablegearing system function is used to enable gearing in the ST
language.
ST MCC
er
om
Sensor
Position
l.c
Synchronization
length
ai
Following axis position =
Leading axis position
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.16
Time
axis
• The following axis is not reversed at the start of synchronization
Settings
settings:
• Synchronization reference: leadsiing axis
• Start of synchronization: at leading axis position
• Reference of the lead@ing axis position: symmetrical
r.s
Additionally, the position of the following axis must be the same as the position
of the leading axis at the start of synchronization:
Following axislu position = leading axis position
With these settings, the velocity of the following axis is increased to the
ne
velocity of the leading axis in a linear fashion. The acceleration of the following
axis is dependent of the synchronization length.
With tehe following axis at rest, the acceleration of the following axis can be
calculated as follows:
ca
Position
Leading axis
GL-TO.current-
syncposition.
slave
om
GL-TO.current-
syncposition.
master
l.c
Following axis
Time
ai
Start of synchronization: Synchronicity:
GL-TO.state = gearing GL-TO.syncstate = yes
FA-TO.syncmonitoring. FA-TO.syncmonitoring.
SIMOTION
Siemens AG 2013. All rights reserved.
gm
followingmotionstate = BASIC_MOTION_ACTIVE
Date:
File:
10.01.2013
MC-SMO-PRG_07.17
syncstate = yes
GL-TO.state The state system variable at the synchronous object indicates whether gearing
er
GL-TO.syncstate This system variable displays the state of synchronicity between leading axis
and following axis at the synchronous object. If the leading axis and the
following axis are synchronized, this variable is set to "yes".
The start of desynchronization or any other loss of synchronization causes the
r.s
Note The syncstate system variable being set to "yes" simply indicates that following
calculation of the synchronous object, the leading axis value supplied (GL-TO.
currentmasterdata.value) and the slave value output at the TO of the following
ne
Sync. position The synchronization position of each of the leading axis and the following axis,
i.e. the position from which the leading axis and the following axis are operating
in synchronism, is saved in the following two variables:
• GL-TO.currentsyncposition.master
• GL-TO.currentsyncposition.slave
om
Master velocity (10 mm/s) Slave velocity
"state"
"syncstate"
Master pos.
l.c
Slave pos.
ai
Gearing: Absolute, i.e. relative to axis zero
Gear ratio: 1:1
SIMOTION
Synchronize:
Synchronization length:
Reference point: Gearing takes place relative to axis zero (absolute gearing, i.e.
position synchronous operation)
ez
Execution The synchronous operation TO of the following axis calculates the required
position/angle reference between leading axis and following axis from the
specified leading axis position and the synchronization length.
In this case, synchronization is initiated immediately. A parabolic acceleration
ramp is used to accelerate the speed of the following axis to that of the leading
ne
axis. At the end of the synchronization length (30 mm), the position of both axes
is synchronous.
ca
"syncstate"
"state"
om
Master velocity (10 mm/s)
Master pos.
l.c
Slave pos.
Slave velocity
ai
Gearing: Relative, i.e. relative to start position
Gear ratio: 1:1
SIMOTION
Synchronize:
Synchronization length:
Reference point: Gearing takes place relative to start position (relative gearing,
i.e. velocity gearing)
ez
Leading axis
velocity
om
Position
Leading axis
Position
l.c
Following axis Time
Start End
ai
• Specification of dynamic parameters -> SIMOTION calculates a time-related
and a position synchronization profile
SIMOTION
• Start position
• End position
10.01.2013
MC-SMO-PRG_07.20
SITRAIN Training for
Automation and Drives
@
Time-related When time-related synchronization is selected, SIMOTION calculates the
synchronization synchronization profile using a specified position and the parameters from the
"Dynamic response" tab.
Dependent upon whether the start or end position of the synchronization
er
• Trailing synchronization:
ez
Notes
(syncPositionReference = be_synchronous_at_position).
• "Symmetrical" cannot be selected for time-related synchronization.
The command is rejected with the following error message:
"030001 - Alarm followingObjectType
ne
Illegal parameter"
ca
Leading axis
velocity
om
Position
Leading axis
Position
l.c
Following axis Time
Start position
ai
Trailing synchronization profile
• Specification of start position
• Velocity
SIMOTION
• Acceleration
At the start, the following axis is accelerated to the specified velocity at the rate
of acceleration indicated. At the end of synchronization, the target velocity of the
leading axis is reached.
ez
Notes • If the velocity of the leading axis changes during the synchronization
procedure, the synchronization profile is recalculated. The end point of the
synchronization procedure is then brought forward (reduction in velocity of
leading axis) or put back (increase in velocity of leading axis) accordingly.
r.s
"state"
Slave velocity
om
"syncstate"
Slave pos.
l.c
Master pos.
ai
Gearing: Absolute, i.e. relative to axis zero
Synchronization direction: Shortest path
Synchronize: From leading axis position 150 mm
SIMOTION
Velocity:
Acceleration:
Jerk:
Date:
File:
gm 10.01.2013
MC-SMO-PRG_07.22
SITRAIN Training for
Automation and Drives
@
Trailing This diagram illustrates synchronization with a trailing synchronization profile.
synchronization The following settings have been made on the individual tabs:
Reference point: Gearing takes place relative to axis zero (absolute gearing, i.e.
position synchronous operation)
ez
position
r.s
mm. At the end of the jerk phase, the velocity of the following axis is accelerated
in a linear fashion along the programmed acceleration ramp to the programmed
velocity.
At the end of the constant motion phase, the following axis is synchronized with
the dynamic response of the leading axis in accordance with the specified
parameters.
Slave velocity
om
Master pos. Slave pos.
"syncstate"
l.c
"state"
Master velocity
ai
Gearing: Absolute, i.e. relative to axis zero
Synchronization direction: Shortest path
Synchronize: From leading axis position 150 mm
SIMOTION
Velocity:
Acceleration:
Jerk:
Reference point: Gearing takes place relative to axis zero (absolute gearing, i.e.
position synchronous operation)
Synchronization reference: Time
ez
position
Leading axis position: 150 mm
r.s
velocity.
The leading axis reverses in the middle of the deceleration phase. If the
"Extended look-ahead" setting has not been selected, the following axis will
overtake the leading axis at the start of deceleration and synchronize accordingly
with the leading axis subsequently.
Specified velocity
Position/Velocity and acceleration
syncingMotion.
maximumOfMasterChange
om
Actual velocity and
acceleration
Leading axis
velocity
Position
l.c
Leading axis
Position
Following axis
Time
ai
End position
Leading synchronization profile
• Specification of end position
SIMOTION
• Velocity
• Acceleration
following axis change accordingly. If the tolerance band specified with the
configuration data item syncingMotion.maximumOfMasterChange is overshot or
undershot, the following error message is displayed:
• 050009 - Alarm followingObjectType
ca
Note If the leading axis reverses its direction of motion during synchronization by
more than the values specified in the settings in the tolerance window,
synchronization is aborted with the following error message:
• 050007 - Alarm followingObjectType
Error while activating/deactivating synchronous operation
Slave velocity
"state"
om
"syncstate"
Master pos.
Slave pos.
l.c
Gearing: Absolute, i.e. relative to axis zero
ai
Gear ratio: 1:1
Synchronize: to leading axis position 800 mm
Velocity: 200 mm/s
Acceleration: 500 mm/s2
SIMOTION
Jerk:
MaxOfMasterChange:
Synchronize
synchronization
position
Leading axis position: 800
r.s
@mm
Dynamic response Velocity: 200 mm/s
position. At the start, the following axis is accelerated to the reduced velocity
(160 mm/s) along the reduced acceleration ramp ("MaxOfMasterChange" =
20%).
When the brake is applied, the following axis is decelerated to the leading axis
velocity along the reduced brake ramp. The following axis runs in synchronism
with the leading axis from the 800 mm position.
"state"
Slave velocity
om
"syncstate"
Master pos.
Master velocity (110 mm/s)
l.c
Slave pos.
ai
Gear ratio: 1:1
Synchronize: to leading axis position 800 mm
Velocity: 200 mm/s
SIMOTION
Acceleration:
Jerk:
MaxOfMasterChange:
synchronization
position
Leading axis position: 800 mm
r.s
MaxOfMasterCghange: 20%
The sylnchronous operation TO of the following axis calculates a time-related
Execution synchronization profile using the specified velocity and acceleration of the
following axis and assuming constant leading axis velocity.
Synchronization is started at the optimum time before the synchronization
ca
position. The following axis is accelerated to the reduced velocity (160 mm/s)
along the reduced acceleration ramp.
After this, the leading axis velocity is increased from 100 mm/s to 110 mm/s
(< 20%). If the synchronization profile is not recalculated, there is a percentage
increase (10%) in the velocity of the following axis.
At the original point of brake application, the following axis is then decelerated to
the leading axis velocity in a linear fashion along an increased brake ramp. The
following axis runs in synchronism with the leading axis from the 800 mm position.
Slave velocity
"state"
om
"syncstate"
Master pos.
Master velocity (150 mm/s)
l.c
Slave pos.
ai
Gearing: Absolute, i.e. relative to axis zero
Gear ratio: 1:1
Synchronize: to leading axis position 800 mm
Velocity: 200 mm/s
SIMOTION
Acceleration:
Jerk:
MaxOfMasterChange:
Reference point: Gearing takes place relative to axis zero (absolute gearing, i.e.
position synchronous operation)
ez
MaxOfMasterChange: 20%
Execution In this case, in the constant motion phase, the velocity of the leading axis is
increased from 100 mm/s to 150 mm/s (> 20%). If the synchronization profile is
ca
not recalculated, there will also be a percentage increase (50%) in the velocity
of the following axis.
The following alarm is also output:
050009 - Alarm followingObjectType
Changing the dynamic response of the master leads to a dynamic violation
when synchronizing and desynchronizing.
If the following axis is able to follow the dynamic response, the synchronization
point (800 mm) is retained.
Leading axis
velocity
om
Position
Following axis
Position
l.c
Leading axis Following axis velocity
Time
ai
End position
Leading synchronization profile
• Specification of end position
SIMOTION
• Acceleration
• Jerk
maximum of the velocity value in the synchronous operation command and the
leading axis velocity with overdrive factor.
The following axis always synchronizes with the leading axis correctly, even if
the velocity of the leading axis changes during synchronization. Error messages
are only displayed if the dynamic values of the synchronous operation TO are
ne
violated or changed.
Notes • If the leading axis velocity increases during synchronization, the overdrive
factor must be set to slightly higher than 100% (e.g. 100.001%).
ca
"state"
"syncstate"
om
Master velocity (100 mm/s)
Slave velocity
l.c
Gearing: Absolute, i.e. relative to axis zero
ai
Gear ratio: 1:1
Synchronize: to leading axis position 50 mm
Velocity: 1 mm/s
Acceleration: 500 mm/s2
SIMOTION
Jerk:
MaxOfMasterChange:
Date:
File:
10.01.2013
MC-SMO-PRG_07.29
SITRAIN Training for
Automation and Drives
@
Leading This diagram illustrates synchronization with a leading synchronization profile.
synchronization The following settings have been made:
Gear ratio: 1 : 1
Parameters Reference point: Gearing takes place relative eto axis zero (absolute gearing,
er
Synchronize
synchronization
position
Leading axis position: 50 mm@
r.s
om
Settings for:
• Velocity profile
• Velocity
• Acceleration
l.c
• Jerk
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.30
SITRAIN Training for
Automation and Drives
@
Dynamic response Settings for the velocity profile, velocities, acceleration, and jerk of the axis
during synchronization and desynchronization are made on the "Dynamic
response" tab.
These dynamic settings can only be entered when selecting a time-related
er
om
Variables for recording the
• CommandId
and the return value of:
• Set master setpoint
l.c
• Camming on
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.31
SITRAIN Training for
Automation and Drives
@
CommandId The status of motion commands can be tracked with the CommandId, which is
unique throughout a project. Previously, the CommandId was reserved for use
in ST programming. However, as of V4.0, it can also be used in MCC
commands.
er
If you enter the name of a variable of data type CommandIdType, you can track
the command status with this variable. The variable (data type: DINT) must
previously have been declared in the MCC source file or in the MCC chart.
If the "Assign value" box is checked, a CommandId that is unique throughout the
ez
If the field is left blank, no variables are assigned to the CommandId parameter
of the command. If the field is blank, the "Assign value" box must be checked.
Return values Many MCC commands are mapped to one or more system functions. They
ne
usually send a return value to the user indicating whether or not the call has
been successful.
If a variable of the specified data type is entered, the return value of the
command step is saved in this variable. The variable must previously have been
declared in the MCC source file or in the MCC chart.
ca
If the field is left blank, the return value of the command step is assigned to an
internal variable which cannot be accessed by the MCC chart (default setting).
Gearing off
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.32
SITRAIN Training for
Automation and Drives
@
Gearing Gearing is disabled in a similar way to that in which it is enabled. You simply
have to enter the leading axis and the following axis for which gearing is to be
disabled on the "Parameters" tab.
The type of desynchronization is specified on the "Desynchronization" tab. The
er
possible parameter settings are exactly the same as those for synchronization.
Either a leading-axis-related or a time-relamted synchronization profile can be
Synchronization selected here. As with synchronization:
reference
ez
Leading axis/follow- If the position of the leading or following axis has been selected as the
ing axis position desynchronization position, the required position can be specified here.
Disable gearing
RetVal := _disablegearing(
followingobject, // Specification of synchronous object
syncoffmode, // Master or slave pos.?
syncoffpositionreference,//Before/after leading axis pos., symm.?
syncprofilereference, // Leading-axis-related or time-related
om
syncofflengthtype, // Type "Desynch. length", direct,...?
syncofflength, // Desynchronization length
syncoffpositionmastertype,// Type "Lead. axis pos.": direct,
user-def.?
syncoffpositionmaster, // Leading axis position
syncoffpositionslavetype,// Type "Slave pos.": direct,...?
syncoffpositionslave, // Slave position
l.c
velocitytype, // Type "Veloc.": direct, user-def.?
velocity, // Velocity: Only if direct
. . ., // Remaining dynamic parameters
mergemode, // Substitute, attach, etc.?
nextcommand, // Wait for ... ?
ai
commandid); // Command ID
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.33
SITRAIN Training for
Automation and Drives
@
_disablegearing This function is used to deselect gearing:
MCC ST
er
Velocity gearing
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.34
SITRAIN Training for
Automation and Drives
@
Velocity Unlike gearing or camming, velocity gearing relates not to the position of an axis
gearing but to its velocity, with constant gear ratio between master value source and
following axis.
With velocity gearing, non-position-controlled (i.e. speed-controlled)
er
operation velocity or from the synchronous operation velocity to the new target
velocity.
Direction The gear ratio can be set in the same direction or in the opposite direction
(corresponding to a negative gear ratio) using the "Gear direction" parameter.
ca
Monitoring The syncMonitoring system variable on the following axis also displays the
status of velocity gearing (as of V3.1):
• differenceCommandVelocity: Setpoint difference in velocity between
master and slave (only valid for velocity gearing).
• differenceActualVelocity: Actual difference in velocity between
master and slave (only valid for velocity gearing).
om
positiveacceltype, // Dynamic parameters for synchronization
positiveaccel, // procedure
negativeacceltype, //
negativeaccel, //
positiveaccelstartjerktype, //
positiveaccelstartjerk, //
l.c
positiveaccelendjerktype, //
positiveaccelendjerk, //
negativeaccelstartjerktype, //
negativeaccelstartjerk, //
negativeaccelendjerktype, //
ai
negativeaccelendjerk, //
velocityprofile, //
mergemode, // Attach, substitute, etc.
SIMOTION
nextcommand,
commandid);
om
l.c
ai
Assignment of a leading axis (master) to a synchronous object
RetVal := _setmaster(
followingobject, // Specification of synchronous object
SIMOTION
master,
...);
10.01.2013
MC-SMO-PRG_07.36
SITRAIN Training for
Automation and Drives
@
Set This command switches the master setpoint for an existing synchronous
master/slave operation relationship. The master/slave can be set when synchronous
operation is active.
The _setMaster() command is used to assign a new master value source to a
er
synchronous object. When it is enabled, the master values are referenced to the
units system of the current master value source.
Transition process A relative or absolute coupling influences the transition process. The transition
ez
behavior when the master value source is set is different for absolute
synchronous operation and relative synchronous operation.
• With a relative coupling, an additional slave value discrepancy occurs only if
the dynamic master values are different with regard to velocity and
r.s
acceleration.
• With absolute coupling, a non-continuous master value transition can occur.
Slave value monitoring at the following axis limits discontinuities in the slave
values to the maximum dynamic axis parameters; compensating motion is
generated in some cases.
ne
Different modulo settings of the master value sources are taken into account.
The dynamic parameters for the compensating motion can also be included in
the command. To include them in the command, select "With programmed
dynamic values" in the "Transition behavior" field. Selecting "Direct" might lead
to a reduction in the dynamic values in the following axis TO.
ca
Compensating motion
Slave velocity
"state"
om
_setMaster
Master_2
Slave pos.
Master_1
"syncstate"
l.c
Slave velocity
ai
Gearing: Absolute, i.e. relative to zero
Gear ratio: 1:1
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.37
SITRAIN Training for
Automation and Drives
@
General This diagram shows a switch on-the-fly between two master values with an
absolute synchronous operation coupling. In this case, synchronous operation
monitoring of the position setpoint had been disabled.
er
Execution First, the following axis is synchronized with the axis position of Master_1. The
synchronization procedure starts at the Mastere_1 position of 70 mm and is
completed at 110 mm.
With a Master_2 position of 180 mm, the _setmasm ter call is sent to the
ez
synchronous object of the following axis with the new master value of Master_2.
Since the following axis is in absolute position synchronous operation,
compensating motion is started firsit to move the following axis to the set
position of Master_2. This compensatings motion is executed with the specified
r.s
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.38
SITRAIN Training for
Automation and Drives
@
Functionality With gearing, this function activates an offset in the master or slave range. A
master range offset moves a straight line which has not moved forward in the X
direction. A slave range offset moves the straight line forward in the Y direction.
The dynamic values for the transition can also be specified. The current and
er
Range Here you select whether the leading axis or following axis range will be offset.
ez
Offset Offset for the selected range. Enter the value as a signed floating-point number.
r.s
Effect Make a selection from this dropdown list box defining when the programmed
offset comes into effect:
ca
On active command (default value) The offset acts on the active gearing
command and remains active until this command is replaced or
desynchronization is activated with the "Gearing off" command.
On following commands: The active gearing command is executed; the offset is
stored and acts on subsequent "Gearing on" commands.
On active command and the following commands: The offset acts on the current
gearing command and all subsequent "Gearing on" commands.
om
velocity, // compensating motion
positiveacceltype, //
positiveaccel, //
negativeacceltype, //
negativeaccel, //
positiveaccelstartjerktype, //
l.c
positiveaccelstartjerk, //
positiveaccelendjerktype, //
positiveaccelendjerk, //
negativeaccelstartjerktype, //
negativeaccelstartjerk, //
ai
negativeaccelendjerktype, //
negativeaccelendjerk, //
velocityprofile, //
nextcommand, //
SIMOTION
commandid,
activationmode);
10.01.2013
MC-SMO-PRG_07.39
SITRAIN Training for
Automation and Drives
@
ActivationMode This parameter is also used to specify whether or not the _setgearingOffset
command is to act on the currently active gearing or on commands sent
subsequently.
• ACTUAL_VALUE
er
The offset acts on the active gearing and remains active until this is substituted
or gearing or desynchronized with the "_disablegearing" command.
• DEFAULT_VALUE
The active gearing command is executed, the offset is not taken into account for
ez
this command. The offset sis saved and acts on subsequent gearing commands.
• ACTUAL_AND_DEFAUL@T_VALUE
The offset acts on the current gearing command and on all subsequent
commands.
r.s
ne
ca
om
masterposition // DIRECT only
);
l.c
_Retstructretgetvalue :=_getmastervalue(
followingobject, // Specification of
synchronous object
slavepositiontype, // CURRENT or DIRECT?
ai
slaveposition // DIRECT only
masterapproachpositiontype, // DIRECT or NONE
masterapproachposition // DIRECT only
);
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.40
SITRAIN Training for
Automation and Drives
@
General Commands that calculate values and supply them as return values are available
for reading out master value positions and slave value positions in pairs:
• When the master value position is programmed, the associated slave value
position is read out (_getSlaveValue)
er
• When the slave value position is programmed, the associated master value
position is read out (_getMasterValue)
ez
_getSlaveValue The _getSlaveValue command supplies the slave value at a specified master
value position. The following is applicable:
• When the master value position is CURRENT, the current slave value is
always returned, regardless of whether or not a synchronous relationship is
active.
r.s
• When the master value position is DIRECT, the specified master value
position is used. This command only supplies the correct slave value
position, if a synchronous relationship is active and synchronized.
• If camming is active, the cam must be interconnected and interpolated when
the command is executed.
ne
_getMasterValue The _getMasterValue command supplies the master value at a specified slave
value position (inverse mapping). The following is applicable:
• When the slave value position is CURRENT, the current master value is
ca
om
Extrapolation at the leading axis for actual value coupling:
TypeOfAxis.Extrapolation.extrapolationTime
TypeOfAxis.Extrapolation.ExtrapolationPositionFilter
l.c
extrapolationData.position
Filtered Position
actual position 2 x PT1 filter Extrapolation Velocity
ai
extrapolationData.velocity
Filtered PT1 filter or mean
actual velocity value generation
SIMOTION
Siemens AG 2013. All rights reserved.
gm
TypeOfAxis.Extrapolation.Filter
Date:
File:
10.01.2013
MC-SMO-PRG_07.41
extrapolationData.filteredvelocity
interface of the leading axis is used. With an external encoder, only the actual
value interface is available.
Extrapolation Extrapolation compensates the local delays (dead times) resulting from using
ez
the actual value instead of the setpoint. Extrapolation is set and parameterized
at the leading axis with the following configuration data item. If 0.0 is entered,
there is no extrapolation.
• Extrapolation time (extrapolation.extrapolationTime).
r.s
Extrapolation starts with the smoothed velocity value being multiplied by the
extrapolation time. The resulting position offset is added to the smoothed
position value and sent to the synchronous operation TO of the following axis as
a new master value.
ne
Smoothing of the So that the position can be extrapolated accurately, the actual velocity must be
actual velocity smoothed accordingly so the "nervous" position changes by the encoder do not
lead to dramatic changes in actual velocity (by differentiation of the encoder
values).
As of V4.2, the individual signals and the parameter settings of the individual
ca
filters can be monitored and made respectively in the new signal flow dialogs.
The signal flow for extrapolation is found at the leading axis under the entry:
Signal flow -> Extrapolation
Extrapolation time
om
Actual
position filter
Actual
l.c
velocity filter
ai
Hysteresis
settings
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.42
SITRAIN Training for
Automation and Drives
@
Smoothing of The position actual value is smoothed by connecting two PT1 filters in series.
of the position The corresponding time constants are set in the following configuration data:
• Time constant 1 (Extrapolation.PositionFilter.T1)
er
Hysteresis In addition, a hysteresis element can be activated for the position value before
the master values are sent to the synchronous operation TO of the following axis
ez
(not shown in the diagram on this slide). The hysteresis element prevents the
would-be "reversing" of the leading axis in the event of "nervous" position
values.
With a leading-axis-related synchronization strategy, reversing the leading axis
would abort the synchronization procedure. The activation and size of the
r.s
With the hysteresis active, it is also possible to select whether the velocity sent
to the synchronous operation TO of the following axis is generated from the
extrapolated position actual value (including hysteresis) by differentiation or the
extrapolated actual velocity is simply used.
• Extrapolation.extrapolatedVelocitySwitch
ca
Note The SRC\ 4_TOOLS directory on the Utilities & Applications CD contains the
"EXTRAPOLATION_EN_V1.1.XLS" program which will assist you in calculating
extrapolation times.
The extrapolation time can only be set exactly by recording the corresponding
actual positions of the leading and following axes with the trace tool.
LA LA
...
...
LA LA
CAM CAM
om
Synchronous Synchronous_
...
...
object object_1
CAM CAM
l.c
Following axis
ai
Basic synchronous object: Superimposed synchronous object:
SyncingMotion.motionImpact: SyncingMotion.motionImpact:
"Standard" "SuperImposed_Motion"
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.43
LA:
CAM:
Leading axis
Cam
Note Only one connection can be configured to each leading axis. Connections
ez
cannot be configured from the basic synchronous object and from the
superimposed synchronous object to the same leading axis.
Functions The functions for superimposed synchronization can be used in ST, LAD, and
MCC alike. All functions familiar from the basic synchronous object can be used
r.s
Coordinate system As in the case of a superimposed motion, each synchronous object has its own
ca
coordinate system. The "outputs" of the synchronous objects are added together
in the TO of the following axis. The output values of a synchronous object (and
thus also the motion component of the superimposed synchronous operation for
the axis) can be read out in the "currentSlaveData" system variables of the
synchronous object concerned.
The positions and dynamic values of the basic motion are also provided within
the TO of the following axis via the "basicmotion" system variable; the positions
and dynamic values of the superimposed motion are provided via the
"superimposedmotion" system variable.
Axis_2
om
Axis_1
Filler Molds
l.c
Sensor
Sheet
ai
Conveyor belt External encoder
(not driven by SIMOTION)
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.44
SITRAIN Training for
Automation and Drives
@
Filling chocolate The above slide illustrates the principle of a "filling installation" for chocolate
molds molds. The filling installation essentially consists of the conveyor belt and the
chocolate hopper.
The conveyor belt is not controlled by SIMOTION, but by a higher-level control
er
system. Producing various chocolate shapes - such as frogs, dog bones, balls,
etc. - involves a highly complex chain of processes where many stations are
connected in series.
To coordinate the chain of processes connected in series, the higher-level
ez
control system needs to continuously change the velocity of the conveyor belt.
The "chocolate mold filling station" must adjust to these conditions.
Filling motionless When the hopper fills a single motionless mold, it has to traverse to the origin
r.s
sheets of each mold and then traverse the appropriate contour relative to the sheet.
Where more chocolate is required in a mold due to its shape (e.g. the ends of a
dog bone), the hopper needs to remain in this position for longer; in places
where less chocolate is required in the mold (middle of a dog bone), the hopper
must move more quickly.
ne
Filling moving Sheets are transported at different speeds on the conveyor belt. To meet the
sheets requirements for speed variation, Axis_1 can be synchronized with the motion of
ca
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_07.45
SITRAIN Training for
Automation and Drives
@
Insert super- In the SIMOTION project navigator, you can insert a maximum of one additional
imposed object superimposed synchronous object under a following axis. To do this, proceed as
follows:
1. Select the required following axis in the project navigator.
er
called <Axis_n_SYNC_2>.
CAM
Leading Synchro-
...
axis nous
object
CAM
om
Following
PROFIBUS axis
master
l.c
Synchro- CAM Synchro- CAM
nous nous
...
...
object object
ai
CAM CAM
Following Following
axis axis
SIMOTION
Siemens AG 2013. All rights reserved.
...
PROFIBUS
slave_1 gm
...
Date:
File:
10.01.2013
MC-SMO-PRG_07.46
PROFIBUS
slave_n
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.1
SITRAIN Training for
Automation and Drives
@
Contents Page
Using cams in SIMOTION .................................................................................................................. 2
Creating a cam ................................................................................................................................... 3
er
External Slave
Virtual- encoder Cam_1
axis Camming
Master Cam_2
operation
axis Synchro-
nous TO
Cam_3
Master
om
Folgeachse
Axis position/
-speed
l.c
Time
Speed//pressure
ai
Characteristics of valves
SIMOTION
Siemens AG 2013. All rights reserved.
gm
(hydraulic axis)
Date:
File:
10.01.2013
MC-SMO-PRG_08.2
Voltage
• Input variable is the actual position of a leading axis, i.e. a virtual master
value source, a voltage applied at a valve, or the time
• Output variable is e.g. the position of a following axis, the velocity of an axis,
etc.
ez
• With the "hydraulic axis TO" as a valve characteristic curve or inverted valve
characteristic curve.
ca
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.3
SITRAIN Training for
Automation and Drives
@
Cams Cams are stand-alone technology objects. Cams can be created, configured,
and parameterized with the SCOUT interface and then downloaded to the target
device.
Like other technology objects, cams can be modified at runtime using system
er
function calls. Cams have system variables which provide information about the
current state.
Creating Cams can be created and edited in SIMOTION SCOUT using the CamEdit tool
ez
cams or with the optional add-on SIMOTION CamTool. Which tool is to be used to edit
a cam must be defined when the cam is created.
The following two options are available for selection under the "Cams" folder:
• Insert cams (edit with CamEdit)
r.s
Converting Cams created with CamEdit can subsequently be converted to CamTool and
cams vice versa. Corresponding commands for converting cams are available in the
ne
Exporting and Cams can also be both exported and imported. The Expert context menu
importing cams contains corresponding commands for export and import operations.
ca
om
Velocity
l.c
Acceleration
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.4
SITRAIN Training for
Automation and Drives
@
CamEdit The CamEdit cam editor is used to describe cams by means of either
interpolation points or segments. These two methods cannot be combined. One
of them must be selected when the cam is created. This selection cannot be
changed at a later date.
er
If the cam is being defined using interpolation points, a linear, cubic or Bezier
spline can be selected for the interpolation type.
If the cam is being created using segments, CamEdit provides the VDI wizard
for describing the segments.
ez
CamTool With SIMOTION CamTool, you can use fixed points, straight lines, sine curves,
arc sine curves, and interpolation points to create cam segments.
SIMOTION CamTool calculates interpolation curves between the individual cam
r.s
Defining cams Cams stored in a device can be manipulated from within the user program with
with ST ST commands. Cams cannot be created with the user program. System
commands can only be used to modify cams already stored in the SIMOTION
device.
ca
Name
Selection:
• Polynomial
• Interpolation point table
om
Slave value
l.c
= interpolation points
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Start value
Date:
File:
10.01.2013
Master range
MC-SMO-PRG_08.5
End value
Master
value
One of these must be selected when the cam is created. This selection cannot
be changed at a later date.
Definition based on Interpolation points are represented in the form P = P(x,y) in interpolation point
ez
interpolation points tables. The order in which the value pairs are entered is irrelevant. They are
automatically sorted in the defineition range in ascending order.
SIMOTION interpolates between the indiividual interpolation points according
to the parameterized "interpolatsion type".
r.s
Definition based on Individual segments are des@cribed in accordance with "VDI Directive 2143",
Advantages and
disadvantages Definition blased on interpolation points
Definition based on segments
Advantages: Less data used for definition
ca
Simple definition
Any algorithms can be mapped by Standard transitions in
interpolation points accordance with VDI
Curve creation assisted by teach-in Contour is very precise
Simple interface to HMI
Continuous transitions
Large number of interpolation points Complex arithmetic required for
Disadvantages: for precise contour required calculation of coefficients
om
l.c
Define interpolation points
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
Basic form of interpolation point table
10.01.2013
MC-SMO-PRG_08.6
SITRAIN Training for
Automation and Drives
@
General Creating the cam geometry as an interpolation point table. The cam
characteristic is specified in the form of an interpolation point table. The cam
itself is created by interpolation between the points in the table.
er
Entering inter- The table for entering the interpolation points contains a master column and a
polation points slave column. It appears on the left-hand side of the CamEdit editor. The values
for the interpolation points of the master and slave axes can be entered
unsorted. When the cam is displayed, they are listed sorted automatically.
ez
One or more lines of the table can be selected by clicking with the mouse or
using a drag-and-drop operation on the entries in the first column.
Context menu The following functions for the lines in the table are accessed via the commands
r.s
in the context menu for the interpolation table (opened by right-clicking with the
mouse):
• Delete Contents: Deletes one or a number of selected lines
• Delete Lines: Deletes one or a number of selected lines from the
interpolation point table
ne
• Insert Line: Inserts a blank line in front of the selected line in the table
• Insert Lines: Inserts a number of lines in front of the selected line
• Sort Table: Sorts the table in ascending order of master values
ca
Draw basic form Select this option to draw the curve of the table entered in the right-hand section
of the editor window. When the cam is displayed, the individual points are linked
by means of straight lines. If an interpolation type has been defined, it is not
taken into account.
om
Interpolation type:
• Linear
l.c
• Cubic splines
• Bezier splines
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.7
SITRAIN Training for
Automation and Drives
@
"Interpolation When you create a new cam based on an interpolation point table, you can
type" tab select the interpolation types to be used by the SIMOTION target device for
interpolation between the individual interpolation points on the "Interpolation"
tab.
er
The following options are available for selection in the "Interpolation type"
selection box:
• Linear: The individual interpolation poinmts in the table are
interpolated by means of linear segments. This results in discontinuities with
ez
as it were.
Note The speclified interpolation type is transferred only to the target device which
created the actual cam characteristic curve from a predefined interpolation point
table. The resulting interpolation curve for the interpolation points entered is not
ca
om
l.c
Cubic splines Bezier splines
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.8
SITRAIN Training for
Automation and Drives
@
Displaying To visualize the actual curve form, in online mode, for example, you
cams download the cam with the selected interpolation type (linear, cubic splines,
Bezier splines) to the SIMOTION device and then upload it again.
The SIMOTION target device converts the downloaded interpolation point table
er
into the appropriate polynomial segments. Then, when the cam is uploaded,
these polynomial segments are visualized when the "Display uploaded cam"
option is selected.
The uploaded cam can be added to the SCOUT project by clicking the Accept
ez
button.
project download.
ne
ca
Maintain gaps
om
min
max
l.c
Merge points
ai
min
max
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.9
Add new
segment
• If the distance lies between the "Maieintain gaps" entry and the "Merge
points" entry, the gap is corrected bys merging the end points of the segments.
The mean value of the dist ance is calculated for this purpose. The shape of the
relevant segments changes as a result.
r.s
Overlapping Conversely, if indlividual segments overlap, the cam segment with priority can
be selected in theg "If segments overlap" selection box.
ne
Cam type
• Non-cyclic
• Cyclic relative
• Cyclic absolute
om
Master range
l.c
Non-cyclic Cyclic relative Cyclic absolute
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.10
SITRAIN Training for
Automation and Drives
@
Master range Under "Master range", you can define the range between the starting point and
the end point of the cam (definition range). Activate "From geometry" to define
the smallest and largest coordinate entered for the leading axis as the start and
end points of the definition range respectively. Defining the range like this
er
means that there are no gaps at the start and end of the cam.
If the "From geometry" option is not selected, ethe definition range of the cam
can be defined by entering values in the "Start" and "End" input fields. The value
in the "Start" input field must always be less than or equal to the smallest
coordinate specified for the leading axis inm the interpolation point table; the
ez
value in "End" must always be greater than oer equal to the largest coordinate
specified for the leading axis in the interpolatiion point table.
If the value specified for "Start" iss a lot smaller than the range of the cam
covered by the interpolation points and the value for "End" is much larger than
it, gaps will appear at the st@art and the end of the cam.
r.s
The "Cam type" selec tion box tells the SIMOTION target device whether the
Cam type characteristic of the ucam downloaded is absolute, cyclic absolute, or cyclic
relative.
ne
Dependent gupon this selection, the target system makes specific changes at
the start and end oof the cam.
Non-cycllic: The SIMOTION device does not make any changes to the cam.
SIMOTION assumes that the cam will have an absolute characteristic when it is
ca
subsequently activated.
om
Original cam with cubic spline
Non-cyclic
interpolation
l.c
ai
SIMOTION
Cyclic absolute
If this is not possible, an error message is displayed accordingly when the cam is
downloaded. So that the target device can peerform interpolation at these transition
points, a small "gap" might need to be created at the end or start of the cam.
Otherwise, in some cases, the dynammic response of synchronous operation
ez
starting point. If this is not possible, an error message is displayed accordingly when
the ca@m is downloaded (as is the case with cyclic absolute).
Note
The procedure follo wed by the SIMOTION device is clear in particular at cams
where there is a gap at uthe start or end. This effect can be illustrated by
ne
Aftekr this, the possible entries for "Cam type" ("absolute", "cyclic absolute", and
"cyclic relative") were varied and the cam was downloaded to and then uploaded
from the target device.
Scalings
Scaled and offset
curve
om
Basic curve
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.12
SITRAIN Training for
Automation and Drives
@
Scaling and You can scale and offset the cam geometry previously defined. You can scale
offsetting the leading axis and following axis or individual sections of these axes
separately. Separate settings can be made for offsetting the leading axis and the
following axis.
er
You can use this functionality on a packaging machine, for example, to adapt a
previously configured cam to varying product lengths.
Basic scaling Basic scaling can be specified for every axis. The scaling factor is entered in the
ez
"Basic scaling" input field. The coordinate origin always forms the center of
basic scaling.
Scaling 1/2 Two ranges for basic scaling can be set for each axis. A separate scaling factor
r.s
Offset Use "Offset" to specify a factor for offsetting the master and following axis,
respectively. The offset refers to the previously scaled cam or the basic form if
you have not scaled the range.
ca
Notes • Select the "Draw scaled and offset" option to draw in the scaled and offset
cam with the basic form.
• The functions for scaling and offsetting a cam can also be used at runtime
via corresponding system functions, provided that the cam is not active
(e.g. _enablecamming(...).
So, at runtime, a downloaded cam can be adapted to meet different
requirements such as varying product lengths, etc.
om
Double-click
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.13
SITRAIN Training for
Automation and Drives
@
Cam type: Once a new polynomial type cam has been created, the geometry of the
Polynomial individual segments can be created. A cam defined based on polynomials
consists of any number of individual segments.
Each cam segment is described as a polynomial of up to the 6th degree which
er
• A definition range (normalized range) for the polynomial and the sine
The definition range is defined in the table with the xn1 and xn2 entries.
• A polynomial P(x) of up to the 6th degree with coefficients a0, ..., a6
P(x) = a0 + a1 * x2 + a3 * x3 + a4 * x4 + a5 * x5 + a6* x6 with arguments x from
definition range xn1, xn2.
r.s
• A master range x1, x2. The definition range xn1, ..., xn2 of the function
is mapped to this master range, i.e. xn1 to x1 and xn2 to x2
• A corresponding slave range (value range) y1, y2. The value range of the
function F(x) with arguments from the definition range is mapped to this
ca
range, i.e. the minimum of the function F(x) is mapped to y1 and the
maximum is mapped to y2
R G U R
Slave value
om
l.c
Master value
ai
R: Dwell (velocity = 0, acceleration = 0)
G: Constant velocity (velocity ≠ 0, acceleration = 0)
U: Reversal (velocity = 0, acceleration ≠ 0)
B: Motion(velocity ≠ 0, acceleration ≠ 0)
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.14
SITRAIN Training for
Automation and Drives
@
General Calculating coefficients for segments of cams manually is usually incredibly
difficult. For this reason, the "CamEdit" tool features the VDI wizard to assist
users when creating cams.
er
VDI 2143 The VDI concept describes the entire cam characteristic by putting together
what are known as working ranges linked by motion transitions. Working ranges
are the sequences of a process.
VDI defines four different types of working range:
ez
Motion transitions are transitions between working ranges, which are not directly
relevant to the process but must satisfy certain boundary conditions (such as
continuity in velocity and acceleration).
ne
VDI wizard A cam consists of individual motion segments and transitions. The VDI wizard
must be executed once for each motion segment or transition. The VDI wizard
provides 2 predefined motion segments (constant velocity and dwell) plus 16
motion transitions. Motion segments and transitions are also parameterized in
the wizard.
ca
The VDI wizard uses the input values to calculate the corresponding coefficients
for the polynomials and enters these in the selected line of the table.
2. Enter geometry
data
1. Select
motion transition
om
l.c
3. Preview
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.15
SITRAIN Training for
Automation and Drives
@
Creating geometry The VDI wizard provides a user-friendly means of creating the geometry data of
data with the wizard a cam and entering it in the table.
1. To open the VDI wizard, either select the menu command:
Cam -> VDI wizard or press the "VDI wizard" button. The VDI wizard is
er
displayed.
2. In the "Type of Motion Transition" dialog, select the required motion segment
or transition and then click the "Next" button.
ez
Note In each of the dialogs, you can click "Back" to go back to the previous dialog and
make changes to the data entered if necessary.
Toolbar
om
l.c
Creating cams
with CamTool
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.16
SITRAIN Training for
Automation and Drives
@
General SIMOTION CamTool is fully integrated in SCOUT. This allows you to use data
configured in SCOUT in SIMOTION CamTool as well (e.g. axis settings).
• Upload cams from target devicesi and download cams to target devices
• Print cams
SIMOTION CamTool prov@ides the following functions for editing cams:
r.s
Creating
• Defining and displaying parameters for the leading axis and following
axis (e.g. dimension unit)
• Defining and dilusplaying the processing type of the cam (e.g. cyclic
relative processingg type)
ne
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.17
SITRAIN Training for
Automation and Drives
@
Representation To change the representation parameters for the leading axis or following axis:
parameters 1. Select the menu command: Cam -> Representation parameters for the
for which you want to modify the representation parameters.
2. The "Master properties" dialog (for the leading axis) or the
er
"S diagram (slave) properties" dialog (for the following axis) is displayed.
Master range
The definition range for the cam in SIMOTmION CamTool is defined based on
ez
the start and end points of the cam in the master range. Cam segments inserted
in CamTool must lie within the definition range.
Specify the definition range of the sicurve displayed in the representation range
by setting its start and end points . The representation range can be selected
r.s
Slave The settings for grid lines @are also made in this dialog.
Settings for theu representation range and grid lines for the following axis can be
made in the "S dliagram (slave) properties" dialog.
ne
Specify the repgresentation range of the curve for the following axis by setting its
start and end opoints.
ca
om
Interpolation points
Straight line
l.c
Fixed point
ai
Double-click
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.18
SITRAIN Training for
Automation and Drives
@
General Fixed points, straight lines, sine/arc sine lines, and interpolation points can be
inserted via the toolbar or using the context menu. Input remains active for the
selected element until you press the ESC key or click the pointer symbol with
the mouse.
er
You can enter more detailed information about the specific properties of the
selected element in the Properties dialog.
Fixed points A fixed point is a predefined following axis position for a given leading axis
ez
position.
The Properties dialog, in which youi can specify the velocity and acceleration at
the fixed point position, opens wshen you double-click the fixed point.
r.s
Straight line A straight line defines a sy@nchronous section in the cam. In the Properties
dialog, you can specify the exact start and end positions, as well as the velocity
along the straight line.
Sine, arc sine The arc sine cuglrve is calculated internally as an interpolation point table. You
ne
can specify the number of interpolation points in the "Fx arc sine properties"
window.
Interpolation points An ineterpolation point is a specified position in the S diagram (distance diagram).
ca
om
Velocity
l.c
Acceleration
ai
Jerk
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.19
SITRAIN Training for
Automation and Drives
@
Simulation The simulation settings are used to simulate camming of leading axis and
settings following axis offline in CamTool. The main element specified for simulation is
the velocity of the leading axis. The resulting dynamic values for the following
axis (e.g. velocity, acceleration, and jerk) are displayed in separate diagrams.
er
The dynamic effects resulting from changes to the cam are also displayed.
You can either take the axis settings for the master and slave axes from axes
configured in the SCOUT project or specify your own.
ez
Diagram The S diagram (distance diagram) for the cam is always displayed first in the
representation SIMOTION SCOUT working area.
ne
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.20
SITRAIN Training for
Automation and Drives
@
General If you create a cam and the cam has never been previously downloaded to the
SIMOTION device, you must first download the entire configuration with the new
cam to the SIMOTION device.
Only after this can you download the cam to the SIMOTION device
er
3. You can switch back to OFFLINE status once the download is complete.
Proceed as follows to upload a cam from a SIMOTION device:
Uploading cams 1. Click the "Connect to target system" button. SCOUT switches to
ne
ONLINE status.
2. Select the menu command: Cam > Upload cam. If you upload a cam from
the SIMOTION target device and have previously made changes to the
displayed cam, a window opens. In this window you can make the changes
to the cam effective in the project.
ca
After this, the cam is uploaded from the SIMOTION device to CamTool.
3. You can switch back to OFFLINE status once the upload is complete.
RetVal :=_resetcam(
cam, // Specification of the cam
insertmode, // Overlapping segments?
usederdefaultdata, // Reset user default values?
activaterestart, // Restart cam TO?
om
camdata); // Delete cam or reset to ES value?
l.c
RetVal := _addpointtocam(
cam, // Specification of the cam
campositionmode, // Basic sys. or scaled system?
ai
leadingrangeposition, // Coordinate of leading axis
followingrangeposition); // Coordinate of following axis
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.21
SITRAIN Training for
Automation and Drives
@
Resetting When a cam is created, the order in which the curve is processed with
a cam system calls is important. If the shape of the cam is dependent on parameters
such as interpolation points, the curve must be reset before each calculation
using the command.
er
The "_resetCam" command "deletes" the cam. The interpolation is cleared, and
the points and segments are removed. The technology object is retained but is
empty.
When resetting a cam, you can specify whether the cam (camdata) or the user
ez
Adding inter- A cam can comprise any number of interpolation points and segments. The
polation points interpolation points and/or segments can then be arranged in the appropriate
order.
The "_addPointToCam" command is used to add an interpolation point. The
ne
If no offsets or scaling have been applied, the basic and actual systems are
identical. However, in principle, part of the cam could be created initially in the
basic coordinate system and offset or scaling applied subsequently.
If a new interpolation point is added at this stage, whether the specified
coordinates reference the basic system or the actual system is relevant.
New interpolation points and segments can only be added provided that the cam
has not been interpolated.
om
2. Add segments to a reset cam
RetVal := _addsegmenttocam(
cam, // Specification of the cam
polynomialcoefficients, // Array with coefficients ai
l.c
sineamplitude, // Sine amplitude
sineperiod, // Sine period
sinephase, // Sine phase
segmentbegin, // Start of segment
segmentend, // End of segment
ai
campositionmode, // Coordinate system? Offset?
leadingrangestartpoint, // Start of master range
leadingrangeendpoint, // End of master range
SIMOTION
followingrangestartpoint,
followingrangeendpoint,
Date:
File:
10.01.2013
MC-SMO-PRG_08.22
SITRAIN Training for
Automation and Drives
@
Adding segments There are two system calls in SIMOTION for adding segments:
• _addsegmenttocam()
• _addpolynomialsegementtocam()
er
way as in CamEdit. It is also possible to specify whether the master and slave
ranges reference the "basic" or "actual" system.
The definition range values of the cam must always be increasing, i.e. specified
in the positive direction.
r.s
Note Once a cam has been entered, it can be read out of the target device and
ne
om
leadingrangeendpointtype, // From geometry
leadingrangeendpoint, // End of definition range
cammode, // Cyclic absolute, ...?
interpolationmode, // C spline, B spline?
nochangedifferenceleadingrange, // Min. distance master range
nochangedifferencefollowingrange,//Min. distance slave range
l.c
combinedifferenceleadingrange, // Max. distance master range
combinedifferencefollowingrange); // Max. distance slave range
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.23
SITRAIN Training for
Automation and Drives
@
Interpolating If the shape of the cam is described completely, interpolation is performed using
cams the "_interpolateCam" command.
points and segments entered. The interpolation type (C spline, Bezier spline,
linear), what happens at the end of a cam (non-cyclic, cyclic absolute, cyclic
relative), and the procedure for gaps between ethe individual segments are
particularly important components of the recalculation process.
This command requires that you specify wmhether interpolation is to take place
ez
in the basic coordinate system or the offset coordinate system. The information
about the definition range of the curve to be interpolated also references this
selection (basic or actual). For exaimple, if an interpolation point of the cam is
located outside the specified definsition range, it is not taken into account during
interpolation.
r.s
offset and scaled cams are displayed in blue. The function to display offset and
scaled cams (in blue) must be enabled separately in CamEdit.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.24
SITRAIN Training for
Automation and Drives
@
Offsetting and The MCC command "Parameterize cam" is used to scale and offset a cam.
scaling In MCC, offset and scaling of a cam can be entered separately for the master
value and the following axis.
Scaling takes place over the complete cam or within a range defined by the start
er
and end points. Scaling of the complete cam is referred to below as basic
scaling; scaling of a range is referred to as range scaling. The definition range
and value range each have one basic scaling and two range scalings (compare
CamEdit).
ez
For basic scaling, the zero point of the coordinate axis becomes the scaling
point, while for range scaling the starting point of the specified scaling range is
used.
This command enables simultaneous specification of one offset and/or basic
r.s
scaling plus one range scaling each for the master and slave axes.
In the case of offset, it is also possible to specify whether the offset should be
calculated as an absolute or relative value:
• Absolute: The offset cam is achieved by offsetting the cam specified in the
basic system (basic form) by the specified offset, i.e. the new offset overrides
ne
Note This command can only be applied to cams that are not active. Accessing an
active cam stops the following axis.
The command can be used for both non-interpolated and interpolated cams.
om
);
l.c
cam, // Specification of the cam
scalingrange, // Leading or following axis
scalingspecification, // Basic or range scaling
specificrangenumber, // 1st or 2nd range
specificrangestartpointtype,// Last progr. or direct?
ai
specificrangestartpoint, // Start of range
specificrangeendpointtype, // Last progr. or direct?
specificrangeendpoint, // End of range
SIMOTION
scalevalue,
);
gm
Date:
File:
10.01.2013
Scaling value
MC-SMO-PRG_08.25
SITRAIN Training for
Automation and Drives
@
Offsetting cams In In ST there are two separate system function calls for offsetting and scaling
non-activated cams.
The "_setcamoffset" call sets an offset for a non-activated cam. This call
requires that you specify both the range (master or slave) and the coordinate
er
Scaling cams The _setcamscale call is used to scale a non-activated cam. This call requires
that the range (master or slave) and whether basic or range scaling is to be
performed are specified, along with the scaling factor.
r.s
ne
ca
om
followingpositionmode, // Value range: absolute or relative?
);
l.c
RetVal := _getcamleadingvalue(
cam, // Specification of the cam
followingpositionmode, // Value range: absolute or relative?
followingposition, // Default position in value range
leadingpositionmode, // Def. range: absolute or relative?
ai
leadingapproachpositiontype // Direct entry of position
leadingapproachposition // Approach position in def. range
);
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.26
SITRAIN Training for
Automation and Drives
@
Reading out The "_getCamFollowingValue" command is used to read out the function value
function values of a cam. The call returns the cam value when a value in the definition range is
specified (master value).
The reference systems for the function can be specified as follows:
er
• Reference system for definition range: Offset and scaled/Not offset and not
scaled
• Reference system for value range: Offset and scaled/Not offset and not
ez
scaled
Reading out the For some applications, it is necessary to determine the master value for a
value of the defined slave value. The master value can be retrieved using
reversal function "_getCamLeadingValue".
r.s
This inverse mapping is only unique in the case of strictly monotone output
functions. In order to supply a master value for output functions that are not
strictly monotone, an x-value can be specified, and the nearest solution (in both
directions) is then sought for the specified x-value. If an x-value is not specified,
the search will begin from the starting point of the cam.
ne
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_08.27
SITRAIN Training for
Automation and Drives
@
System variables Like any other TO, a cam has system variables to reflect its state. In particular,
for cams the system variables contain information about the following properties:
userdefault: Information about the default settings for the coordinate systems
(basic, actual)
er
position)
reset: Processing state of the reset command
error: Information about whether there is an error pending at the cam TO
activationmodechangedconfigdata: Information about activating changed
ne
configuration data
Restartactivation: Information about executing a TO restart
definitionstate: This variable indicates whether points or segments have been
inserted in this cam. Geometry elements can be inserted by means of a
ca
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.1
SITRAIN Training for
Automation and Drives
@
Contents Page
Gearing in SIMOTION ....................................................................................................................... 3
Camming in SIMOTION ..................................................................................................................... 4
er
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.2
SITRAIN Training for
Automation and Drives
@
Contents Page
Examples: Set scaling on synchronous object ................................................................................... 27
Set offset on camming ........................................................................................................................ 28
er
Master value
• Position axis External
• Following axis encoder
• Ext. encoder Virtual
• Virtual axis axis
Slave value
om
Leading
Synchro-
axis
nous
operation
Settings TO
l.c
• Master value Master value
• Gear ratio
• Synchronization and
desynchronization profile
ai
Buffer IPO Servo
• Limitations of use
SIMOTION
• Monitoring functions
Date:
File:
10.01.2013
MC-SMO-PRG_09.3
SITRAIN Training for
Automation and Drives
@
How synchronous The "synchronous operation" technology object is used to connect two or
operation is more axes to create a synchronous group.
structured A leading axis (master) generates a master value, which is processed by the
synchronous object according to specific criteria (gear ratio, scaling, cam, etc.)
er
The master and slave values arse coupled without physical conversion in the
relevant parameterized units. If the leading axis is a linear axis (unit mm), for
r.s
example, and the following axis is a rotary axis (unit degrees), then with a
conversion ratio of 1:1, one@ millimeter corresponds to one degree.
Mechanical Mechanically, the suynchronous object represents the gear with driving gear/
model driven gear or, inl conjunction with the "Cam" TO, the cam gear with the
ne
mechanical cam and sensor system. The model also includes a coupling for
enabling and dgisabling the following motion on-the-fly.
Coupling via The geaelr functionality is characterized by a constant ratio between master
gear value source and following axis. The ratio can either be programmed as a
rational gear factor or using a numerator/denominator ratio.
ca
The slave value is calculated from the programmed gear factor and the master
value and transferred to the gear axis. A following axis can be interconnected
with more than one master value by means of the synchronous object, but only
one of these is evaluated. At runtime, you can switch over the master value in
the user program.
When you select the gearing, you differentiate between absolute and relative
synchronous operation. You can also select from different types of
synchronization/desynchronization profile (related to master value or time).
Master value
• Position axis External
• Following axis encoder
• Ext. encoder Virtual
• Virtual axis Cam_1
axis
om
Slave value
Leading Cam_2
axis TO Synchro-
nous
operation Cam_3
Settings
• Master value TO
l.c
• Cam
• Scalings Master value
• Synchronization and
desynchronization profile
ai
Buffer IPO Servo
SIMOTION
• Monitoring functions
synchronous operation, a following axis does not receive its position setpoints
from one synchronous operation TO but from two, i.e. the basic synchronous
operation TO and a superimposed synchronous operation TO.
Several cams can be used in camming. You can switch from one cam to
another in the user program during runtime.
r.s
• The synchronous object and the following axis are permanently assigned to
one other in the configuration
• The master value object (position axis, virtual axis, following axis or external
encoder) can be interconnected with several synchronous objects
ca
om
l.c
Synchronous operation
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.5
SITRAIN Training for
Automation and Drives
@
Create synchronous If the "synchronous operation" technology is selected when creating an axis in
object SIMOTION SCOUT, SIMOTION SCOUT will automatically create a
synchronous object belonging to the axis.
The synchronous object appears in the project navigator underneath the
er
corresponding axis. The object is automatically assigned the axis name and
suffixed with "_SYNCHRONOUS_OPERATION.
Assignments Master value and cam assignments are indicated in the SIMOTION SCOUT
ez
IPO levels The interpolation for a TO (e.g. axis TO) can be assigned to the "IPO level" or to
"IPO level_2" in the execution system. This means that, in cases where axes do
not require a high time resolution to calculate reference variables, interpolation
can be placed in an IPO task with a longer cycle time, thereby requiring less
processing power.
ca
Note The required "IPO level" can be assigned to a TO via the expert list
(Configuration data -> Execution -> ExecutionLevel).
• Setpoint coupling
• Actual value coupling
with extrapolation
om
l.c
• Assignment of
cams
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.6
SITRAIN Training for
Automation and Drives
@
Assignments Assignments between the synchronous object and possible leading axes and
cams are made in the "Interconnections" dialog. This dialog opens when you
double-click Interconnections under the <AxisName>_SYNCHRONOUS
OPERATION object in the project navigator.
er
In this dialog, the possible master values and cams are assigned to the
synchronous object of the following axis. The currently used master value/active
cam is defined during runtime using the appropriate functions.
ez
Setpoint and actual With real axes, you can also choose between setpoint and actual value
value coupling coupling. External encoders only support actual value coupling, virtual axes only
support setpoint coupling.
The reference value for the actual value coupling can be extrapolated for the
r.s
compensation of dead times. The extrapolation compensates for the local delays
that result from use of the actual value instead of the setpoint.
Notes Gearing or camming with a following axis is only possible if at least one master
value has been assigned to the associated synchronous object.
ne
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.7
SITRAIN Training for
Automation and Drives
@
Settings The most important configuration settings for synchronous operation can be
made in this dialog.
Abs. synchr. with For absolute synchronization, if "Yes" is set the jerk is taken into account.
consideration of jerk If "No" is set, the set jerk will be ignored in spite of velocity profile = SMOOTH
ez
Overdrive Overdrive factor folur the adapted dynamic response values to compensate
factor a remaining path difference (syncingMotion.overdriveFactor) The value is
ne
specified in pegrcent (%). Reference to the current master value velocity for the
start of syonchronization.
Tolerance for Toleerance window for aborting synchronization for direction reversal of the
direction reversal
master values (syncingMotion.masterReversionTolerance). Position value in
ca
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.8
SITRAIN Training for
Automation and Drives
@
Default parameter Default settings for camming are made in the "Default" dialog. In this dialog,
settings parameters (defaults) for calling synchronous operation functions are set.
However, these parameters are only evaluated if no special settings have been
made in the associated function calls for synchronization/desynchronization
er
Cam on
om
Cam selection
Direction setting
Selected evaluation
settings:
• Absolute or
l.c
• Relative
Cam processing:
• Non-cyclic
ai
• Cyclic
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.9
behavior and program
advance
Here you select the following axis for synchronization. All axes of the device for which
Following axis
the synchronous operation functionality has been configured as well as all variables
of the MCC chart with data type "followingAxis" are available for selection.
ez
Here you select the axis or externali encoder which supplies the master value in the
Leading axis synchronous relationship. You can choose from all position axes, following axes, and
external encoders that are available on the device or a DP master, as well as from all
variables of the MCC chart with data type: "posAxis",
r.s
"followingAxis", or "externalEncoderType".
Here you select uthe cam. All the cams that have been created on the device are
Cam available for selelction, as well as the "CamType" variables
ne
Here youo specify the direction in which the cam is to be processed when the masterl
Cam direction values are increasing.
• Poseitive means in the same direction. Increasing master values
correspond to increasing values in the definition range of the cam, and vice
versa.
ca
SY-TO.state
om
Cam
l.c
Slave pos.
Synchronization
length
ai
10
Start End
280
Master pos.
30
SIMOTION
Siemens AG 2013. All rights reserved.
Absolute
Absolute
gm
Date:
File:
Start of synchronization:
Reference point:
10.01.2013
MC-SMO-PRG_09.10
At leading axis position
From synch. pos. synch.
absolute values based on the definition range of the cam and the slave values
are interpreted as absolute values based on the value range of the cam.
Any offset between the master value and slave value that occurs during
synchronization is compensated. When the synchronization is complete, a
ez
defined relationship has been established between the master value and slave
value positions.
This relationship is described by the cam, unless an additional offset is specified
using the "Start of synchronization: At leading axis position with offset" setting.
r.s
This offset corresponds to a shift in the direction of the positive following axis.
Execution When the synchronization point is reached, the following axis is synchronized
with the relevant cam position. The beginning of the synchronization process is
signaled by the state "camming" of the system variable SY-TO.state of the
ne
om
10
l.c
30
280
Slave pos.
ai
Master pos.
Evaluation of leading axis:
Evaluation of following axis:
Non-cyclic processing
SIMOTION
Siemens AG 2013. All rights reserved.
Absolute
Relative
gm
Date:
File:
Start of synchronization:
Reference point:
10.01.2013
MC-SMO-PRG_09.11
At leading axis position
From synch. pos. synch.
The start position of the cam (Y coordinate) is set equal to the following axis
position at the time of starting the synchronization task (SY-TO.state =
camming).
ez
Note "Slave relative" mode must be selected if you want a cam to be processed in a
"cyclic relative" manner. With "cyclic relative" processing, once a cam cycle has
been completed for the leading axis, the slave position moves by the precise
difference between the Y coordinates at the beginning and end of the cam.
r.s
ne
ca
SY-TO.state
Cam
om
Slave pos.
10
l.c
30
280
ai
Master pos.
SIMOTION
Siemens AG 2013. All rights reserved.
Relative
Absolute
gm
Date:
File:
Start of synchronization:
Reference point:
10.01.2013
MC-SMO-PRG_09.12
At leading axis position
From synch. pos. synch.
Note "Master relative" mode must be selected if, after one cam cycle has been
completed, you want the system to synchronize with a new cam on the basis of
the synchronization condition: "Start of synchronization: At end of cam cycle".
r.s
ne
ca
SY-TO.state
Cam
om
10
l.c
0
30
280
Slave pos.
ai
Master pos.
Evaluation of leading axis:
Evaluation of following axis:
Non-cyclic processing
SIMOTION
Siemens AG 2013. All rights reserved.
Relative
Relative
gm
Date:
File:
Start of synchronization:
Reference point:
10.01.2013
MC-SMO-PRG_09.13
At leading axis position
From synch. pos. synch.
The start position of the cam (Y coordinate) is set equal to the following axis
position at the time of starting the synchronization task (SY-TO.state =
camming).
r.s
ne
ca
Non-cyclic
Slave pos.
Master pos.
om
30 280 530
Cyclic absolute
Evaluation of the
following axis:
Absolute
l.c
Master pos.
30 280 530
Cyclic relative
ai
Evaluation of the
following axis:
Relative
SIMOTION
30
Cyclic absolute For "cyclic absolute" processing, the following settings need to be made:
• "Evaluation of the following axis: Absolute"
• "Cam type: Cyclic absolute". It is only when this setting is made in the target
system that constant-position and constant-speed interpolation is applied to
the cam to avoid discontinuous movements during processing when making
ne
Cyclic relative For "cyclic relative" processing, the following settings need to be made:
• "Evaluation of the following axis: Relative"
• "Cam type: Cyclic relative". In this case, a constant-speed transition is
guaranteed at the end of a cycle. The setting "Cyclic absolute" could result in
cyclic absolute processing.
Selection of synchro-
nization reference:
• Leading axis
• Time
om
Settings for synchroni-
zation position, length,
and offset
l.c
Settings for transition
behavior and program
advance
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.15
SITRAIN Training for
Automation and Drives
@
Synchronization Use the "Synchronization" tab to make settings for the synchronization profile
and position.
command is issued.
At leading axis position: Cammings starts at the position specified for the
leading axis.
r.s
At leading axis position wit@h offset: Camming starts at the specified leading
axis position. An offset can also be specified for the following axis.
Offset This is where you uenter the offset for the following axis if "At leading axis
position with offset" has been selected. This offset results in a shift of the cam
ne
in the Y direction.g
Reference point This isl where you select the synchronization point with reference to the
of the leading selected synchronization profile.
ca
axis position
If you have selected a "leading axis" synchronization reference, this is where
you enter the synchronization length.
Synchronization
length If you have selected "relative" evaluation for the leading axis, you can specify
the offset here. This offset results in a shift of the cam in the X direction.
start position
Position
Master pos.
om
Synchroni-
zation length
l.c
Slave pos.
Time
ai
Leading-axis-related synchronization profile:
• Specification of synchronization length -> Synchronization position is clearly defined,
dynamic parameters are not effective
SIMOTION
Time-related synchronization profile:
• Specification of dynamic parameters-------->
10.01.2013
MC-SMO-PRG_09.16
SITRAIN Training for
Automation and Drives
@
Synchronization
reference The profile for synchronization can reference the leading axis or time.
• Leading axis
er
• Time
Synchronize The following axis is synchronized in accordance with the distance traveled
with master value by the leading axis. Synchronization is described by the MCC parameter
ez
"Synchronization length".
Setting the parameters in this way ensures that the synchronous object has
synchronized the leading axis and the following axis at a specific position, but
without consideration of the dynamic parameters from the "Dynamic response"
tab. The values that are defined there are not evaluated by the synchronous
r.s
Synchronize The following axis is synchronized in the specified time interval, while taking
ne
after time account of the parameters from the "Dynamic response" tab. In this case, both
the synchronization time and the synchronization position can only be
determined on the basis of your own calculations.
In this case, parameters such as the synchronization length are ignored.
ca
Notice In the case of leading axis synchronization, the leading axis is not allowed to
reverse during the synchronization procedure, otherwise the "Cam on"
command will be aborted with an error message.
Offset
om
Slave
pos.
Master pos.
l.c
Issue command Start End
Start of synchronization:
• Immediately (+ offset): The time when the command is issued and the start of synchronization match
ai
• Leading axis position: Synchronization starts, is partway through, or is completed at the leading axis
(+ offset) position. In addition to the leading axis position, an offset can be entered for the
following axis. The offset corresponds to a shift of the cam in the positive Y
direction (slave direction)
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Corresponds to a shift of the cam in the negative X direction (master direction)
Date:
File:
10.01.2013
MC-SMO-PRG_09.17
SITRAIN Training for
Automation and Drives
@
Start of synchro- The following options are available for defining the start of synchronization:
nization
At end of cam cycle: Synchronization begins or is completed when the leading axis
reaches the end of the cam cycle. In this case, the beginning or end is specified
er
If you want to use the existing cyclic camming eas a starting point for synchronizing
with a new cam, you also need to make the following setting:
"Evaluation of the leading axis: Relative".
ez
In this case, it is not possible to speceify an additional offset for the following axis.
Synchronize immediately: Synchroniization starts immediately as soon as the
command is issued. Once the sysnchronization length (related to leading axis) has
been traveled, the master and slave axes are synchronous. With the time-related
r.s
If the master value sou rce and following axis are at zero speed and
synchronization is ubeing performed with reference to the master value, relative
ne
At leadeing axis position: Camming starts or ends at the position specified for the
leadking axis. This position is specified with the "Reference point of leading axis"
setting.
At leading axis position with offset: Camming starts or ends at the specified leading
axis position. This position is specified with the "Reference point of leading axis"
setting.
An offset can also be specified for the following axis. This offset has the same effect
as a shift of the cam in the positive Y direction.
om
l.c
ai
Leading axis position Master pos.
Synchronize before synchronization position
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Synchronize symmetrically
Synchronize from synchronization position
Date:
File:
10.01.2013
MC-SMO-PRG_09.18
SITRAIN Training for
Automation and Drives
@
Reference point of The "Reference point of leading axis" (syncPositionReference) parameter
leading axis is used to manipulate the position of the synchronization point during
synchronization:
Synchronize from synchronization position: In this case, synchronization starts
er
with all other conditions (e.g. synchronization length, etc.) when the
synchronization position is reached.
Synchronize before synchronization position: Synchronization takes place so
that all other conditions (e.g. synclength, etc.) are adhered to and the following
ez
om
Slave pos.
l.c
Leading axis pos. Offset to cam starting point
ai
Master pos.
SIMOTION
Siemens AG 2013. All rights reserved.
Relative
Absolute
gm
Date:
File:
Start of synchronization: At leading axis position
Reference point:
Offset to cam starting point
10.01.2013
MC-SMO-PRG_09.19
From synch. pos. synch.
shifted by this offset. This "offset to cam starting point" causes a phase offset in
the position of the leading axis. Of course, this does not affect the actual position
of the leading axis.
ez
r.s
ne
ca
om
Settings for:
• Velocity profile
• Velocity
• Acceleration
l.c
• Jerk
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.20
SITRAIN Training for
Automation and Drives
@
Dynamic response Settings for the velocity profile, velocities, acceleration, and jerk of the axis
during synchronization and desynchronization are made on the "Dynamic
response" tab.
These dynamic settings can only be entered when selecting a time-related
er
om
Variables for recording the
• CommandId
and the return value of:
• Set master setpoint
l.c
• Camming on
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.21
SITRAIN Training for
Automation and Drives
@
CommandId The status of motion commands can be tracked with the CommandId, which is
unique throughout a project. Previously, the CommandId was reserved for use
in ST programming. However, as of V4.0, it can also be used in MCC
commands.
er
If you enter the name of a variable of data type CommandIdType, you can track
the command status with this variable. The variable (data type: DINT) must
previously have been declared in the MCC source file or in the MCC chart.
If the "Assign value" box is checked, a CommandId that is unique throughout the
ez
If the field is left blank, no variables are assigned to the CommandId parameter
of the command. If the field is blank, the "Assign value" box must be checked.
Return values Many MCC commands are mapped to one or more system functions. They
ne
usually send a return value to the user indicating whether or not the call has
been successful.
If a variable of the specified data type is entered, the return value of the
command step is saved in this variable. The variable must previously have been
declared in the MCC source file or in the MCC chart.
ca
If the field is left blank, the return value of the command step is assigned to an
internal variable which cannot be accessed by the MCC chart (default setting).
Cam off
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.22
SITRAIN Training for
Automation and Drives
@
Disabling Camming is disabled in a similar way to that in which it is enabled. You simply
camming have to enter the leading axis and the following axis on the "Parameters" tab.
The type of desynchronization is specified on the "Desynchronization" tab. The
possible parameter settings are similar to those for synchronization. .
er
• With a time-related profile, the dyenamic parameters are effective, but the
position is difficult to determine at the end of desynchronization procedure
r.s
The options available he@re for the desynchronization position of the leading
Desynchronization
position axis or the following axis are "Desynchronize immediately" and "At end of cam
cycle".
Reference point of Here again it isl possible to choose between before or after the synchronization
ne
Leading axis/ If the position of the leading or following axis has been selected as the
following position desynchronization position, the required position can be specified here.
om
cam, // Specification of the cam
synchronizingmode, // Start of synchr.: leading axis pos.?
syncpositionreference, // Ref. point: before lead. axis pos., symm.?
syncprofilereference, // Leading-axis-related or time-related
synclengthtype, // Type "Synch.length": direct,...?
synclength, // Synchronization length
camstartpositionmastertype, // Type "Offset to cam starting point"
l.c
camstartpositionmaster, // "Offset to cam starting point"
syncpositionmastertype, // Type "Lead. axis pos.": direct, user-def.?
syncpositionmaster, // Leading axis position
syncpositionslavetype, // Type "Slave offset": direct,...?
syncpositionslave, // "Offset in slave direction"
ai
velocitytype, // Type "Veloc.": direct, user-def.?
velocity, // Velocity: only if direct
. . ., // Remaining dynamic parameters
SIMOTION
mergemode,
nextcommand,
commandid);
Date:
File:
10.01.2013
MC-SMO-PRG_09.23
SITRAIN Training for
Automation and Drives
@
_enablecamming The _enablecamming system function is used to enable camming in the ST
language. The individual parameters are identical to the input parameters for the
associated MCC command:
MCC ST
er
Disabling camming
RetVal := _disablecamming(
followingobject, // Specification of synchronous object
syncoffmode, // Master or slave pos., end of cam cycle?
syncoffpositionreference,//Before/after leading axis pos., symm.?
syncprofilereference, // Leading-axis-related or time-related
om
syncofflengthtype, // Type "Desynch. length": direct,...?
syncofflength, // Desynchronization length
syncoffpositionmastertype,//Type "Lead. axis pos.": direct, user-def.?
syncoffpositionmaster, // Leading axis position
syncoffpositionslavetype,// Type "Slave pos.": direct,...?
syncoffpositionslave, // "Offset in slave direction"
velocitytype, // Type "Veloc.": direct, user-def.?
l.c
velocity, // Velocity: only if direct
. . ., // Remaining dynamic parameters
mergemode, // Substitute, attach, etc.?
nextcommand, // Wait for ... ?
commandid); // Command ID
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.24
SITRAIN Training for
Automation and Drives
@
_disablecamming The _disablecamming system function is used to disable camming in the ST
language. The individual parameters are identical to the input parameters for the
associated MCC command:
MCC ST
er
om
l.c
ai
Assignment of a leading axis (master) to a synchronous object
RetVal := _setmaster(
followingobject, // Specification of synchronous object
SIMOTION
master,
...);
10.01.2013
MC-SMO-PRG_09.25
SITRAIN Training for
Automation and Drives
@
Set This command switches the master setpoint for an existing synchronous
master/slave operation relationship. The master/slave can be set when synchronous
operation is active.
The _setmaster command is used to assign a new master value source to a
er
synchronous object. When it is enabled, the master values are referenced to the
units system of the current master value source.
Transition process A relative or absolute coupling influences the transition process. The transition
ez
behavior when the master value source is set is different for absolute
synchronous operation and relative synchronous operation.
• With a relative coupling, an additional slave value discrepancy occurs only if
the dynamic master values are different with regard to velocity and
r.s
acceleration.
• With absolute coupling, a non-continuous master value transition can occur.
Slave value monitoring at the following axis limits discontinuities in the slave
values to the maximum dynamic axis parameters; compensating motion is
generated in some cases.
ne
Different modulo settings of the master value sources are taken into account.
As of Version 3.1 As of Version 3.1, there is a new command that allows you to include the
dynamic parameters for the compensating motion as well.
To include them in the command, select "With programmed dynamic values" in
the "Transition behavior" field. Selecting "Direct" might lead to a reduction in the
dynamic values in the following axis TO.
om
l.c
RetVal := _setcammingscale(
followingobject,
scalingrange,
scalespecification,
ai
scalevalue,
velocitytype,
velocity,
:
SIMOTION
Siemens AG 2013. All rights reserved.
gm
nextcommand,
commandid,
activationmode);
Date:
File:
10.01.2013
MC-SMO-PRG_09.26
SITRAIN Training for
Automation and Drives
@
Scaling This function scales the master or slave range of the relevant cam. Among other
things, this parameter can be used to define:
• The time when the scaling is to be applied (immediately/next cam cycle)
er
• Whether the selected function is to affect just the active command and/or
subsequent commands
Scaling operations that act on the active command as well as scaling operations
that are stored and act on subsequent commands can be read from the
ez
Axis Under "Axis", select the axis for which the command is to be programmed.
Range This is where you select whether it is the leading axis or the following axis range
ne
Offset Scaling factor for the selected range. The value is entered as a signed floating-
point number.
ca
Master
om
Issue "Set scaling"
Slave _enableCamming Time: Immediately
Effect: On active
command
l.c
Master
ai
command and
the following
commands
SIMOTION
Siemens AG 2013. All rights reserved.
gm
_enableCamming
Date:
File:
10.01.2013
MC-SMO-PRG_09.27
Master
Scaling acts on the active camming command and remains active until this
command is substituted or desynchronized using the "Cam off" command.
The scaling value is stored (depending on the cam range) in system variable
ez
cammingAdjustment.master.scale or cammingAdjustment.slave.scale.
• On following commands
The active camming command is executed, the scaling is not taken into account
for this command. The scaling is saved and acts on subsequent cam
commands.
r.s
The scaling value is stored (depending on the cam range) in system variable
cammingAdjustment.defaultValueMaster.scale or
cammingAdjustment.defaultValueSlave.scale.
• On active command and the following commands
ne
The scaling acts on the current camming command and on all subsequent "Cam
on" commands. The scaling value is stored (depending on the cam range) in
system variables cammingAdjustment.master.scale and
cammingAdjustment.defaultValueMaster.scale, or
cammingAdjustment.slave.scale and
ca
cammingAdjustment.defaultValueSlave.scale.
om
l.c
RetVal := _setcammingoffset(
followingobject,
offsetrange,
ai
offsetspecification,
offsetmode,
offsetvalue,
:
SIMOTION
Siemens AG 2013. All rights reserved.
gm
nextcommand,
commandid,
activationmode);
Date:
File:
10.01.2013
MC-SMO-PRG_09.28
SITRAIN Training for
Automation and Drives
@
Offset This command causes an offset in the leading axis or following axis range of the
associated cam during camming. Parameters can be used to define (among
other things):
• The time when the offset is to be applied (immediately/next cam cycle)
er
variable.
r.s
ne
ca
Scale:
Master range. 2.0
Cam
om
Scale:
Slave range. 2.0
l.c
Compensating Offset:
motion Slave range. 20 mm
ai
Compensating motion
Offset:
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.29
Master range. 20 mm
greater or smaller distance so that the same displacement can be achieved for
the following axis.
• Scaling the slave range stretches or compresses the curve in the Y
direction. This results in the following axis being displaced to a greater or lesser
ez
• Setting a slave range@ offset shifts the entire curve in the Y direction.
om
operation
SY.currentmasterdata.value TO
SY.currentslavedata.value
• Max. velocity Slaveaxis.positioningstate.commandposition
• Max. progr. vel.
• Max. acceleration
l.c
Buffer IPO Servo
Error 40202: Dynamic response
of the synchronous operation
setpoints cannot be achieved
Following axis TO
ai
(SY.currentslavedata.value >
Max. velocity)
Alarm 40201 "Synchronous operation
tolerance exceeded on gear axis"
SIMOTION
Siemens AG 2013. All rights reserved.
Date:
File:
gm
(SY.currentslavedata.value >
TypeofAxis.GearingPosTolerance.commandValueTolerance)
10.01.2013
MC-SMO-PRG_09.30
SITRAIN Training for
Automation and Drives
@
Synchronization At the start of synchronization, when the SY.state system variable is set to the
"gearing" or "camming" state and a leading axis reference is selected for the
synchronization profile, the synchronous operation TO calculates an appropriate
position or speed profile for the following axis (SY.currentslavedata.value or
er
However, at this point any synchronous operation monitoring functions are also
enabled.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_09.31
SITRAIN Training for
Automation and Drives
@
System variables If the synchronous operation monitoring functions are disabled, there is no further
response on the part of SIMOTION. The master and slave axes may not become
synchronous until a later point in time.
This time cannot be read from the "syncstate" synchronous operation system
er
Error 40201 The Synchronous operation monitoring tab of the Monitoring dialog box can be
used to enable setpoint and actual value monitoring functions. At the end of the
synchronization procedure calculated by the synchronous operation TO, the
"syncstate" is set to "yes" and the configured synchronous operation monitoring
function is enabled.
ne
The monitoring function of the following axis TO reports error 40201: "Dynamic
response of the synchronous operation values cannot be achieved" (setpoints or
actual values) if, at the current point in time, the difference exceeds the value
entered. The response to this error also depends on the configuration.
ca
Error 40110 In addition, you can make a setting to specify whether or not any errors should be
reported to the leading axis TO. If this message is disabled, no notification is sent
to the leading axis. The leading axis may carry on moving at quite a pace even
though the following axis has been stopped.
If the "Report error to leading axis" synchronous operation monitoring function is
enabled, the synchronous operation error is reported to the leading axis, which
triggers alarm 40110 "Error triggered on slave during synchronous operation
(setpoint violation or actual value violation)". The response to this error also
depends on the configuration.
SITRAIN Training for MC-SMO-PRG
Automation and Drives Page 31 Camming
Synchronization with velocity reduction
om
Slave velocity
l.c
Slave pos.
ai
Gearing: Absolute
Ratio: 1:1
SIMOTION
Synchronize:
Synchronization length:
Execution For the synchronization procedure, the synchronous operation TO uses the
position of the leading axis (master pos.) to calculate a corresponding position
or velocity profile for the following axis (SY slave pos. or SY slave velocity).
ez
However, the following axis TO restricts the velocity profile calculated for the
following axis (SY slave velocity) to the configured maximum value of 20 mm/s,
with the result that the following axis actually moves at a reduced velocity (slave
velocity).
r.s
operation TO, the "syncstate" is set to "yes", despite the fact that the master and
slave axes are not synchronous at this point in time. At this point, any
synchronous operation monitoring functions are also enabled.
Due to the fact that setpoint/actual value monitoring is disabled for the
synchronous operation motion, there is no other response at this point in time.
This restriction means that the master and slave axes are actually only
synchronized later.
SY slave pos.
SY slave velocity
om
Master pos.
"syncstate"
Slave velocity
l.c
Slave pos. Setpoint difference between SY slave pos. and slave pos.
ai
Gearing: Absolute
Ratio: 1:1
SIMOTION
Synchronize:
Synchronization length:
Execution For the synchronization procedure, the synchronous operation TO uses the
position of the leading axis (master pos.) to calculate a corresponding position
or velocity profile for the following axis (SY slave pos. or SY slave velocity).
As in the previous example, the velocity is reduced by the following axis TO.
ez
operation TO, the "syncstate" is set to "yes" and the configured synchronous
operation monitoring function is enabled.
The setpoint monitoring function of the following axis TO detects that the
deviation between the position setpoint calculated by the synchronous operation
TO and the position setpoint reduced by the IPO exceeds the specified
ne
SY slave pos.
SY slave velocity
om
Master pos.
"syncstate"
Slave velocity
l.c
Slave pos. Setpoint difference between SY slave pos. and slave pos.
ai
Gearing: Absolute
Ratio: 1:1
SIMOTION
Synchronize:
Synchronization length:
the synchronous operation TO and the following axis position setpoint that
has been reduced by the IPO.
Because the deviation exceeds the set tolerance, alarm 40201 "Synchronous
operation tolerance exceeded on gear axis" is triggered.
The response set here is for the following axis to be stopped.
ne
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.1
SITRAIN Training for
Automation and Drives
@
Contents Page
Safety information for our course participants ................................................................................... 4
Safety information for our course participants ................................................................................... 5
er
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.2
SITRAIN Training for
Automation and Drives
@
Contents Page
Exercise 6.2: Creating an ErrorHandler for the TechFaultTask ......................................................... 28
Exercise 6.3: Program concept for a "flying shear" ............................................................................ 29
er
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.3
SITRAIN Training for
Automation and Drives
@
Contents Page
Exercise A.2: Settings for "Fixed gear" ............................................................................................. 52
Exercise A.2: Activation and deactivation logic (1) ............................................................................ 53
er
om
If the building has to be evacuated, follow the emergency exit
signs (emergency exit lights).
In an emergency, only use the Siemens emergency number
which you can dial from any internal phone:
Int: 2222
l.c
Familiarize yourself with the locations of fire extinguishers,
wall hydrants, and emergency stop buttons
Report any accidents that happen on the way to the Training
ai
Center or during course attendance to the Course Office or to
your trainer
to the trainer
SIMATIC S7
Siemens AG 2013. All rights reserved.
Date:
File:
gm
All equipment and tools used by the course participants must
be in perfect working order; faulty equipment must be reported
10.01.2013
MC-SMO-PRG_10.4
SITRAIN Training for
Automation and Drives
@
er
ez
r.s
ne
ca
om
The exercises must never be carried out alone. At least one other person must be present.
When working on the training units, exercise caution with rotating parts (motor shafts, etc.). It is only
permissible to work without a protective cover if the control is switched off (Emergency OFF).
l.c
Notice !!
Rotating parts
ai
High voltage
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.5
SITRAIN Training for
Automation and Drives
@
er
ez
r.s
ne
ca
ET200S PN
TP170B COLOR 16 DI/DO
IP addr.: IP addr.:
192.168.0.12 192.168.0.2 Motor red
1FK7022-5AK7-1LG3
SINAMICS
SINAMICS
0O with integrated
PROFINET
encoder connection
270O
om
90O
6,000 rpm
..........
..........
Absolute encoder
3 ..........
.......... 180O 512 pulses/4,096 rev.
..........
..........
..........
0O
270O
..........
..........
..........
90O
..........
..........
..........
..........
Motor blue
..........
.......... 1FK7022-5AK7-1AG3
180O with SMC connection
l.c
6,000 rpm
Incr. encoder 2,048
pulses
SMC
ai
PG/PC
IPaddr.:192.168.0.10
PROFIBUS address: 0
SIMATIC S7
Siemens AG 2013. All rights reserved.
D425-2
IP addr.:
192.168.0.1
gm
Smart
Line
Module
Date:
File:
Double
Motor Module
3A/3A
6SL3120-2TE13-0AA3
10.01.2013
MC-SMO-PRG_10.6
SITRAIN Training for
Automation and Drives
@
Objective The objective of this exercise is to download the basic project for the above
configuration to the D425-2 and create the prerequisites for completing the rest
of the exercises. The basic project is located in the file:
• PRG_D425-2_V431_PN_E_0.zip
er
project and the configuration in the actual system. After downloading the project,
to check the system functionality, both axes of the drive unit are to be traversed
from SIMOTION using the SCOUT control panel.
What to do 1. Open SIMOTION SCOUT and activate the following menu command to
r.s
You must also check that the corresponding active online connection has
been entered in "NetPro" and make the appropriate settings if necessary.
The IP address of the integrated PROFINET interface should be set to the
following value:
- 192.168.0.1
Hardware configuration
om
Network view
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.7
SITRAIN Training for
Automation and Drives
@
Continued The IP address of the PG should be set to the following value:
- 192.168.0.10
Save and compile the settings in "NetPro" and then close "NetPro".
er
3. After this, select the SCOUT menu command Project -> Connect to target
system or click the corresponding button on the toolbar to establish an online connection
between SCOUT and the D425-2 or SINAMICS_Integrated.
4. Click the "Download project to target system" symbol to download the project
ez
data from SIMOTION and SINAMICS_Integrated. You must also ensure that the
SIMOTION and SINAMICS_Integrated data is saved to the CF card when the download
completes.
To do this, select the co mmand: Target device -> Copy RAM to ROM from the context
menu for the corresponding device (D425-2 or
r.s
SINAMICS_Integrated@).
To do this, gin the project navigator, right-click the SINAMICS_Integrated and select the
command Target device -> Download to PG from the context menu.
Then save the uploaded data by clicking the "Save project" symbol in the SCOUT project.
6. Finally, establish an online connection with the SIMOTION device and traverse
ca
om
Axis_1
Axis_2
l.c
Program for the
PeripheraFaultTask
ai
Drive_blue
Drive_red
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.8
SITRAIN Training for
Automation and Drives
@
Configuration The following two axes have been configured in the SCOUT project:
- Axis_1 (following axis)
- Axis_2 (position axis)
er
Time For the basic project, an empty program is required for the PeripheralFaultTask.
synchronization This is due to automatic time synchronization between SIMOTION and the
SINAMICS_Integrated.
During time synchronization, if the difference detected between the "old" time
and the "new" time is too great, SINAMICS generates an I/O event automatically
to start the PeripheralFaultTask in SIMOTION. If there is not a program (at least
an empty program) for the PeripheralFaultTask, SIMOTION cannot be switched
to RUN.
Created by SIDEMO
IB 0 DI DO
QB 4
.0.......... .0
.1.......... .1
.2.......... .2
om
.3.......... .3
.4.......... .4
.5.......... .5
.6.......... .6
.7.......... .7
.0.......... .0
.1.......... .1
.2.......... .2
.3.......... .3
.4.......... .4
l.c
.5.......... .5
.6.......... .6
IB 1 .7.......... .7 QB 5
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.9
SITRAIN Training for
Automation and Drives
@
Objective The first exercise is designed to familiarize you with the ST programming
environment (editor, compilation, testing, etc.).
Task The program Flash_1 sets a bit at output byte 4 of the target system and rotates
er
it in the sequence bit 0 -> bit 1 -> ... -> bit 7 -> bit 0, etc. Each bit of output byte 4
is set and then reset one after the other.
Bit rotation is implemented using the systemm function ROL() ("Rotate left"). The
function is found in the SCOUT command library under bit string -> rol. The
ez
1. In the interflace part of the ST unit, declare an INT data type variable
CounterVagr and a BYTE data type variable OutputVar.
Initialize each of the two variables with the initial value 1.
ca
Created by SIDEMO
IB 0 DI DO
QB 4
.0.......... .0
.1.......... .1
.2.......... .2
om
.3.......... .3
.4.......... .4
.5.......... .5
.6.......... .6
.7.......... .7
.0.......... .0
.1.......... .1
.2.......... .2
.3.......... .3
.4.......... .4
l.c
.5.......... .5
.6.......... .6
IB 1 .7.......... .7 QB 5
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.10
SITRAIN Training for
Automation and Drives
@
Continued - The bit in the OutputVar variable is rotated by one position.
- The CounterVar counter variable is reset to 1.
4. Compile the ST source file with debug info, download the ST unit to the
er
target system, and test your program called "Flash" with the test functions
presented in this Chapter.
Task 2.2 In this exercise, the difference in the initialization of global interface variables
ez
Question How does the flashing light display behave in the "Flash_1" program when you
switch the SIMOTION device to "STOP" operating mode and then back to
"RUN"?
r.s
What to do Change the name of the existing program to "Flash_2" and modify it so that
every time the operating mode switches from "STOP" to "RUN", the running light
starts to flash with bit 0.
ne
Task 2.3 The program Flash_2 is to be expanded into a running light that lets the 16 bits
of output word 4 rotate. Every time the operating mode switches from "STOP" to
"RUN", the running light is to start with bit 0.
ca
Task 2.4 How would the program called "Flash_3" behave if a temporary variable
OutputVar was declared instead of the static program variable OutputVar
(solution: Flash_4)?
MyFC : SumMeanValue
om
OF LREAL
l.c
TYPE SumMeanValue: STRUCT
Sum : LREAL;
ai
MeanValue : LREAL;
END_STRUCT;
END_TYPE
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.11
SITRAIN Training for
Automation and Drives
@
Task Create a function for calculating the sum and mean value of a measurement
series:
• The function expects an array of 10 LREAL values at the Measured
values input parameter (data type: ARRAY[0..9] OF LREAL).
er
• The function's return value comprises a structure with the components Sum
(Type: LREAL) and Mean value (type: LREAL) of the array elements passed.
• It should be possible for other blocks in your user program to call this
ez
function.
What to do 1. Create an ST unit called "FC_Unit". "FC_Unit" exports the data type
"SumMeanValue" and the function "MyFC".
r.s
2. Create the function "MyFC". Declare the following parameters in the FC‘s
declaration part:
Input parameters:
- Measured value: ARRAY{0 ..9] OF LREAL. This input parameter is used
ne
Parameters/Variables MotionTask_2
om
MyFC
MyMeasValues
ARRAY[0..9] OF LREAL
Detail window
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.12
SITRAIN Training for
Automation and Drives
@
Testing FCs In this exercise, we are going to test the function called "MyFC". For this
purpose, a short test program is created in MCC. This program is then assigned
to MotionTask_2.
er
What to do 1. Use the MCC editor to create an MCC program called Call_FC in the MCC
unit called "Test".
2. Next, establish a connection to the "FC_Unit" unit in the Start button of the
MCC unit and declare the following global variables in the INTERFACE part
ez
of the MCC unit called "Test" for the actual parameters of the FC call:
- MyMeasValues: data type: LREAL, array length 10
- MySumMeanValue: data type: SumMeanValue
3. Program the statement part of the MCC Chart. First insert a "Wait for signal"
r.s
condition (%I1.7).
4. Then call the "MyFC" FC. Assign the associated variables from the MCC unit
called "Test" to the parameters of the FC.
5. Following compilation, configure the execution system. Assign MotionTask_1
ne
to the MCC chart. In the "Task Configuration" tab of MotionTask_1, set the
option "Activation after StartupTask".
Then switch to online mode and download your project to the target device.
6. Use the "Control" function in the detail window of the symbol browser to
specify appropriate values for the "MyMeasValues" variables declared in the
ca
MyFC2 : SumMeanValue
om
OF LREAL // with dynamic length
l.c
TYPE SumMeanValue: STRUCT
Sum : LREAL;
ai
MeanValue : LREAL;
END_STRUCT;
END_TYPE
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.13
SITRAIN Training for
Automation and Drives
@
Task In the previous exercise, we created a function with the ability to calculate the
sum and the mean value of a measurement series with 10 measured values.
We are now going to expand this "rigid" function by adding the new options
supported in V4.2. This function is going to be able to evaluate measurement
er
parameter (VAR_IN_OUT).
• The following new functions mustie be used to access the index
limits or length:
_firstIndexOf (in := ArrayNam e)
r.s
Mode_Main
Operating mode
... EN ENO
om
%I0.0 Start System_ON %Q4.0
%I0.1 Stop Mode_Manual %Q4.1
%I0.2 Manual_Auto Mode_Auto %Q4.2
%I0.3 Activate_Mode
l.c
System ON/OFF: Manual/Automatic Mode
ai
%I0.0: Start (NO contact, pushbutton) %I0.2: Manual_Auto
%I0.1: Stop (NC contact) %I0.3: Activate mode
%Q4.0: System_ON %Q4.1: Manual mode selected
%Q4.2: Automatic mode selected
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.14
SITRAIN Training for
Automation and Drives
@
Task A system is to be automated. First, an FB called "OP_Mode" is to be created to
switch the system on and off and to select the mode. An instance of this function
block is called in the next exercise in the BackgroundTask and assigned the
actual parameters indicated in the slide above.
er
After every ramp-up (mode transition "STOP" -> "START"), the state of
the system must be switched off.
• Selection of operating mode: Immediately after the system is switched on, no
mode is active. From this state, either "Manual" or "Automatic" mode can be
r.s
FB in a user program.
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.15
SITRAIN Training for
Automation and Drives
@
Testing an In this exercise, an FB instance is to be called in the BackgroundTask and
FB instance tested. For this purpose, a small program called "OB_Main" is first created using
the LAD editor. Within this program, the FB instance is then called.
After this, the "Mode" FB can be tested.
er
What to do 1. Use the LAD editor to create a LAD/FBD unit called "LAD_Main".
2. Then add the "OB_Main" program to the "LAD_Main" unit.
ez
"LAD_Main" unit?)
5. Insert a network in the LAD program and call the FB-Instance "Mode_Main".
4. Assign the actual operands listed on the previous page to the input and
output parameters of the block
ne
Move_Axis_A1
Move_Axis
... EN ENO
om
%I0.4 JOG_Pos
l.c
Static motion of a defined axis
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.16
SITRAIN Training for
Automation and Drives
@
Task The "Move_Axis" function block is created for position-controlled motion of an
axis. In the cyclic program "OB_Main", an instance "Move_Axis_A1" is then
called.
er
What to do 1. Insert an ST source file called "UNIT_POS". In the local settings, select
"Permit status". The function block is to be eintegrated into this unit.
2. Write the "Move_Axis" FB with the following properties:
• The FB has an input parameter camlled "JOG_Pos“
ez
• When the input parameter is eset, a _move command for one axis
(velocity: 100 mm/s) is calledi.
Since the FB is to be dessigned for a cyclic runtime environment, the
parameters at the _mov e command are first set in such a way that a call aborts
the old mo@vement and starts the new movement.
r.s
Move_Axis_A1
Move_Axis
... EN ENO
om
%I0.4 JOG_Pos
l.c
ai
Edge evaluation for the "JOG_Pos" parameter
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.17
SITRAIN Training for
Automation and Drives
@
Task The "Move_Axis" FB is to be expanded. The axis is now to be started by the
positive edge at the "JOG_Pos" input and stopped by the negative edge.
What to do 1. For edge evaluation, integrate one instance of the system FB for
er
Move_Axis_A1
Move_Axis
... EN ENO
om
%I0.4 JOG_Pos
Act_Velocity Velocity
l.c
ai
Passing the axis velocity
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.18
SITRAIN Training for
Automation and Drives
@
Task Make it possible to specify the velocity of the axis using another parameter.
What to do 1. In the FB, insert an additional input parameter of the LREAL data type
called "Velocity".
er
This parameter is used with the MOVE command for specifying the velocity.
2. Create a global variable called "Act_Velocity" (LREAL type) with an
initialization value of 100.0 in the INTERFACE part of "UNIT_POS". When the
FB instance is called in "OB_iMain", the "Velocity" parameter is supplied with
ez
this variable.
Since the "Act_Velocity" variable is created as a global variable, its value can
be monitored and modified with the symbol browser.
3. Test the program by changing the value of the "Act_Velocity" variable
with the symbol browser
r.s
ne
ca
Move_Axis_A1
Move_Axis
... EN ENO ...
%Q4.4
om
%I0.4 JOG_Pos BUSY
Act_Velocity Velocity
l.c
ai
Evaluating the busy signal
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.19
SITRAIN Training for
Automation and Drives
@
Task The "Move_Axis" FB is to report back whether the axis is in motion.
What to do 1. In the FB, insert an output parameter called "BUSY_Pos" of the BOOL
data type.
er
Move_Axis_A1
Move_Axis
... EN ENO ...
%I0.4 JOG_Pos BUSY_Pos %Q4.4
Axis_1 Axis
om
Act_Velocity Velocity
Move_Axis_A2
Move_Axis
l.c
... EN ENO ...
%I0.6 JOG_Pos BUSY_Pos %Q4.6
Axis_2 Axis
ai
Act_Velocity Velocity
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.20
SITRAIN Training for
Automation and Drives
@
Task In the "Move_Axis" FB, an axis object is to be passed in an additional input
parameter called "Axis". This makes for flexibility when implementing the
selection of the required axis.
er
direction.
ne
ca
om
Axis_1 Axis
Act_Velocity Velocity
Move_Axis_A2
Move_Axis
l.c
... EN ENO ...
%I0.6 JOG_Pos BUSY_Pos %Q4.6
%I0.7 JOG_Neg BUSY_Neg %Q4.7
ai
Axis_2 Axis
Act_Velocity Velocity
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Additional negative direction with "JOG_Neg"
Date:
File:
10.01.2013
MC-SMO-PRG_10.21
SITRAIN Training for
Automation and Drives
@
Task Make it possible to select the negative travel direction with an additional input
parameter called "JOG_Neg". Moreover, the output parameter "BUSY_Pos" or
"BUSY_Neg" is to output whether the axis is in motion in a positive or negative
direction.
er
What to do 1. In the FB, insert an input parameter called "JOG_neg" and an output
parameter called "BUSY_Neg" of the "BOOL" data type.
r.s
2. In the declaration part, insert two new static variables "Pos_Command" and
"Neg_Command" of the BOOL data type so that traversing commands
issued in each direction can be stored.
3. Only issue a traversing command in the respective direction if:
ne
With the stop, also reset the variables for storing the traversing commands.
5. Then assign the corresponding TRUE values to the BUSY signals when
the axis is moving (motionstatedata.motionstate <> standstill) and
the actual velocity in the respective direction is greater than "0".
om
Axis_1 Axis Error
Act_Velocity Velocity CommandAborted %Q5.5
Move_Axis_A2
Move_Axis
l.c
... EN ENO ...
%I0.6 JOG_Pos BUSY_Pos %Q4.6
%I0.7 JOG_Neg BUSY_Neg %Q4.7
%Q5.6
ai
Axis_2 Axis Error
Act_Velocity Velocity CommandAborted %Q5.7
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Additional output parameters: "Error" and "CommandAborted"
Date:
File:
10.01.2013
MC-SMO-PRG_10.22
SITRAIN Training for
Automation and Drives
@
Task Up until now, no troubleshooting has been performed in the "Move_Axis" FB. An
implicit assumption has been made that the "Axis" input parameter actually
pointed to a valid axis object when the command was issued and that the
issuing of the motion command was always successful.
er
If either of the two conditions is not fulfilled, the "Error" output parameter is set to
TRUE (synchronous with the activation). The "Error" parameter is then reset
when the associated input parameter is reset.
Neither was the fact that axis motion can be stopped from elsewhere in the user
ez
program or aborted when a TO error occurs taken into account. This state can
only be detected by tracking the command status of the issued motion
command using the CommandId (asynchsronous to issuing the job).
If the motion command is abor ted "externally", then the "CommandAborted"
r.s
4. Also remember that you may only access system variables of an axis
TO if the axis parameter refers to a valid axis TO.
om
Axis_1 Axis Error
Act_Velocity Velocity CommandAborted %Q5.2
Move_Axis_A2
Move_Axis
l.c
... EN ENO ...
%I0.6 JOG_Pos BUSY_Pos %Q4.6
%I0.7 JOG_Neg BUSY_Neg %Q4.7
%Q5.3
ai
Axis_2 Axis Error
Act_Velocity Velocity CommandAborted %Q5.4
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Additional output parameters: "Error" and "CommandAborted"
Date:
File:
10.01.2013
MC-SMO-PRG_10.23
SITRAIN Training for
Automation and Drives
@
Step 2 In the next step, integrate asynchronous error evaluation.
1. Create a global variable of the commandidtype type.
2. Assign a CommandId to this variable (with _getcommandid()).
er
completed.
Create a further global variabsile of the structretcommandstate type that is
used as the return value of the structretcommandstate function.
Call the _getstateofaxiscommand function and evaluate the return value
r.s
accordingly.
Following evalua tion and completion of the command, issue
_removebufferuedaxiscommandid)= to delete the buffered CommandId.
5. Download andl test the program. Pay particular attention to the
"Error" and g"CommandAborted" outputs.
ne
VAR
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.24
SITRAIN Training for
Automation and Drives
@
Task In this exercise, PLCopen blocks from the command library are to be integrated
into the project. Along with the block for mode selection, the blocks for enabling
the axes, for JOG mode, and for resetting the axes (i.e. axis error
acknowledgment) are integrated in the "OB-Main" LAD program.
er
The enables for the axes are only to be set if either "Manual" or "Automatic"
operation is selected. Traversing of the axes using the appropriate direction
pushbuttons is only possible if "Manual" mode is selected. The axis can be reset
regardless of the selected operating mode and system state.
ez
What to do 1. In the "OB_Main" program, delete the declaration of the instances and the
calls of the "Move_Axis" FB so that only the declaration of the instance and
the call of the "Mode" FB remain.
r.s
2. Open the command library and drag the "_mc_power" function block
(enable axes) from the command library to the "OB_Main" program.
If necessary, select the command: Display -> All parameters from the
context menu of the LAD/FBD editor to display all parameters of the block.
3. Then enter the name "Enable_Axis_1" as the name of the instance for the
ne
first call of the "MC_Power" block. The dialog box for declaring variables
opens.
4. Make sure that the instance is created as a variable type VAR, i.e. as a
program-local instance (why?) and confirm the dialog with "OK".
The instance is entered in the declaration part of OB_Main.
ca
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.25
SITRAIN Training for
Automation and Drives
@
Continued 6. Insert the corresponding logic for the enable input so that the axis is only
enabled if automatic or manual mode is active.
7. Insert another instance of "_mc_power" to enable Axis_2.
er
11. IF used, delete the "En_axes" program from the task configuration.
12. Compile, download, and test your user program. For test purposes,
the output parameters of the FBs should be assigned "dummy" variables.
ca
Technical data:
Speed of the belt: 0 - 200 mm/s
Cut-off length: Acquired by sensor
om
Initial
Sensor position Synchronous
100 mm 100 mm
Axis_1
l.c
ai
Axis_2
0.0 mm 100 mm 200 mm
SIMATIC S7
Siemens AG 2013. All rights reserved.
Date:
File:
gm 10.01.2013
MC-SMO-PRG_10.26
SITRAIN Training for
Automation and Drives
@
Task The material (e.g. sheet metal) driven by the feed (Axis_2) must be cut on-the-
fly at the synchronization marks. The synchronization mark sensor detects the
cut-off point on the product and must synchronize the shear with this position
(on-the-fly actual-value setting).
er
400 mm/s). The shear (linear axis) waits in this position until the sensor
detects the synchronization mark.
3. The material feed (Axis_2) is then activated. It transports the bar material
into the working range of the shear at a velocity of 200 mm/s.
ne
om
TaskId
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.27
SITRAIN Training for
Automation and Drives
@
Task In the first part of this exercise, we are going to create the "TaskStartStop"
auxiliary function for traversing axes in automatic mode. Once we have created
the function, we will call it in OB_Main and start/stop MotionTask_3.
The "TaskStartStop" function is implemented in the "ST_Main" unit.
er
• In all cases, i.e. regardless of "Start" and "Stop", the function's return
value (BOOL) contains information about TASK_STATE_RUNNING.
The return value of the function is TRUE if the return value of
_getStateOfTaskId() contains the part TASK_STATE_RUNNING; otherwise
ca
it is FALSE
What to do Create the "TaskStartStop" function in the "ST_Main" unit with the required
properties.
"ErrorHandlerTechFault" program
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.28
SITRAIN Training for
Automation and Drives
@
Task In this exercise, we are going to create a simple ErrorHandler for the
TechnologicalFaultTask. The ErrorHandler will acknowledge alarms relating to
axes, i.e. alarms that do not represent errors from the programmer's point of
view (e.g. alarm 30002). In this case, an alarm message frame is not sent to
er
OCM devices and the axis TO does not switch to the error state (<TO>.error =
yes). The ErrorHandler evaluates the "TaskStartInfo" to identify the TO
triggering the alarm and the error number.
In the following exercises, we are going to add more alarm numbers and TOs
ez
om
Motion Task 4
User Interrupt LAD/FBD (Cutting)
Synchronous operation
l.c
"Automatic" mode
Move to "start position"
Axis_1
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
Axis_2
gm
Date:
File:
Endless motion
10.01.2013
MC-SMO-PRG_10.29
SITRAIN Training for
Automation and Drives
@
Task In this exercise, we are going to integrate the function call of "TaskStartStop"
into OB_Main. The associated program part in OB_Main evaluates the state of
the variable "Mode_Auto" and starts or stops the related MotionTask_3.
. When MotionTask_3 is stopped, possible traversing movements invoked from
er
MotionTask_3 must also be stopped. This is achieved with two instances of the
PLCopen block "_mc_stop".
om
Move Axis_1 to
start position
l.c
Start and stop
Axis_2
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.30
SITRAIN Training for
Automation and Drives
@
Task In this exercise, we are going to create the MCC program for MotionTask_3.
This program moves Axis_1 (shear) to its start position in automatic mode and
then starts the belt running for Axis_2 (material feed).
er
"MCC_Auto" and @assign these variables to the velocity parameter of the MCC
command "Start axis position-controlled"
- The input siugnal %I1.2 (toggle) can be used to stop and restart the belt
movelment of Axis_2 in automatic mode.
2. Compile gthe program called "RunAuto" and assign it to MotionTask_3
ne
position axis
gearing on
om
100 mm
0 mm 200 mm 850 950 Synchronization mark
l.c
Initial
Sensor position Synchronous
100 mm 100 mm
Axis_1
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
Axis_2 gm
0 mm
Date:
File:
100 mm
10.01.2013
MC-SMO-PRG_10.31
200 mm
Synchronize For this strategy, you must start by entering the following settings in the "Settings"
r.s
The following settings must then be made in the synchronous operation command:
• Reference point: "Gearing takes place relative to axis zero"
• Synchronization reference: "Time"
• Start of synchronization: "At leading axis position"
ca
• Reference point of the leading axis position: "Synchronize before leading axis
position"
• Leading axis position: "200 mm"
• Synchronization direction: "Positive"
• Velocity profile: "Smooth"
• Velocity: "Some value < = 10 mm/s"
• Acceleration: "500 mm/s2"
• Jerk: "2,000 mm/s3"
Start of Axes
synchronization synchronized
om
l.c
ai
"Shear" velocity
SIMATIC S7
"Shear" position
MC-SMO-PRG_10.32
SITRAIN Training for
Automation and Drives
@
Desynchronization The axes traverse the next 650 mm in synchronism and the actual cutting
process can take place.
When position 850 mm is reached, the shear is desynchronized. After the shear
has stopped, it returns to its start position at a velocity of 400 mm/s and waits for
er
New cycle
again if the previous cutting process has completely finished. Otherwise, an
error message is looutput.
Tkhe actual cycle for synchronization and desynchronization is implemented
in the "Cutting" program (MotionTask_4). Detection of the synchronization
Program and mark, evaluation of whether the previous cycle has finished, the setting of the
actual value for the material feed, and the start of MotionTask_4 are all
ca
StartGearing
om
Cutting
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.33
SITRAIN Training for
Automation and Drives
@
What to do 1. Create the "StartGearing" program in the "LAD_Auto" unit to start the
synchronization process.
2. Next, use the "TaskStartStop" function to check whether MotionTask_4,
i.e. the task for the cutting process, is still active.
er
3. If MotionTask_4 is not active, set the actual value system of Axis_2 to the
value 0.0 and then start MotionTask_4. In the _redefinePosition() command,
make sure that "WHEN_COMMAND_mDONE" has been selected for the step
enabling condition "nextCommand".
However, if MotionTask_4 is acetive, the call _alarmSQId() is used to issue an
ez
om
l.c
Messages -> Configure
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.34
SITRAIN Training for
Automation and Drives
@
Message Messages are mainly used to display machine errors/machine states or
configuration unexpected control/user program states on HMI systems. SIMOTION supports
both these options by means of the following two message procedures:
• Alarm_S message procedure (machine error/states)
er
Alarm_S Alarm_S is a more recent procedure for configuring and displaying message
ez
Diagnostics In exactly the same way as the operating system, the user is able to enter
buffer entries messages in the diagnostics buffer of a SIMOTION device. Messages stored in
the SIMOTION device diagnostics buffer (which can hold up to 100 entries) can
be used subsequently by experts for troubleshooting. The messages can also
be sent to other OCM equipment on the network.
om
l.c
New message
ai
Fault message (must be acknowledged)
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.35
SITRAIN Training for
Automation and Drives
@
Configuring a You can open the window for configuring an Alarm_S message by selecting:
new message Target system -> Configure messages.
• If the "Alarm_S" option is activated, the screen will display an overview of all
configured Alarm_S messages
er
a new message via the "New" button. The following entries are mandatory in this
dialog:
Symbol Under "Symbol", enter the name of the new message which is to be created.
Permitted characters A-Z, a-z, 0-9, underscore (_). The first character must not
be a digit; multiple underscores must not be placed one after the other.
r.s
No. Enter the number of the created message here or accept the number suggested
automatically. The number must be unique for the configured message.
Message text Under "Message text", enter the text which should be displayed when the
message is called. It is displayed in the detail view on the Alarms tab or on the
HMI device.
ne
Infotext Under "Infotext", enter comments for the message. This text is displayed as help
text when the message occurs.
Message type Under "Message type", select a type for the configured message. Fault
messages and operating messages are acknowledged in different ways on the
ca
display device.
Display class Select a "display class" between 0 and 15. The display class is required if a
definite choice of specific messages is requested for an operator panel during
the configuration of the display (e.g. ProTool).
Printout (at OP) Check this box if you want the incoming message to be forwarded to and
displayed on the HMI equipment. This setting is irrelevant for SIMOTION
SCOUT.
Incoming message
Meaning of the input
parameter "sig":
Outgoing message
_alarmSId
om
Message does EN ENO
not require BOOL sig OUT DWORD
acknowledgment StructAlarmdD ev_id
ANY_NUM sd
l.c
Interconnection of input
e.g.: _alarm.cutting_active
parameter "ev_id":
_alarmSQId
ai
Message requires EN ENO
acknowledgment BOOL sig OUT DWORD
SIMATIC S7
Siemens AG 2013. All rights reserved.
StructAlarmdD
ANY_NUM
gm
Date:
File:
ev_id
sd
10.01.2013
MC-SMO-PRG_10.36
SITRAIN Training for
Automation and Drives
@
Sending You can send freely configured messages to and/or check the status
messages of logged-on display devices. Specifically, you can:
• Send a message that does not require acknowledgment (alarmS, alarmSId)
er
These differ according to the method of identification selected for the message:
• The message is specified by means of a unique AlarmId (e.g. alarmSId).
These functions are available with version V3.1 or later of the SIMOTION
Kernel and can also be used in libraries and in LAD/FBD programs
(like the system functions for task handling).
r.s
You can obtain the AlarmId for a configured message name in the following
way: alarm.name, where name is the message identifier configured in
SIMOTION SCOUT under the "Symbol entry".
• The message is identified by its "Symbol" (e.g. alarmS). These functions
ne
are available in all versions of the SIMOTION Kernel, but can only be used in
ST. They cannot be used in LAD/FBD programs or in libraries.
The message is identified by its "symbol" at input "Al_Name".
Input parameter If the signal has a positive edge in relation to the last call with this message ID,
ca
"Output cam"
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.37
SITRAIN Training for
Automation and Drives
@
Task In this exercise, we are going to implement the actual cutting process, i.e.
control the shear, using an output cam output. For this purpose, we are going to
set up a time-based output cam for the axis "Axis_1".
Once "Axis_1" has synchronized with the synchronization mark, the cutting
er
process will be initiated via an output cam. It will commence at position 200 mm
and take 5 seconds to complete.
On the D425-2, the output cam is set up as a fast output cam of the bidirectional
inputs/outputs at the connector X142 of the D425-2. The cutting process is also
ez
Procedure 1. Open the screen form with the parameterization of the bidirectional
inputs/outputs at the connector X142 of the D425-2.
r.s
2. Select the "Channel 0 – 7" tab, and parameterize the DI/DO3 as "output
cam".
3. Below the axis "Axis_1" in the folder "Cams", insert a output cam TO with
the name "Cutter".
ne
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.38
SITRAIN Training for
Automation and Drives
@
Task In this exercise, we are going to create a cam (Name: Cutting) with the help of
the VDI wizard in the "CamEdit" tool. This cam will then be used to provide an
alternative gearing solution for synchronizing the following axis (Axis_1) with the
leading axis (Axis_2).
er
section at constant velocity. It starts at the 200 mm position and finishes at 850
mm.
This motion section describes the synchronous motion of the following axis
"Filler" in relation to the leading axis "Conveyor belt" and it is during this section
that the actual cutting operation takes place.
ne
Segment 3 : The axis moves at constant velocity back to the initial position. The
initial position should be reached at the 1500 mm position of the leading axis.
Essentially, this motion describes desynchronization and ramp-down.
ca
FC: Create_Cam
om
OF InterpolationPoint
IPO_Type
enumcaminterpolationmode
Cam_TYPE enumcammode
Cam
l.c
CamType
ai
TYPE Interpolation point : STRUCT
X_pos : LREAL;
Y_pos : LREAL;
END_STRUCT;
SIMATIC S7
END_TYPE
What to do 1. In CamEdit, first create an "empty" cam called "MyCam" and download it to
the target device.
2. Create an ST unit called "Cam_Unit". "Cam_Unit" exports the data type
ez
function.
4. Next, reset the cam in the statement part of the function. Then create a loop
with the corresponding passes. In each pass, another interpolation point from
the array passed is added to the cam. At the end, interpolate the completed
cam. The function is to work exclusively in the "Actual" coordinate system.
The definition range (master range) is fixed from 0 to 100.
Parameters/Variables
MotionTask_5
om
Interpolation FC: Create_Cam
Detail window _Point
ARRAY[0..9]
IPO_Type OF InterpolationPoint
enumcaminterpolationmode
CAM_TYPE
l.c
enumcammode
Act_Cam
CamType
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.40
SITRAIN Training for
Automation and Drives
@
Task In this exercise, we are going to test the function called "Create_Cam". The test
is carried out using a small MMC program called "Test_Cam" (MotionTask_5) in
the "Test" unit.
er
What to do 1. Use the MCC editor to create a program called "Test_Cam" in the unit
called "Test".
2. Next, establish a connection to the "Cam_Unit" unit in the "Test" unit.
For the actual parameters of the FC call, also declare the following global
ez
program, add an end less While loop followed by "Wait for signal (%I1.7)
condition".
4. Then call thel "Create_Cam" FC. Assign the associated variables from
the "Test" unit gto the parameters of the FC. The "MyCam"cam is assigned to
the Cam input oparameter.
5. Clonfigure the execution system. Assign the "Test_Cam" program to
ne
Cut2
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.41
SITRAIN Training for
Automation and Drives
@
Task In this exercise, we are going to replace the existing program "Cutting" for the
synchronization of both axes and the cutting process with another program
"Cut_2". This program utilizes the cam created in exercise 8.1.
er
What to do 1. Create a program called "Cut_2" in the unit called "MCC_Auto". In this
program, both "synchronization" and the return of the shear to its start
position are implemented with camming.
Start the synchronization process with a leading-axis-related synchronization
ez
om
"Shear" velocity
l.c
ai
SIMATIC S7
"Shear" position
MC-SMO-PRG_10.42
"Shear" position
Receiver
Sender
IP addr.: 192.168.2.2
IP addr.: 192.168.2.1
SINAMICS
SINAMICS
Subnet: 255.255.255.0
270O
0O
Subnet: 255.255.255.0
90O
om
Port: 2222
Port: 2222 180O
0O
270O
SINAMICS
SINAMICS
90O
270O
0O
90O
180O
180O
0O
270O
90O
SMC
180O
l.c
SMC
ai
cyclic
SIMATIC S7
Siemens AG 2013. All rights reserved.
16
Bytes
Date:
File:
gm
Axis_1.positioningstate.commandposition
Axis_1.motionstatedata.commandvelocity
10.01.2013
MC-SMO-PRG_10.43
SITRAIN Training for
Automation and Drives
@
Objective In the following exercise, we are going to establish UDP communication
between two D425-2 devices. For this purpose, two neighboring training stations
are connected via an additional Ethernet cable (see slide).
The sender station sends status information about its own Axis_1 (position,
er
velocity) cyclically to the second station. The partner station receives the data
and displays the information in user variables.
One group creates a user function UDP_Send() in which the two system
variables "Axis_1.postioningstate.commandposition" and
ez
The second group creates the corresponding receive function. For this purpose,
the user function UDP_Receive() is created. It receives data with the system
function _udpreceive() and unpacks the information into two user variables.
This function is also called cyclically by the receiver station's
TimerinterruptTask_2 in another program, "OB_Receive".
ne
ca
1. Double-click
om
2. Properties
3. Enter IP address
192.168.2.2
l.c
ai
SIMATIC S7
4. Confirm with "OK"
1. Double-click the D425-2 symbol in the SCOUT project window to open the
HW Config tool and double-click the PNxIE-NET entry in the D425-2 station.
The properties dialog for the Ethernet interface PNxIE-NET opens.
ez
5. Save your entries and download the new settings to the receiver station by
clicking the Download button on the HW Config toolbar.
6. Once the D425-2 station has restarted, check the new IP address using the
online function: Target device -> Device Diagnostics.
ne
ca
om
END_INTERFACE
IMPLEMENTATION
FUNCTION UDP_Send : VOID
DataSend := ANYTYPE_TO_LITTLEBYTEARRAY(
anydata := Axis_1.positioningstate.commandposition,
offset:=0);
l.c
DataSend := ANYTYPE_TO_LITTLEBYTEARRAY(
anydata := Axis_1.motionstatedata.commandvelocity,
offset:=8);
myRetDINT := _udpSend(sourceport := 2222,
destinationaddress := ReceiverAddress,
ai
destinationport := 2222,
communicationmode := DO_NOT_CLOSE_ON_EXIT,
datalength := 16,
data := DataSend);
END_FUNCTION
END_IMPLEMENTATION
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.45
SITRAIN Training for
Automation and Drives
@
What to do In the sender station, data transmission is implemented with a simple user
function called "UDP_Send". Following data transmission, this function is called
in the LAD program "OB_Send". The OB_Send program is assigned to
TimerinterruptTask_1.
er
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.46
SITRAIN Training for
Automation and Drives
@
What to do In the last step, the function created is called in a separate LAD program,
"OB_Send". This LAD program is then assigned to TimerinterruptTask_1 in the
execution system. TimerinteruptTask_1 is called every 24 ms.
1. In the "LAD_Main" unit, establish a connection to the ST unit called
er
"ST_Send".
2. In the "LAD_Main" unit, create a program caelled "OB_Send".
3. In the first network, call the user function "UDP_Send". Also, link
the EN input of the function to the simulator input signal %I1.5.
ez
INTERFACE
VAR_GLOBAL
myRetStructRetUdpReceive : StructRetUdpReceive; //Return structure for receiving
DataReceived : ARRAY[0..15] OF BYTE; //Receive buffer
MyPosition : LREAL;
MyVelocity : LREAL;
END_VAR
om
FUNCTION UDP_Receive;
END_INTERFACE
IMPLEMENTATION
FUNCTION UDP_Receive : VOID
MyRetStructRetUdpReceive :=_udpReceive(port := 2222,
communicationmode := DO_NOT_CLOSE_ON_EXIT,
nextcommand := IMMEDIATELY,
l.c
receivevariable := DataReceived);
IF MyRetStructRetUdpReceive.functionresult = 0 THEN
MyPosition := LITTLEBYTEARRAY_TO_ANYTYPE(DataReceived, 0);
MyVelocity := LITTLEBYTEARRAY_TO_ANYTYPE(DataReceived, 8);
ai
END_IF;
END_FUNCTION
END_IMPLEMENTATION
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.47
SITRAIN Training for
Automation and Drives
@
What to do In the receiver station, the actual receipt of the data is implemented with the
simple user function "UDP_Receive". Following data receipt, the function is
called in the LAD program OB_Receive. The "OB_Receive" program is
assigned to TimerinterruptTask_2, which is called every 28 ms.
er
error.
In addition, publish the user function "UDP_send()" in the INTERFACE
part of the user function. It is called later from the "LAD_Main" unit.
3 Implement the user function "UDP_Receive()" in the IMPLEMENTATION
part without parameters or a return value.
ne
6. Next, issue the receive call _udpReceive() for port 2222. Remember that this
call is executed subsequently in a cyclic program. Therefore, you must pass
the value IMMEDIATELY for the nextcommand parameter.
In the return structure, the functionResult entry indicates whether new data
ca
has actually been received and copied to the "DataReceived" receive buffer.
Only unpack the data from receive buffer and write it to the two user
variables "MyPosition" and "MyVelocity" if new data has been received and
copied to the receive buffer.
Use the LITTLEBYTEARRAY_TO_ANYTYPE function to unpack the data.
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.48
SITRAIN Training for
Automation and Drives
@
What to do In the last step, the function created is called in a separate LAD program,
"OB_Receive". In the execution system, this LAD program is assigned to
TimerinterruptTask_2, which is called every 28 ms.
1. In the "LAD_Main" unit, establish a connection to the ST unit called
er
"ST_Recv".
2. In the "LAD_Main" unit, create a program called "OB_Receive".
3. In the first network, call the user functionm "UDP_Receive".
Also, link the EN input of the funcetion to the simulator input signal %I1.5.
ez
om
MySendData : MyDataStruct;
DataSend : ARRAY[0.._sizeof(in := MyDataStruct) -1] OF BYTE; //Send buffer
ReceiverAddress : ARRAY[0..3] OF USINT := [192,168,214,2]; //Address of receiver
END_VAR
FUNCTION UDP_SEND;
END_INTERFACE
IMPLEMENTATION
FUNCTION UDP_SEND : VOID
l.c
MySendData.Position := Axis_1.positioningstate.commandposition;
MySendData.Velocity := Axis_1.motionstatedata.commandvelocity;
DataSend := ANYTYPE_TO_LITTLEBYTEARRAY(
anydata := MySenderData,
offset:=0);
ai
myRetDINT := _udpsend(sourceport := 2222,
destinationaddress := ReceiverAddress,
destinationport := 2222,
communicationmode := DO_NOT_CLOSE_ON_EXIT,
datalength := dint_to_udint(_sizeof(in := MyDataStruct)),
SIMATIC S7
END_FUNCTION
END_IMPLEMENTATION
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.49
SITRAIN Training for
Automation and Drives
@
UDP_Send2() In this case, the user structure of the data to be transmitted must be defined
prior to transmission. A structure "MyDataStruct" with the individual data types
to be transmitted is defined in the TYPE section.
Next, a user variable "MySendData" with type "MyDataStruct" is created, along
er
with the send buffer with type ARRAY OF BYTE. The length in BYTES of the
send buffer is determined using the system function _sizeof(), with the
"MyDataStruct" structure being passed in the "in" parameter.
In the statement part of the function, the required information about position and
ez
INTERFACE
TYPE
MyDataStruct : STRUCT // Structure of receive data following unpacking
Position : LREAL;
Velocity : LREAL;
END_STRUCT;
END_TYPE
om
VAR_GLOBAL
myRetStructRetUdpReceive : StructRetUdpReceive; //Return structure for receiving
DataReceived : ARRAY[0.._sizeof(in := MyDataStruct) -1] OF BYTE; //Receive buffer
MyReceivedData : MyDataStruct; // Structure variable for unpacked data
END_VAR
FUNCTION UDP_Receive2;
END_INTERFACE
l.c
IMPLEMENTATION
FUNCTION UDP_Receive2 : VOID
MyRetStructRetUdpReceive :=_udpreceive(port := 2222,
communicationmode := DO_NOT_CLOSE_ON_EXIT,
nextcommand := IMMEDIATELY,
ai
receivevariable := DataReceived);
IF MyRetStructRetUdpReceive.functionresult = 0 THEN
MyReceivedData := LITTLEBYTEARRAY_TO_ANYTYPE(DataReceived, 0);
END_IF;
END_FUNCTION
END_IMPLEMENTATION
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.50
SITRAIN Training for
Automation and Drives
@
UDP_Receive2() In this case, the user structure of the data to be received must be defined prior
to receipt. This structure must be the same, i.e. have the same data types (not
necessarily the same names) as that used when sending data. A structure
called "MyDataStruct" with the individual data types is therefore defined in the
TYPE section.
Next, a user variable called "MyReceiveData" ewith type "MyDataStruct" as
er
well as the receive buffer with type ARRAY OF BYTE is created. The length in
BYTES of the receive buffer is determinedm using the system function
_sizeof(), with the "MyDataStruct" structure beeing passed in the "in"
parameter.
Then the system function _udpreceiive is called in the statement part of the
function. If there is new data in the receive buffer, it can be unpacked to the
ez
"Fixed gear" TO
%I1.6
om
Initial
Sensor position
l.c
Slave value
Axis_1
ai
SIMATIC S7
Axis_2
10.01.2013
MC-SMO-PRG_10.51
SITRAIN Training for
Automation and Drives
@
Objective In this exercise, a rigid coupling of both axes is to be achieved using a "Fixed
gear" TO so that both axes can be traversed when coupled. The axes are
coupled using a relative position synchronous operation with a gear ratio of 1:1.
Gearing is activated and deactivated in manual mode via switch %I1.6.
er
Axis_2 provides the master values, Axis_1 implements the following axis.
In addition, synchronous operation is to be executed in the superimposed
coordinate system of Axis_1.
The actual logic for activating and deactivating the coupling is implemented in
ez
Default: A2_A1_Coupling
om
Interconnections: A2_A1_Coupling
l.c
Axis_2 - Sepoint
Interconnections: Axis_1
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
"D425-2" – A2_A1_Coupling – Motion output
Date:
File:
10.01.2013
MC-SMO-PRG_10.52
SITRAIN Training for
Automation and Drives
@
Continued 5. Enter the following settings in the "Default" dialog:
- Direction: Same direction
- Gear type: Relative gear
er
7. In the "Interconnections" dialog for the motion input of Axis_1, select the
motion output of the "A2_A1_Coupling" TO.
8. Also, change the default behavior of the feedback of the superimposed
coordinate system to the basic coordinate system.
Open the expert list of Axis_1 and change the following configuration data:
ne
- Axis_1.typeOfAxis.decodingConfig.transferSuperimposedPosition =
TRANSFER_RESET
ca
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.53
SITRAIN Training for
Automation and Drives
@
Objective In the next step, we are going to create the MCC program "ActivateCoupling".
This program is started from the LAD program "OB_Main" and implements the
activation and deactivation logic for the "Fixed gear" and for the motion input of
Axis_1.
er
When the program starts, the fixed gear is activated. After this, the motion input
for the superimposed coordinate system at Axis_1 ise activated.
The program then waits for deactivation so that it can first stop Axis_1 in the
superimposed coordinate system and tmhen deactivate the gear. Deactivation
ez
- nextCommand: WHEN_COMMAND_DONE
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.54
SITRAIN Training for
Automation and Drives
@
Continued 5. Then use the system function _enableFixedGear() to activate the "Fixed
gear". As all relevant settings have already been made in the Default dialog,
only the following entries have to be made explicitly in this command:
- fixedGear: A2_A1_Coupling
er
- nextCommand: WHEN_GEARING_START
6. Before you activate the motion input at Axis_2, remember:
Motion via the MotionIn interface is executed in the superimposed coordinate
ez
system.
To prevent compensating motion when the motion input is activated due to
differences in the values of the motion output of "Fixed gear" and the
instantaneous position of Axis_1 in the superimposed coordinate system, the
current superimposed position of Axis_1 must be calculated with the motion
r.s
- offsetRange: SLAVE_RANGE
- offsetMode: ABSOLUTE
- offsetValue: Axis_1.superimposedmotion.position
- activationMode: ACTUAL_VALUE
ca
- nextCommand: WHEN_COMMAND_DONE
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.55
SITRAIN Training for
Automation and Drives
@
Continued 7. In the next step, the motion input of the MotionIn interface of Axis_1 can now
be activated with the _runPositionBasedMotionIn() command:
- axis: Axis_1
er
- reference: A2_A1_Coupling
- megeMode: SUPERIMPOSED_MOTION_MERGE
- nextCommand: AT_MOTION_START
8. The above settings activate the MotionIn interface with coupling to
ez
"Fixed gear". The MCC program is now waiting for the following conditions
to be fulfilled so that it can then execute the corresponding deactivation
logic for Axis_1 and the "Fixed gear":
- %I1.6 changes state to FALSE
r.s
OB_Main
om
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.56
SITRAIN Training for
Automation and Drives
@
Objective In the last step, the "ActivateCoupling" program is assigned to MotionTask_6 in
the execution system and the start logic for MotionTask_6 is integrated into
OB_Main.
MotionTask_6 is started with the "TaskStartStop" function based on the
er
What to do
MotionTask_6. MotionTask_6 is noet started automatically after the
StartupTask.
2. Open the LAD program "OB_sMain" and enter a new network at
the end.
r.s
om
For Data Access
For Alarms&Events
l.c
4. Enter interface 3. Enter path
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Drive:\Documents and Settings\All Users\Anwendungsdaten\
Siemens\SIMATIC.NET\opc2\binS7\simotion\xml\
Date:
File:
10.01.2013
MC-SMO-PRG_10.57
SITRAIN Training for
Automation and Drives
@
Task In this exercise, we are going to perform an OPC data export. We will then use
OPC Scout to test whether the OPC server on the programming device is
functioning correctly. As a first step, we will export the required files from
SIMOTION SCOUT and store them in the OPC server directory.
er
What to do 1. Switch SIMOTION SCOUT to offline mode if it is not already offline. Then
select menu command: Options -> Export OPCe data...
The dialog "Setting the Data for Expormt" opens.
ez
2. Activate "SIMATIC NET V8.1.1" foer the version of the OPC server and
the global export option for controillers (not drives).
Under Use, check all of the bosxes (i.e. "OPC data", "Arrays with single
elements", and "OPC alar m/event"). Then confirm your selection with "OK".
3. Next, the "OPC Export@" dialog opens in which you must enter the
r.s
target directory for the export files. In our case, the OPC server runs on the same
platform as SI MOTION SCOUT. Therefore, we can specify the directory
expected by the OuPC server when the system starts up as the target directory:
D:\Dokumgente und Einstellungen\AllUsers\Anwendungsdaten\ Siemens
\SIMATIC.NEoT\opc2\binS7\simotion\xml".
ne
om
OPC Settings -> Symbols: Select *.sti File
l.c
Advanced symbols
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.58
TCP/IP ->Intel ...
What to do 1. Start by opening the Windows Start menu on your PG and select:
Start -> SIMATIC -> SIMATIC NET -> Comnfiguration Console
to open the "Configuration Consolee" tool.
ez
necessary.
3. In the navigation w indow, select "Symbols". Click the "Edit list" button
to open the "Manage suymbol files" dialog.
In this dialog, click the "Browse" button and select the exported *.sti file from our
SIMOTION project.
ne
After you have selected the symbol file, close the "Edit list" dialog by clicking
"OK". The selected symbol file is displayed in the "Active symbol files" list.
4. The last step is to open the "Advanced Symbols" dialog by clicking the
"Advanced Symbols" button. In this box, select the interface via which the OPC
server will access the SIMOTION device.
ca
om
Step 3: Add items to the group and
monitor
l.c
ai
SIMATIC S7
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_10.59
SITRAIN Training for
Automation and Drives
@
Task In this exercise, we are going to test the accessibility and correct functioning of
the OPC server. To do this, we will start the OPC client application OPC Scout
and check whether OPC server variables can be accessed.
er
Once the OPC server is running, the "Add Group" dialog opens.
3. Enter a group name of your choice and click "OK" to confirm your entry
and close the dialog. The new group is displayed in the navigation window of
OPC Scout.
4. The next step is to add the desired process variables to the new group.
r.s
5. Select the folder of your choice in the navigation window; the process
variables (items) it contains will be displayed in the "Leaves" window.
Select the desired process variables in the "Leaves" window and click the
" -> " button. The selected process variable is added to the OPC group and
displayed in the right-hand window.
ca
6. Repeat the selection made in Step 5 until you have added all the required
process variables to the OPC group. Then confirm your selections by clicking
"OK".
The OPC navigator closes. The selected process variables and their current
values are now visible in the OPC Scout window.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_11.1
SITRAIN Training for
Automation and Drives
@
Contents Page
Exercise 2.1: Flash_1 ....................................................................................................................... 3
Exercise 2.2: Flash_2 ....................................................................................................................... 4
er
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PROG_11.2
SITRAIN Training for
Automation and Drives
@
Contents Page
Exercise 5.2: OB_Main (2) .............................................................................................................. 27
Exercise 6.1: Creating the "TaskStartStop" function ......................................................................... 28
er
om
UNIT ST1;
INTERFACE
VAR_GLOBAL
CounterVar : INT := 1;
OutputVar : BYTE := 1;
l.c
END_VAR
PROGRAM Flash_1;
ai
END_INTERFACE
IMPLEMENTATION
PROGRAM Flash_1
CounterVar := 1;
END_IF;
ez
END_PROGRAM
END_IMPLEMENTATION
r.s
ne
ca
om
UNIT ST1;
INTERFACE
PROGRAM Flash_2;
l.c
END_INTERFACE
IMPLEMENTATION
ai
PROGRAM Flash_2
VAR
CounterVar : INT := 1;
OutputVar : BYTE := 1;
END_VAR
gm
IF CounterVar <= 500 THEN
@
CounterVar := CounterVar + 1;
ELSE
%QB4 := OutputVar;
er
OutputVar := ROL(OutputVar,1);
CounterVar := 1;
END_IF;
ez
END_PROGRAM
END_IMPLEMENTATION
r.s
ne
ca
om
UNIT ST1;
INTERFACE
PROGRAM Flash_3;
l.c
END_INTERFACE
IMPLEMENTATION
ai
PROGRAM Flash_3
VAR
CounterVar : INT := 1;
OutputVar : WORD := 256;
END_VAR
gm
IF CounterVar <= 500 THEN
@
CounterVar := CounterVar + 1;
ELSE
%QW4 := OutputVar;
er
OutputVar := ROL(OutputVar,1);
CounterVar := 1;
END_IF;
ez
END_PROGRAM
END_IMPLEMENTATION
r.s
ne
ca
om
UNIT ST1;
INTERFACE
PROGRAM Flash_4;
l.c
END_INTERFACE
IMPLEMENTATION
ai
PROGRAM Flash_4
VAR_TEMP
OutputVar : WORD := 256;
END_VAR
VAR
CounterVar : INT := 1;
gm
END_VAR
@
IF CounterVar <= 500 THEN
CounterVar := CounterVar + 1;
er
ELSE
%QW4 := OutputVar;
OutputVar := ROL(OutputVar,1);
ez
CounterVar := 1;
END_IF;
END_PROGRAM
r.s
END_IMPLEMENTATION
ne
ca
UNIT FC_UNIT;
INTERFACE
om
TYPE SumMeanValue : STRUCT
Sum : LREAL;
MeanValue : LREAL;
END_STRUCT;
END_TYPE
l.c
FUNCTION MyFC;
END_INTERFACE
ai
IMPLEMENTATION
END_VAR
FOR Index := 0 TO 9 BY 1 DO
ez
MyFC.Sum := IntermSum;
r.s
END_FUNCTION
ne
END_IMPLEMENTATION
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
INTERFACE
TYPE SumMeanValue : STRUCT
Sum : LREAL;
om
MeanValue : LREAL;
END_STRUCT;
END_TYPE
FUNCTION MyFC;
FUNCTION MyFC2;
l.c
END_INTERFACE
IMPLEMENTATION
FUNCTION MyFC : SumMeanValue
ai
VAR_INPUT
MeasValue: ARRAY[0..9] OF LREAL;
END_VAR
VAR
Index : INT;
IntermSum : LREAL;
END_VAR
FOR Index := 0 TO 9 BY 1 DO
gm
@
IntermSum := IntermSum + MeasValue[Index];
END_FOR;
MyFC.Sum := IntermSum;
MyFC.MeanValue := IntermSum / 10;
er
END_FUNCTION
i : DINT;
IntermSum : LREAL;
END_VAR
ne
DO
IntermSum := IntermSumo+ MeasValue[i];
END_FOR;
ca
MyFC2.Sum := IntermSum;
MyFC2.MeanValue := IntermSumk /_lengthIndexOf(in:= MeasValue);
END_FUNCTION
END_IMPLEMENTATION
FUNCTION_BLOCK OP_Mode;
om
END_INTERFACE
IMPLEMENTATION
FUNCTION_BLOCK OP_Mode
l.c
VAR_INPUT
Start: BOOL;
Stop: BOOL;
ai
Manual_Auto : BOOL;
Activate_Mode : BOOL;
END_VAR
VAR_OUTPUT
System_ON : BOOL;
Mode_Manual : BOOL;
Mode_Auto : BOOL;
END_VAR
gm
@
// Two "networks" for switching on and off
IF Start THEN System_ON := TRUE; END_IF;
IF NOT Stop THEN System_ON := FALSE; END_IF;
er
END_FUNCTION_BLOCK
ne
END_IMPLEMENTATION
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
UNIT Unit_Pos;
INTERFACE
USEPACKAGE CAM; //Select technology package
om
FUNCTION_BLOCK Move_Axis;
END_INTERFACE
IMPLEMENTATION
l.c
FUNCTION_BLOCK Move_Axis
VAR_INPUT
ai
JOG_Pos: BOOL; //Start axis motion
END_VAR
VAR_TEMP
Ret_Val: DINT;
END_VAR
IF JOG_Pos THEN
gm
//Variable for storing the return value
ret_val:=_move(
@
axis:=Axis_1,
direction:=positive,
velocitytype:=USER_DEFAULT,
velocity:=100,
er
velocityprofile:=USER_DEFAULT,
mergemode:=immediately,
nextcommand:=IMMEDIATELY, //Advance immediately
commandid:=_getcommandid(),
ez
movingmode:=POSITION_CONTROLLED);
END_IF;
END_FUNCTION_BLOCK
r.s
END_IMPLEMENTATION
ne
ca
UNIT Unit_Pos;
INTERFACE
USEPACKAGE CAM; //Select technology package
om
FUNCTION_BLOCK Move_Axis;
END_INTERFACE
IMPLEMENTATION
l.c
FUNCTION_BLOCK Move_Axis
VAR_INPUT
JOG_Pos: BOOL; //Start axis motion
ai
END_VAR
VAR
r_trig_1 : r_trig; //Instance for R_TRIG FB
f_trig_1: f_trig;
END_VAR
VAR_TEMP
Ret_Val: DINT;
gm
//Instance for F_TRIG FB
velocitytype:=USER_DEFAULT,
velocity:=100,
velocityprofile:=USER_DEFAULT,
mergemode:=immediately,
nextcommand := IMMEDIATELY,
r.s
commandid:=_getcommandid(),
movingmode:=POSITION_CONTROLLED);
END_IF;
ne
stopid:=_getcommandid (),
mergemode:=IMMEDIATELY,
nextcommand := IMMEDIATELY,
commandid:=_getcommandid());
END_IF;
END_FUNCTION_BLOCK
END_IMPLEMENTATION
UNIT Unit_Pos;
INTERFACE
USEPACKAGE CAM; //Select technology package
om
FUNCTION_BLOCK Move_Axis;
VAR_GLOBAL
Act_Velocity: LREAL := 100;
END_VAR
END_INTERFACE
l.c
IMPLEMENTATION
FUNCTION_BLOCK Move_Axis
VAR_INPUT
ai
JOG_Pos: BOOL; //Start axis motion
Velocity: LREAL; //Passing of velocity
END_VAR
VAR
r_trig_1 : r_trig;
f_trig_1: f_trig;
END_VAR
gm
//Instance for R_TRIG FB
//Instance for F_TRIG FB
VAR_TEMP
@
Ret_Val: DINT; //Variable for return value
END_VAR
axis := Axis_1,
direction:=positive,
velocitytype:=USER_DEFAULT,
velocity:=Velocity,
velocityprofile:=USER_DEFAULT,
r.s
mergemode:=immediately,
nextcommand := IMMEDIATELY,
commandid:=_getcommandid(),
movingmode:=POSITION_CONTROLLED);
ne
END_IF;
stopmode:=STOP_and_ABORT,
stopspecification:=ALL_AXIS_MOTION,
stopid:=_getcommandid (),
mergemode:=IMMEDIATELY,
nextcommand := IMMEDIATELY,
commandid:=_getcommandid());
END_IF;
END_FUNCTION_BLOCK
END_IMPLEMENTATION
UNIT Unit_Pos;
INTERFACE
USEPACKAGE CAM; //Select technology package
om
FUNCTION_BLOCK Move_Axis;
VAR_GLOBAL
Act_Velocity: LREAL := 100;
END_VAR
END_INTERFACE
IMPLEMENTATION
l.c
FUNCTION_BLOCK Move_Axis
VAR_INPUT
JOG_Pos: BOOL; //Start axis motion
ai
Velocity: LREAL; //Passing of velocity
END_VAR
VAR_OUTPUT
VAR
BUSY_Pos: BOOL;
END_VAR
r_trig_1 : r_trig;
f_trig_1: f_trig;
gm
// Status of axis motion
velocity:=Velocity,
velocityprofile:=USER_DEFAULT,
mergemode:=immediately,
nextcommand := IMMEDIATELY,
ne
commandid:=_getcommandid(),
movingmode:=POSITION_CONTROLLED);
END_IF;
om
ELSE
BUSY_Pos:= FALSE;
END_IF;
END_FUNCTION_BLOCK
END_IMPLEMENTATION
l.c
ai
gm
@
er
ez
r.s
ne
ca
UNIT Unit_Pos;
om
INTERFACE
USEPACKAGE CAM; //Select technology package
FUNCTION_BLOCK Move_Axis;
VAR_GLOBAL
Act_Velocity: LREAL := 100;
END_VAR
l.c
END_INTERFACE
IMPLEMENTATION
FUNCTION_BLOCK Move_Axis
VAR_INPUT
ai
JOG_Pos: BOOL; //Start axis motion
Axis : posAxis; //Selected axis
Velocity: LREAL; //Passing of velocity
END_VAR
VAR_OUTPUT
BUSY_Pos: BOOL;
END_VAR
VAR
gm
// Status of axis motion
VAR_TEMP
er
direction:=positive,
velocitytype:=USER_DEFAULT,
velocity:=Velocity,
velocityprofile:=USER_DEFAULT,
mergemode:=immediately,
ne
nextcommand := IMMEDIATELY,
commandid:=_getcommandid(),
movingmode:=POSITION_CONTROLLED);
END_IF;
IF f_trig_1.q THEN //On negative edge
ca
om
IF NOT (Axis.motionstatedata.motionstate = standstill) THEN
BUSY_Pos:= TRUE; //Busy signal evaluation
ELSE
BUSY_Pos:= FALSE;
END_IF;
l.c
END_FUNCTION_BLOCK
END_IMPLEMENTATION
ai
gm
@
er
ez
r.s
ne
ca
om
VAR_GLOBAL
Act_Velocity: LREAL := 100;
END_VAR
END_INTERFACE
IMPLEMENTATION
l.c
FUNCTION_BLOCK Move_Axis
VAR_INPUT
JOG_pos: BOOL; //Start axis motion
JOG_neg: BOOL;
ai
Axis : posAxis; //Selected axis
Velocity: LREAL; //Passing of velocity
END_VAR
VAR_OUTPUT
BUSY_POS: BOOL;
BUSY_NEG: BOOL;
END_VAR
gm
// Status of axis motion
@
VAR
r_trig_1 : r_trig; //Instance_JOG_Pos for R_TRIG FB
f_trig_1: f_trig; //Instance_JOG_Pos for F_TRIG FB
r_trig_2: r_trig; //Instance_JOG_Neg for R_TRIG FB
er
VAR_TEMP
Ret_Val: DINT; //Variable for return value
END_VAR
r.s
ret_val:=_move(axis:=Axis,
direction:=positive, velocitytype:=USER_DEFAULT,
velocity:=Velocity,
velocityprofile:=USER_DEFAULT,
mergemode:=immediately,
nextcommand := IMMEDIATELY,
commandid:=_getcommandid(),
movingmode:=POSITION_CONTROLLED); //Next page
END_IF;
//On a positive edge at JOG_neg if a pos. edge is not pending
om
//simultaneously at JOG_pos and a pos. motion command is not pending,
//then ...
IF r_trig_2.q AND NOT r_trig_1.q AND NOT Pos_Command THEN
ret_val:=_move(axis:=Axis,
direction:=negative,
velocitytype:=USER_DEFAULT,
l.c
velocity:=Velocity,
velocityprofile:=USER_DEFAULT,
mergemode:=immediately,
nextcommand := IMMEDIATELY,
commandid:=_getcommandid(),
ai
movingmode:=POSITION_CONTROLLED);
Neg_Command := TRUE;
END_IF;
gm
//On a negative edge with associated traversing command
IF (f_trig_1.q AND Pos_Command) OR (f_trig_2.q AND Neg_Command) THEN
ret_val :=_stop(
@
axis:=Axis,
er
stopmode:=STOP_and_ABORT, stopspecification:=ALL_AXIS_MOTION,
stopid:=_getcommandid (), mergemode:=IMMEDIATELY, nextcommand :=
IMMEDIATELY, commandid:=_getcommandid());
Pos_Command := FALSE;
ez
Neg_Command := FALSE;
END_IF; //Busy signal evaluation
IF NOT (Axis.motionstatedata.motionstate=standstill) i AND
(Axis.motionstatedata.actualVelocitys >= 0) THEN BUSY_POS:= TRUE;
r.s
FUNCTION_BLOCK Move_Axis_7
VAR_INPUT
om
JOG_pos: BOOL; //Start axis motion
JOG_neg: BOOL ;
Axis : posAxis; //Selected axis
Velocity : LREAL; //Passing of velocity
END_VAR
l.c
VAR_OUTPUT
BUSY_POS: BOOL; // Status of axis motion
BUSY_NEG: BOOL ;
Error: BOOL; // Synchronous error
ai
CommandAborted: BOOL; // Asynchronous error
END_VAR
VAR
r_trig_2: r_trig;
f_trig_2: f_trig;
gm
r_trig_1 : r_trig; //Instance_JOG_Pos for the R_TRIG FB
f_trig_1: f_trig; //Instance_JOG_Pos for the F_TRIG FB
//Instance_JOG_Neg for the R_TRIG FB
//Instance_JOG_Neg for the F_TRIG FB
Pos_Command: BOOL ;
@
Neg_Command: BOOL ;
ret_val_id: STRUCTretcommandstate; //Stores the RetVal of
_getstate...
myid: commandidtype; //CommandID
er
END_VAR
VAR_TEMP
Ret_Val_1: DINT; //Variables for return value
ez
Ret_Val_2: DINT;
RetVal : DINT;
END_VAR
om
direction:=positive,
velocitytype:=DIRECT,
velocity:=Velocity,
velocityprofile:=USER_DEFAULT,
mergemode:=immediately,
nextcommand := IMMEDIATELY,
l.c
commandid:=myid,
movingmode:=POSITION_CONTROLLED);
ai
axis := Axis, // Axis
removemode := SPECIFIC_ID, // Specific
commandid := myID);
END_IF;
// Ret_Val_2
// Ret_Val_1
gm
IDCounter := IDCounter - 1;
END_IF;
Ret_Val_2 := -1;
IF NOT (Axis = TO#NIL) THEN
myid:=_getcommandid (); //commandid assignment
Ret_Val_1 := _bufferaxiscommandid( // Buffer CommandId in TO
r.s
axis:=Axis,
commandid := myid);
velocity:=Velocity,
velocityprofile:=USER_DEFAULT,
mergemode:=immediately,
nextcommand := IMMEDIATELY,
commandid:=myid,
movingmode:=POSITION_CONTROLLED);
//Next page
om
removemode := SPECIFIC_ID, // Specific
commandid := myID);
IDCounter := IDCounter - 1;
END_IF; // Ret_Val_2
END_IF; // Ret_Val_1
l.c
IF Ret_Val_1 = 0 AND RET_VAL_2 = 0
THEN Error := FALSE;
ELSE Error:= TRUE;
END_IF; //
Neg_Command := TRUE;
ai
ELSE Error := TRUE; //Else branch to axis = TO#NIL
END_IF; //Axis = TO#NIL
END_IF; //Edge detection
Ret_Val_2 :=_stop(
axis:=Axis,
gm
IF (f_trig_1.q AND Pos_Command) OR (f_trig_2.q AND Neg_Command) THEN
IF NOT (Axis = TO#NIL) THEN //On negative edge
//Access only with valid pointer
stopmode:=STOP_and_ABORT,
@
stopspecification:=ALL_AXIS_MOTION,
stopid:=_getcommandid (),
mergemode:=IMMEDIATELY,
nextcommand := IMMEDIATELY,
er
commandid:=_getcommandid());
Pos_Command := FALSE;
Neg_Command := FALSE;
Error := FALSE;
CommandAborted := FALSE;
END_IF; //Edge evaluation;u
ne
om
END_IF;
l.c
// has not been aborted with _stop(), another command
// or state must have caused motion to be aborted
IF (ret_val_id.commandidstate = ABORTED)
THEN CommandAborted :=TRUE;
ai
ELSE CommandAborted := FALSE;
END_IF; // ret_val_id ... ABORTED
END_IF; //Axis = TO#NIL
Error := FALSE;
CommandAborted := FALSE;
END_IF;
gm
IF JOG_pos = FALSE AND JOG_neg = FALSE THEN // Reset outputs
@
END_FUNCTION_BLOCK
er
ez
r.s
ne
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
VAR_INPUT
om
Start: BOOL := FALSE;
Stop: BOOL := FALSE;
TaskID : StructTaskId;
END_VAR
VAR
l.c
MyTaskState : DWORD;
END_VAR
ai
TASK_STATE_RUNNING) = 0
THEN
MyTaskState := _restartTaskId(TaskId);
END_IF;
THEN
gm
IF Stop AND (_getStateOfTaskId(TaskID) AND TASK_STATE_RUNNING) <> 0
MyTaskState := _resetTaskId(TaskId);
END_IF;
@
TaskStartStop:=(_getStateOfTaskID(TaskId) AND TASK_STATE_RUNNING)<>0;
END_FUNCTION
er
ez
r.s
ne
ca
INTERFACE
USEPACKAGE CAM;
om
PROGRAM ErrorHandlerTechFault;
END_INTERFACE
IMPLEMENTATION
PROGRAM ErrorHandlerTechFault
l.c
VAR
MyDriveAxis : driveAxis;
myRetDINT : DINT;
END_VAR
ai
MyDriveAxis := ANYOBJECT_TO_OBJECT(TSI#toInst);
IF MyDriveAxis <> TO#Nil THEN
CASE TSI#alarmNumber OF
30002,
40021,
12345,
54321:
gm
// Command aborted
// StopEmergency ommand abort ...
// 1. Fantasiealarm
// 2. Fantasiealarm
@
myRetDINT := _resetAxisError(axis := MyDriveAxis,
errorresetmode := SPECIFIC_ERROR,
errornumber := TSI#alarmNumber,
nextcommand := IMMEDIATELY);
er
END_CASE;
END_IF; // END_IF DriveAxis
END_PROGRAM
ez
END_IMPLEMENTATION
r.s
ne
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
RunAuto
om
l.c
ai
gm
@
er
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
UNIT Cam_Unit;
INTERFACE
USEPACKAGE CAM;
om
TYPE Interpolation point: STRUCT
X_pos : LREAL;
Y_pos : LREAL;
END_STRUCT;
END_TYPE
FUNCTION Create_Cam;
l.c
END_INTERFACE
IMPLEMENTATION
ai
FUNCTION Create_Cam : VOID
VAR_INPUT
Interpolation points: ARRAY[0..9] OF interpolation point;
IPO_Type: enumcaminterpolationmode;
CAM_Type: enumcammode;
Cam: CamType;
END_VAR
VAR
gm
index : INT;
@
Error_number : DINT;
END_VAR
FOR index := 0 TO 9 BY 1 DO
Error_number := _addPointToCam(
ez
END_FOR;
Error_number := _interpolateCam(
cam := cam, //Specification of the cam
camPositionMode := ACTUAL, //Scaled range
ne
leadingrangestartpointtype := LEADING_RANGE_START,
// From starting point
leadingRangeStartPoint := 0.0, //Start value
leadingrangeendpointtype := LEADING_RANGE_END,
// From end point
leadingRangeEndPoint := 100.0, //End value
ca
camMode := CAM_Type,
interpolationMode := IPO_Type);
END_FUNCTION
END_IMPLEMENTATION
r
Unit "Test"
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
1. Select "Test"
om
3. Enter inter-
polation points
l.c
2. Open the symbol
browser
ai
gm 4. Interpolation points
@
"Control"
er
5. Call FC with
%I1.7
ez
5. Upload "My_Cam"
to CamEdit
r.s
ne
ca
om
l.c
ai
gm
@
er
ez
r.s
ne
ca
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.1
SITRAIN Training for
Automation and Drives
@
Contents Page
Communication networks in TIA ........................................................................................................ 3
Communication services for SIMOTION ........................................................................................... 4
er
Reading the states of individual bits from bit data types ................................................................... 12
Splitting a byte into 8 bits ................................................................................................................... 13
_Xsend(), _Xreceive() (S7 basic communication) ............................................................................. 14
Sending data via PROFIBUS/MPI: _Xsend() ..................................................................................... 15
ne
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.2
SITRAIN Training for
Automation and Drives
@
Contents Page
Opening the communication port on the server side: _tcpOpenServer() ........................................... 27
Starting a connection request on the client side: _tcpOpenClient() .................................................. 28
er
om
Shared communication:
PROFIBUS, PROFINET, Ethernet
C230-2/C240
l.c
P350-3
D4x5/D410
ai
Shared use of
distributed I/Os and
SIMOTION
drives via PROFIBUS
and PROFINET
The CSMA/CD alccess method is used. Before sending data, each station
ne
checks whether data is being transmitted by other stations. If not, it can send the
data immediately. If a collision occurs due to data being transmitted
simultaneously, both stations abort and repeat transmission after a random wait
time. Thlis access method means that all stations on the Industrial Ethernet
have equal priority.
ca
PROFINET PROFINET is the innovative and open Industrial Ethernet standard (IEC 61158)
for industrial automation. With PROFINET, devices can be linked from field level
through to management level.
In conjunction with the IRT protocol (Isochronous Real Time), PROFINET can
be used to control drives isochronously and for non-time-critical communication
(e.g. TCP/IP) between automation components via a single cable.
SINAMICS
Program-controlled
via MPI or PROFIBUS
MPI=2
om
up to 200 bytes
SIMOTION/SIMATIC
SIMOTION
l.c
_tcpSend/ _tcpReceive
SINAMICS
SINAMICS
Program-controlled
ai
via Industrial Ethernet
MPI=2
up to 1,400/4,096 bytes
SIMOTION/SIMATIC/PC
SIMOTION
SIMOTION
The program on the receiving device recognizes whether it is the data packet to
be received on the basis of a user-definable integer (job identifier) appended to
the data packet. Moreover, data exchange is only successful if the user program
accepts and does not reject the data packet.
ez
Data is sent in the form of byte sequences in an array, i.e. the data has no
logical structure. SIMOTION devices can send or receive up to 200 bytes at
once; the actual user data length depends on the communications partner.
A SIMATIC station, for example, restricts the user data length to 76 bytes.
r.s
_udpSend/ These functions support simple data transfer across different networks
_udpReceive without acknowledgment (datagram service) according to layer 4 of the ISO
reference model. Contiguous data blocks with a maximum size of 1,400 bytes
can be transferred between two Ethernet stations based on IP. (UDP = User
Datagram Protocol.)
ne
The UDP service enables communication with any communications partner (e.g.
PC or third-party system) supporting UDP send/receive. UDP telegrams are not
secure because the receipt of data is not acknowledged. However, UDP is
mainly used in applications which work on the principle of user
ca
acknowledgment.
_tcpSend/ The function sends and receives a TCP data stream (Transmission Control
_tcpReceive Protocol). Contrasting with the UDP protocol, internal acknowledgment
mechanisms are used together with a retransmission function to ensure that lost
data packets can be processed, thereby making data communication secure.
Data transmission with UDP and TCP is exclusively performed via Industrial
Ethernet and additionally via TCP/IP networks (e.g. telephone network or
Internet).
om
2. Send data
_Xsend(...) or _udpSend(...), _tcpSend
Receiver:
l.c
1. Receive data
_Xreceive(...) or _udpReceive(...), tcpReceive
ai
2. Unpack data from ARRAY OF BYTES
BigByteArray_to_AnyType (from SIMATIC, Motorola, SUN, etc.)
SIMOTION
Siemens AG 2013. All rights reserved.
gm
LittleByteArray_to_AnyType (from PC, DEC Alpha, etc.)
Date:
File:
10.01.2013
MC-SMO-PRG_A1.5
SITRAIN Training for
Automation and Drives
@
Procedure for The procedure for sending is essentially divided into the following two steps:
sending
• Packing the transmit data in an ARRAY OF BYTES (byte stream)
er
• The byte array is then sent to the receiver using the corresponding system
functions.
Procedure for The procedure for receiving data transmitted by any sender follows the reverse
ca
receiving order:
• The corresponding receive functions are used to receive the data from the
the target system and store the data in an ARRAY OF BYTES.
• The SIMOTION user program then has to unpack the individual information
units from this "byte stream". Depending on the byte
order of the sender, this is done using:
- BigByteArray_to_AnyType()
- LittleByteArray_to_AnyType()
om
Axis_1.positioningstate.commandposition
4
5
Data type: LREAL, i.e. 8 bytes
6 .
7 .
. .
.
l.c
n Data_Send := ANYTYPE_TO_LITTLEBYTEARRAY(
anydata := Axis_2.positioningstate,
n+1
offset:=n)
n+2
n+3
ai
Axis_2.motionstatedata
n+.
n+.
Data type: STRUCT
n+. (has a total of 44 bytes)
SIMOTION
n + 43
N
.
Date:
File:
10.01.2013
MC-SMO-PRG_A1.6
SITRAIN Training for
Automation and Drives
@
Overview The following functions:
• AnyType_to_LittleByteArray()
• AnyType_to_BigByteArray()
er
Notes • Each variable of the BOOL data type (including variables that are
components within a structured data type) occupies one byte in the byte
ne
array. The value FALSE is mapped to 16#00, the value TRUE to 16#01.
• When enumerator data types ("Enum") are converted, a warning:
"Data type Enum is not portable when converted" is output. Enumerator data
types are stored internally as UDINT and thus occupy 4 bytes in the byte
array.
ca
om
MyPosition Data type: LREAL, i.e. 8 bytes
4
5
6 .
7 .
. .
.
l.c
n MyVelocity := LITTLEBYTEARRAY_TO_ ANYTYPE (
bytearray := MyVelocity,
n+1
offset:=n)
n+2
n+3
ai
MyVelocity Data type: LREAL, i.e. 8 bytes
n+4
n+5
n+6
SIMOTION
n+7
.
N
convert a byte array to a variable of any data type (elementary data types,
system data types, user-defined data types).
The array index of the first element to be evaluated in the array is an optional
constant offset (default = 0). It must fall within the array limits.
ez
• 4 bytes from the byte array are assigned to an enumerator variable ("Enum"
data type). If the value (as UDINT) is outside the valid value range, this
(invalid) value is assigned to the variable.
In this case, an error message is not output. The user is responsible for the
ca
om
. . .
END_STRUCT;
END_TYPE
l.c
MySendData : MyDataStruct;
DataSend : ARRAY[0.._sizeof(in := MyDataStruct) -1] OF BYTE;
END_VAR
ai
3. Copy process variable to user variable and pack user variable in send buffer
MySendData.Position := Axis_1.positioningstate.commandposition;
MySendData.Velocity := Axis_1.motionstatedata.commandvelocity;
SIMOTION
. . .
Date:
File:
10.01.2013
MC-SMO-PRG_A1.8
SITRAIN Training for
Automation and Drives
@
Overview The example above demonstrates the packing of send data with the "system
function" _sizeof(), which is available as of V4.0. This procedure is
recommended if:
• Data is to be transferred between two SIMOTION devices and
er
2. Next, ao user variable of the same type as the structure created and a
send buffeelr (as ARRAY[0.._sizeof(..)-1]) must be created in the VAR section.
The size of the data structure can be identified by running the _sizeof() function
and used to specify the max. array index when declaring the send buffer.
3. It is only after this that the process variables to be sent are copied to the
ca
user variable and then the packing function is called to copy the user variable to
the send buffer. 0 must be specified as the offset.
With this procedure, neither the memory requirements of the individual data
types nor the total size of a structure are relevant. The _sizeof() function can also
be used in the send function (e.g. _udpsend()) to specify the number of bytes to
be sent.
om
. . .
END_STRUCT;
END_TYPE
l.c
MyReceivedData : MyDataStruct;
DataReceived : ARRAY[0.._sizeof(in := MyDataStruct) -1] OF BYTE;
END_VAR
ai
3. Unpack receive buffer in user variable
MyReceivedData := LITTLEBYTEARRAY_TO ANYTYPE( anydata := DataReceived,
offset:=0);
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.9
SITRAIN Training for
Automation and Drives
@
Procedure The procedure for unpacking data is as follows:
1. First, a data structure with the data elements to be received must be
created in the TYPE section. Essentially, the order and the types of the
individual data elements are defined in this structure.
er
The order and type must be the same as in the data structure to be sent.
2. Next, a user variable of the same type as the structure created and a
receive buffer (as ARRAY[0.._sizeof(..)-1]) are created in the VAR section. The
size of the data structure can be identified by running the _sizeof() function and
used to specify the max. array indeex when declaring the receive buffer. With
ez
this procedure, the receive buffer and the send buffer are always the same size.
3. After this, following data receipt (e.g. _udpreceive()), the data from the
receive buffer is copied to the user variable by calling the unpack function. The
data is then a vailable there for further processing.
r.s
ne
ca
om
in:= MyAnyBit, Reset bit in byte, word,
n:= BitNo, or double word
value:= FALSE);
l.c
n:= BitNo); or double word
ai
X
MyByte := _setbit(MyByte, 5, TRUE)
SIMOTION
7 6
The following functions can be used to modify an individual bit within a bit string
variable (data type: BYTE, WORD, DWORD). The return value is the value of
the modified bit string variable "in".
If the data type of the "in" input parameter (e.g. DWORD) cannot be converted
ez
to the data type of the return value (e.g. BYTE), a corresponding error message
is output during compilation.
The value for the bit number "n" should be within the valid range. The valid
ranges are:
r.s
_setbit This function returns the value of the bit string variable "in", in which the bit
ca
specified in "n" has been set to the defined Boolean value ("value" := TRUE or
FALSE).
_togglebit This function returns the value of the bit string variable "in", in which the bit
specified in "n" has been inverted..
om
bit1 := MyBit1,
bit2 := MyBit2,
bit3 := MyBit3,
bit4 := Axis_1.error = YES,
bit5 := Achse_2.error = YES,
bit6 := Axis_1.motionstatedata.motionstate <> STANDSTILL,
bit7 := Axis_2.motionstatedata.motionstate <> STANDSTILL);
l.c
// With language extension
MyByte.0 := MyBit0;
ai
.
MyByte.4 := Axis_1.error = YES;
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.11
SITRAIN Training for
Automation and Drives
@
_byte_from_8bool The system function _byte_from_8bool() is used to combine eight Boolean
variables or expressions in a byte. The Boolean value TRUE is then equivalent
to the bit state "1" and the value FALSE to the bit state "0".
er
Direct bit access The "Permit language extensions" option in the compiler settings provides a
user-friendly means of accessing individual bits in a bit string data type (BYTE,
WORD, or DWORD, for example).
The number of the bit to be accessed can be entered after the name of the
ez
om
END_VAR
l.c
MyAnyBit
1 MyResult := _getbit(MyAnyBit, 5)
ai
7 6 5 4 3 2 1 0 returns MyResult equals TRUE
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.12
SITRAIN Training for
Automation and Drives
@
_getbit(..) The _getbit() function returns the value of the bit specified in "n" from bit string
variable "in" (data type: BOOL). The bit state "1" is equivalent to the return value
TRUE, the state "0" is equivalent to FALSE.
The value for the bit number "n" should be within the valid range. The valid
er
ranges are:
• [0..7] for BYTE
• [0..15] for WORD
ez
VAR
MyByte : BYTE;
MyBit0, MyBit1, MyBit2, MyBit3, MyBit4, MyBit5, MyBit8, MyBit7 : BOOL;
Task MyByteToBool : _byte_to_8bool;
END_VAR
MyBytetoBool (bytein := MyByte); // Split a byte into 8 bits
Solution with OPC
om
// MyByte is the input byte
MyBit0 := MyBytetoBool.bit0; // Assign 8 outputs
MyBit1 := MyBytetoBool.bit1;
MyBit2 := MyBytetoBool.bit2;
.
.
l.c
.
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.13
SITRAIN Training for
Automation and Drives
@
_byte_to_8bool System function block _byte_to_8_bool() is used to split a variable or expression
of the BYTE data type into eight individual Boolean variables. The bit state "1" is
then equivalent to the value TRUE and the state "0" is equivalent to FALSE.
An instance must be created in the declaration part in order to use the system
er
function block. The actual instance name is then used in the call.
Direct bit access The "Permit language extensions" option in the compiler settings provides a
user-friendly means of accessing individual bits in a bit string data type (BYTE,
ez
via a constant.
ne
ca
om
User data up to 200 bytes (SIMOTION) or 76 bytes (SIMATIC S7)
l.c
Job tracking is possible
ai
be in different S7 projects
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.14
SITRAIN Training for
Automation and Drives
@
Overview The system functions _Xsend() and _Xreceive() are used to exchange small
data volumes between SIMOTION devices and between SIMOTION and an
S7/M7-300/400 CPU respectively.
The communications partners must be connected to the same PROFIBUS or
er
User data size Communication between SIMOTION and an S7/M7-300/400 CPU module is
only possible via an MPI subnet. In this case, the data volume per call is
ez
communications partners.
The partner is addressed by specifying the address directly in the call.
Therefore, no connection configuration is necessary (i.e. communications
partners can be located in different S7 projects).
ca
Job identifier The program on the receiving device recognizes whether it is the data packet to
be received on the basis of a user-definable integer appended to the data
packet.
Job tracking The status of an Xsend or Xreceive job can be checked with the command
GetStateOfXCommand().
om
commandid, // Command identification
data, // ARRAY[0..199] OF BYTE for send data
datalength); // Number of bytes (UDINT)
StructXsendDestAdddr
l.c
StructXsendDestAddr STRUCT
deviceId; // (USINT)1:X8,X101,X126 2:X9,X102,X136
remoteSubnetIdLength; // (USINT) Always 0 for PROFIBUS and MPI
remoteStaddrLength; // (USINT) Always 1 for PROFIBUS and MPI
ai
nextStaddrLength; // (USINT) Always 0 for PROFIBUS and MPI
remoteSubnetId; // (ARRAY[0..5] of USINT) not relevant
remoteStaddr; // (ARRAY[0..5] of USINT), array element
// with index 0 = partner address 0 .. 126
SIMOTION
nextStaddr);
END_STRUCT
Date:
File:
gm (ARRAY[0..5] of USINT) not relevant
10.01.2013
MC-SMO-PRG_A1.15
SITRAIN Training for
Automation and Drives
@
Overview The _Xsend() function sends a data packet with transparent data to a
communications partner.
until the receiver acknowledges receipt of the data packet. During asynchronous
data transmission, the program is resumed immediately after the command is
issued. The status can be determined with _GetStateOfXCommand.
commandId: Needed for _GetStateOfXCommand().
data (ARRAY[0..199] OF BYTES): Contains the data to be sent.
dataLength: Specifies the number of bytes to be sent from data.
Return value: The return value indicates whether the call was successful
(RetVal = 0) or unsuccessful (RetVal < 0).
StructRetXreceive
om
StructRetXreceive STRUCT
functionResult; // (DINT) Result of call
dataLength; // (UDINT) Number of bytes received
data; // (ARRAY[0..199] OF BYTES) Receive data
END_STRUCT
l.c
functionResult indicates the following states:
• Asynchronous start:
16#00007000 Job is still active
ai
16#000000xx Job is complete. Number of received bytes in xx (also in "datalength")
16#000080xx Job was aborted with errors. xx reports a unique error number.
• Synchronous call:
16#000000xx Execution was completed without errors (xx length of data). Number of
SIMOTION
received bytes also in "dataLength"
Date:
File:
10.01.2013
MC-SMO-PRG_A1.16
SITRAIN Training for
Automation and Drives
@
Overview The _Xreceive() function receives the data sent by a communications partner
with _Xsend().
Parameters messageId: The Xreceive call uses this job identifier to identify a data packet
er
intended for it. An Xreceive call only receives data packets in which the job
identifier (messageid parameter) added by the sender in the Xsend call matches
the job identifier of the Xreceive call.
Data packets with different job identifiers are not accepted by an Xreceive call.
ez
om
StructRetXCommandState
StructRetXCommandState STRUCT
functionResult; // (DINT) Result of call
commandIdState; // ACTIVE, NOT_EXISTENT, WAITING
END_STRUCT
l.c
CommandIdState indicates the following states:
• ACTIVE: The job is currently underway (asynchronous command).
ai
• NOT_EXISTENT: The job is already complete or does not exist yet.
• WAITING: The job is waiting for data (synchronous command).
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.17
SITRAIN Training for
Automation and Drives
@
Overview The _GetStateOfXCommand() function is used to scan the command execution
status of an _Xsend or _Xreceive job.
commandId: Used to identify the Xsend or Xreceive job whose status is to be
Parameters determined.
er
The commandIdState parameter only reeturns the valid status if execution was
successful.
• commandIdState: If executsion was successful, the command execution
status of the Xsend or Xreceive job identified by commandId is stored here.
r.s
command).
ca
om
Bus system suitable for use in distributed automation
solutions
l.c
Internet Protocol (IP)
Transmission Control Protocol (TCP)
User Datagram Protocol (UDP)
ai
Flexible addressing
SIMOTION
IP addresses
Port numbers
application:
• Fast commissioning thanks to a really straightforward connection method
• High availability since existing networks can be extended without any
adverse effects
ez
FTP NFS
SMTP rlogin Telnet TFTP BOOTP
om
TCP UDP
ICMP
l.c
Internet protocol (IP)
ARP RARP
ai
Network hardware
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.19
SITRAIN Training for
Automation and Drives
@
Network access The lowest layer, the network access layer, matches the OSI layer model to a
layer large extent and provides the basis for data transfer on the network. On this
layer, data is packed into packets and prepared for physical transmission (layer
1 in OSI).
er
A further function of the network access layer is the resolution and conversion of
logical addresses to physical addresses. Under TCP/IP, this is handled by the
Address Resolution Protocol (ARP). Reverse ARP (RARP) is used for the
reverse procedure (conversion from physicmal to logical addresses).
ez
Internet protocol The Internet protocol (IP) providesi the basis for all TCP/IP networks. It creates
what are called datagrams - datas packets prepared specifically for the Internet
protocol - and handles their tr ansport within the local subnet or their forwarding
to other subnets (i.e. routing@).
r.s
different routeso.
TCP TCP ise the transport protocol used to exchange data between two hosts. Data
is referred to as segments in TCP jargon. TCP ensures a high level of security,
kbecause data sent across the network has to be acknowledged by the
ca
Properties
No protection against loss of packet content or sequence
Ideal for real-time applications in automation
Flexible addressing based on IP addresses and ports
om
Sending of multicast message frames
SINAMICS
SINAMICS
Port: 3333
l.c
Application_1
Application_n
SIMOTION
ai
IP address: 169.254.11.22 IP address: 169.254.11.20
SIMOTION
Siemens AG 2013. All rights reserved.
IP header
Date:
File:
gm
UDP header
10.01.2013
MC-SMO-PRG_A1.20
SITRAIN Training for
Automation and Drives
@
Overview The User Datagram Protocol (UDP) is a simple connection-free protocol. UDP
was defined in order to provide application processes with a direct means of
sending data packets and thus to meet the needs of transaction-oriented traffic.
UDP resides immediately above the IP layer, on which it is based.
er
automatic retransmission takes place - unlike TCP - if packets are lost. This
makes UDP suitable for real-time applications where the application implements
(indeed has to implement) altesrnative measures in the event of an error such
as packet loss, a connection fault, failure of the communications partner, etc. An
optional checksum can be used to detect data transmission errors.
r.s
A further advantage UDP has over TCP is its support of "broadcast message
frames", which allow data to be sent to multiple nodes in a single call.
The same method las for TCP/IP connections is used for the addressing of UDP
packets. Twog tuples consisting of the IP address and port number represent
ne
Addressing
the end points oof a TCP connection.
application.
In SIMOTION, ports with numbers greater than 2000 can be used freely. Ports
Note with numbers less than or equal to 2000 (well-known ports) should not be used
in the user program.
om
Class B:
10 14 bits network 16 bits host 128 to 191 16384 65534
l.c
Class C:
110 21 bits network 8 bits host
ai
192 to 223 2097152 254
SIMOTION
Note: The numbers 0 and 127 are reserved.
specifies the subnet to which the host is connected; the host ID specifies the
address of the access point for the host.
IP Classes The subdivision of an IP address into a subnet and host breaks the IP network
down into a large collection of interconnected subnets. 5 classes were originally
r.s
Subnet mask A subnet mask is a filter used to identify all systems connected to the same
physical network section.
The rules for the subnet mask are very simple:
ne
• Ones in the subnet mask identify the number part of the subnet
• Zeros identify the part of the address used for the host ID
Even if the subnet masks are not used, the hardware automatically defines the
default subnet mask for class A, B, or C.
ca
Note If send and receive stations are connected to the same network, or connected
directly by a crossed Ethernet cable, the network ID of both IP addresses must
match.
Send data
RetVal := _udpSend(
sourcePort, // (UINT) Sender port
destinationAddress, // (ARRAY[0..3] OF USINT) IP addr. receiver
om
destinationPort, // Receiver port
communicationMode, // CLOSE_ON_EXIT, DO_NOT_CLOSE ON_EXIT
dataLength, // Number of bytes (UDINT)
data); // ARRAY[0..1399] OF BYTE for send data
l.c
16#00000000 Data sent successfully
16#FFFFFFFF Resource bottleneck
16#FFFFFFFE Port not available
16#FFFFFFFD Internal error
ai
16#FFFFFFFB Error receiving
16#FFFFFFF9 Error sending
16#FFFFFFF8 Incorrect parameter
SIMOTION
Siemens AG 2013. All rights reserved.
Date:
File:
gm 10.01.2013
MC-SMO-PRG_A1.22
SITRAIN Training for
Automation and Drives
@
Overview The udpSend(..) function sends a UDP message frame to the receiver identified
by the IP address and port number. Up to 1,400 bytes can be transmitted in one
call. Command execution is always synchronous. The return value can be used
to determine whether or not the call has been successful.
er
data (ARRAY [0g..1399] OF BYTE): Buffer for the data to be sent (user data
area).
Return vlalue (DINT): The return value indicates whether the call was
successful (RetVeal = 0) or unsuccessful (RetVal < 0). Possible values are:
ca
om
StructRetUdpReceive
StructRetUdpReceive STRUCT
functionResult; // (DINT) Result of call
sourceAdress; // IP address of sender
sourcePort; // Port number of sender
l.c
dataLength; // (UDINT) Number of bytes received
END_STRUCT
ai
16#00000000 Communication on this port completed without errors 16#FFFFFFFF Resource bottleneck
16#00007001 Communication on this port started 16#FFFFFFFD Internal error
16#00007002 Communication on this port active 16#FFFFFFFC Receive function on this
16#00007003 Communication on this port aborted port already active
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.23
16#FFFFFFFB Error receiving
16#FFFFFFF8 Incorrect parameter
aborted (abort).
receiveVariable (ARRAY [0..1399] OF BYTE): Buffer for receive data.
Return value: The parameter has the data type StructRetUdpReceive:
• functionResult: functionResult indicates whether or not command
ca
om
Communication procedure based on client/server model
Before data can be sent, a client must set up a connection
with the server
Multiple clients can set up a connection with a server
l.c
Simultaneous bidirectional data transmission is supported on
one connection
Flexible addressing based on IP addresses and ports
(like UDP)
ai
Due to unpredictable time delays caused by retransmissions,
often unsuitable for real-time applications in automation
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.24
SITRAIN Training for
Automation and Drives
@
Overview The Transmission Control Protocol (TCP) is a reliable, connection-oriented,
byte-stream protocol. Its main task is to support secure data transport over a
network. Like UDP, TCP resides immediately above the IP layer, on which it is
based.
er
that TCP behaves in a way that is not deterministic. The sender never knows
when a sent packet reaches its recipient. TCP is, therefore, unsuitable for many
applications in automation which require real-time properties and determinism.
In the same way as with UDP, the applications are connected to ports of the
system.
ne
Before an application can send data to a partner, a connection must be set up.
To set up the connection, the client first sends a connection request to the
server. Simultaneous bidirectional data transmission can only take place when
the connection has been set up successfully. The application writes data to the
TCP port, the data is transferred via the network and read by the application at
ca
the other end. Once data exchange has been completed, the connection can be
closed by the client or server.
TCP creates packets from the byte stream in an arbitrary manner; any limits
between the individual sections of a message are not taken into account. For
example, if an application writes five times to the TCP port, the application on
the other side may have to read ten times to receive data, or even just once. At
both ends, there is no correlation between the number and scope of the
individual read and write operations, although TCP does guarantee that data will
be in the correct order.
Time
SIMOTION (client) SIMOTION (server)
_tcpOpenServer()
_tcpOpenClient()
om
_tcpSend() _tcpSend()
_tcpReceive() _tcpReceive()
.
l.c
. .
. .
. .
.
ai
_tcpCloseConnection() or _tcpCloseConnection()
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.25
_tcpCloseServer()
Once the connection has been set up, the _tcpOpenClient() call returns a
ConnectionId to identify the communication connection.
This ConnectionId is required for further addressing of the server in the
_tcpSend() and _tcpReceive() calls.
r.s
om
Double-click
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.26
SITRAIN Training for
Automation and Drives
@
Settings In the HW Config, you can set the timeout behavior for TCP communication for
the controller in the "Object Properties - Ethernet Extended" dialog.
Any changes to the default values may cause undesired behavior and should,
therefore, only be made by experts.
er
• Connect Timeout (default value: 15,000 ms, minimum value: 1,000 ms):
Maximum time the TCP waits internally for the communications partner
to respond to a connection request.
ez
for the maximum number of times, the connection is considered faulty (i.e. the
partner can no longer be reached).
Note When a connection is disconnected, this will only be detected by the TCP/IP
functions after a time delay (>= 1 second) due to system constraints.
ca
If the _tcpSend() function sends additional data on this connection during this
time lapse, the data is lost. When the disconnect is detected, both sides need to
close the connection before a new connection setup can be initiated.
Usually this only occurs if the control fails or if there is damage to a cable.
om
structRetTcpOpenServer
StructRetTcpOpenServer STRUCT
functionResult; // (DINT) Result of call
connectionId; // ID identifying the connection
clientAddress; // IP address of connecting client
l.c
clientPort; // Port number of connecting client
END_STRUCT
ai
16#00000000 Connection set up successfully 16#FFFFFFFF Resource bottleneck
16#00007001 Function started 16#FFFFFFFD Internal error
16#00007002 Function active
16#FFFF8FFF
SIMOTION
Server port assigned more than once
.
The function may on ly be called in the BackgroundTask or in a MotionTask.
ne
ca
om
nextCommand) // IMMEDIATELY or WHEN_COMMAND_DONE;
structRetTcpOpenClient
StructRetTcpOpenClient STRUCT
functionResult; // (DINT) Result of call
connectionId; // ID identifying the connection
l.c
END_STRUCT
ai
16#00000001 Function started and port assigned more than once
16#00000002 Function active 16#FFFF8FFB Connection request
16#FFFFFFFF Resource bottleneck refused
16#FFFFFFFD Internal error.
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.28
SITRAIN Training for
Automation and Drives
@
Overview The _tcpOpenClient function sets up a TCP/IP connection on the client side.
When the function is called, a connection request is sent to the server
addressed by serverAddress and serverPort.
The returned connectionId is required for subsequent write and read calls
er
(_tcpSend(), _tcpReceive()).
The function must have return value = 16#0 before data transmission with
TCP/IP can start.
ez
om
RetVal (DINT) indicates the following states:
l.c
16#00000000 Data sent successfully
16#00007001 Function started (only with nextCommand = IMMEDIATELY)
16#00007002 Function active (only with nextCommand = IMMEDIATELY)
16#FFFFFFFF Resource bottleneck
16#FFFFFFFD Internal error
ai
16#FFFF8FFE Invalid connection ID
16#FFFF8FFD Connection closed by communications partner
16#FFFF8FFC Connection termination
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.29
SITRAIN Training for
Automation and Drives
@
Overview _tcpSend() is used to send data to a communications partner via a connection
previously established with _tcpOpenServer() or _tcpOpenClient(). Up to 4,096
bytes can be sent in one call.
Both the client and the server can send data over the active connection.
er
case of an error).
Negative values in functionResult indicate an error during data transmission. In
this case, the connection must be closed by calling _tcpCloseConnection().
The function may only be called in the BackgroundTask or in a MotionTask.
r.s
ne
ca
om
structRetTcpReceive
StructRetTcpReceive STRUCT
functionResult; // (DINT) Result of call
dataLength; // Number of data items received
END_STRUCT
l.c
RetVal (DINT) indicates the following states:
16#00000000 Data sent successfully
16#00007001 Function started (only with nextCommand = IMMEDIATELY)
16#00007002 Function active (only with nextCommand = IMMEDIATELY)
ai
16#FFFFFFFF Resource bottleneck
16#FFFFFFFD Internal error
16#FFFF8FFE Invalid connection ID
16#FFFF8FFD Connection closed by communications partner
SIMOTION
16#FFFF8FFC
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.30
SITRAIN Training for
Automation and Drives
@
Overview The _tcpReceive() function waits for data at the active connection to the
communications partner and reads it out. The function receives data via a
connection previously established with _tcpOpenServer() or _tcpOpenClient().
Data can be received in arbitrary packet sizes. Generally, the packet sizes do
er
not correspond to those on the transmitting side. A send packet can be split up
into several receive packets and multiple send data packets can also be
combined in one receive packet.
If the call was successful, i.e. if the value = 16#0 has been returned in
ez
om
RetVal (DINT) indicates the following states:
16#00000000 Connection closed
16#FFFFFFFD Internal error
16#FFFF8FFE Invalid connection ID
l.c
Port closed by server
RetVal:= _tcpCloseServer(
port); // Number (UINT) of the server port;
ai
RetVal (DINT) indicates the following states:
16#00000000 Wait state terminated
SIMOTION
16#FFFF8FFE
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.31
SITRAIN Training for
Automation and Drives
@
Close Calling the _tcpCloseConnection() function closes an active connection that was
connection set up by calling _tcpOpenClient() or _tcpOpenServer() and releases the
internal resources previously occupied.
The return values of the _tcpSend() and _tcpReceive() calls tell the SIMOTION
er
Close The _tcpCloseServer() function terminates the wait state for connection
server port requests from TCP clients initiated by _tcpOpenServer.
The function may only be called in the background task or in a motion task.
r.s
ne
ca
SINAMICS
SINAMICS
270O
90O
0O
180O
270O
0O
90O
180O
om
SMC
SIMOTION
IP address: 192.168.0.1 IP address: 192.168.0.10
Subnet: 255.255.255.0 Subnet: 255.255.255.0
l.c
Port: 2222 Port: 2222
Axis_1.control Cyclic
Axis_2.control
ai
Start_1
Axis_1.motionstatedata.motionstate <> STANDSTILL
Start_2
Axis_2.motionstatedata.motionstate <> STANDSTILL
Axis_1.error Event- Pos_Axis_1 34
34 Pos_Axis_2 bytes
Axis_2.error controlled
bytes Axis_1.positioningstate.commandposition Velo_Axis_1
SIMOTION
Axis_2.positioningstate.commandposition
Axis_1.motionstatedata.commandvelocity
Axis_2.motionstatedata.commandvelocity
in this window on the PC and the desired axis started from there. The
transmission of this information is event-controlled, not cyclic, and occurs when
the user activates the axis start button.
In the same cycle as the one used to send data, the SIMOTION device also
r.s
checks whether the PC has transmitted new setpoint data. It sends the
corresponding request using an asynchronous udpReceive(..) function call.
If new data is available, MotionTasks are activated in the SIMOTION user
program in order to move the desired axis to the new target position at the
desired velocity.
ne
om
1. Connect
3. Start
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.33
SITRAIN Training for
Automation and Drives
@
Overview This VB application is used to control axis motion from the PC. The status of the
axes is also displayed in the window.
1. When the application has been launched, activate the "Connect" button
to open an internal connection between the application and a
communications socket. This socket bears the address information of the
communications partner. It can be specified in the "Connect to" and "Remote
ez
selected.
2. The next step is to define new settings for the end positions and velocities
of both axes and set the axes in motion using the associated "Start" button.
3. A new data packet is not transmitted to the SIMOTION device until the
"Start" button is selected. If a suitable udpReceive call is not active in
ne
om
l.c
ai
SIMOTION
MCC program for
communication
These MCC programs are assigned to MotionTasks which are started automatically
when the system ramps up.
MCC-UDP
ez
This program calls the udp_receive(..) user function to check cyclically whether new
data has been received from the PC. If new data has been received, it is unpacked
from the byte array with the udp_receive(..) function and written to the interface
variables of the ST UNIT.
r.s
The status information of both a xes is then packed in a byte array and transmitted
to the PC with@ the udp_send(..) function.
The udp_receive(..) and udp_send(..) functions are part of the ST UNIT listed on
the next two pages.
MCC program for
ne
axis motion This MCC proggram evaluates the "Start_1" variable sent by the PC together with
the new target position and velocity for Axis_1. The programmed traversing
movement starts on a rising edge.
Anel identical MMC program is used to move Axis_2.
ca
UDP example
project Tkhe SIMOTION project is contained in PRG_D425-2_UDP_V431_e.zip. The
Visual Basic project is in the directory called UDP_english. The corresponding EXE
file is UDP_comm.exe.
VAR_GLOBAL
_MccRetDINT: DINT; // Return value for sending
_MccRetStructRetUdpReceive : StructRetUdpReceive; // for receiving
om
StatusByte : BYTE; // Bit 0 AxisEnable_1, Bit 1 AxisEnable_2,
// Bit 2 Axis_1 moving, Bit 3 Axis_2 moving,
// Bit 4 AxisError_1, Bit_5 AxisError_2
l.c
Pos_Axis_2: LREAL; // New position for Axis_2
Velo_Axis_1: LREAL; // New velocity for Axis_1
Velo_Axis_2: LREAL; // New velocity for Axis_2
Start_1: BOOL; // Start signal for Axis_1
ai
Start_2: BOOL; // Start signal for Axis_2
LocalPort : UINT := 2222;
RemoteAdress : ARRAY[0..3] OF USINT := [169,254,11,20];
RemotePort: UINT := 2222;
END_VAR
FUNCTION UDP_SEND;
FUNCTION UDP_RECEIVE;
END_INTERFACE
gm
// Function for sending data
// Function for receiving data
IMPLEMENTATION
@
FUNCTION UDP_SEND : VOID
anydata := Axis_2.positioningstate.commandposition,
offset:=8);
Data_Send := ANYTYPE_TO_LITTLEBYTEARRAY(u
lanydata := Axis_1.motionstatedata.commandvelocity,
offset:=g16);
ne
oData_Send := ANYTYPE_TO_LITTLEBYTEARRAY(
anydata := Axis_2.motionstatedata.commandvelocity,
offset:=24);
Data_Send[32k] := StatusByte;
c._MccRetDINT := _udpsend(sourceport := LocalPort,
ca
destinationaddress := RemoteAdress,
destinationport := RemotePort,
communicationmode := DO_NOT_CLOSE_ON_EXIT,
datalength := 34,
data := Data_Send);
END_FUNCTION
_MccRetStructRetUdpReceive :=
_udpreceive(
port := LocalPort,
communicationmode := DO_NOT_CLOSE_ON_EXIT,
nextcommand := IMMEDIATELY,
om
receivevariable := Data_Received);
IF _MccRetStructRetUdpReceive.functionresult = 0 THEN
Pos_Axis_1 := LITTLEBYTEARRAY_TO_ANYTYPE(Data_Received, 0);
Pos_Axis_2 := LITTLEBYTEARRAY_TO_ANYTYPE(Data_Received, 8);
Velo_Axis_1 := LITTLEBYTEARRAY_TO_ANYTYPE(Data_Received, 16);
l.c
Velo_Axis_2 := LITTLEBYTEARRAY_TO_ANYTYPE(Data_Received, 24);
Start_1 := _getbit(Data_Received[32],0);
Start_2 := _getbit(Data_Received[32],1);
ai
END_IF;
END_FUNCTION
END_IMPLEMENTATION
gm
@
er
ez
r.s
ne
ca
SINAMICS
270O
90O
0O
180O
270O
90O
0O
180O
om
SMC
SIMOTION
IP address: 192.168.0.1
Subnet: 255.255.255.0
IP address: 192.168.0.10
l.c
Port: 2222
Subnet: 255.255.255.0
Port: xxxx
Cyclic
AxisNumber
ai
Axis.control
34 Axis.motionstatedata.motionstate <> STANDSTILL
Event-
Start 34
Axis.error Pos_Axis
bytes Axis.positioningstate.commandposition controlled Velo_Axis bytes
Axis.motionstatedata.commandvelocity
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.37
SITRAIN Training for
Automation and Drives
@
Description The following example illustrates TCP communication between a SIMOTION
device and TCP clients on a PC. Once the SIMOTION device is running,
MotionTask_5 is started automatically. When _tcpOpenServer() is called,
MotionTask_5 waits cyclically for connection requests from TCP clients.
er
Once a TCP client is running, a connection to the SIMOTION TCP server can be
set up by clicking the "Connect" button. The connection status is displayed in a
text field.
The first TCP client which requests a connection to the SIMOTION server is
ez
connected with the 1st axis by the SIMOTION system; the second TCP client is
connected with the 2nd axis, and the third TCP client gets no connection. If
another client requests a connection to the SIMOTION server, this request is
refused.
r.s
information of the 1st axis). As in the UDP example, all of the information is
"converted" to a 34-byte array (Little Endian) and then sent to the client with the
_tcpSend() function. The status information is displayed in a pane in the client
window.
Conversely, each client can specify a new setpoint position and velocity for its
ca
axis and start the desired axis. The transmission of this information is event-
controlled, not cyclic, and occurs when the user activates the axis start button.
In the same cycle as the one used to send data, the SIMOTION device also
checks whether the PC has transmitted new setpoint data. It sends the
corresponding request using an asynchronous _tcpReceive() function call.
om
1. Connect/Disconnect
l.c
2. Specify new target
positions and velocities
ai
3. Start
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A1.38
SITRAIN Training for
Automation and Drives
@
Overview This VB application is used to control axis motion from the PC. The status of the
axes is also displayed in the window.
First, the SIMOTION device must be started. On startup, SIMOTION
automatically waits for connection requests from TCP clients. The switches for
er
the %I0.0, %I0.1, and %I0.2 inputs must be set to "0" on the SIMOTION device
("1" closes the connection on the server side).
Up to three connection requests will only be accepted if %I0.0, %I0.1, and %I0.2
equal 0. The status of the connection (active = 1, inactive = 0) is displayed at
ez
The status of the connection is displayed in the client window. It can also be
output on a DOS screen by issuing the command: "netstat".
2. An end position and a velocity can be specified for the axis. Motion is
started by clicking the "Start" button.
ca
A new data packet is not transmitted to the SIMOTION device until the
"Start" button is selected. It is also at this point that motion is executed.
Active traversing can only be aborted by specifying a new position or
velocity.
3. The application can be closed with the "Exit" button. The connection to the
communications partner is then aborted.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.1
SITRAIN Training for
Automation and Drives
@
Contents Page
Channel structure for "supplementary technology objects" ............................................................... 2
Supplementary technology objects .................................................................................................... 3
er
External
encoder
Virtual Cam_1
axis
Leading Cam_2
axis TO Synchro-
nous
om
_enablegearing Cam_3
operation
_enablecamming
TO
...
_pos
_move
... Buffer IPO Servo
l.c
_runpositionbasedmotion
_runvelocitybasedmotion
_runmotioninpositionlockedvelocityprofile
Motion input
ai
Formula FixedGear
Axis
Object Controller ...
TO
Adder
SIMOTION
Siemens AG 2013. All rights reserved.
...
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.2
...
into each "Axis" TO. The motion input of an axis can, for example, be
interconnected with motion outputs of other TOs, such as the motion outputs of
supplementary technology objects.
This allows modular and flexible configuration of complex motion dependencies
ez
via TO interconnections.
The motion of an axis can be triggered over the following channels:
• Via a single-axis command, e.g. _move(), _pos(),, etc. In this case, the
motion command is sent to the interpolator via the buffer. The interpolator
r.s
Note The supplementary technology objects in a SCOUT project can only be used via
the "CAM_EXT" technology package. You might need to integrate "CAM_EXT"
into the project with the menu command: Edit -> Select technology packages.
om
for 1 output vector
l.c
SensorObject for acquiring scalar measured values
ai
ControllerObject can process and control
SIMOTION
Siemens AG 2013. All rights reserved.
scalar variables
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.3
SITRAIN Training for
Automation and Drives
@
FixedGear The FixedGear technology object enables you to implement fixed synchronous
operation (without synchronization/desynchronization) based on a defined gear
ratio. A FixedGear converts an input variable to an output variable with a
configured gear ratio.
er
AdditionObjectType The AdditionObjectType TO enables you to add up to four input vectors for one
output vector. All input vectors and the output vector are "Motion" type vectors
(generalized motion vectors).
An AdditionObjectType can be used as follows, for example:
ne
SensorObject The Sensor TO is used to record and process scalar measured values. The
Sensor TO imports a value from the I/O and then smoothes, scales, and limits
the output signal in standardized formats.
ControllerObject The ControllerObject TO is used to process scalar variables and control them
with a universal PIDT1 controller.
om
"Motion vectors" are graphically gated with other TOs at the input
of a TO
The supplementary TOs are controlled via system functions
System functions
l.c
Input e.g.: Output e.g.:
Motion output of an axis Motion input of an axis or
(setpoint or actual value) another TO
or motion output of a TO
ai
Supplementary
TO
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.4
SITRAIN Training for
Automation and Drives
@
Motion vector A motion vector consists of three components:
• s: Position
• v : Velocity
• a: Acceleration (not currently in use)
er
The following TOs have "motion vector" type inputs: Axes (virtual and real),
FixedGear, AdditionObjectType, FormulmaObject, and ControllerObject as well
as the SynchronousOperation TOs for a following axis.
The following TOs provide "motion vecietor" type outputs: Axes (virtual and
real), ExternalEncoder, SensorObject, FixedGear, AdditionObjectType,
r.s
the Axis TO, FixedGear TO (the derivative of the position variable is the velocity
variable, the derivative of the velocity variable is acceleration).
The components of the motion vector are not kept consistent at the output side
of the "AdditionObjectType" and "FormulaObject" TOs. Velocity and acceleration
can be specifically defined in this item for the position.
om
+ X +
Offset Gear ratio Offset
l.c
Application:
• To make allowance for diameters in a master variable
• To implement a fixed gear ratio without coupling
ai
• As a motion-coupled gear on the master; slaves are "engaged" or "disengaged".
This ensures that the gear is always synchronized with the master.
SIMOTION
Example: A paper web
gear ratio. The individual vector componeents are multiplied by the gear ratio.
No limiting operations, no transitioni phases, and no corrections (except the
offset value) are taken into account. sOffset changes, gear changes, and input
changeovers are directly enab led on the output vector.
r.s
Properties
• Both absolute and rela@tive synchronous operation with or without
offset are possible
• The master vaulue can be changed on the fly (direct transition)
• If velocity is sellected as the motion basis, the component s (position)
ne
side. The offset is relative to the selected gear basis. The offset does not have
a unit; it references the set user unit.
om
Insert fixed gear
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.6
SITRAIN Training for
Automation and Drives
@
Overview FixedGear technology objects for all devices are created in the "Technology"
folder. Once it has been created, a "FixedGear" can be assigned to all
compatible TOs of a device.
er
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.7
SITRAIN Training for
Automation and Drives
@
Configuration Double-click the "Configuration" entry underneath the inserted TO to open the
dialog for configuring the "FixedGear". The following settings can be made in
this dialog box.
er
Ignore position If this box is checked, velocity is be selected as the motion basis. The
components v (velocity) and a (acceleration) are multiplied by the gear ratio and
output at the motion output. The component s (position) is set to 0 on the output
side.
ez
In this case, if gated with a motion input of an Axis TO, the output of the motion
vector can only be used for synchronous velocity operation
(_runVelocityBasedMotion()).
If this box is not checked, the position is used as the motion basis. The
r.s
components s, v, a of the input vector are multiplied by the gear ratio and an
offset is calculated for s if necessary.
Configuration Here you can select the following types for the output vector:
• Linear axis: The components of the motion output are displayed in the
ne
Processing You can select either IPO or IPO2 for the processing level.
cycle clock
ca
Input side Here you specify whether the replacement value or the last valid value is to be
used for calculating the output vector if the input vector is invalid.
Activate modulo Here you can activate modulo calculation for the motion output. If you select
"System specification", the modulo properties are taken from the axis assigned
to the motion output.
If you select "Set using configuration", you can enter the modulo values directly.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.8
SITRAIN Training for
Automation and Drives
@
Default In this dialog, you can specify the system variables for the default values
(userdefault....). To open the dialog, double-click the "Default" entry in the
project navigator.
er
Gear ratio Depending on which mode is selected, the gear ratio is specified here either as
a numerator/denominator ratio or as a floating-point number.
Activation/ The "FixedGear" is activated and deactivated (i.e. the motion input is gated to
Deactivation the motion output) either immediately (i.e. when the enable command is issued)
(_enablefixedgearing()) or when the motion input reaches a specific position.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.9
SITRAIN Training for
Automation and Drives
@
Interconnections A "FixedGear" has one motion input and one motion output. In the
"Interconnection" dialog, the motion input can be interconnected to the motion
outputs of other technology objects, such as the motion output (setpoint or
actual value) of an Axis TO, an external encoder, or a suitable supplementary
er
technology object.
However, only one interconnection can ever be active at runtime, i.e. return the
master value for the motion output of the "FixedGear".
e
ez
Activating the Which of the configured interconnections is active can be set with the following
interconnection system function.
• _setFixedGearMaster()
At runtime, you can use this function to switch between different master values
r.s
on the fly.
Procedure Proceed as follows to interconnect the motion input of the "FixedGear" to other
TOs:
ne
been created.
Note The "Cam profile" entry is intended for use in a future version. It is not active in
Version 3.2.1.
om
_enableFixedGearMotionIn Commands for setting the "master" or for
_disableFixedGearMotionIn enabling and disabling the motion input
_setFixedGearMaster
l.c
_enableFixedGearing Commands for enabling and disabling
_disableFixedGearing the gear and setting offsets
_setFixedGearingOffset
ai
_resetFixedGear
_resetFixedGearError
_resetFixedGearConfigDataBuffer Other commands
_resetFixedCommandId
SIMOTION
_getStateOfFixedGearCommand
_getFixedGearErrorNumberState
om
Disable motion input
RetVal := _disablefixedgearmotionin(//
fixedgear, // Specification of the FixedGear object
nextcommand, // Wait for ... ?
l.c
Commandid); // Command identification
ai
RetVal := _setfixedgearmaster( //
fixedgear, // Specification of the FixedGear object
master, // Specif. of the TO for the current input
nextcommand, // Wait for ... ?
SIMOTION
Commandid);
gm
Date:
File:
Command identification
10.01.2013
MC-SMO-PRG_A2.11
SITRAIN Training for
Automation and Drives
@
Enabling/Disabling The input interconnection is enabled and disabled separately from the
the motion input functionality itself. If the input values are not active, the replacement values
are used.
• _enableFixedGearMotionIn(): Use interconnected input values
er
specify which of the following values is used if the interconnection values are
enabled but invalid:
• LAST_VALID_INTERFACE_VALUE: the last valid value or
• DEFAULT_VALUE: the replacement values from the system variables for
MotionInDefault
r.s
(Following system startup, the last valid value is 0). If input interconnection is not
active, the replacement value is always used.
Switch master
ne
setpoint The active master can be defined and switched online with the
• _setFixedGearMaster()
function. The TO to be activated must be interconnected with the motion input,
otherwise the call returns error number: 10 "A connection to a technology object
required for this operation does not exist".
ca
om
gearingratio, // Specification of floating-point number
gearingnumerator, // Specification of numerator
gearingdenominator, // Specification of denominator
enablemode, // Immediate or leading axis position
startpositionmastertype, // DIRECT or USER DEFAULT
startpositionmaster, // Specification of leading axis position
nextcommand, // Wait for ... ?
l.c
commandid); // Command identification
Disable gear
RetVal := _disablefixedgearing(
ai
fixedgear, // Specification of the FixedGear object
disablemode, // Immediate or leading axis position
endpositionmastertype, // DIRECT or USER DEFAULT
endpositionmaster, // Specification of leading axis position
SIMOTION
nextcommand,
commandid,
Date:
File:
10.01.2013
MC-SMO-PRG_A2.12
SITRAIN Training for
Automation and Drives
@
Enabling/Disabling The actual gear functionality, i.e. the the gating of the motion input to the
"FixedGear" motion output, is performed with the following functions:
• _enableFixedGearing(): Enable gear functionality
er
Set offset
RetVal := _enablefixedgearing(
fixedgear, // Specification of the FixedGear object
offsetrange, // Master or slave
offsetmode, // Absolute or additive
offsetvalue, // Offset value
om
activationmode, // For active or future SO
nextcommand, // Wait for ... ?
commandid); // Command identification
l.c
activationmode:
DEFAULT_VALUE: For all future synchronous operations
ACTUAL_VALUE Only for the currently active synchronous operation
ai
ACTUAL_AND_DEFAULT_VALUE For the currently active synchronous operation and
for all future synchronous operations
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.13
SITRAIN Training for
Automation and Drives
@
Setting the offset on
the input/output side This function is used to set an offset on the input or output side.
The following is applicable:
er
System variables The synchronous operation adjustments on the "FixedGear" can be read out in
the system variables for the gearingAdjustments structure.
ca
The master and slave structure elements indicate the current offset entries for
the active gearing.
The defaultValueMaster and defaultValueSlave indicate the offset adjustments
for future gearing.
These system variables are read-only. Write operations are only possible with
the _setFixedGearingOffset() function.
om
+ X +
Offset Gear ratio Offset
motionin.state motionout.state
motionin.value.s fixedgearvalue.s motionout.value.s
motionin.value.v fixedgearvalue.v motionout.value.v
l.c
motionin.value.a fixedgearvalue.a motionout.value.a
ai
..gearingsettings.ratio
..gearingsettings.numerator
..gearingsettings.denumerator
..
Settings for gear type, trans-
mission ratio, direction, etc.
SIMOTION
Siemens AG 2013. All rights reserved.
gm
gearingadjustment.master.offset
gearingadjustment.slave.offset
Date:
File:
10.01.2013
MC-SMO-PRG_A2.14
Settings for offsets
MotionInDefault The structure elements for MotionInDefault indicate the replacement values of
er
the motion vector interconnected to the FixedGear. The variables are read/write
variables.
FixedGearValue The structure elements for fixedGearValue indicate the output values of the
ez
MotionOut The structure elements for MotionOut indicate the values of the output interface
s
MotionOutDefault The structure elements for MotionOutDefault indicate the replacement values of
u
read/write variables.
userDefault The structure elements for userDefault indicate the user defaults (direction,
ratio, numerator, denominator, etc.) at the FixedGear. These variables are
read/write variables.
ca
effectiveData The structure elements for effectiveData indicate the values that are currently
effective (direction, ratio, numerator, denominator, etc.) at the FixedGear.
These variables are read-only variables.
om
_runpositionbasedmotion
_runvelocitybasedmotion
_runmotioninpositionlockedvelocityprofile
l.c
TO_CONNECTION VALUE
ai
Fixed
Gear - defaultMotionIn.position
... - defaultMotionIn.velocity
... - defaultMotionIn.acceleration
SIMOTION
Siemens AG 2013. All rights reserved.
Date:
File:
gm 10.01.2013
MC-SMO-PRG_A2.15
SITRAIN Training for
Automation and Drives
@
MotionIn As of V3.2, an axis can be traversed according to the defaults set at the MotionIn
interface interface. The MotionIn values can be picked up directly by another TO such as
Axis, ExternalEncoder, AdditionObjectType, FormulaObject, or FixedGear.
As of V4.0, the MotionIn values can also be set from within the user program. In this
er
case, it is possible to set the value directly as a parameter in the command or using
the system variables defaultMotionIn.position, etc. If you choose to use a system
variable, new values are applied cyclically in the system variables.
Thus, both a job-based interface, wheere new axis positions are only taken into
ez
account when a new motion commandi is issued, and a cyclic interface are available
at the Axis TO. The usesr program can activate the MotionIn interface with a
_runPositioBasedMotionIn() or _runVelocityBasedMotionIn() command, for
example, and then set new axis positions or velocities continuously by cyclically
r.s
operation commands), motion can be executed from the MotionIn interface in the
basic or superimposed coordinate system. In this case, execution is controlled with
the merge parameter of the corresponding command.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.16
SITRAIN Training for
Automation and Drives
@
Interconnections As of V3.2, each Axis TO has a multi-point capable motion input which can be
interconnected with the motion outputs of other TOs.
This makes it possible to couple motion outputs of the following technology
objects directly to the motion input of an axis:
er
• Axis
• ExternalEncoder
• AdditionObjectType
ez
• FormulaObject
• FixedGear
• Sensor
• Controller
r.s
However, only one interconnection can ever be active at runtime, i.e. return the
position and velocity values for the motion of the axis.
Which of the configured interconnections is active is determined by setting
parameters in the following system functions:
ne
• _runPositionBasedMotionIn() or
• _runVelocityBasedMotionIn()
• _runmotioninpositionlockedvelocityprofile()
ca
Procedure Proceed as follows to interconnect the motion input of the "FixedGear" to other
TOs:
1. In the project navigator, double-click the "Interconnections" entry underneath
the "Axis" TO. This opens a dialog in which you can select the
interconnections.
2. Click in the corresponding input field on the right-hand side and select the
motion output of the required TO. You can only select TOs that have already
been created.
om
negativeacceltype, // DIRECT or USER DEFAULT
negativeaccel, // Acceleration neg. direction
positiveaccelstartjerktype, // DIRECT or USER DEFAULT
positiveaccelstartjerk, // Jerk on startup pos. direction
positiveaccelendjerktype, // DIRECT or USER DEFAULT
positiveaccelendjerk, // Jerk at the end of the accel. ramp
negativeaccelstartjerktype, // DIRECT or USER DEFAULT
l.c
negativeaccelstartjerk, // Jerk at the start of the decel. phase
negativeaccelendjerktype, // DIRECT or USER DEFAULT
negativeaccelendjerk, // Jerk at the end of the decel. phase
velocityprofile, // Continuous or trapezoidal
mergemode, // Attach, substitute, or superimpose
ai
nextcommand, // Wait for ... ?
commandid, // Command identification
valuereferencetype, // TO_CONNECTION or VALUE
motionintype, // Value direct or system variable
SIMOTION
positionin,
velocityin,
accelerationin);
Date:
File:
10.01.2013
MC-SMO-PRG_A2.17
SITRAIN Training for
Automation and Drives
@
Overview The
• _runPositionBasedMotionIn()
command activates the MotionIn interface with position reference. Once the
er
MotionIn interface has been activated with position reference, the axis moves to
(is synchronized with) the position defined in the interface with the velocity
profile and dynamic parameters defined in the command.
The "mergemode" parameter can be set to select whether the motion is
ez
VALUE). In the former case, the "reference" parameter determines the active
TO; in the latter case, the "motionInType" parameter is also evaluated. In the
former case, the MotionIn interface must also be connected to the required TO
under the axis interconnections.
If "motionInType = DIRECT", the "positionIn" parameter of the command is
ne
axis moves to the new positions according to the defined dynamic parameters.
Currently, the state of synchronization is neither stored in the system variables
of the axis nor can it be checked with corresponding system functions. Whether
the axis is synchronized with the motion input, i.e. whether the position of the
axis matches the position in the motion input, must be evaluated in the
application.
om
negativeaccel, // Acceleration neg. direction
positiveaccelstartjerktype, // DIRECT or USER DEFAULT
positiveaccelstartjerk, // Jerk on startup pos. direction
positiveaccelendjerktype, // DIRECT or USER DEFAULT
positiveaccelendjerk, // Jerk at the end of the acceleration ramp
negativeaccelstartjerktype, // DIRECT or USER DEFAULT
negativeaccelstartjerk, // Jerk at the start of the decel. phase
l.c
negativeaccelendjerktype, // DIRECT or USER DEFAULT
negativeaccelendjerk, // Jerk at the end of the decel. phase
velocityprofile, // Continuous or trapezoidal
mergemode, // Attach, substitute, or superimpose
nextcommand, // Wait for ... ?
ai
Commandid, // Command identification
movingmode, // Position-controlled or speed-controlled
valuereferencetype, // TO_CONNECTION or VALUE
motionintype, // Value direct or system variable
SIMOTION
positionin,
velocityin,
accelerationin);
Date:
File:
10.01.2013
MC-SMO-PRG_A2.18
SITRAIN Training for
Automation and Drives
@
Overview The
• _runVelocityBasedMotionIn()
command activates the MotionIn interface with velocity reference. Once the
er
MotionIn interface has been activated with position reference, the axis
accelerates or decelerates to the velocity defined in the interface with the
velocity profile and dynamic parameters defined in the
_runVelocityBasedMotionIn() command.
ez
the modified values are also applied to the MotionIn interface cyclically and the
axis is accelerated/decelerated to the new velocity according to the defined
dynamic parameters.
Currently, the state of synchronization is neither stored in the system variables
of the axis nor can it be checked with corresponding system functions. Whether
the axis is synchronized with the motion input, i.e. whether the position of the
axis matches the position in the motion input, must be evaluated in the
application.
om
negativeacceltype, // DIRECT or USER DEFAULT
negativeaccel, // Acceleration neg. direction
positiveaccelstartjerktype, // DIRECT or USER DEFAULT
positiveaccelstartjerk, // Jerk on startup pos. direction
positiveaccelendjerktype, // DIRECT or USER DEFAULT
positiveaccelendjerk, // Jerk at the end of the accel. ramp
negativeaccelstartjerktype, // DIRECT or USER DEFAULT
l.c
negativeaccelstartjerk, // Jerk at the start of the decel. phase
negativeaccelendjerktype, // DIRECT or USER DEFAULT
negativeaccelendjerk, // Jerk at the end of the decel. phase
velocityprofile, // Continuous or trapezoidal
mergemode, // Attach, substitute, or superimpose
ai
nextcommand, // Wait for ... ?
Commandid, // Command identification
movingmode); // Pos.-controlled or speed-controlled
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.19
SITRAIN Training for
Automation and Drives
@
Overview The
• _runmotioninpositionlockedvelocityprofile()
command activates the MotionIn interface with velocity reference. The axis
er
The cam itself is defined with the "Profile" parameter. The axis interconnections
must include the interconnection of the "Motion profile" entry to the required
cam.
The dynamic parameters for any required transition motions, e.g. to approach
r.s
the profile and to move away from the profile, are defined in the command.
The "mergemode" parameter can be set to select whether the motion is
attached or substitutes. "mergemode" can also be set to select whether motion
is to take place in the basic or superimposed coordinate system.
ne
ca
om
_runPositionBasedMotionIn()
_enableFixedGear()
_setFixedGearMaster()
l.c
ai
Set position Position component
of the "leading axis" of the motion output
SIMOTION
Siemens AG 2013. All rights reserved.
Position component
of the motion input gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.20
Set position
of the "following axis"
• <LeadingAxis>.positiongstate.commandposition
• <FixedGear>.motionIn.value.s
• <FixedGear>.motionOut.value.s
• <FollowingAxis>.positioningstate.commandposition
ez
"ABSOLUTE" was selected as the gear type and 1:1 as the gear ratio. No
additional zero offsets were programmed.
Sequence The leading axis (linear axis with modulo property) moves in the positive
r.s
The motion input of the following axis is enabled with position reference when
the _runPositionBasedMotionIn() command is issued. The following axis moves
to the position in the motion input in accordance with the specified velocity
profile. After this, the following axis moves in synchronism with the leading axis.
_setFixedGearMaster()
om
_runPositionBasedMotionIn()
l.c
of the "leading axis"
Set position of the
"following axis"
ai
Position component Position component
of the motion input
of the motion output
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A2.21
SITRAIN Training for
Automation and Drives
@
Overview The above trace recording illustrates the sequences during activation of relative
synchronous operation via a "FixedGear". The following system variables have
been recorded for this purpose:
er
• <LeadingAxis>.positiongstate.commandposition
• <FixedGear>.motionIn.value.s
• <FixedGear>.motionOut.value.s
• <FollowingAxis>.positioningstate.commandposition:
ez
"RELATIVE" was selected as the geari type and 1:1 as the gear ratio. No
additional zero offsets were progsrammed.
The leading axis (linear ax@is with modulo property) moves in the positive
Sequence direction at constant velocity.
r.s
When the _setFixedGea rMaster() command is issued, the motion output of the
leading axis (positionu setpoint) is applied to the motion input. The value of the
"FixedGear" motionIln.value.s system variable changes from 0 to the position
setpoint of theg leading axis. The value of the position component of the
motion output mootionOut.value.s remains set to 0.
ne
The motion input of the following axis is enabled with position reference when
the _runPositionBasedMotionIn() command is issued. The following axis
moves to the position in the motion input in accordance with the specified
velocity profile.
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
Date:
File:
gm 10.01.2013
MC-SMO-PRG_A3.1
SITRAIN Training for
Automation and Drives
@
Contents Page
Communication with SIMOTION - The mission ................................................................................. 3
Solution using client/server architecture ........................................................................................... 4
er
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.2
SITRAIN Training for
Automation and Drives
@
Contents Page
Step 2: Selecting the symbol file (*.sti tag file) .................................................................................. 27
Step 3: Access to SIMOTION with OPC SCOUT .............................................................................. 28
er
Step 3: Establishing a connection to the OPC server and setting up a group ................................... 29
Step 3: Adding items to a group ........................................................................................................ 30
Step 3: Monitoring and writing items ................................................................................................. 31
Restrictions affecting OPC communication ....................................................................................... 32
ez
Windows PC/Panel PC
Third-party
HMI
?
Parameteri-
om
zation
SCOUT ProTool/Pro
Control
Drivers Drivers
l.c
PROFIBUS/Ethernet
ai
SIMOTION
Siemens AG 2013. All rights reserved.
SIMOTION P3xx
gm
SIMOTION D4xx
Date:
File:
10.01.2013
MC-SMO-PRG_A3.3
SIMOTION C2xx
However, some users prefer to use their own tools and defaults for SCADA
ez
(Supervisory Control and Data Acquisition) systems. How can applications like
these be integrated, i.e. how can datae exchange between the applications and
SIMOTION be implemented?
Access with
drivers In the past, using software app lications to control multi-vendor hardware was an
r.s
arduous task. A multitude of different systems and protocols was used. Users
had to integrate special so@ftware (drivers) for each vendor and protocol in
order to access the specific interface of the automation system.
In most cases, uyou had to be an expert in C/C++ programming in order to be
able to implemenlt data exchange between an application "A" and an automation
ne
system "B". Programmers needed in-depth knowledge of both the data interface
of application "A" and the driver interface to the programmable controller "B".
Toolkits had to be purchased in order to use both the data interface of "A" and
the driver interface of "B". This frequently cost thousands.
User eprograms were tied to a particular vendor, protocol, or system.
ca
Windows NT/2000/XP
PC application
PC
om
Example
Database
Server
S7 protocol
l.c
PROFIBUS Industrial Ethernet
ai
SIMATIC SIMOTION SIMATIC
S7 S7 SIMOTION
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.4
SITRAIN Training for
Automation and Drives
@
Client/server The client/server architecture is another concept for the implementation of data
approach communication between an application and an automation system. The server -
in this case a Windows application - uses a standard interface to pass the
automation system data to a separate PC application for processing. The
er
End users can now choose freely between different hardware and software
vendors, basing their choice on the functionality they need, without having to
check whether a suitable driver is available.
ca
om
Example
OLE is based on COM, the component model of Microsoft
Objects are self-contained units
l.c
Objects can be accessed beyond process boundaries
Objects are extensions of the operating system
Since Windows NT, objects can also be accessed beyond
ai
computer boundaries (DCOM)
SIMOTION
technology
Date:
File:
10.01.2013
MC-SMO-PRG_A3.5
SITRAIN Training for
Automation and Drives
@
What is OPC? OPC stands for OLE for Process Control. The standard interface of the future, it
is based on the component model of the Microsoft company, which produces the
Windows operating system.
The term OLE "Object Linking and Embedding" was at one time used by
er
What does the As an industrial stuandard, OPC defines the exchange of information for different OPC
interface do? applications inl industrial environments. It allows you to monitor, retrieve, and
ne
process systgem data and events from the automation systems on your PC.
The OPC ointerface is the part of the software on a PC which acts as the
platform for operator control and monitoring systems or other applications. It
resides below elthe application program.
ca
Tkhe applications of the OPC interface are based on the client/server model. A
component makes its services available to other components via interfaces. The
other components can avail of these services as needed. In the case of OPC, an
application can detect which OPC servers are set up in a given system. It can
then address one or more of those servers and check which services are
available on each server.
A vendor of a hardware module which transmits process data (communication
systems, measuring instruments, etc.) provides an OPC server for the module,
which handles the connection to the data source.
om
Digital
Example
Fisher-Rosemount Systems
Honeywell Software
Intellution Inc.
l.c
Microsoft
Siemens
ai
Toshiba
Rockwell
...
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.6
SITRAIN Training for
Automation and Drives
@
OPC Foundation Microsoft has defined a de-facto standard with its Windows operating systems.
Microsoft's most important basic technology for the exchange of data between
applications is COM/OLE.
OLE for Process Control (OPC) is based on this technology. The primary
er
the OPC Foundation comprised 5 members. Today, the OPC Foundation has
approximately 360 members, including all the main worldwide vendors of
automation systems such as Fisher-Rosemount, Siemens, Trebing & Himstedt,
Rockwell Automation, Wonderware, ABB, National Instruments, and Honeywell.
r.s
43% of the member organizations of the OPC Foundation are from the USA,
30% from Europe, and 23% from Asia. The notably high proportion (more than
20%) of end users in the OPC Foundation is an indication of the significant
benefits anticipated by the end users of OPC technology. Microsoft also
demonstrates its full support of the standard through its membership.
ne
No other organization has the same scope of bundled resources at its disposal
in terms of development capacity and global marketing.
The implementation of the OPC specification in products occurred so fast that
neither corporate interests nor established standards committees could keep
pace. Exiting the starting blocks at such a pace meant that OPC managed to
ca
Bringing an end to
Task
dependency on specific PC 1 PC 2
vendors for hardware Application Application
and software
om
1 2
Client interface Client interface
Example Plug & play configuration
of data exchange COM/DCOM
l.c
data distribution
OPC server OPC server
Network capability A B
(Intranet)
ai
Device Device
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.7
A
...
B
...
Bringing an end This technology was previously characterized by the need to use special drivers
to dependency to handle data exchange between a PC application and the hardware.
on specific vendors OPC has created a standard interface which makes services available
independently of a specific application.
ez
Plug & play confi- OPC makes configuring of data exchange between hardware and applications
guration of much easier. The database for an OPC server is selected in familiar
data exchange Microsoft Explorer style by clicking with the mouse. Individual tags can be
combined in groups so that only data that is actually relevant is exchanged.
ne
Multi-client access Any OPC server is able to process requests from several clients. If data is to
and data be used in several different places, for example by a visualization program
distribution and a database, different software packages can access the data on the OPC
server. This capability is already supported by the functions of the operating
ca
Network capability In addition to COM technology, OPC uses DCOM (Distributed COM) for network
(Intranet) (Intranet) capability. This means that both data sources (OPC servers) that are
available on the local PC and all servers on the network are available as remote
data sources. Distributed operator stations, multi-user systems, and access to
distributed data sources are no problem with OPC. The OPC clients don't even
notice whether the data source is local or remote. OPC and DCOM hide the
difference.
om
Benefits of OPC OPC Alarms and Events
SIMATIC NET
OPC Historical Data Access
Licenses
l.c
OPC Data Exchange (OPC DX)
Prices
OPC XML
ai
...
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.8
SITRAIN Training for
Automation and Drives
@
OPC specifications OPC encompasses a range of general and detailed specifications which build on
one other and cover special requirements. OPC is an object-oriented
client/server architecture based on Microsoft's COM/DCOM technology.
Networking takes place using DCOM over Ethernet.
er
Data Access Data Access (OPC DA) describes the cyclic exchange of process data. An OPC
server for Data Access manages the process variables and the different
features used to access these variables.
ez
Alarm&Events In addition to the "Data Access" initerface, a specification has been defined for
event handling. Standard acknowsledgement mechanisms, alarm categories,
filter mechanisms, etc. are ava ilable. Alarms can thus be distributed to any
r.s
number of clients.
Historical Data
Historical Data Acce ss allows data to be stored in and retrieved from long-term
Access (HDA)
archives. Access tou historical data was previously only possible within a
SCADA system using anallysis tools (trend loggers, etc.). OPC HDA has
ne
om
to the server
Example
Definition of a name space and an
object hierarchy (branch and leaf nodes)
l.c
The name space contains all data, in any
structure
ai
Data items (OPC items) have attributes
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.9
SITRAIN Training for
Automation and Drives
@
What is OPC Data The most frequently used interface within the OPC standard today is the
Access (OPC DA)? Data Access interface. Data Access is an OPC specification for accessing
process data via variables. An OPC server for Data Access manages the
process variables and the features used to access these variables.
er
PLC. If a new value is detected, the server returns the value to the client. The
data type, a time stamp, and a quality inference about the validity of the value
are transmitted in addition to the actual value.
The messages to the client are not transmitted faster than the update rate
specified by the client. If a value changes faster than the update rate, the client
ne
Data Access OPC Data Access can be used on a SIMOTION device to access the
with SIMOTION following variables:
• System variables of the device and the technology objects
• Global device user variables
• Symbolic I/O variables
• Interface variables from user programs
Visual
Basic Automation
Task
interface
client/ (DLL)
MS Office "sopcdaauto.dll"
om
OPC server Protocol
Benefits of OPC software
and
C/C++ hardware
SIMATIC NET connection
Client Custom
Licenses interface
l.c
"OPCDAServer.exe"
Prices
SIMATIC NET
Visual Data Control
Basic
ai
(OCX)
client/ "sinet_opcdata.
MS Office ocx"
SIMOTION
Siemens AG 2013. All rights reserved.
Date:
File:
gm10.01.2013
MC-SMO-PRG_A3.10
SITRAIN Training for
Automation and Drives
@
Overview The OPC standard defines objects described by object interfaces. The OPC
standard defines two versions of the object interfaces on an OPC server which
can be addressed by an OPC client.
• COM Custom Interface
er
Custom Interface The Custom Interface is designed for languages that use function points, such
as C++, and optimized for performance. It is not suitable for access by script
languages (VBA).
r.s
Automation The Automation Interface is an add-on for the Custom Interface. With the
Interface aid of the Automation Interface, the convenience of modern development
systems and script languages can also be used in OPC programming.
The Automation Interface is implemented as a DLL (SOPCDAAuto.dll). A link to
this DLL must be set up when creating the OPC clients with Visual Basic.
ca
OCX Control SIMATIC Data Control enables access to OPC data from container applications
such as Visual Basic or Microsoft Office without any programming effort. The
selection and association of the data with the display and input fields of an
application is configured using a convenient browser.
Data Control (sinet_opcdata.ocx) has to be added to the client project when
creating the OPC clients.
OPC client
om
OPCGroup OPCGroup
Example
OPCItem OPCItem
OPCItem
l.c
Namespace
(address
C230 space)
ai
Axis 1 Axis 2 xxx
SIMOTION
Current_set
Date:
File:
10.01.2013
MC-SMO-PRG_A3.11
SITRAIN Training for
Automation and Drives
@
Class model The OPC specification for Data Access subdivides the interfaces and their
for OPC DA functions (methods) into three hierarchical classes. This structure is known as the
class model. A class defines the set of functions (methods) and properties which an
object has to support.
er
OPC server The OPC Server class is at the top of the hierarchy. Every OPC server belongs
to this class. This class represents the access point for all further services
supported by the OPC Data Access server.
ez
The "OPC server" class has various aettributes and methods which provide
information about the status, versiion, and address space of the process variables
available on an OPC sesrver object. An OPC server also manages the instances of
the "OPC group" class, which resides below it.
r.s
OPC group The "OPC group" class str@uctures the process variables used by the OPC
server. An OPC client can use the objects of the "OPC group" to generate suitable
units of pruocess variables and run operations with them. For example, all process
variablles on a given screen page of an OCM system could be combined in gthe
same group.
ne
The "OPC group" class defines methods which can be used to read and write
the valueslo of the process variables. Multiple variables can be combined in one
reequest and transmitted simultaneously. These set calls make for high processing
speeds in particular when an OPC server is used across a DCOM knetwork
connection.
ca
Synchronous read/write
Asynchronous read/write
Task
Cache
ActiveState
om
CycleTime
Example
Set operations (creation of groups, etc.)
Messaging in the event of a change
l.c
UpdateRate
PercentDeadband
ActiveState
Attribute items
ai
VARIANT data type
Time stamp
SIMOTION
Siemens AG 2013. All rights reserved.
Quality
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.12
SITRAIN Training for
Automation and Drives
@
Data access at Functions are available at group and item level both for monitoring variables and
group level for other read and write access operations.
A client can use the OPCGroup object to generate semantically meaningful units
of OPC items in order to process them together.
er
For example, monitoring of all of the OPC items in a group can be activated by
calling a single function. Therefore, all process variables on a given screen page
of an OCM system should be combined in one group, for example. Monitoring of
the variables can then be activated when the screen page is opened.
ez
Synchronous and asynchronous functions for reading and writing variables are
available within the group. The OPC Automation interface uses events to return
changes to the values of active items and the results of asynchronous
operations.
Data access can also be optimized by reading process variables from the
ne
Data access at Individual items can also be read in synchronous or asynchronous mode.
item level Additional information such as access rights, data type, time stamp (i.e. the time
when the last value was recorded), and the quality of the value can be scanned
ca
om
events to be transmitted
Benefits of OPC
l.c
Prices
Option to transmit auxiliary values is
supported
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.13
SITRAIN Training for
Automation and Drives
@
What is OPC Alarms & Events is a specification for transmitting process alarms and events.
Alarms & Events? It is highly flexible and can, therefore, be used on a wide variety of event
sources.
The spectrum ranges from simple to complex events and even events requiring
er
Selection using Events are special process states which have to be signaled to a receiver.
filter criteria The OPC client uses filter criteria to define which events are signaled to the
corresponding programs.
All events that match the filter criteria must be transmitted to the user by the
r.s
creator of the event. his is the main difference between Alarms & Events and
Data Access. When variables are monitored, only value changes that occur
within the specified time scale are signaled.
Message content The message returns the parameters defined in the OPC specification along
ne
OPC client
Task "OPCAlarmload.exe"
OPCEvent
Server
om
OPCEvent
Browser
Benefits of OPC
Alarms & Events
server
SIMATIC NET
OPCEvent OPCEvent
Licenses Subscription Subscription
l.c
Prices
Namespace
D425-2
ai
Axis 1 Axis 2 xxx
SIMOTION
Siemens AG 2013. All rights reserved.
Alarm Alarm
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.14
SITRAIN Training for
Automation and Drives
@
Overview The class model of Alarms & Events allows the OPC client to be adapted to the
needs of an automation solution. Alarms & Events distinguishes between three
classes:
• OPCEventServer
er
• OPCEventSubscription
• OPCEventAreaBrowser (the OPCEventAreaBrowser class is optional; it is
not supported by the SIMOTION OPC Alarms & Events server).
ez
OPC Alarms server The OPCEventServer class is at the top of the hierarchy. Every OPC Alarms &
Events server belongs to this class. This class represents the access point for
all further services supported by the OPC Alarms & Events server.
The objects of the OPCEventServer class essentially handle the logging in of
r.s
OPCEvent- A client uses the objects of the OPCEventServer class to create one or more
Subscription objects of the OPCEventSubscription class. An object of this class is a
ne
subscription to a set of events. Objects of this class manage the required filters
and attributes on a client-specific basis.
OPCEventArea Alarms & Events supports the subdivision of large plants into different plant
ca
areas. Areas can be used to filter events. The plant areas can be examined
using objects of the OPCEventAreaBrowser class.
Objects of the OPCEventAreaBrowser class are optional; they are not supported
by the SIMOTION OPC Alarms & Events server.
Event types:
Task Simple events
e.g.: Diagnostics buffer entries
om
Benefits of OPC
Conditional events
SIMATIC NET
e.g.: TO alarms, AlarmSQ
Licenses
l.c
Prices
Tracking events
e.g.: operator actions (not supported by the SIMOTION
ai
Alarms server)
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.15
SITRAIN Training for
Automation and Drives
@
Simple events Simple events are typically informative messages which are not associated with
any particular actions. Simple events do not usually refer to error states which
need to be acknowledged specifically. System messages such as start of ramp-
up, device error, etc., are examples of simple events.
er
Information about the event (e.g. time stamp, alarm no., source, alarm text,
severity, etc.) is transmitted to the client in a SimpleEvent object.
In a SIMOTION system, all entries in the diagnostics buffer (not user-specific
entries) are mapped to simple events. When a client logs in, it first receives the
ez
Conditional events Conditional events are always associated with the detection of a particular
condition which usually requires some kind of response (acknowledgment) from
r.s
the user or operator. Conditional events are thus always associated with
information about system states (e.g. incoming alarm, outgoing alarm,
acknowledged, etc.).
In a SIMOTION system, the TO alarms and the configured AlarmS messages
are mapped to conditional events.
ne
Tracking events Tracking events are similar to simple events, but indicate that a particular action
has been initiated by the operator at the "event source". Information about the
operator ("ActorID", etc.) is thus transmitted in addition to the information
associated with a simple event.
ca
om
Example
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.16
SITRAIN Training for
Automation and Drives
@
SIMATIC NET for The following packages are required to create OPC applications under
Windows XP Windows XP: Version V7.1.3 can only be used in combination with the following
packages:
• Windows XP Professional + SP3
er
SIMATIC NET V8.1 or 8.2 is required fomr the Windows 7 Enterprise and
SCOUT V4.3.1.3.
The version which is internally storedie on "SIMATIC NET, PC Software, Edition
2008 + SP3" CD is V7.1.3.
r.s
ne
ca
om
Multi-vendor capability
Example
SIMATIC NET OPC server with multiplexer
l.c
(Send/Receive) server server
ai
comm. (FDL) Base CP5613/14
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.17
SITRAIN Training for
Automation and Drives
@
SIMATIC NET The OPC server for Data Access enables standardized access to the
DA OPC server industrial communication networks of SIMATIC NET.
The SIMATIC NET OPC server supports the interfacing of applications to any
automation components networked using PROFIBUS or Industrial Ethernet. The
er
Task
om
Example
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.18
SITRAIN Training for
Automation and Drives
@
SIMATIC SIMATIC Computing, part of the SIMATIC NET PC software, is used to
Computing generate simple applications for data access without any need for programming.
The process data can be read from or written to a SIMOTION system via
PROFIBUS or Industrial Ethernet.
er
SIMATIC NET OPC The most important control is SIMATIC NET OPC Data Control. Without this
Data Control control, no other SIMATIC control can access the process data.
(sinet_opcdata.ocx) Data Control accesses process data determined by the OPC server.
r.s
Display controls Display controls are elements for the visualization of process data. They
receive their data via SIMATIC NET OPC Data Control and not directly by
accessing OPC or another interface.
ne
Task
om
Step 7 SCOUT ProTool/Pro OPC SCOUT EXCEL/
Drivers Drivers Drivers
Visual Basic
SIMATIC NET
l.c
CP5611 Ethernet
Ethernet
ai
SINAMICS
SINAMICS
0O
270O
90O
180O
0O
270O
90O
SIMOTION
Siemens AG 2013. All rights reserved.
Date:
File:
gm
180O
SMC
10.01.2013
SIMOTION D425-2
MC-SMO-PRG_A3.19
SITRAIN Training for
Automation and Drives
@
Overview The following examples illustrate communication between two OPC client
applications, OPC SCOUT, and a Visual Basic application, and a SIMOTION
system using the SIMATIC NET OPC Data Access server.
This example shows how a SIMOTION D425-2 is connected to a PG/PC via
er
Ethernet. The two OPC client applications, "OPC SCOUT" and "VB Application",
run on the same PG/PC as the OPC server.
ez
r.s
ne
ca
om
xml file (all S/Q, TO alarms, and other communication
information)
Step 2:
Make settings to start the OPC server
l.c
Set the operating mode of the PG interface
Select the S7 protocol
ai
Select the required sti file
Step 3:
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Start OPC client application (OPC SCOUT)
Date:
File:
10.01.2013
MC-SMO-PRG_A3.20
SITRAIN Training for
Automation and Drives
@
Overview In order to establish a connection between a PG/PC and a SIMOTION device
via OPC at runtime, you must first carry out a number of steps to configure the
OPC interface:
er
Engineering Start by performing the following actions when creating the project on the
system engineering system of the SIMOTION device:
1. Create a project for the SIMOTION device using SIMOTION SCOUT.
2. Export the OPC data with SCOUT in omffline mode.
ez
they will need to be configur@ed and combined using the SIMOTION OPC
File Manager.
5. Then copy the ex ported files to the PG/PC on which the OPC server
is running.
ne
The followingg settings are required on the PG/PC with the OPC server:
PG/PC
Task
om
For Data Access
For Alarms&Events
l.c
4. Enter interface 3. Enter path
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Drive:\Documents and Settings\All Users\Anwendungsdaten\
Siemens\SIMATIC.NET\opc2\binS7\simotion\xml\
Date:
File:
10.01.2013
MC-SMO-PRG_A3.21
SITRAIN Training for
Automation and Drives
@
Procedure To declare the data configured in SIMOTION SCOUT to SIMATIC NET, the
necessary files need to be exported. OPC data can only be exported when
SIMATIC NET OPC is installed, a project is loaded, and SIMOTION SCOUT is
in offline mode.
er
Proceed as follows:
1. Switch OPC SCOUT to offline mode if necessary and select the menu item:
Options -> Export OPC data... .
ez
Select the "OPC data" entry if you want to access SIMOTION process
variables. If the box is checked, the symbol names and variable addresses
r.s
3. The next step is to enter the target directory for the exported files in the
ne
Task
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.22
SITRAIN Training for
Automation and Drives
@
Overview Existing symbol files can be accessed with the Symbol File Configurator.
Symbol files can be extended or modified. In particular, the following properties
of a symbol can be modified:
• Visibility in the OPC Browser
er
OPC ItemID The OPCItemID is the process variable identifier used by the OPC server. An
ItemID is passed from the OPC client to the OPC server to identify a process
variable and is unique on the OPC server.
Detailed knowledge of the exact structure of the ItemID is important, especially
ne
when programming your own OPC clients with C/C++ or Visual Basic.
Symbolic name A symbolic name is an OPCItemID used within a hierarchical namespace. In this
case, the symbolic name is derived in the established namespace from the
ca
names of the hierarchical levels and the actual symbol. The symbolic name can
also be used to access a process variable.
Runtime name A runtime name is an OPCItemID which contains tracking and address
information for assignment purposes. It is accepted directly by the OPC server
without using a symbol file. The Symbol File Configurator assigns a symbolic
name to a runtime name.
Alarm and
message texts
Task
om
Ethernet and
PROFIBUS
address
l.c
List of all
TOs
ai
Access point
for SIMOTION
OPC server
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.23
SITRAIN Training for
Automation and Drives
@
Overview The file in the screenshot above is an OPC_AE.xml file. It can be opened in
Internet Explorer by double-clicking the file name. A file of this type contains the
following data for each configured language:
• Texts of all AlarmS/Q messages configured by the user
er
Task
om
Modules -> Intel(R) PRO... -> General
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.24
SITRAIN Training for
Automation and Drives
@
Overview The "Configuration Console" is a tool with versatile features for the configuration
and diagnostics of PC hardware components and PC user programs. The
settings of the OPC servers supplied with the software can also be configured
here.
er
The "Configuration Console" tool can be launched from the Windows start menu
by selecting:
Start -> SIMATIC -> SIMATIC NET -> Configuration Console
ez
Operating mode The operating mode of the module can be changed. The possible settings
module are:
Configured mode:
In this mode, as is the case with a SIMATIC station, a configuration of the
r.s
PG/PC must be created. In this case, the PG/PC is treated in exactly the same
way and has the same properties (e.g. routing) as a PLC. The Ethernet module
and the OPC server are configured in exactly the same way as the modules in a
SIMATIC station.
All parameters of the module have to be defined in the PC station configuration
ne
and downloaded to the device. The download can also be performed from a
remote engineering system.
PG mode
In this mode, the module remains under the control of the local Windows
ca
SIMOTION "PG mode" should be set for the Ethernet module to enable the OPC server to
access the SIMOTION device. "Configured mode" should be selected, for
example, whenever the OPC server has to access both SIMOTION and
SIMATIC stations.
Task
Modules -> Intel(R) PRO... -> Address
Solution with OPC
om
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.25
SITRAIN Training for
Automation and Drives
@
Ethernet The settings for the IP address and subnet mask of the Ethernet module are
address entered in the Modules -> Intel(R) ...-> Address dialog. However, the values can
only be changed if the module is in PG mode and you have the corresponding
administrator rights.
er
tool.
ez
Note The IP address and the net mask set in this dialog must match the IP address
e
Task
om
OPC protocol selection
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.26
SITRAIN Training for
Automation and Drives
@
Protocol selection The OPC server supports various protocols. All protocols are activated in the
initial configuration. When commissioning a plant with several different
protocols, it can be advisable to put the communication system into operation
gradually.
er
Task
om
Symbols
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.27
SITRAIN Training for
Automation and Drives
@
OPC symbols One or more cross-protocol symbol files (*.sti) can be selected with the OPC
server in the "Symbols" dialog. A symbol file contains a symbolic namespace for
the OPC Server which can be organized hierarchically.
In Step 1, the symbol file of a project was exported from SIMOTION SCOUT. In
er
SIMATIC NET 7.0, the symbol file for SIMOTION must be stored in the following
location:
<System drive>\Documents and Settings\All Users\Application Data\Siemens\
SIMATIC.NET\opc2\binS7\simotion\xml\
ez
Symbol files/ If several symbol files are selected, aie name prefix can be entered in "Edit list"
Prefix in order to prevent name conflictss.
The prefix used to classify the symbols from the symbol file in the namespace is
r.s
displayed in the "Prefix" column. The prefix (e.g. "SYM1") is then inserted in
front of all symbols from this symbol file when browsing.
The default symbol file has no prefix. Its symbols are then classified
immediately below the root "SYM" uof the symbol namespace.
ne
Advanced In this g dialog, you select the module (TCP/IP -> Intel(R) ...) used by the OPC
symbols server to handle communication with the SIMOTION target device on the
PG/PC.
ca
PG/PC
Task
om
OPC SCOUT
SIMATIC NET
l.c
CP5611 Ethernet
Ethernet
ai SINAMICS
SINAMICS
0O
270O
90O
180O
0O
270O
90O
180O
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
SIMOTION D425-2
MC-SMO-PRG_A3.28
SITRAIN Training for
Automation and Drives
SMC
@
Overview OPC Scout can be used to test access to the OPC server and thus to start up
the OPC server.
OPC Scout can be launched from the Start menu of the Windows operating
system:
er
Task
om
Step 1: Double-click OPC SimaticNet
(to establish a connection to the OPC server)
l.c
(create OPC group)
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.29
SITRAIN Training for
Automation and Drives
@
Connecting Before the process variables of the SIMOTION device can be controlled and
OPC Scout to monitored, a connection to the desired OPC server must be established from
the OPC server OPC Scout.
To do this, double-click the "OPC.SimaticNET" entry or select the "Connect"
er
Creating an In the next dialog, "Add Group", you are prompted to create a new
OPC group OPC group.
Enter a group name (e.g. "MyGroup") and acknowledge with the "OK" button.
The OPC.SimaticNet server creates a new group and activates it, i.e. the
r.s
process variables (items) inserted in the group are automatically updated on the
SIMOTION device by the server.
The "Requested update cycle" entry is used to adjust the rate at which the
OPC.SimaticNet server transmits new values to OPC Scout.
ne
The "Advanced" check box is used to modify additional properties such as the
"Percent Deadband" or to display other information about the OPC group
created, such as the client and server group handle.
ca
Double-click
Task
om
\SYM
Step 3: Add items to group
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.30
SITRAIN Training for
Automation and Drives
OK
@
OPC Navigator Next, the namespace of the OPC.SimaticNet server can be scanned and new
process variables added to the new OPC group.
To do this, double-click the group you have just created or select the Add item
command from the shortcut menu.
er
The OPC Navigator opens. The process variables of the SIMOTION device are
displayed below the SYM root if no additional prefix has been declared.
e
ez
Adding an item The left-hand column of the OPC Navigator window shows the hierarchical
structure of the process space. You can insert process variables as follows:
1. Double-click to open the desirsied secondary level of the process
space in the left-hand window.
2. Select the level for which you want to display the variables.
All variables on that le@vel are displayed in the middle column.
r.s
3. In the middle pane, se lect the process variables you want to add to
the group and clicku the "->" button.
The selected lvariables are transferred to the right-hand pane. Conversely,
you can remove variables from the group again by clicking the "<-" button.
4. When youo have finished adding the variables to the group, confirm
your selection by clicking the "OK" button.
The selected variables are copied to the main window of OPC Scout and
ne
Monitor items
Task
om
Write value(s)
Right-click with the mouse
l.c
ai
SIMOTION
Siemens AG 2013. All rights reserved.
gm
Date:
File:
10.01.2013
MC-SMO-PRG_A3.31
SITRAIN Training for
Automation and Drives
@
OPC ItemIDs Unique name of the OPC item
Value Value of the variable, displayed in the format set in the Format column.
Format You can choose between original, hexadecimal, and binary notation for integer
er
values. The "original" notation for integer values is decimal. All non-integer
values are always shown in original notation. It is not possible to change the
format for these data types.
Type Canonical data type of the OPC item.
ez
Access Access rights for the OPC item ( "R"= Read-only, "W"= Write-only, "RW" =
Read/Write)
Quality Qualifies the meaningfulness of the value. "Good" quality indicates that the
value has been determined reliably.
r.s
Time stamp (UTC) Last time the OPC server detected a value change. The time stamp is
represented in UTC (Universal Coordinated Time) format. The UTC time is
equivalent to Greenwich Mean Time (GMT).
Result Write result of the last write operation for this OPC item.
Group Name of the group containing the OPC item.
ne
Change values 1. Right-click to open the context menu for the variables you wish to overwrite
and select the "Write Value(s)" command.
The "Write Value(s) to the Item(s)" dialog is opened.
2. Enter the new value in the "Value" input field and confirm your entry by
clicking the "Apply" or "OK" button.
The new value is transferred to the process variable in the controller.
Restrictions
Communication based on OPC client
COM/DCOM mechanisms Firewall?
Windows operating
Restricted to devices with system ...
om
Windows operating system DCOM (TCP/IP connections)
l.c
TCP/IP connections during access
via the Internet Windows operating
system
Î Problems with firewalls PROFIBUS/Ethernet
ai
Solution which gets around the
above problems:
SIMOTION
Î OPC XML
10.01.2013
MC-SMO-PRG_A3.32
SIMOTION
D4x5
SIMOTION
C230-2/C240
vendor of an HMI system no longer has to develop and provide drivers for
different communication systems.
too expensive due to the underlying DCOM and RPC (Remote Procedure
Call) mechanisms.
• Remote maintenance and diagnostics is another area where OPC now plays
a role. OPC is designed to support access via the Internet. Because of the
"generous" allocation of free port numbers for underlying TCP/IP
ca
OPC XML DA With the "OPC XML DA" specification, the OPC Foundation has extended the
scope and application of OPC. This specification provides a means of operating
OPC connections via the Internet.
Properties
DCOM mechanisms are OPC XML
client
replaced by IT mechanisms
Any operating system
HTTP (Hyper Text Transfer Protocol) (Linux, Windows, etc.) ...
om
SOAP (Simple Object Access
Protocol)
No problems with firewalls LAN,
(HTTP uses port 80) Internet
l.c
OPC XML client can run on any
Ethernet
platform (Linux, etc.)
OPC XML server runs directly on OPC XML
ai
the SIMOTION device server
SIMOTION
is not required
Function calls A web service allows function calls to be sent to a server via the Internet
via the Internet using the independent SOAP protocol (Simple Object Access Protocol). The
ez
It is thus only necessary to know the Internet address and the URL of the web
service in order to use web services.
OPC XML Data transfer using OPC XML is an example of this type of web service. The
exact description of the data interfaces and methods is contained in the WSDL
ne
specification, which is supplied by the OPC Foundation together with the OPC
XML DA specification.
Access to methods direct from the Internet presents a significant security risk.
Therefore, SOAP uses the Internet HTTP (HyperText Transfer Protocol) channel
ca
exclusively for data transfer. This channel can be managed easily with a firewall.
SIMOTION In the case of SIMOTION, the OPC XML DA Server runs directly on the target
hardware. An OPC XML Client can thus use the services of the server directly to
access the data and operating modes of the SIMOTION device.
The use of the integrated OPC XML server is only possible via Ethernet.