You are on page 1of 71

SIMOTION

SIMOTION
Example for Beginners

SIEMENS AG 2009
Automation and Drives

Example for Beginners


Disclaimer of liability
SIMOTION

The application examples and the associated documentation


Task contained on this DVD are made available without cost. The
customer receives for the software the non-exclusive, non
SIMOTION - Basic transferable, free right to use the software; this includes the right to
Information change the software, to copy it changed or unchanged, and to
combine it with the customer's own software.
Program
Design Siemens AG has not subjected the software to the normal system
test otherwise usual for software.
Program
Implementation Any liability irrespective of the legal reason in particular
because of software errors or the associated documentation or
damages resulting from consulting is excluded, unless, for example,
because of premeditation, gross negligence, risk to life, injury or
health, acceptance of suitability guarantee, malicious concealment
of a fault or a violation of significant contractual obligations, would
force liability. A reversal of the burden of proof to the customer's
disadvantage is thus not included.
German legal right applies. Place of jurisdiction is Erlangen.

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/2


Automation and Drives

Example for Beginners


Some preliminary comments
SIMOTION

Before processing the Example for Beginners, it is advisable to study


Task
Getting Started with SIMOTION SCOUT" (Menu Help\Getting Started).
SIMOTION - Basic
Information In the example, some elements have been extended more than
necessary in order to demonstrate as many different aspects of
Program SIMOTION possible (e.g. a virtual axis as master).
Design In some cases, the notes page provides further information for the
associated slide.
Program
The screenshots were created with SIMOTION Version 4.1 (05/2009).
Implementation
Under some circumstances there may be minor changes for future
versions.
The firmware version on the D435 should agree with the SIMOTION
SCOUT version

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/3


Automation and Drives

Example for Beginners


Machine diagrams
SIMOTION

Task

SIMOTION - Basic
Information
Extractor
Program - electric travel

Product feed
Design - eject pneumatically
Package (empty)
Package (full)
Program
Implementation

Palletizer
Carton erector Conveyor belt

Sensor

Procedure notes are contained in the Program Design section

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/4


Automation and Drives

Example for Beginners


Topology of the automation solution
SIMOTION

Task SIMOTION SCOUT


HMI MP270 D435
SIMOTION - Basic
Information

Program
Design PROFIBUS DP
Carton erector*
Program Feed*
Implementation

ET 200 * Transport

MICROMASTER 420 * Extractor

1 FK7

* Not considered in the example, but part of the complete plant


SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/5
Automation and Drives

Example for Beginners


Execution system
SIMOTION

Task Stop Run Start-up Task

SIMOTION - Basic
Information Run
Call Motion
Background Task Background Task 1 Tasks (se-
Program quential
tasks)
Design
Motion Tasks Motion Task 1 Motion Task 2 Motion Task 20
Program
Implementation Monitor the
Synchronous Tasks IPO - sync Task 1 IPO - sync Task 2
2 emergency
off criteria

Time-triggered Tasks Task 1 Task 2 Task 5

System Int Tasks Response to


System Int Tasks process
Interrupt Tasks User Int Task 1 User Int Task 2 System Int Tasks
signals

Run Stop 3

Shut-down Task

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/6


Automation and Drives

Example for Beginners


Comparison of cyclical and sequential programming
SIMOTION

To simplify the understanding, the comparison on a sample task follows: Pos should move to
Task Target; the Finished variable is set to TRUE when the position is reached.

SIMOTION - Basic Sequential task: Cyclical task:


Information
_pos ( axis:=Pos, Query status
Program position := Ziel, Pos_status := pos. command
Design _getStateOfAxisCommand (Pos,
nextCommand:=WHEN_MOTION_DONE) PosCommandID)
Program
Advance IF (Pos_status <> ACTIVE AND Pos. command
Implementation
command Fertig = FALSE ) THEN
_pos (axis:=Pos, Advance
position:= Target, command
Program processing stops until nextCommand:=IMMEDIATELY,
the target position is reached commandID:= PosCommandID);
END_IF
Finished:= TRUE;
IF Pos.motionstatedata.motioncommand =
MOTION_DONE THEN Query position
Fertig:= TRUE;
END_IF
Cyclical program section continued

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/7


Automation and Drives

Example for Beginners


Variable model
SIMOTION

System variables
Task
Technology objects Variable is assigned to a TO (e.g. actual position of an axis)

SIMOTION - Basic
SIMOTION device
Information Variable is assigned to the SIMOTION device
(e.g. system clock)

Program
Design
Global user variables Variable indicates an input/output area
Program I/O variables (e.g. Startpos -> P10.1)
Implementation Variable can be accessed from anywhere on the device
Device global variables

Variable can be accessed from programs, FCs and FBs in a unit


Unit variables

Local user variables Variable can only be used within the declaring program
Program variables
Variable can only be used within the declaring function (FC)
FC variables

Variable can only be used in the declaring function block (FB)


FB variables

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/8


Automation and Drives

Example for Beginners


Solution guide
SIMOTION

Current situation Creation of a hardware


Task configuration
Problem task (machine diagram)
SIMOTION - Basic Specification of the possible DP
Topology concept with SIMOTION
Information cycle clock
Program concept
Axis configuration
Program Technology objects
Design Master axis
Task structure
Conveyor belt
Program Task relationships
Implementation Extractor
Variables
Output cam configuration
Drives
Cam configuration
611U parameterization
Form
System environment
Parameterization
Create device
Programming, parameterization and
Specification of the possible DP cycle test
clock
ProTool connection

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/9


Automation and Drives

Example for Beginners


Technology objects
SIMOTION

Virtual master axis Cam controller - pneumatic


Task extractor
Positioning axis
SIMOTION - Basic Position-based cams
Rotary axis (modulo)
Information Interpolator
Real axis - conveyor belt
Program
Design
Following axis
Rotary axis (modulo)
Program
Implementation Gearbox synchronism
Real axis - pusher
Following axis
Linear axis
Camming
Cam - extractor
Not cyclical

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/10


Automation and Drives

Example for Beginners


Task structure
SIMOTION

Startup Task User Interrupt 1 (stock outage


Task detection)
ST initialization
Call the extractor task MCC
SIMOTION - Basic Background Task
Information IPO synchronous task (emergency
Execution control FBD stop monitoring)
Program Test protective door MCC
Call the homing task / initial setting
Design
travel FBD Tech Fault / Peripheral Fault - Task
Program Call the automatic operation FBD (error handling)
Implementation Acknowledge error MCC
Motion Task 2 (Hominging)
Homing and possibly initial setting
travel of the associated axes - MCC
Motion Task 3 (Automatic operation)
Start the master axis MCC
Synchronize the conveyor belt
MCC
Trigger the pneumatic valve MCC

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/11


Automation and Drives

Example for Beginners


Task relationships
SIMOTION

Motion Task 2
Task
Start-up
SIMOTION - Basic
Information Motion Task 3

Program Background
Design

Program
Implementation
User Interrupt Start program pEject

Interrupts the task


Motion Task 2
IPO Sync Task
Motion Task 3

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/12


Automation and Drives

Example for Beginners


Variables
SIMOTION

Device-global variables I/O Variables (symbol browser)


Task
None Onboard inputs:
SIMOTION - Basic Unit-global variables dig_inputs (alle
Information Eingnge)
Velocity of the leading axis WORD
Program Open protective door (PIW298)
Design Program end i_boEject (Sensor)
Bool PI299.2
Program Operating mode
Implementation i_boProtDoor
Locale variables Bool PI299.0
None i_boStartBelt
Bool PI299.1
Fast outputs (output cam object)
Onboard outputs:
Ausschieber aktiv
Nocken
PQ298.0
Naming variables
Variables are named in accordance with the instructions from the SIMOTION ST V4.0
programming standards

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/13


Automation and Drives

Example for Beginners


HW configuration create device
SIMOTION
New Scout create project
Create new device (D435 V4.1)
Task
Select the interface for PG
SIMOTION - Basic (retain the default setting)
Information The networking for PG in NetPro will be created
automatically
Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/14


Automation and Drives

Example for Beginners


HW configuration
SIMOTION Select cycle for internal interface
e.g. 2ms increase factor to 8

Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/15


Automation and Drives

Example for Beginners


Net Pro
SIMOTION

The network configuration for PG is created automatically


Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/16


Automation and Drives

Example for Beginners


Configure drive 1
SIMOTION

Configure drive device


Task
Use unregulated infeed for
SIMOTION - Basic SIMOTION D - demonstration kit
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/17


Automation and Drives

Example for Beginners


Configure drive 1
SIMOTION
Select power section (dual-axis module)
Select rating according to the rating plate
Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/18


Automation and Drives

Example for Beginners


Configure drive 1
SIMOTION

Motor with DRIVE-CLiQ no further details for the motor type required
Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/19


Automation and Drives

Example for Beginners


Configure drive 1
SIMOTION

Task
Telegram type 105
SIMOTION - Basic
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/20


Automation and Drives

Example for Beginners


Configure drive 2
SIMOTION

Motor with SMC


Task
motor type and
SIMOTION - Basic speed in
Information accordance
with rating plate
Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/21


Automation and Drives

Example for Beginners


Configure drive 2
SIMOTION

Select encoder in accordance with rating plate, e.g. Endat


Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/22


Automation and Drives

Example for Beginners


Comparison with hardware configuration
SIMOTION
SINAMICS configuration
Comparison with the hardware configuration
Task Entry of the I/O addresses by SIMOTION SCOUT

SIMOTION - Basic
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/23


Automation and Drives

Example for Beginners


Telegram extension for control unit in HW-Config
SIMOTION Open hardware configuration

Sinamics-integrated
object properties
Task

SIMOTION - Basic
Information Activate

Program
Design Select
standard telegram 1
Program
Implementation

Save and
compile

No further comparison with


hardware configuration!!!
SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/24
Automation and Drives

Example for Beginners


Telegram for control unit
SIMOTION Wiring of the digital inputs to the send telegram
of the control unit
Inputs available for Simotion
Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

Mouse click on
interconnection icon:

Control unit
other interconnections
r722

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/25


Automation and Drives

Example for Beginners


Wiring of an input for the infeed (e.g. input 7)
SIMOTION

The wiring must be made for both drives


Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/26


Automation and Drives

Example for Beginners


Reduce the device connection voltage
SIMOTION
For SIMOTION D demo kit:
Reduce the parameter 210 from 600 V to 345 V for single phase
Task connection
Must be carried out for both drives
SIMOTION - Basic
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/27


Automation and Drives

Example for Beginners


System cycle clocks
SIMOTION Set system cycle clocks
Right-click on the execution
system
Task
Ratio:
SIMOTION - Basic DP to LR to IPO = 1 : 1 : 1
Information Clock times:
3 ms : 3 ms : 3 ms
Program Note: The goal is to always have 1:1:1 as
Design setting.
Note: The ratio of IPO2 can be set if
Program necessary
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/28


Automation and Drives

Example for Beginners


Axis configuration Master axis
SIMOTION

Create a virtual master axis


Task

SIMOTION - Basic Positioning axis


Information

Program
Design

Program Rotary axis


Implementation Modulo
Cycle length (product length)
360

Virtual axis

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/29


Automation and Drives

Example for Beginners


Axis configuration - Conveyor belt
SIMOTION

Create a real
Task Conveyorbelt slave axis
SIMOTION - Basic
Information Following axis

Program
Design

Program
Implementation Rotary axis
Modulo
Cycle length (product length)
360

First axis of the


dual axis case,
nrated = 6000 rpm
Message frame type 105
DSC selected
Encoder and resolution
default values

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/30


Automation and Drives

Example for Beginners


Axis configuration - Ejector
SIMOTION

Create a real Ejector slave axis


Task

SIMOTION - Basic Following axis


Information

Program
Design

Program Linear axis


Implementation Modulo deselected

Second axis of the dual axis case,


nrated = 6000 rpm
Message frame type 105
DSC selected
Encoder and resolution
default values

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/31


Automation and Drives

Example for Beginners


Axis configuration - Parameterization
SIMOTION Homing parameterization (here
MasterAxis Conveyorbelt)
No modifications
Task
Conveyorbelt
SIMOTION - Basic Homing
Information Only zero mark
Control (position-)
Program
Speed-
Design precontrol activated
Kv=50 ; DSC activated
Program
Implementation
Ejector Position control parameterization
Homing (here Ejector)
Only zero mark
Control (position-)
Speed-
precontrol activated
Kv=50 ; DSC activated

Note: The parameterization in the masks is


made offline

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/32


Automation and Drives

Example for Beginners


Programming - I/O variables
SIMOTION

Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation
Add the I/O variables to the Symbol Browser
I/O symbol in the project tree
Definition of the I/O symbols
i_boProtDoor Protective door contact
i_boStartBelt Start conveyor belt
i_boEject Sensor detects bad part
Note: The input in the Symbol Browser is made offline.

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/33


Automation and Drives

Example for Beginners


Access to I/O in cyclical tasks
SIMOTION
Access to I/Os of the drives (e.g. onBoard inputs of the CU)
only when the drive components have also been ramped up
Task (after Power On)

SIMOTION - Basic Test in the program for valid accesses of the I/O variables
Information Must be made in all cyclical tasks
Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/34


Automation and Drives

Example for Beginners


Programming def_init (variable definition in ST)
SIMOTION Programming
Add ST program (source) def_init
Task Add VAR_GLOBAL and END_VAR
keywords
SIMOTION - Basic
PROGRAM init keyword
Information
Definition of the variables and
Program default values
Design
g_boProgEnd
Program g_boProtDoorOpen
Implementation
g_rVMasterAxis
g_rVMasterAxisOld
Function
g_iMode
Definition of unit-global variables in a source
Ensures the simple export of global variables and
avoids complicated cross-references
(connections or USES)
Retain variables and HMI variables should also be
declared in their own separate source

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/35


Automation and Drives

Example for Beginners


Programming def_init (variable initialization in ST)
SIMOTION Programming
Add PROGRAM init and
END_PROGRAM keywords
Task
Initialization of the variables for
SIMOTION - Basic STOP RUN transition
Information
g_boProgEnd
Program g_boProtDoorOpen
Design
g_rVMasterAxis
Program g_rVMasterAxisOld
Implementation
g_iMode
Save and compile

Function

The init program in the def_init source is used


to set the variables to their defined initial value
during the startup.
The init ST program must be assigned to the
startup task

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/36


Automation and Drives

Example for Beginners


Programming - Techfault Task (MCC)
SIMOTION Create tecfault MCC Chart.
Used for the error handling.
Generally, an empty program can also be used.
Task
In this case, the controller does not STOP, even
for errors.
SIMOTION - Basic
Information However, all alarms of one object (e.g. Ejector)
can also be acknowledged.
Program It is also possible to acknowledge a specific
Design alarm (e.g. 30002) of an object (here
Conveyorbelt).
Program
Implementation Note: During commissioning and troubleshooting, it is advisable to directly acknowledge as few
alarms as possible. Such alarms often provide useful information about the cause of a
malfunction.
Warning: When a Techfault task is used, the user assumes the responsibility for the error handling.

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/37


Automation and Drives

Example for Beginners


Programming Monitoring Motion Tasks
SIMOTION
Basic procedure

Task When a program (MCC,


ST, LAD/FBD) is created, it
SIMOTION - Basic is also possible to
Information parameterize whether
the program monitors
Program and can operate in
Design single-step mode (MCC).
The appropriate
Program checkboxes are located in
Implementation the Compiler tab.
This setting can be made
later in the Properties
dialog box of the
program.

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/38


Automation and Drives

Example for Beginners


Programming Connection with another source (unit)
SIMOTION
Basic procedure

Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation When variables from the def_init source are used in another program, they
must be connected to this program.
Establish connection with the source (unit) def_init, Connections tab
MCC: in the Start node (button)
LAD/FBD: program button

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/39


Automation and Drives

Example for Beginners


Programming - Background Task (FUP)
SIMOTION Add bckFUP LAD/FBD plan.
The setup program and the automatic operation are
started depending on the contents of the g_iMode
Task variable

SIMOTION - Basic g_iMode = 0 : Setup


Information g_iMode = 1 : Automatic operation

Program This occurs only when:


Design The protective door is closed

Program MotionTask_1 or Motiontask_2 is


Implementation Stopped (performed),
Waiting and has been suspended (emergency
stop)
Suspended (emergency stop)

Note: If necessary, switch


between LAD and FBD

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/40


Automation and Drives

Example for Beginners


Programming Background Task (FBD)
SIMOTION

Task Network 1: Jump to the end if the drives


have not yet been ramped up
SIMOTION - Basic (no access possible to I/Os from Sinamics)
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/41


Automation and Drives

Example for Beginners


Programming - Background Task (FBD)
SIMOTION
Create local variables

bTaskState : Status of
Task MotionTask_1 or
MotionTask_2
SIMOTION - Basic bRetStart : Return value of
Information the _startTaskID function
Program boResult : Result bit of the
Design FBD networks
bResAnd : Result of the
Program Label in NW9 Taskstatus evaluation
Implementation
boGo: Task start bit (TRUE
if MotionTask_1 or
MotionTask_2 must be
restarted)
sTaskSel : Structure that
Network 2: Query protective door contact
can contain TaskIDs (e.g.
No new tasks will be started if the protective MotionTask_1 or
door is open MotionTask_2)

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/42


Automation and Drives

Example for Beginners


Programming - Background Task (FBD)
SIMOTION

Network 3 and network 4:


Task
Depending on the g_iMode
SIMOTION - Basic variable (operating mode, 0:
Information homing, 1: automatic), the
sTaskSel variable will be
Program assigned the value
Design MotionTask_1 or
MotionTask_2, respectively.
Program Add with
empty box The task stored in the
Implementation
sTaskSel variable can be
started in network 9.

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/43


Automation and Drives

Example for Beginners


Programming - Background Task (FBD)
SIMOTION Network 5:
The status of a task can be queried in
FBD using the
Task _GetStateOfTaskId
system function from the Command
Library tab (built-in compiler
SIMOTION - Basic functions) and so is always unique
Information and consistent (advantage compared
Add with with locking using bits).
Program empty box
Design The function return value is a
DWORD (bTaskState) that can be
processed bitwise.
Program
Implementation The sTaskSel variable contains the
task whose status is to be queried.

Network 6:
By performing a bitwise logical operation with 16#0022 (corresponds to 2#0000
0000 xx1x xx1x) on the return value. Also refer to Task States ST-documentation.

Task stopped Task suspended


It can be decided whether the task needs to be restarted. This is the case when the
return value (bResAnd) after the logical operation is larger than 16#0000.

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/44


Automation and Drives

Example for Beginners


Programming - Background Task (FBD)
SIMOTION Network 7:

The result of the bit AND logical


Task operation is evaluated in this
network.
SIMOTION - Basic
Information If the return value is larger than
16#0000, the associated task
must be restarted (boGo = TRUE).
Program
Design

Program
Implementation
Jump label Network 8:
(label is
created in If the return value matches
NW9) 16#0000, boGo becomes FALSE.
This bypasses restarting the task.
Jump label is end (network 9)

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/45


Automation and Drives

Example for Beginners


Programming - Background Task (FBD)
SIMOTION

Network 9:
Task
This network becomes active as
SIMOTION - Basic soon as a task needs to be
Information restarted.
This system function is called
Program _restartTaskID. The result of the
Design function call is stored in
bRetStart.
Program
Network 10:
Implementation
Network 10 is the end jump label
when no task needs to be started.
Jump label on/off

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/46


Automation and Drives

Example for Beginners


Programming - Background Task (FBD)
SIMOTION

Task The status of the FBD program


can be monitored in this
SIMOTION - Basic snapshot (monitor online).
Information Network 1: The protective door
is closed.
Program Current value Network 2 and 3: The operating
Design at runtime mode is automatic (g_iMode =
1). Consequently, Motiontask_3
Program is stored in the sTaskSel variable.
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/47


Automation and Drives

Example for Beginners


Output cam configuration at the ejector valve
SIMOTION Note: Output cams
are stored in the
Nocken subdirectory
under the directory of
Task the associated axis.
Here Ejector.
SIMOTION - Basic Note: The 298.0
Information output does not need
to be stored in I/O
Program Browser.
Design

Program
Implementation

Valve output cam


Output cam type Position-based output cam
(related to Ejector)
Output cam cycle clock Interpolator
Type of the output
cam value Setpoints
Fast output cams Yes
Active output Yes
Logical HW address 298.0
SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/48
Automation and Drives

Example for Beginners


Programming Homing (Motion Task 2 MCC) 1/2
SIMOTION Add Homing MCC chart
Declare ret_resetAxis local variable in
the start button (VAR variable type,
Task
DINT data type)
SIMOTION - Basic Connect with def_init
Information
Reset axes in the ST zoom (after
Program emergency stop):
Design ret_resetAxis := _resetAxis (Axis
:= MasterAxis);
Program
Implementation ret_resetAxis := _resetAxis (Axis
:= Conveyorbelt);
ret_resetAxis := _resetAxis (Axis
:= Ejector);
Alternatively, the axis enable can also
be removed and reapplied.
Set g_boProtDoorOpen to false
Set g_rvMasterAxisOld to 0

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/49


Automation and Drives

Example for Beginners


Programming Homing (Motion Task 2 MCC) 2/2
SIMOTION

Homing

Task Zeros on the MasterAxis


Enable Conveyorbelt
SIMOTION - Basic
Information Enable Ejector

Program Deactivate Valve output cam


Design
Active homing conveyor belt
Program The initialization values can be retained
Implementation
Active homing ejector
The initialization values can be retained
Optionally, an initial position motion can also
be connected here
Set g_iMode variable to 1

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/50


Automation and Drives

Example for Beginners


Programming Assignment to the execution system
SIMOTION
Open execution system with a double-
click
Task Use the arrow buttons to assign
previously created programs to the
SIMOTION - Basic execution levels
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/51


Automation and Drives

Example for Beginners


Programming First test
SIMOTION

Task

SIMOTION - Basic
Open the Homing program (SCOUT must be online)
Information
and start monitoring
Program Switch SIMOTION D435 to RUN
Design Both axes perform homing movements

Program Optionally, the program can also be run in single-step


Implementation mode
The axes are homed after passage through the
program

Note for the execution:


The bckFUP program in the background task starts the automatic
operation as soon as the g_iMode variable is set to 1.
Note: There are additional comments on the FAQ slide

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/52


Automation and Drives

Example for Beginners


Programming Automatic operation (Motiontask 3 in MCC)
SIMOTION Add Auto MCC chart
Connect with def_init

Task Enable MasterAxis


The conveyor belt starts with the positive edge of
SIMOTION - Basic the i_boStartBelt signal
Information
Synchronize the conveyor belt
Program See parameterization (following slides)
Design Activate the Valve output cam
Program See parameterization (following slides)
Implementation If the set velocity changes, advance
g_rvMasterAxis <> g_rvMasterAxisOld
Start master axis position-controlled with
g_rvMasterAxis velocity
For comparison, save the current velocity in
g_rvMasterAxisOld := g_rvMasterAxis
Until-loop with g_boProgEnd condition

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/53


Automation and Drives

Example for Beginners


Parameterization - Automatic (MCC)
SIMOTION Switch on the gearbox
synchronism of the
Conveyorbelt
Task Synchronize immediately
Synchronization length 1
SIMOTION - Basic
Synchronization reference
Information master axis
Program Relative to the start
position (Parameters tab)
Design

Program
Implementation

Activate the Valve output cam


Switch-on position
0.1 mm
Switch-off position
0.4 mm

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/54


Automation and Drives

Example for Beginners


Programming Second test
SIMOTION The Auto program must now also be assigned
to the execution system
As previously, the monitoring is now activated
Task Operation:
Once the axes have been homed, the
SIMOTION - Basic Conveyorbelt starts to turn as soon as a
Information positive edge of i_boStartBelt is detected

Program
Design

Program
Implementation

The g_rvMasterAxis set velocity


can be controlled in the Symbol
Browser (control immediately)
The automatic program responds
only to a change to the set
velocity

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/55


Automation and Drives

Example for Beginners


Programming Test using trace
SIMOTION
Open the trace

Task Variables from the


program and from
SIMOTION - Basic technological objects (e.g.
Information axes) can be recorded in
the trace
Program
Design Procedure:
Program Select variables
Implementation
Load trace into the D435
Start D435
Start trace
i_boStartBelt from 0 to 1

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/56


Automation and Drives

Example for Beginners


Cam Form (with CAM Tool)
SIMOTION

Task

SIMOTION - Basic Cam_Ejector cam


Information 3 Elements
1 interpolation point
Program left
Design 1 straight line at 45
1 interpolation point
Program right
Implementation Function of the
segments
Segment 1:
Synchronize to the
conveyor belt
Segment 2:
Synchronous operation
with conveyor belt
Segment 3:
Desynchronize and
return to the initial
Segment 2 position (wait for the
next defective part)

Segment 1 Segment 3 Note: CAM Tool must be installed.

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/57


Automation and Drives

Example for Beginners


Cam - Parameterization
SIMOTION
Curve elements (straight line,
interpolation point) are selected in
the CAMtool function bar.
Task
Properties (right mouse click on the
SIMOTION - Basic curve element)
Information Straight line
x1, y1 0.1
Program x2, y2 0.4
Design Interpolation point left (create with
symbol)
Program x, y 0.0
Implementation
Interpolation point right (create with
symbol)
x 0.8
y 0.0
Scaling (Cam - Target Device
Parameter menu)
Master
Base scaling 360
Slave
Base scaling 10
Note: The mouse pointer must be active in order to
move curve elements with the mouse. A decimal
point must be used for floating point numbers.
SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/58
Automation and Drives

Example for Beginners


Programming Eject by cam
SIMOTION

Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation
Add Eject MCC chart
Synchronize the cam
This motion task is started with
a user interrupt
The cam is processed
acyclically

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/59


Automation and Drives

Example for Beginners


Programming Stock outage detection (user interrupt in MCC)
SIMOTION

Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

Stock outage detection


Add program pEject
Specify condition for user interrupt in the execution
system
Sensor at I299.2 (i_boEject) at TRUE means eject
is coming (the right-hand red pushbutton on the
D435 test rack)

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/60


Automation and Drives

Example for Beginners


Programming Protective door (IPO synchronous in MCC) 1/2
SIMOTION
Monitoring the protective door
Add ProtDoor MCC chart
Task Connect with def_init
SIMOTION - Basic Query whether protective door closed
Information (True = closed)
If open, set g_boProtDoorOpen bit,
Program
because axes must be explicitly reset
Design
after an emergency stop (see
automatic operation (Motion Task 3
Program
in MCC) 1/2)
Implementation
Query all Motion Tasks using
_GetStateOfTask (Motiontask_x) <>
16#0002 (where x= 1 to 3) (test
whether task stopped)
All running tasks will be interrupted

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/61


Automation and Drives

Example for Beginners


Programming - Protective door (IPO synchronous in MCC) 2/2
SIMOTION
Monitoring the protective door
Query the axes for stoppage using
Task MasterAxis.motionstatedata.mo
tionstate <> standstill
SIMOTION - Basic
Information Conveyorbelt.motionstatedata.
motionstate <> standstill
Program Ejector.motionstatedata.motion
Design state <> standstill
Program
Implementation

If the axes are moving


Deactivate Valve output cam
Stop axes using Fast stop with
maximum deceleration

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/62


Automation and Drives

Example for Beginners


Programming - Test and diagnosis - Possibilities
SIMOTION Test the program execution
Create a Watchtable variable table.
The variable can be moved with a
Task right click in the Symbol Browser.

SIMOTION - Basic
Information Recording object variables such as
actual position and actual velocity
Program of an axis using Trace
Design

Program
Implementation

Test the program execution of a


Motion Task using Monitor and
Single Step

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/63


Automation and Drives

Example for Beginners


FAQ
SIMOTION After STOPRUN transition nothing moves, what is the problem?
Have the tasks been correctly added to the execution system?
Is the protective door (PI299.0) closed?
Task
The extractor output cam does not come!
SIMOTION - Basic An output cam must be activated. Are the limits correctly parameterized in the Switch
Information on SW output cam mask ?
The homing task hangs on the axis enable of the real axes. Why is this?
Program
Design The axis enable does not arrive. Possible causes:
Message frame type incorrectly set (SINAMICS and SIMOTION to 105).
Program
Implementation Bus terminating resistances not set correctly (at ON rather than at OFF bus end
points).
In the HW configuration, the Master application cycle in the slave properties does
not agree with the position control cycle in the SCOUT under Execution system
Expert settings. They must be identical!
The axes homing is not correct. What can be the error cause?
Check the settings in the Homing Axes mask

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/64


Automation and Drives

Example for Beginners


ProTool/Pro Connection
SIMOTION

Task Connectable variables:


System variables
SIMOTION - Basic Technology objects
Information
SIMOTION device
Prerequisite :
Program
ProTool in STEP7
Design
integrated installed!
Program HMI (ProTool) D435 Global user variables
Implementation
I/O variables

Device-global variables

Unit variables
PROFIBUS DP

Data exchange example needs a


display resolution
of 1280 x1024

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/65


Automation and Drives

Example for Beginners


Add pHMIaus" ST source
SIMOTION

Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/66


Automation and Drives

Example for Beginners


pHMIaus" ST source in background task
SIMOTION

Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/67


Automation and Drives

Example for Beginners


ProTool/Pro connection (project) 1/2
SIMOTION

Create a new ProTool/Pro


Task configuration with ProTool/Pro CS
Close SIMOTION SCOUT
SIMOTION - Basic
Information Open ProTool/Pro CS
Project Integrate in Step7-Proj
Program
Design Select the source SIMOTION project
(example on CD)
Program Here: PRO__00
Implementation
Include in the introductory project

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/68


Automation and Drives

Example for Beginners


ProTool/Pro connection (project) 2/2
SIMOTION

Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

Under Parameters ...


Configuration of the network connection
Here Ethernet
Restore the symbols

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/69


Automation and Drives

Example for Beginners


ProTool/Pro connection (compile, generate, start RunTime)
SIMOTION

Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

Compile project and regenerate


Start ProTool RunTime

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/70


Automation and Drives

Example for Beginners


ProTool/Pro connection (picture)
SIMOTION

Task

SIMOTION - Basic
Information

Program
Design

Program
Implementation

SIEMENS AG 2009 Issued: 05/2009 Siemens I IA DT MC SIMOTION_EXAMPLE_FOR_BEGINNERS_D435.PPT/71

You might also like