0% found this document useful (0 votes)
5 views

04+Introduction+to+Programming+with+MCC+en

Uploaded by

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

04+Introduction+to+Programming+with+MCC+en

Uploaded by

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

IA

D
The unit concept in SIMOTION
IN
Programming languages in SIMOTION ................................................................................................
...........................................................................................
3
4
N
Programming with motion control chart MCC ................................................................................ 5
Creating or opening the MCC units in the PROGRAMS folder................................................................ 6
Compiler settings for MCC units ...................................................................................... 7
AI

Inserting MCC units in subfolders ........................................................................................... 8


Creating or opening an MCC program ............................................................................................ 9
Programming MCC commands ................................................................................................. 10
Position axis – Parameterizing an MCC command ................................................................. 11
Settings regarding the dynamics of an MCC command ........................................................................ 12
TR

Sequential and cyclic programming .................................................................................... 13


Wait commands in motion tasks ........................................................................................................... 14
Wait for condition ........................................................................................................................ 15
The micro languages LAD/FBD and Formula ...................................................................................... 16
Setting and resetting ................................................................................................................... 17
Assigning variables ................................................................................................................... 18
The SIMOTION variable model ............................................................................................... 19
SI

Device-specific and TO-specific system variables................................................................................... 20


I/Os and global device user variables ........................................................................................ 21
Access to I/Os and process images ....................................................................................... 22
Assigning I/Os in the address list ........................................................................................................ 23
Global variables in units ................................................................................................. 24
Local program variables and parameters ...................................................................................... 25
Elementary data types for SIMOTION ............................................................................................ 26
Character strings (STRING) in MCC ..................................................................................................... 27
Arrays (ARRAY) in MCC .................................................................................................................. 28

SITRAIN Page Course MC-SMO-PM


Training documentation 4-1 Introduction to programming with MCC
Local I/O variables for process image access ................................................................................. 29
Creating structures in MCC ........................................................................................................... 30
Defining enumerations in MCC ....................................................................................................... 31
Connections to other MCC and LAD/FBD units, ST units, and libraries ............................. 32
Making programs modular .................................................................................................... 33
Operations using the ST zoom function ............................................................................................. 34
Inserting system function calls in MC charts ................................................................................ 35
Task handling operations in MCC ........................................................................................... 36
IF, CASE, and GOTO branches ......................................................................................... 37
Iterations with FOR, WHILE, and REPEAT .............................................................................. 38

IA
MCC synchronous start ................................................................................................................. 39
Compiling created MCC charts ..................................................................................................... 40
Assigning created programs to a task ........................................................................................ 41
Compile a project and downloading ......................................................................................... 42
Download individual sources .............................................................................................................

D
43
The "Monitor" test function ......................................................................................................... 44
Monitoring variables using the symbol browser ........................................................................... 45
Monitoring I/Os via the address list ........................................................................................ 46
Monitoring variables in watch tables
Operations with lists (watch tables, …)

IN
............................................................................................
.....................................................................................
Reference data: Cross-references (1)..................................................................................................... 49
Reference data: Cross-references (2)..................................................................................................... 50
Reference data: Program structure and code attributes.......................................................................
Finding/replacing variables in the project................................................................................................. 52
47
48

51
N
Exercise 4.1: Write an empty program for the PeripheralFaultTask ................................................. 53
Exercise 4.1: Establish an online connection, load the project, and test the operating changeover..... 54
Exercise 4.2: Creating a program for traversing axes ............................................................. 55
Exercise 4.2: Establish an online connection and load the project............................................................. 56
AI

Exercise 4.3: Expand the program with a program loop counter ........................................................ 57
Exercise 4.4: The "Test_LEDs" program .......................................................................................... 58
If you want to know more ................................................................................................. 59
Downloading a program during run .................................................................................................... 60
Downloading individual sources ......................................................................................................... 61
TR

Downloading additional data .............................................................................................................. 62


Project offline/online comparison ................................................................................................. 63
User interface of the project comparison.....................................................................................................64
Starting a detailed comparison for individual objects ......................................................................... 65
Result of the detailed comparison (1)..................................................................................................... 66
Result of the detailed comparison (2)..................................................................................................... 67
SI

Transferring data for an object comparison............................................................................................ 68


Using breakpoints in MCC – Overview ....................................................................................... 69
Breakpoints in MCC – Selecting the debug mode ............................................................................... 70
Breakpoints in MCC – Defining the "debug task group" ................................................................... 71
Breakpoints in MCC – Setting breakpoints ........................................................................................ 72
Breakpoints in MCC – Defining a call path ....................................................................................... 73
Breakpoints in MCC – Activating breakpoints .................................................................................... 74
Stopping program execution – Tracking variables ............................................................................ 75

SITRAIN Page Course MC-SMO-PM


Training documentation 4-2 Introduction to programming with MCC
IA
D
Overview
IN
SIEMENS offers a range of task-oriented programming languages for
SIMOTION that allow the user to focus on the actual task at hand.
N
SIMOTION's modular design makes it possible to create modular blocks in
different languages.

MCC MCC is a graphical language for creating operational sequences. In particular,


AI

this language offers entry-level users support with quick and transparent
creation of program sequences in MotionTasks.

LAD/FBD These programming languages are unparalleled for programming binary signal
logic operations. In addition to the wide range of options in the area of binary
TR

signal logic operation (edge evaluation, flip-flops, etc.), many other functions
such as IEC-compliant counter and timer blocks are integrated. Almost all
system functions can be directly called and tested in a network.

ST Structured Text is a text-based, high-level language similar to PASCAL. ST


contains all typical elements of a high-level language, such as operators,
expressions, control statements, etc. ST supports, in particular, programming of
mathematical algorithms and data administration tasks.
SI

Due to the many control structures it offers, ST is also suitable for programming
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. At the moment, programming with DCC is only possible in the STEP 7
environment with SCOUT Classic.

SITRAIN Page Course MC-SMO-PM


Training documentation 4-3 Introduction to programming with MCC
IA
D
Unit concept
IN
SIMOTION SCOUT supports the concept of units for programming in the MCC,
LAD/FBD and ST languages. A unit is used as a container for the modules it
N
contains (programs, functions, or function blocks). This concept allows you to
clearly structure a large collection of individual modules. The unit concept
therefore permits better structuring of the complete user program in logical
units.
AI

Before programs, functions, and function blocks can be created in a


programming language, a unit must first be created in that language. Programs,
functions, and function blocks can then be added to this unit.

Modular machines With the help of units, the concept for "modular machines" is also better
supported. Machines are usually put together out of individual machine
TR

modules. To control a module, several programs, FC and FBs, are usually


required. Using the unit concept, these modules are then stored in a unit
alongside the required data. If the same module is used again with a different
machine, the entire unit including all blocks variables, etc. can be copied into the
project for the new machine, for example, by copy and paste.

Know-how protection Further, units can be protected against unauthorized access (shortcut menu ->
Know-how protection). Then, a password must be entered to open or view the
SI

protected units and the blocks contained in them.


Compiling and
downloading Units are also the smallest unit that can be compiled as a whole and loaded into
a SIMOTION controller.

SITRAIN Page Course MC-SMO-PM


Training documentation 4-4 Introduction to programming with MCC
IA
D
Motion control
chart (MCC)
IN
MCC is a new graphical programming language that greatly simplifies the
N
automation of production machines. Production machines are often extremely
complex and their control systems must be able to handle control of motion
sequences and technologies with very diverse motion functions in addition to bit
logic, arithmetic functions, and data management tasks. MCC is the neutral
AI

description tool used to represent a sequence chart. This sequence chart is


called an MCC chart. Together with motion tasks, all the necessary description
symbols are provided to quickly and efficiently describe and provide a solution
to an automation task. MCC also offers a wide range of tools for structuring
large-scale automation jobs. MCC charts can be used to create programs,
function blocks or functions conforming to IEC 61131-3.
TR

Embedding in
SIMOTION SCOUT The individual components of the MCC programming environment are easy and
convenient to use. They are fully integrated into the SCOUT Workbench.
• Project navigator: The project navigator displays the project structure. It also
provides an overview of all programs that have been created. The project
navigator can be used for example to create new MCC charts.
• Work area: The MCC editor displays the charts and associated parameter
screens in the work area. The MCC program elements can be inserted from
SI

the tool list into the MCC chart for creation of program sequences.
• The top part of the editor contains a window for declaration of the local
variables.
• Detail view: Variables, alarms, error messages, etc. are displayed in this
window. The display depends on the element selected in the project
navigator.

SITRAIN Page Course MC-SMO-PM


Training documentation 4-5 Introduction to programming with MCC
IA
D
MCC units
IN
SIMOTION SCOUT supports the concept of MMC units when programming with
MCC charts. An MCC unit is a container for the MCC charts. This MCC unit
N
concept allows you to clearly structure a large collection of individual MCC
charts.
On the other hand, within MCC units, global unit variables can be created.
These unit variables are roughly comparable with the data blocks in a
AI

SIMATIC S7.
Further, MCC units can be protected against unauthorized access (shortcut
menu -> Know-how protection). Then, a password must be entered to open or
view the protected MCC units and the MCC charts contained in them.
TR

Insert MCC unit You can insert a new MCC unit in the following ways:
• In the project navigator: In the "PROGRAMS" folder, via the Insert MCC unit
element.
• Via the menu Paste -> Program -> Insert MCC unit
• Via the shortcut menu Insert new object -> MCC unit
• Via the "MCC unit" toolbar with the "Insert MCC unit" icon.
SI

Defining the name The name of the MCC unit is defined in the "Name" entry field. The name can
be up to 128 characters long. Further, names must comply with the rules for
identifiers of the ST language:
• Names comprise letters (A to Z, a to z), numbers (0 to 9), or individual
underscores (_) in any sequence.
• The first character must be a letter or underscore.
• No distinction is made between upper case and lower case.

SITRAIN Page Course MC-SMO-PM


Training documentation 4-6 Introduction to programming with MCC
IA
D
Settings
IN
Under the "Compiler" tab the following can be defined:
• Use global settings: The settings, selected underthe menu command:
N
Options -> Settings-> Compiler apply:
• Selective linking: Unused code is removed from units that are loaded
in the target system. (This should always be selected.)
• Use preprocessor: Preprocessor is used. Properties of the preprocessor is
AI

handled in the SIMOTION programming course.


• Enable program status: This setting must be selected for subsequently
monitoring variables using the block status.
• Permit language extensions Language elements are permissible that do not
conform to IEC 61131-3, especially a user-friendly access in conformance
TR

with STEP 7 to individual bits in a BYTE, WORD, and DWORD is possible.


• Creating programming instances only once: The static variables of a
program are only stored once in the user memory of the unit.
• Permit language extensions after the 3rd IEC edition and object-oriented
programming: Some language elements can be used in accordance with
IEC 61131-3 3rd edition. Moreover, classes and interfaces in accordance
with IEC can be used.
SI

• Issue warnings: In addition to error messages, the compiler can output


warnings. You can set the scope of the warning messages to be output.
• Permit single step: Check this option if you want to test sequential
execution in single-step mode later on. Progressing to the next command in
an MCC program can then be controlled from SCOUT.
• Enable tracer: This makes it possible to monitor the program sequence in
cyclically executed program branches.
• Permit OPC/XML: Symbol information of the unit variables in the interface
section of the MCC unit is loaded into the SIMOTION device.

SITRAIN Page Course MC-SMO-PM


Training documentation 4-7 Introduction to programming with MCC
IA
D
Subfolders in
The project
IN
In SCOUT subfolders can be inserted under all main folders of the CPU. The
N
number of folders is not limited. These folders serve to further structure the
entire project. The idea of a modular machine concept therefore receives further
support.
For example, all STs and LAD/FBD and ST units required to control a machine
AI

module can now be accommodated in one subfolder with its own name. This
subfolder can be copied to the clipboard or exported via "XML- Export" and
inserted or imported into another project in which the same machine module is
used.
A subfolder could also be inserted into the TO folder axes to accommodate all
TO axes required to control the machine module.
TR

Subfolders only offer structuring capabilities; they have effect on naming. This
means that the name assigned to all objects in the main folder must be unique.
For example, the axis name "Axis_1" or the unit name "Source_1" can only exist
once in the "AXES" folder or "PROGRAMS" folder.

Libraries Subfolders are also possible in a library and in the monitor for the watch tables.
Note that different libraries cannot be combined in one folder. Subfolders are
SI

only permitted within a library.

SITRAIN Page Course MC-SMO-PM


Training documentation 4-8 Introduction to programming with MCC
IA
D
Inserting an
MCC Chart
IN
There are several ways to insert a new MCC chart:
N
• In the project navigator: In the "PROGRAMS" folder, via the element
"Insert MCC chart"
• from the menu command: Insert -> Program -> MCC Chart
• Via the command in the shortcut menu: Insert new object -> MCC Chart
AI

• Via the toolbar of the MCC editor: "Insert MCC Chart"


After an MCC chart is inserted, the Properties dialog box opens where settings
can be made.
TR

Settings The following settings can be made under the "General" tab:
• Name: Enter the name of the program or function block or function to be
created (within the surrounding unit) here. This name can be up to
25 characters long.
• Creation type: Here you can select whether the created MCC chart will
describe a program, function block, or function.
• Exportable: If the check box is activated, an MCC chart can be called from
other program sources (e.g. MCC units, ST source files) in the same way as,
SI

for example, a function or a function block.


• A program can only be assigned to a task when the check box is selected.
• If the check box is not selected, this MCC chart can only be called by blocks
of the associated MCC unit.

SITRAIN Page Course MC-SMO-PM


Training documentation 4-9 Introduction to programming with MCC
IA
D
Programming
sequences
IN
Each newly created MCC chart already contains a starting node and an end
N
node. Commands and statements are inserted in between. The commands you
program are executed from the starting node in the direction of the end node.

Toolbar All commands are sorted into command groups and are available on a toolbar.
AI

The toolbar contains four command groups:


• General commands: General commands for setting and resetting variables
as well as commands for controlling tasks, implementing control structures
such as branches (IF ... THEN, etc.), repeats (REPEAT ... UNTIL, etc.) is,
wait conditions (WAIT ... FOR, etc.), etc.
TR

• Single-axis commands: This group especially includes the commands for


open-loop and closed-control of axes as well as commands for axis enable,
for referencing etc. Another group also includes commands for programming
external encoders, measuring inputs and output cams.
• Gearing and camming commands: This group contains all commands for
synchronizing/desynchronizing the gearing and camming.

Inserting a command You can insert a command in an MCC chart from a command group as follows:
SI

1. First select the position in the MCC chart where you want to insert the
command.
2. Click the command you want to execute on the toolbar. It is automatically
inserted at the selected position.
Double-clicking a command in the sequence chart opens further command-
specific dialog boxes. You can define the associated command parameters in
these dialog boxes.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 10 Introduction to programming with MCC
IA
D
General syntax
IN
The "axis" (mandatory parameter) that is to be moved or stopped must always
be specified in the upper part. The center section contains different input fields
N
and selection boxes relating to the axis motion or stop commands.
To ensure better clarity, this part contains several entry fields. Only the 1st entry
field, i.e. the "position", must be specified to obtain an executable command. All
other entry fields such as the "Dynamic response" and "Expert" tab are optional
AI

and are available for special settings (e.g.: acceleration, velocity profile, etc.).
The end position of a traversing motion is defined in the middle entry field.
The exact interpretation of the "Position" parameters depends on the "Type"
parameter.
If you select "Absolute" as type, the position is interpreted as an absolute
TR

position. The programmed position value marks the end position of the motion.
If "relative" is set, the position is interpreted as a traverse path of the movement,
starting at the current axis position.
The traversing direction for a relative motion can be set in "Direction". Modulo
axes can be set to "Shortest path" in addition to the directions "Positive" and
"Negative".
The lower half of the box contains the settings for the transitional behavior from
the preceding command and the step enabling condition for the next command.
SI

"Delay program
execution" This check box determines when the next command will be executed. MCC is
optimized for sequential programming; therefore, the default setting for this
check box is "active". Otherwise the next command in the sequencer is
executed immediately.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 11 Introduction to programming with MCC
IA
D
Velocity profile
IN
The velocity profile is used to specify the transitions between the individual
motion phases. The velocity profile influences the start and end of the
N
acceleration phase, the transition to the constant acceleration or constant
velocity phase.
The velocity profile also influences the motion transitions at the start and end of
the deceleration phase to the constant acceleration or constant velocity phase.
AI

The following velocity profiles can be selected:


• Trapezoidal: For the motion command, a trapezoidal velocity profile is
effective. Only the acceleration and deceleration can be programmed.
• Smooth: The velocity profile with smooth acceleration characteristic is in
effect for the command. The acceleration and deceleration change (jerk)
TR

can be specified.

Note If the value "Default" is selected in the appropriate entry fields, a reference is
made to the settings in the "Default" screen form of the associated axis TOs.
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 12 Introduction to programming with MCC
IA
D
Sequential
programming
IN
With sequential programming, the entire program is separated into individual
N
steps with the associated function calls. When one command will switch to the
next is defined in the dialog boxes for the individual commands.
If the next command is only enabled when the task has been completed, this is
referred to as sequential programming or synchronous function calls. The
AI

program execution – i.e. the execution of the function calls – runs in


synchronism with the process. The commands in MCC chart mirror the
individual phases of the process sequence.
This type of program creation corresponds to programming of sequencers in
PLCs. This type of programming offers significant benefits over conventional
cyclic programming, in particular, for process sequences where the entire
TR

process can be divided into individual phases (sub-movements).


It is easier and much quicker to create and debug a "synchronous" program
because the "process control" can be implemented directly in the associated
control program.
In SIMOTION, programming sequential program flows is linked to tasks that are
not executed cyclically. SIMOTION supports this programming concept,
especially by providing so-called MotionTasks.
SI

Cyclic
programming Cyclic programming corresponds to conventional program creation in PLCs. In
this case function calls are performed asynchronously. After the function call is
issued, the program advances to the next command without waiting for the job
to be completed. It is then necessary to query the status of the command in the
following program section run The next task can be started upon termination of
the current one.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 13 Introduction to programming with MCC
IA
D
Wait time
IN
This command is for stopping program execution for a defined period of time.
The wait time can be entered as a value or as a variable of type TIME.
N
Granularity is 1 ms. The precision depends on the task level in which the
command is executed.
If the wait time is 0, this means there is no wait time. The operating system will
however trigger a task change. For cyclic tasks, e.g. the BackgroundTask or a
AI

TimerInterruptTask, the time monitoring is applied, which is the reason why


longer wait times can result in time monitoring errors (time out).

Wait for axis This command can stop execution of a motion task until the specified axis has
reached the programmed axis status or axis position. The axis status or axis
position refers to the total movement of the axis.
TR

If the event occurs, the priority of the motion task is temporarily raised. The
commands that are located within the grayed out area under the wait command
are started with the next IPO cycle and processed with the highest priority. After
execution of the commands in the grayed out area, the priority of the motion
task is reset.

Wait for signal With this command, execution of a motion task is stopped until the selected
SI

signal reaches the defined state or the state has changed.


If the event occurs, the priority of the motion task is temporarily raised. The
commands that are located within the grayed out area under the wait command
are started with the next IPO cycle and executed with higher priority. After
execution of the commands in the grayed out area, the priority of the motion
task is reset.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 14 Introduction to programming with MCC
IA
D
Wait for condition
IN
This command is used to stop execution of a motion task until the programmed
condition is met. If the condition is fulfilled, the priority of the motion task is
N
temporarily raised. The commands within the shaded area under the wait
command are started in the next IPO cycle clock and executed with the highest
priority.
Once the commands in the shaded area have been executed, the priority of the
AI

motion task is reset.

Condition The condition can be programmed in one of the programming languages:


ladder diagram (LAD), function block diagram (FBD), or formula (ST).
The programmed condition can be made up of:
TR

• Global variables of the same MCC chart


• Global device variables
• Constants
• I/O variables and process image accesses (inputs)
• Operators
• The expression may not contain:
• Function calls
SI

• Local variables or variables imported from other MCC charts


• Loops

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 15 Introduction to programming with MCC
IA
D
LAD/FBD/Formula
IN
In the dialog boxes, you can select from the micro languages LAD/FBD/Formula
for the following MCC commands:
N
• Variable assignment
• Wait for condition
• IF statement
AI

• WHILE statement
• UNTIL statement
• Synchronous start

Editing The buttons can be used to create the desired functions in ladder diagram
TR

(LAD), function block diagram (FBD) or formula format.


With logic operations that have already been created, you can change between
languages as long as the programmed function can be represented in that
particular language.
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 16 Introduction to programming with MCC
IA
D
Setting and
resetting
IN
Using the commands for setting and resetting, you can set outputs and
N
variables to the state "1" or "0".
These commands can be used for outputs and variables of data type BOOL, as
well as for data types BYTE (SINT,USINT), WORD (INT, UINT), and DWORD
(DINT, UDINT). In this case, each bit of the addressed output or variable is set
AI

to value "1" or "0".


TR
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 17 Introduction to programming with MCC
IA
D
Assignments
IN
You can use this command to assign values to user or system variables.
The assignment takes place when the command is executed in MCC chart.
N
A variable can be moved from the symbol browser to the entry field using
drag-and-drop. Multiple variables can be assigned. The assignment can be
programmed in one of following programming languages: ladder diagram (LAD),
function block diagram (FBD) or formula (ST).
AI

Interruptibility If the assignments are to take place without being interrupted by other tasks,
select the "Uninterruptible assignments" check box.
If you select this check box, UserInterrupt Task_1 must be created. If an error
occurs during execution, the execution system automatically calls
UserInterruptTask_1. You can program an error response in this task.
TR
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 18 Introduction to programming with MCC
IA
D
Variable model
IN
Variables are an important programming component. A distinction is made
between user variables and system variables in SIMOTION. User variables can
N
be defined by the user. System variables are provided by the system.
Variables are used to structure programs. They are wild cards in a program and
can assume values.
In SIMOTION a distinction is made between basically three types of variable
AI

groups:
• System variables
• Global user variables
• Local user variables
TR

Note You can also access system variables and global user variables from HMI
devices.
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 19 Introduction to programming with MCC
IA
D
System variables
IN
System variables are automatically supplied by the system or technology
objects; the user does not need to create them. A SIMOTION device and each
N
technology object has specific system variables that mirror the respective state
of the device or TO. The system variables can be accessed by all programs and
HMI devices in the SIMOTION device.
You can view the values of the system variables in the symbol browser. For this
AI

purpose, select the required device or the TO in the project navigator; the
variables of the device or TO are then displayed in the symbol browser (detail
view).

Global device
variables Global device user variables are created with the symbol browser. For this
TR

purpose, the "Global device variables" item must be selected in the project
window below the required SIMOTION device. In the symbol browser window,
the required variables can then be created with their name, data type, settings
for POWER OFF, and initial value.
These variables can be accessed from all sections of the user program. And
can be monitored and modified in the symbol browser in online mode. They can
also be accessed from HMI devices.
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 20 Introduction to programming with MCC
IA
D
I/O variables for
I/O access
IN
With I/O variables, inputs, and outputs, as well as process images can be
N
accessed. I/O variables can be assigned to the following areas:
• or "OUT" can be selected. In the Assignment column, the variable of the
SINAMICS_Integrated can be selected. With set auto. direct I/O variables:
Here, you need to specify the area identifier (PI: peripheral inputs, PQ:
AI

peripheral outputs), start address (byte address) and the length of the
variables (B: byte, W: word, D: double word) in the "I/O address" column
(e.g. PIW5, PQD3; PI4.5, etc.).
• Peripheral variables of SINAMICS_Integrated: To do this, in the
"I/O address" column, the entry "IN" automatic telegram configuration,
"Save and compile" automatically creates an appropriate telegram extension
TR

so that required information can be transferred from or to


SINAMICS_Integrated.
• IO variables in process images (BackgroundTask): I/O accesses can also be
performed using conventional PLC process images. A symbolic variable can
be assigned to the classic process image by specifying the area identifiers
%I (process image of inputs) and %Q process image of outputs) in the
column "I/O Address".
SI

• The process images of the BackgroundTask are automatically set up by the


system with a length of 64 bytes each. These process images can also be
accessed directly from the user program without symbolic variables by
absolute identifiers, such as %IB0, %Q4.1, etc.
• I/O variables in the user-defined process images: I/O variables can also be
created in user-defined process images.
• To do this, the I/O address (PIW4, PQB5, etc.) must be specified in the "I/O
Address" column, and the required cyclic task selected in the "Process
Image" column. The created I/O variable is then automatically updated in the
associated task cycle.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 21 Introduction to programming with MCC
IA
D
Direct I/O access
IN
With symbolic I/O variables, inputs and outputs can be accessed. In direct
access with I/O variables, the inputs and outputs are updated as follows:
N
• For the onboard I/O of the SIMOTION device, access is immediate, i.e. the
values are also updated immediately.
• For the central or distributed I/O, updates are performed in the position
controller cycle clock, i.e. the inputs are read before the position controller is
AI

called and the outputs are written to after the position controller is called.
During the StartupTask access is not possible to the I/O variables. In the RUN
operating state and in the ShutdownTask, I/O variables can be accessed
without restriction.
TR

I/O of the
SINAMICS_Integrated On accesses to the I/Os of the SINAMICS_Integrated or the CX32 modules, the
associated I/O variable is updated in the set position control cycles.

Access via
process images Process images are memory areas in the RAM of the SIMOTION device, onto
which a subset of the I/O address space is mapped.
The system automatically mirrors the first 64 bytes of the I/O address area to
SI

the process images of the BackgroundTask. With user-defined process images,


the 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 of the outputs is output to
the I/O. The process image is therefore consistent for the entire cycle of the
associated task.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 22 Introduction to programming with MCC
IA
D
Entering I/O variables
IN
I/O variables can be created by inserting a new line at the end of the address list
and filling in all fields manually. In the individual fields, a valid name, the
N
address of the I/O variables (direct or process image) and other information
(data type, strategy, replacement value, etc.) must be entered by the user.
As an alternative, an already existing line can be copied into the address list and
then the contents of the fields adapted.
AI

Assigning
I/O variables For I/O variables that originate from the SINAMICS_Integrated, for example, this
procedure is extremely tedious, as the user must also handle the necessary
extension of the telegram, the BICO interconnections and the correct calculation
and input of the I/O address.
With V4.2, this work is performed by the "Symbolic assignment" via SIMOTION
TR

SCOUT. Users create and interconnect I/O variables using an assignment


dialog box. The necessary telegram extensions and BICO interconnections are
then performed by SCOUT during "Saving and compiling".
As the user, proceed as follows:
1. In the "Name" column, enter a valid name for your I/O variable.
2. In the column "I/O address", select "IN" for an input or "OUT" for an output
variable.
SI

3. Click the 3 dots in the "Assignment" column to open the Assignment dialog
box.
4. In the assignment dialog box that opens, select the required variable and in
the "Assignment" column select "Assign".
5. Confirm the dialog box with "OK".
6. This assigns the I/O variable. At the next "Save and compile", the system
automatically performs the necessary extensions etc.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 23 Introduction to programming with MCC
IA
D
Unit variables
IN
Unit variables can be declared within a unit. The validity range (scope) of the
variable depends on the section of the declaration table in which the variable is
N
declared:
• If a variable is declared in the INTERFACE section of the declaration table,
this variable is valid throughout the entire MCC unit. All MCC charts
(programs, function blocks and functions) within the MCC unit can access it.
AI

In addition, blocks which are inserted in other MCC units can also access
these variables (global variables). INTERFACE variables are also available
on HMI devices, this means that an HMI device can also access these
variables. The total size of all unit variables in the interface section is limited
to 64 KB.
• If a variable is declared in the implementation section (IMPLEMENTATION)
TR

of the declaration table, this variable is only valid in the MCC unit. All MCC
charts (programs, function blocks and functions) within the MCC unit can
access these variables. Access from other MCC units or from HMI devices
to these variables is not possible.

Variable type The following variable types can be selected:


• VAR_GLOBAL: Program-global variable; is lost at power off
SI

• VAR_GLOBAL_RETAIN: Permanently saved global variables; are retained


after power failure.
• VAR_GLOBAL_CONSTANT: Global constants; cannot be changed from
the program.
If you want to access global variables of an MCC unit for an MCC chart from
another MCC unit; a link to the unit with the variable declaration must first be
defined in the other MCC unit ("Connection" tab).

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 24 Introduction to programming with MCC
IA
D
Program variables
IN
Local program variables and parameters can be created in the declaration part
of an MCC chart. These variables and parameters can only be accessed from
N
the statement part of this program. They cannot be accessed from other
programs.
The variables/parameters are defined with their name, variable type, data type
and – if applicable – initial value under the "Parameters/Variables" tab.
AI

Variable type The following variable types can be selected:


• VAR: Local variable (available in FB, FC, program).
• VAR_CONSTANT: Local variable; cannot be changed from the program
(available in FB, FC, program).
TR

• VAR_TEMP temporary variables (FB, program).


• VAR_INPUT input parameter; the value is supplied from the calling block
and can only be read in the MCC chart (FB, FC).
• VAR_OUTPUT output parameter; the value is returned to the caller by the
FB. Can be read by caller after FB call as instance variable (FB instance
name.variable name). Can also be read within the FB (FB only).
• VAR_IN_OUT input and output parameter; the FB uses this parameter to
SI

directly access (using a reference) the created variable.

Note Only the static variables of the local variables of an MCC chart can be
monitored and changed in the symbol browser.
In the symbol browser, it is not permissible to select the higher-level source, but
rather the "Execution system" entry. The appropriate task in the symbol browser
window is then taken to navigate to the program with the static variables.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 25 Introduction to programming with MCC
IA
D
Overview
IN
The data types of the declared variables and data types can be defined in the
"Data type" column. SIMOTION supports the following data type groups:
N
• Elementary data types
• Compound data types (arrays)
• User-defined data types (UDT: User Defined Data Type)
Elementary
AI

data types The elementary data types are the smallest elements of any programming
system. In SIMOTION, the elementary data types are predefined according to
IEC 61131-3. The data types have been selected to allow time stamp
management and high-precision motion control of axes in addition to the
conventional tasks of a PLC, which include digital and analog signal processing.
TR

BOOL, BYTE,
WORD, DWORD Variables of the BOOL data type consist of one bit, variables of data types
BYTE, WORD, DWORD are bit sequences of 8, 16, or 32 bits. The individual
bits are not processed in these data types.

SINT, INT, DINT ... Variables of these data types represent integers for performing calculations,
such as counting operations. SIMOTION supports both signed integers – such
as: SINT, INT, and DINT and the corresponding unsigned data types: USINT,
SI

UINT, and UDINT.

REAL, LREAL These are numeric data types with the corresponding number of 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.).

TIME, DATE, ... With these data types, time stamps can be managed in the user program of a
SIMOTION device.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 26 Introduction to programming with MCC
IA
D
STRING
IN
From V4.0, the STRING data type is available in SIMOTION. As a
consequence, names and texts can be managed by the user program on the
N
SIMOTION runtime system and can be sent or received from a connected HMI
system (e.g. to transfer recipe names). The STRING data type is used to accept
character strings. A character string is a sequence of 0 or more characters with
an apostrophe at the start and at the end. Each character is encoded with 1 byte
AI

(8 bits) in the string (ASCII string).


A character can be entered as follows:
• As printable characters (ASCII code $20 to $7E, $80 to $FF), except the
dollar signs (ASCII code $24) and apostrophe (ASCII code $27), as these
have a special function within the string
TR

• As the two-digit hexadecimal ASCII code of the relevant character preceded


by the dollar sign ($)

STRINGs in MCC If, in MCC variables, the STRING data type is declared, the maximum number
of characters that can be included in the string variables is limited to 80 (default
setting). String variables with a maximum length of 254 characters can only be
declared in the ST language.
Comparison
SI

operations String variables are used to assign constant character strings (e.g. 'Fueller_rot')
or other string variables. If the character string to be assigned has more than
80 characters, it is automatically truncated.
For all comparison operations, a comparison is made of the individual
characters based on the associated ASCII code from left to right (lexicographic
comparison).
When comparing two string variables of different lengths, the shorter variable is
expanded to the longer variable by inserting $00.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 27 Introduction to programming with MCC
IA
D
Array
IN
The data type array (ARRAY) represents a data type with a fixed number of
components of the same data type. The array length N defines the array limits
N
(<array name> [0..N-1].
As a constant, you can enter positive integer values. If, in the "array length"
column, an entry is not made, an array is not created, but instead a simple
variable.
AI

Access Arrays can be accessed component-by-component. e.g.:


• ArrayName [index] := . . .
When making assignments, the complete array can also be accessed, e.g.:
• ArrayName := .:= . . .
TR

From V4.0, using comparison operations (=, <>) complete field variables can be
compared with one another for equality and/or inequality, for example:
• ArrayName1 = ArrayName2

Note If array limits are violated during the runtime, this results in a processing error in
the program.
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 28 Introduction to programming with MCC
IA
D
Array Initialization
IN
Each single Element of an Array can be initialized with a certain value.
The elements are separated by Comma.
N
A range of elements that shall be initialized with the same value can be defined
by a number and the initial value in brackets.
Initial value These initialization values can be specified as a constant or as an expression, in
this case, constants, arithmetic operations as well as bit shift and data
AI

conversion functions are permissible.


TR
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 29 Introduction to programming with MCC
IA
D
Symbolic
I/O variables
IN
Symbolic I/O variables for access to the process images of the Background task
N
can also be set up in the declaration part of an MCC unit or MCC chart.
To do this, you need to declare symbolic names for the process image access
in the declaration part of an MCC unit or MCC chart in the tab "I/O symbols".
These symbolic names are treated by SIMOTION in the same way as variables
AI

of an MCC unit or MCC chart.


This way you can access symbolic I/Os which were declared in the
INTERFACE part of an MCC unit, from programs of other units. You can then
also monitor the I/O variables of an MCC unit in the symbol browser. HMI
devices can also access these I/O symbols.
TR
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 30 Introduction to programming with MCC
IA
D
Setting up a structure
IN
The user-defined data type STRUCT or structure defines a data type with a
fixed number of components. The data types of the individual components can
N
be different. In addition to elementary data types, previously declared data types
(UDT), as well as system and TO data types can be used. A structure is created
as follows: in the declaration part of an MCC unit or an MCC chart within the
"Structures" tab. The name of the structure must be entered into the first line of
AI

the "Name Structure" column. In the same line, the name of the first element
must be entered, together with its data type and additional identifiers (array
length, initial value). Additional elements of the structure are then added in the
following lines, in this case, the "Name Structure" field remains empty. The
definition of a new structure starts with a new name in the "Name Structure"
field.
TR

Variables Defining a structure does not reserve memory space to store data. Variables of
the defined structure can be declared as usual under the "Variable/parameter"
tab in the declaration part of an MCC unit or an MCC chart. Access is only
possible after declaring variables.

Access Individual components of structure variables can then be accessed as follows:


• VariableName.ComponentName
SI

A point must be entered as a separator between VariableName and


ComponentName. It goes without saying that in the user program, the complete
structure can be accessed. From V4.0, using comparison operations (=, <>)
complete structure variables can be compared with one another for equality
and/or inequality, for example:
• MyMotorsArray[X] = MyMotorsArray[Y];

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 31 Introduction to programming with MCC
IA
D
Monitor Structures in the Symbol browser
IN
Highlight the Unit “AxisOpt” and automatically the Symbol browser shows all
N
global variables of this Unit.
AI
TR
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 32 Introduction to programming with MCC
IA
D
Enumerations
(enumerators)
IN
For enumeration data types, the declared data type is assigned a certain
N
number of enumeration elements. After the declaration of the enumerator data
type, e.g. "STATE" then under the "Parameter / Variable" tab, individual
variables of the enumerator data type can be created. To create your own
enumeration, proceed as follows:
AI

1. Open the declaration part of an MCC unit or an MCC chart and select the
"Enumerations" tab.
2. In the first line of the column "Enumeration name", enter the name of the
enumeration.
3. In the same line, add the name of the first element.
TR

4. Enter additional elements of the enumeration in the following lines; the


"Enumeration name" field remains empty.
5. You begin the definition of the new enumeration by entering a new name in
the "Enumeration name" field.
Variables By defining an enumeration, no variable has yet been reserved to store data.
Variables of the enumeration (e.g. "protective door") are declared in the
"Parameter / Variable" tab. Access is only possible after declaring variables. In
the statement section, you can assign only elements from the list of defined
SI

enumerator elements to these variables, such as: protective door := OPEN.


Note The operating system as well as the technology packages frequently use, for
identifying properties, such as task states (RUNNING, STOPPED, etc.), axis
states (ACCELERATING, STANDSTILL), etc., pre-defined in enumerators.
From V4.0, in the ST language, for declaring individual values the enumerator
data types numbers (e.g.: OPEN := 11) can be assigned. Using the conversion
function ENUM_TO_DINT, the values can also be converted into DINT
numbers.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 33 Introduction to programming with MCC
IA
D
Access to
IN
INTERFACE variables It is not possible to automatically access INTERFACE variables that were
N
created in a MCC unit from another MCC chart. For example, for access, a
connection to the MCC unit, in which the INTERFACE variable was declared,
must first be established.
You can define connections in an MCC unit:
AI

• to another MCC, ST, and LAD/FBD source under the same SIMOTION
device
• to libraries
Setting up
connections Connections to other units (program source files) are defined in the declaration
TR

table of the MCC unit. The mode of action of a connection depends on the
section of the declaration table in which it is defined.
• In the interface section of the declaration table: The imported functions,
variables, etc., will continue to be exported to other units and to HMI devices.
This can lead to name conflicts. This setting is necessary, for example, if
variables are declared in the interface section of the MCC unit with a data
type that is defined in the imported program source file.
• In the implementation section: The imported functions, variables, etc. will no
SI

longer be exported. This setting is usually sufficient.


1. In the declaration table, select the section for the desired mode of action.
2. Select the "Connections" tab.
3. For the connection type, select: Program/Unit
4. In the same line, select the name of the unit to be connected: Units (program
sources) must be compiled beforehand.
Namespace For libraries, in addition, any namespace can be specified to resolve name
conflicts for variables, functions etc. with the same name. Elements of the
associated library can then be accessed via the syntax: <namespace>.<name in
the library>.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 34 Introduction to programming with MCC
IA
D
Modules
IN
Modules are used to structure the MCC chart. Modules comprise a number of
interrelated commands that are joined to make one single command. This
N
feature allows even complex MCC charts to be structured in a clear, easily
readable fashion. You can also nest modules and copy them for multiple use in
different charts. Program sections to be used in several programs (MCC charts)
must generated as FC or FB.
AI

Structured
programming SIMOTION supports the concept of structured programming using functions
(FC) and function blocks (FB). FCs and FBs are parameterizable blocks, in
which the necessary algorithms and data for solving partial tasks (mathematical
calculations, closed-loop controls, etc.) of a user program can be saved. FCs
and FBs can be called using different parameter sets at various locations in a
TR

user program and support, in this way, the reusability concept. FCs and FBs for
special tasks can also be combined in preconfigured libraries and supplied.
Further, standard FCs and FBs are already integrated in the system.

Functions (FC) Functions are parameterizable code blocks without memory, i.e. without static
data. Intermediate results, which are obtained while the function is being
executed, can be saved in temporary variables. All local variables of a function
lose their value when you exit the function and are reinitialized the next time you
SI

call the function.

Function block (FB) A function block (FB) is a code block with static data. Unlike FCs, FBs are
instantiated, i.e. an FB is assigned to its own private data area. When called,
this instance can for example "note" process states from call to call. Programs
are similar to FBs, but cannot be parameterized. However, they can be
assigned to execution levels or tasks.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 35 Introduction to programming with MCC
IA
D
ST zoom
IN
Using the command "ST Zoom" when generating programs in MCC, individual
commands or sequences of statements can be entered in "Structured Text".
N
In this way, all statements and system function calls from ST can also be used
when generating programs in MCC.
AI
TR
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 36 Introduction to programming with MCC
IA
D
System function call
IN
The "System function call" command enables you to use any system functions
and system function blocks in the MCC chart and to parameterize the call
N
conveniently.
The required system function or system function block can be directly dragged
from the command library and dropped into the entry field or directly entered.
The command library can be displayed via the "Command library" tab in the
AI

project navigator window.


After inserting the system function or the system functioned block, all input,
output and in-out parameters or the return value are displayed in the dialog box.
Parameters can be connected with actual operands in the list selection fields.
When the command is called, the programmed system function or system
TR

function block is executed. Once the system function or system function block is
executed, the execution of the MCC chart resumes after the command.
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 37 Introduction to programming with MCC
IA
D
Controlling tasks
IN
A range of commands are available in MCC for controlling tasks. They can be
used to start, stop, and resume MotionTasks.
N
Start task This command starts a MotionTask from the beginning, i.e. a stopped task is
executed from the beginning. If the task is already active, it is stopped and
processed again from the beginning.
AI

Corresponds to the call _restartTaskId

Interrupt task This command interrupts a task at the current location. The command does not
stop axis motion that has previously been started from this task.
Corresponds to the call _suspendTaskId
TR

Continue task This command will resume processing of an interrupted task at the location at
which it was interrupted. Interrupted motions are not automatically resumed.
Resumption of interrupted motions must be programmed explicitly.
Corresponds to the command _resumeTaskId

Reset task Using this command, a MotionTask is stopped. The task can be restarted with
the Start task command with data initialization.
SI

Corresponds to the command _resetTaskId

Task state This command returns the state of a task.


Corresponds to the command _getStateOfTaskId

Determine taskId This command generates a project-wide unique task ID from the name of a
task. This task ID is assigned to a variable of data type StructTaskId.
Corresponds to the call _getTaskId

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 38 Introduction to programming with MCC
IA
D
Principle
IN
Often in programs, different statements must be executed or different
programming paths used, depending on particular conditions that apply at the
N
time.
This problem is solved with conditional statements/program paths that branch
the execution sequence off into various subroutines.
AI

IF branch The program flow branches into the TRUE or FALSE branch depending on the
result of the logic operation.
The program flow branches as follows:
• Condition is fulfilled: Execution continues down the TRUE path.
• Condition is not fulfilled: Execution continues down the FALSE path.
TR

The condition can be programmed in the programming languages: Ladder


diagram (LAD), function block diagram (FBD) or formula.

CASE branch The CASE statement is used to select 1 of n program sections. The selection
defines an expression, which must be one of the following types – integer
number data type (SINT, INT, etc.) or enumeration data type (selector). The
selection is made from a list of values (constants) and a program path is
assigned to each value or group of values.
SI

The value of the selector is tested during program execution. If its value is
contained in the value list, the program branches to the associated path. The
ELSE branch is optional. It is executed if the value returned by the selector is
not contained in the value list.

GOTO You can implement program jumps within an MCC chart using the Go To
command. A jump is defined as a jump label (Go to command) and a jump
destination (Selection command), each with the same name. A circle symbol
with a name marks the exit and entry point in each case. Several exit points with
the same name can be programmed, but only one entry point.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 39 Introduction to programming with MCC
IA
D
Overview
IN
MCC provides the control structures FOR, WHILE, and REPEAT for iterating
statement sequences.
N
FOR loop A FOR statement executes a series of statements in a loop and incremented
values are assigned to a variable (control variable). The control variable must
be a variable of type SINT, INT, or DINT.
AI

When the loop is started, the control variable is set to the initial value and
incremented (or reduced for a negative step width) by the specified value on
each loop cycle. The FOR loop is exited when the control variable has reached
the end value.
The FOR statement is used whenever a statement sequence is to be looped
TR

through for a fixed, known number of cycles. If the number of cycles is not
known, use the WHILE or REPEAT statement.

WHILE statement The WHILE statement allows a sequence of statements to be executed


repeatedly under the control of an iteration condition. The iteration condition is
formulated in accordance with the rules for a logic expression.
The statement section is repeated as long as the condition is TRUE, otherwise
the loop is exited.
SI

REPEAT statement REPEAT statements repeat statement sequences between REPEAT and
UNTIL until a particular condition is fulfilled and the action is aborted. The
termination condition is formulated in accordance with the rules for a logic
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.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 40 Introduction to programming with MCC
IA
D
Synchronous start
IN
You can use this command to start several commands simultaneously.
The next command is started once all the commands in the branches have been
N
executed and ended.
There is no limit to the number of commands started simultaneously nor to the
number of synchronous starts within an MCC chart.
This command should only be used in MotionTasks.
AI

Notice When using the synchronous start command, the UserInterruptTask_1 must be
created, as MCC calls this when an error occurs. You can program an error
response in this task.
TR
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 41 Introduction to programming with MCC
IA
D
General
IN
Before you can determine in which execution level (task) a program is to run,
you need to save and compile the program. Compiling then generates the code
N
that is downloaded to the target system and executed there. When the
compilation process is triggered for a program in an MCC unit, the entire MCC
unit always compiled, i.e. all blocks that are contained in the MCC unit. You
cannot compile one program by itself.
AI

The consistency checks are triggered with the compilation process – and in the
event of an error, explanatory error messages are output in the detail window.
Double-click the error displayed in the detail view, then you are taken directly to
the command containing the error.

Save and compile You can save and compile an MCC unit in the following ways:
TR

• Select the required MCC chart in the MCC unit and click the "Save and
Compile" icon on the MCC toolbar.
• In the project navigator, select the desired MCC chart from the MCC unit and
choose the following command from the shortcut menu:
Accept and compile.
• In general, all blocks belonging to the selected source are compiled.
The detail view (tab: "Output") displays any errors occurring during
SI

compilation of the MCC charts. You can double-click on an error entry.


The cursor goes to the corresponding position in the block.
You can save and compile the entire project via the menu command in the
menu bar: Project -> Save and compile or via the associated icon on the
toolbar.
With this compilation, new telegram extensions possibly required between
SIMOTION and SINAMICS_Integrated are created. Generally, the subsequent
download must be performed in SIMOTION as well as in the
SINAMICS_Integrated device.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 42 Introduction to programming with MCC
IA
D
Assigning programs
to tasks
IN
Before a can be downloaded project to the target system (SIMOTION device),
N
the programs created must be assigned to the required tasks. SIMOTION
provides a range of different tasks with different priorities and/or system
response.
Follow the steps below to assign a program to a task:
AI

1. In the project navigator, double-click the EXECUTION SYSTEM object below


the required SIMOTION device. The window for configuring the execution
system opens.
2. In the left-hand section of the window, select the desired task (e.g.
MotionTask_1). The selected task is also displayed in the output window of
TR

the right-hand half of the window.


3. Click the "Program assignment" tab and select the required program
in the "Programs" selection list.
Only correctly compiled programs are displayed in the list.
Programs, where compilation was completed with error messages are not
displayed.
The programs are displayed in the list with the following notation:
<source name>. <program name>
SI

4. Click the ">>" button. The selected program is displayed in the "Programs
used" list.
5. Select the "Task configuration" tab and define any additional settings for the
task there. Especially for MotionTasks, you can select with a check box
whether the selected MotionTask will be automatically started after the
StartupTask.
6. Click the "Close" button to confirm what you have entered. The settings that
have been made will be applied in the project data. Before the project can be
loaded into the target system, the complete project must be compiled.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 43 Introduction to programming with MCC
IA
D
Compilation
IN
The SIMOTION SCOUT Workbench contains editors for creating programs in
MCC, LAD/FBD, and ST. Once an MCC chart has been created, it must be
N
compiled to create an executable program. The language used by MCC is
Structured Text. Therefore, the result of the first compilation of an MCC chart is
Structured Text. A program written in MCC can also be exported as ST source
file and used for further processing in the ST editor. However, a program edited
AI

in ST cannot be decompiled back into MCC.

Downloading to
the target device The intermediate code generated in SIMOTION SCOUT can be downloaded
after a connection has been established with the target system (online channel).
Follow the steps below to download a project to the target system:
TR

1. First check the consistency of the program. To do this, select the menu
command Project -> Check Consistency.
2. Compile the project from scratch again, taking account of all dependencies.
To do this, select the menu command: Project -> Save and Compile All or
the equivalent icon on the toolbar
3. Go online with the target system: To do this, use the menu command
Project -> Connect to target system or the corresponding icon on the toolbar
SI

4. Download the project to the target system. To do this, use the menu
command Target system-> Download -> Project to target system or the
corresponding icon on the toolbar.
In this case, the project data of all devices of the project are loaded. Whether
the data are also loaded into the drive units depends on the settings in the
dialog box: Options -> Settings -> Download.
Alternatively, the project data can be downloaded into individually selected
devices using the command: Target system -> Download -> To target device
or using the icon "Download CPU to target device".

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 44 Introduction to programming with MCC
IA
D
Downloading
Individual units
IN
Larger projects are normally created by several operators. There are therefore
N
independent processing units that are edited simultaneously. These units can
also be loaded individually during commissioning without overwriting other units
that are not consistent at the time of loading. It is possible to download an
individual source or selected sources via multiple selection (from online-
AI

inconsistent programs). This can be performed in the STOP and RUN operating
states. Subsections of a configuration can therefore be downloaded and
commissioned even when certain units are not yet ready for a download.
If several operators have an online connection between their PCs and a
SIMOTION controller, in particular during commissioning, each user can load
and test their own processing units.
TR

Downloading The downloading of individual sources can only be started via the shortcut menu
on the unit or on the execution system. The execution system is relevant if you
wish to load a new source with a program which has been newly registered in
the execution system. So that the program is also performed on the target
device, the execution system must also be loaded along with the unit. If several
units are loaded, they must be marked via multiple selection in the project
navigator and then loaded via the shortcut menu command "Load to target
SI

device".
After downloading a subset, SIMOTION SCOUT ensures that a consistent state
is established again on the target device as a whole. To do this, SCOUT checks
and visualizes the dependencies on other units, which must then also be
downloaded when required.
With this specification, the user can verify whether the download would cause
problems (e.g. that no unit is downloaded outside of its appropriate area). After
the download confirmation loading to the target device is started.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 45 Introduction to programming with MCC
IA
D
Tracking the
program flow
IN
Program execution tracking can be switched on and off during program
N
operation. When program execution monitoring is activated, the current active
command is shown in yellow. The parameter screen forms of the active MCC
chart can be opened and read, but no changes can be made.
Monitoring program execution has no effect on program processing itself, but it
AI

does make the program execution time longer. The program execution tracking
can only be activated for MCC charts that are assigned to precisely one task.
Program execution monitoring is started by activating the menu command MCC
Chart -> Monitor with an open MCC chart or by clicking the associated icon on
the MCC toolbar.
TR

Program execution
with single step Only MCC charts that are created as a program and assigned to exactly one
task can be tracked in single-step mode. If single step is active, the program
is suspended until the user activates the next program step. The next command
to be executed is highlighted in pale blue. After initiation of the next single step,
the active command is shown in yellow until execution of the command has
finished. The program is then suspended again.
SI

Program status You can use Program Status to monitor variables for the following commands:
• IF, WHILE, UNTIL, and ST zoom
• The values of the following variables are displayed:
• Variables with an elementary data type (INT, REAL, etc.)
• Individual elements of a structure, provided an assignment is given
• Individual elements of an array, provided an assignment is given
• Variables with enumeration data types
The Status of ST Loops is available if Monitoring is active, just place the cursor
on a variable to see the status value.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 46 Introduction to programming with MCC
IA
D
Overview
IN
The name, data type and values of the global variables are displayed in the
symbol browser. The values of the variables can be monitored and, if required,
N
changed (controlling variables).
Using the
symbol browser For the following functions, a connection to the target system must have been
established and the project data loaded to the target system.
AI

1. In the project navigator, select the required entry, for example:


DEVICE-GLOBAL VARIABLES, source, TO, device.
2. Click the "Symbol browser" tab. The status values of the variables are
displayed.
3. The "Control of variables" function can also be executed.
TR

The following variables can be controlled:


• All device-global variables and all unit variables that can be written to
• All TO or device variables that can be written
• In the "Control value" column, enter a value, activate the check box
in this column and click the "Immediate control" button. The entered
value is written to the variable.

Fixing the display Normally, in the symbol browser, the variables of the particular object are
SI

displayed that was selected in the project window. By clicking the "Maintain
display" symbol in the right-hand upper corner of the symbol browser, the
display in the symbol browser can be fixed for the active object. To free the
display, click the same symbol again.
• The display is fixed. The content of the symbol browser window does not
change if another object is selected in the project window.
• The display is not fixed. The content is displayed depending on the selected
object in the project window.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 47 Introduction to programming with MCC
IA
D
Overview
IN
The inputs/outputs of a SIMOTION device can be monitored from the address
list. In the address list, you can choose between the "I/Os" view and the "All
N
addresses" view. Using the "View" list box in the function area at the top left, the
view in the address list can be toggled between the two options.

"I/Os" view In this view, the I/O variables are specified that should either be connected to
AI

the signals of the SINAMICS or TMs using an assignment or assigned using


absolute addresses of the hardware. The assignments are made in a special
assignment dialog box.
However, the additional information from the "All addresses" view is not
displayed here.
"All addresses"
TR

view The All addresses view contains all the information contained in the I/Os view
as well as additional information on the I/O variables. It also contains
information on interfaces on TOs that have been assigned by the system as well
as I/O variables as "Sources", which are interconnected to telegram extensions
via assignments.
You can also enter I/O variables in this view that are to be connected via
assignments. The assignments are made in an assignment dialog box.
SI

Note The "All addresses" view is available only when the CPU firmware version is at
least V4.2 and, in the SCOUT user interface, the symbolic assignment has been
activated with the command: Project -> Use symbolic assignment.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 48 Introduction to programming with MCC
IA
D
Overview
IN
With the symbol browser, you can only monitor variables belonging to one
object (specifically to a device, I/O, and unit) in a project, And with the "Program
N
status" test function, you can monitor variables only in a user-definable range of
the program. With watch tables, on the other hand, selected variables of
different origins can be monitored as a group. In offline mode, you can monitor
and control the data type of the variables, in online mode their content.
AI

Watch table To monitor variables using the watch table:


1. In the project navigator, open the "Monitor" folder.
Select "Insert -> Watch table" to create a watch table; enter a name for the
table. A watch table with this name appears in the "Monitor" folder.
TR

2. In the project navigator, click the object (I/O variables, device-specific


variables, unit variables) from which variables are to be added to the watch
table. The corresponding table of variables then appears in the symbol
browser.
For the SINAMICS Parameters open the expert list of the target Drive.
3. In the table of variables, click the first entry to select the whole variable line
right click to display the associated shortcut menu and choose “Add to watch
table" In the subsequent menu that is displayed, also select the
SI

corresponding watch table, in the example "Watch table_1".


In the SINAMICS Expert list right click a parameter and select “Add to watch
table“.
4. Now double click the required watch table in the project navigator to open it
and the selected variables in the watch table can be monitored and
controlled. No forcing is available
Repeat steps 2 and 3, to insert all of the required variables/ parameters from the
various objects into the watch table.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 49 Introduction to programming with MCC
IA
D
Overview
IN
When working with lists – e.g. watch table, address list, symbol browser, or
expert list – various options are provided for sorting, structuring and customizing
N
tables.

Move The individual entries in a watch table can be moved as required. This can be
used to resort a watch table. For this purpose, select the appropriate entry in the
AI

first column and move it to the required position with the mouse button pressed.

Hide/display Entries in the watch tables can be hidden and displayed again. For this purpose,
select the appropriate entry in the first column and select the "Hide" or "Display"
command from the shortcut menu.
TR

Group To reduce the complexity of entries in a watch table and to structure the data,
elements of a watch table can be combined to form a group. For this purpose,
select the required element and select the "Group" item from the shortcut menu.
The group created can be opened using the "+" character or closed again using
the "-" character. You can assign a specific name to the new group in the
"Name" column. This grouping can be ungrouped again using the "Cancel
grouping" item from the shortcut menu.
SI

Information For user variables, comments from the declaration of variables are displayed in
the "Information" column. The entry can be overwritten as required in the watch
table.

Comment lines Comment lines can be displayed at any position in a watch table. To do this, in
the first column select the line in front of which a comment line should be
inserted, and from the shortcut menu, select the "Insert comment line"
command. Any text can then be inserted in the comment line.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 50 Introduction to programming with MCC
IA
D
Reference data
IN
Reference data allows you to obtain an overview of the identifiers used together
with their declaration and use (cross-references) as well as of function calls and
N
nesting (program structure) and of the memory requirement for retentive and
non-retentive unit variables (code attributes).
Cross-reference list The cross-reference list shows all identifiers in program source files (ST source
files, MCC charts, and LAD/FBD programs)
AI

• That are declared as variables, types, or as program organization units


(programs, functions, function blocks)
• That are used in declarations as previously defined type identifiers
• That are used as variables in MCC commands.
• The cross-reference list can be generated selectively for:
TR

• A single program source (MCC chart or ST source file)


• All program sources on a SIMOTION system
• All program sources and libraries of the project
• Libraries (all libraries, single library, individual program source within a
library)
To display the cross-reference list, select the PROGRAMS folder and, from the
shortcut menu, choose: Display reference data -> Cross-references.
SI

Using the
cross-reference list The following functions can be executed using the cross-reference list:
• Sort the column contents alphabetically
• Set filter functions
• Copy the content to the clipboard and transfer to Excel
• Print contents
• Using the "Go to use" button, open the referenced program source and
position the cursor onto the associated MCC command (line of the ST
source file or LAD/FBD element)

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 51 Introduction to programming with MCC
IA
D
Homing of
variables
IN
If the identifier of a variable has been selected in the opened editor window of a
N
programming language, it is then possible to jump to other points of use or a
table with all points of use can be listed via the shortcut menu.
You select the identifier of a variable:
• For SIMOTION ST: in the editor window of an ST source.
AI

• For SIMOTION MCC: in the entry field on the parameter screen of an


open MCC command in an MCC chart
• For SIMOTION LAD/FBD: in the Editor window of a LAD/FBD program
• An identifier is recognized as a variable under the following conditions:
• The identifier is declared as a variable. The scope of the variable includes
TR

the respective window (ST source, MCC chart, LAD/FBD program).


• The program source is compiled.
• The variable is selected as follows (in an open parameter screen within an
MCC chart):
• The identifier is fully marked or
• The cursor is within the identifier.
SI

Note In arrays and structures, only the variable can be selected, not a single element.

Go to The following options are available in the shortcut menu:


• local use >> and <<
• to the declaration
• create a table with all points of use

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 52 Introduction to programming with MCC
IA
D
Program structure
IN
After generating the cross-reference list, you can selectively display the
structure of the programs. A tree structure appears, showing:
N
• As the root, the program organization units (programs, functions, function
blocks) declared in the program source
• Below these, the subroutines referenced in this program organization unit
The minimum and maximum stack requirements are displayed in brackets.
AI

Code attributes The following are displayed in a table for all selected program sources:
• Identifier of program source file
• Memory requirement, in bytes, for the following data areas of the program
source:
TR

 All unit variables (retentive and non-retentive) in the interface and


implementation sections (dynamic data)
 Retentive unit variables in the interface and implementation section
(retain data)
 Unit variables (retentive and non-retentive) in the interface section
(interface data),
 The size of the blocks programmed in the implementation section
SI

(code size)
• Number of referenced sources

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 53 Introduction to programming with MCC
IA
D
Search in the project
IN
You can search through the entire project data of the currently opened project
for variables and any text with Edit > Search in the project and, if required,
N
replace this with Replace. Search results are displayed in the detail view in the
Search result tab.
Double-clicking the search result displays, for example, the found variable in the
symbol browser. For positions found in programs, double-clicking the search
AI

result opens the program and the corresponding position in the program is
highlighted.
If you perform a replace action, the replacement term is displayed in the detail
view in addition to the found results. Click "Replace" to replace the search
results with the new term. A check box precedes each search result.
TR

For the replace action, only those search results that you have marked will be
replaced. The search also returns results that cannot be replaced. In this case,
you cannot mark the search result for the replace action.

Know-how protection If you have set know-how protection on sources, they are no longer included in
the search. They are excluded from the search. A search is only possible if you
open the source in the appropriate editor or if you delete the know-how
protection.
SI

The free search does not return any results for the technology objects and
drives from the expert lists.
Use the cross-reference list if you want to search for variables and the relations
and uses in the programs. You will find it in the shortcut menus of each of the
objects in the project navigator under Reference data > Create.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 54 Introduction to programming with MCC
IA
D
Task
IN
In the following exercises, in the "FaultUnit" MCC unit, you should write a small
program called "PeriFaultProgram". Because of the automatic time
N
synchronization and the associated start of PeripheralFaulTask, this program
should prevent the SIMOTION device from entering the STOP state.
Procedure
1. Double-click on the "Insert MCC unit" icon. The "MCC unit" dialog box
AI

opens.
2. In the "Name" field, enter the name "FaultUnit".
3. Confirm your entries by clicking "OK".
4. Double-click on the "Insert MCC Chart" icon below the inserted MCC unit.
The "MCC chart" dialog box opens.
TR

5. Enter the name "FaultProgram" and set the creation type to "Program".
6. Confirm your entries by clicking "OK."
An empty MCC program with a start and end step is displayed
7. Save and compile the program.
In the next step, assign the program to the execution system.
8. In the project navigator, double-click the "Execution system" symbol.
The task overview opens.
SI

9. In the "Program assignment" tab, assign the program "FaultUnit.


FaultProgram" to PeripheralFaultTask. Also check, whether the option
"Use task in execution system" is selected.
10.Save and compile the project.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 55 Introduction to programming with MCC
IA
D
Task
IN
After an online connection has been established, the project data should be
loaded into the target system and the changeover of the operating modes tested
N
via the associated control.

Procedure
1. To establish an online connection to SIMOTION, click the highlighted icon
AI

"Connect with target system".


2. After the connection has been established, the data can be transferred via
the symbol "Load project to target system" or "Load CPU to target
system". To transfer project data, SIMOTION must be brought into the STOP
operating state.
TR

In the open "Load to target system" dialog box, the following options can
already be selected.
• "Store additional data on the target device"
• "After loading, copy RAM to ROM"
3. After successfully downloading the project, use the operating mode control to
put the SIMOTION device into the required operating modes. Can the RUN
operating mode now be selected?
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 56 Introduction to programming with MCC
IA
D
Exercise
IN
In the following exercises, you will write a small program
"Optimization_Filler_red" in the MCC unit "AxisOpt". This program will
N
implement a typical axis oscillation motion of an axis for subsequent position
controller optimization. This program should first perform the following function:
With a rising edge at input %I0.0, the axis "Filler_red" will be traversed in a
positive direction for 50 mm at a speed of 20 mm/s. Then it is to move in
AI

negative direction at the same speed and for the same distance.
Procedure
1. Double-click the "Insert MCC unit" icon. The "MCC unit" dialog box opens.
2. In the "Name" field, enter the name "AxisOpt" and, under the "Compiler" tab,
select the options "Permit program status" and "Permit single step".
TR

3. Confirm your entries by clicking "OK".


4. Double-click on the "Insert MCC Chart" icon below the inserted MCC unit.
The "MCC chart" dialog box opens.
5. Enter the name "Optimization_Filler_red" and set the creation type to
"Program".
6. Confirm your entries by clicking "OK".
7. Now insert the following steps in the MCC chart:
SI

• Wait condition at input %I1.7


• Position controller enable for axis "Filler_red"
• Relative traversing motion in the positive direction (travel distance
50 mm, traversing velocity: 20 mm/s)
• Relative traversing motion in the negative direction (travel distance
50 mm, traversing velocity: 20 mm/s).
• Remove axis enable
8. Save and compile the program.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 57 Introduction to programming with MCC
IA
D
IN
In the next step, assign the program to the execution system.
9. In the project navigator, double-click the "Execution system" symbol.
N
The task overview opens.
10.In the "Program assignment" tab, assign the program "AxisOpt.
Optimization_Filler_red" to Motiontask_1. Also check, whether the option
"Use task in execution system" is selected.
AI

11.In the "Task configuration" tab, activate the "Activation after StartupTask"
option.
12.Save and compile the project.
Task After an online connection has been established, the project data should be
loaded into the target system and the MCC program tested. Procedure:
TR

1. To establish an online connection to SIMOTION, first of all TIA Portal is to be


connected online. Then click the yellow highlighted icon "Connect with target
system".
2. After the connection has been established, the data can be transferred via
the symbol "Load project to target system" or "Load CPU to target system".
To transfer project data, SIMOTION must be put into the STOP operating
state.
The "Download to target system" dialog box opens where you can activate
SI

the option "After loading, copy RAM to ROM".


3. After successfully downloading the project, use the mode switch to switch
the CPU to RUN mode.
4. Test your program. Using the icon "Program status", the program execution
can be tracked.
5. If the "Automatic" RAM to ROM is not activated, the project data should be
backed up to the CF card using the menu command: Target system -> Copy
RAM to ROM.
Solution The solution is provided in "TIA_PM_D425-2_V5.1_E1".

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 58 Introduction to programming with MCC
IA
D
Task
IN
In the next step, the "Optimization_filler_red" should be expanded by the
following functions:
N
• The traversing part of the program should be run through five times.
• If the axis "Filler_red" traverses in the positive direction, output %Q5.6
is set to "1"; if the axes traverses in the negative direction, output %Q5.7
is set to "1".
AI

Procedure The following steps must be performed to perform this task:


1. Declare a global variable "loop" with data type INT (integer) in the
INTERFACE part of the MCC unit "AchsOpt".
2. Set the variable at the start of the program "Optimization_Filler_red" to a
TR

value of "1".
3. Use the WHILE or FOR commands to implement the loop function. Observe
the following points:
• The "loop" variable must be incremented by 1 at the end of each run.
• If the variable exceeds a value of five, the loop must be exited.
4. Before each traversing motion, set the corresponding output or reset the
output after every traversing command.
SI

5. "Save and compile" the project and download it to the target system.
6. After the download, switch the D425-2 into the RUN operating mode and test
the program.
7. In the project navigator, select the MCC unit "AchsOpt", and in the symbol
browser, check the value of the "loop" variable.
8. Check the value of the "loop" variable, by opening the While instruction
and selecting the function "Program status".

Solution The solution is provided in "TIA_PM_D425-2_V5.1_E2".

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 59 Introduction to programming with MCC
IA
D
Exercise
IN
In the MCC unit "LED_Test", create the program "Test_LED". After the CPU has
booted, the program sets the I/O output word 5 to "1" and after 5 seconds resets
N
it back to "0". Only symbolic access is possible to I/O output word 5.

Procedure Perform the following steps:


1. To address an I/O output byte symbolically, go offline in SIMOTION SCOUT
AI

and select the entry ADDRESS LIST in the window of the project navigator.
2. Select the detail view for the "Symbol browser". In the symbol browser,
create a variable called "bo8_All_DO_1" with assignment to I/O output byte 5
(PQB5). As a data type of the variable "bo8_All_DO_1", select the BYTE
entry.
TR

3. Make sure that the item "replacement value" is selected under "Strategy".
4. Create a new MCC unit "LED_Test". In this unit, create the MCC program
"Test_LEDs". Implement the desired functionality.
5. Save and compile the MCC unit file.
6. Open the dialog box for setting the EXECUTION SYSTEM and assign
the created program to MotionTask_2. For MotionTask_2, under the "Task
configuration" tab, select the item "Activation after StartUpTask".
SI

7. Save and compile the project.


8. Download the project into the target system and test the program.

Solution The solution is provided in "TIA_PM_D425-2_V5.1_E3".

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 60 Introduction to programming with MCC
IA
D
Note
IN
The following pages either contain additional information or are used as
reference to complete a specific topic.
N
AI
TR
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 61 Introduction to programming with MCC
IA
D
IN
Download during RUN To make minor changes to programs and transfer them directly during
operation, you can download these changes to the target system in the RUN
N
operating state.

Notes For MotionTasks, the MotionTask must first be terminated before the code can
be changed. With cyclic tasks, the system will try for 2 seconds to replace the
AI

code. If this is not successful, because, for example, long commands are being
processed, the download is interrupted with the corresponding message. The
function must be enabled via the SCOUT menu command: Options -> Settings
->CPU download -> Permit download / RAM to ROM during RUN.
The download during RUN must be performed via the menu command: Target
system - Download -> To target device or alternatively via the corresponding
TR

icon on the toolbar.


Downloading of individual sources is also possible in the RUN state using the
shortcut menu

Procedure Proceed as follows:


1. After you have made changes to your program, click the "Save and compile"
button. The program is saved and compiled.
SI

2. In the project navigator, select the device for which you have made the
program changes, e.g. D425-2.
3. Click the "Download CPU / drive unit to target system" icon or open the
shortcut menu and choose the command: Target device -> Download to
target device.
4. However, after a download, the changes are in the RAM, not in the ROM.
If the data on the data storage medium of the target device are to be saved,
then, in the message window that opens, select the option "Copy RAM to
ROM". Then confirm with "Yes".

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 62 Introduction to programming with MCC
IA
D
Downloading
Individual units
IN
Larger projects are normally created by several operators. There are therefore
N
independent processing units that are edited simultaneously. These units can
also be loaded individually during commissioning without overwriting other units
that are not consistent at the time of loading.
It is possible to download an individual source or selected sources via multiple
AI

selection (from online-inconsistent programs). This can be performed in the


STOP and RUN operating states.
Subsections of a configuration can therefore be downloaded and commissioned
even when certain units are not yet ready for a download. If several operators
have an online connection between their PCs and a SIMOTION controller, in
particular during commissioning, each user can load and test their own
TR

processing units.

Downloading The downloading of individual sources can only be started via the shortcut menu
on the unit or on the execution system. The execution system is relevant if you
wish to load a new source with a program which has been newly registered in
the execution system. So that the program is also performed on the target
device, the execution system must also be loaded along with the unit. If several
units are loaded, they must be marked via multiple selection in the project
SI

navigator and then loaded via the shortcut menu command "Load to target
device".
After downloading a subset, SIMOTION SCOUT ensures that a consistent state
is established again on the target device as a whole. To do this, SCOUT checks
and visualizes the dependencies on other units, which must then also be
downloaded when required. With this specification, the user can verify whether
the download would cause problems (e.g. that no unit is downloaded outside of
its appropriate area). After the download confirmation loading to the target
device is started.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 63 Introduction to programming with MCC
IA
D
Storage of
additional data
IN
Using this check box, additional data, for example, all sources (SIMOTION and
N
SINAMICS) can be loaded into the target device. This data is then saved in the
target device and can be uploaded again using the menu command: Target
system -> Download CPU/drive unit to PG. If you deactivate the option, the
additional data is deleted at the next download.
AI

Procedure To store additional data, proceed as follows:


1. Select the menu command: Options -> Settings. The "Settings" dialog box
opens.
2. Switch to the "Download" tab.
TR

3. Activate the setting "Store additional data on the target device" and confirm
the dialog box with "OK".
4. Before downloading the project, select the function "Save and recompile all".
The next time the project is downloaded to the target device, the additional data
will be automatically saved on the target device.
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 64 Introduction to programming with MCC
IA
D
Object comparison
IN
You can use the SIMOTION SCOUT/Starter function Project comparison (start
using Start object comparison button) to compare objects within the same
N
project and/or objects from different projects (online or offline) with one another.
Objects are devices, programs, technology objects (TOs) or drive objects (DOs)
and libraries. The project comparison is available with SIMOTION SCOUT and
Starter. Comparing projects is useful if you need to perform service work on the
AI

system.
Object comparisons are only performed using saved data. By contrast, detailed
comparisons use the data in the work memory of the PC/PG. Object and
detailed comparisons may, therefore, produce different results.
An online comparison and a comparison with a different project behave as
TR

follows:
• The comparison only uses the saved data in the open project.
• During an online comparison, the device being used for comparison
purposes is implicitly uploaded. Therefore, the comparison is made with a
copy of the online data.

Note A comparison with online objects is only possible if an online connection has
already been established to the target system. No communication connection is
SI

established when the comparison is started.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 65 Introduction to programming with MCC
IA
D
Dialog box
IN
This slide provides an overview of the elements and the structure of the Object
comparison dialog box. You can start the detailed comparison for ST source
N
files, TOs and DOs from this dialog box.
The user interface
1. Comparison partner A and comparison partner B
2. Comparison tree made up of comparison partner elements.
AI

3. Object present (column A, column B): The columns indicate whether or not
a tree object is present for comparison partner A and/or comparison partner
B.
4. Result of comparison: The comparison result is shown in this column
(same/different).
TR

5. Select/change comparison partner


6. Update comparison
7. Call up online help
8. Display object attributes: The attributes of the comparison partners are
compared in two columns.
9. Start detailed comparison
10. Comparison attributes of one object
SI

11. Data transfer: Transfer of data from comparison partner B into the open
project.
12. Status bar
13. Object comparison tab

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 66 Introduction to programming with MCC
IA
D
Detailed comparison
IN
From version V4.2 for SIMOTION SCOUT, a detailed comparison for objects is
performed, i.e. for
N
• ST source files (Structured Text)
• MCC units (Motion Control Charts)
• LAD/FBD units (ladder/function block diagram)
AI

• TOs (technology objects, for example; axes, output cams, measuring inputs,
etc.)
• DOs (Drive Objects in SINAMICS drives)
Starting a
detail comparison The detailed comparison for ST/MCC/LAD/FBD programs, TOs and DOs can
be directly started from the comparison tree by clicking on the "Start detail
TR

comparison" button.
You can only start the detail comparison if
• you have found differences or
• if the additional data required is available for the online comparison.
In a detailed comparison, the different values of the two objects being compared
are displayed in tabular form.
SI

Comparison result For MCC units, the comparison is performed at the source text level (ASCII
basis). For INTERFACE (Exported declaration and connections are the first
difference shown in the detailed comparison.) For IMPLEMENTATION (Internal
source declarations and connections are also the first difference shown in the
detailed comparison.)
For programs, functions, and function blocks, a detailed comparison is available
for declarations, execution-relevant code and for differences in the comments
and formatting.
Differences in the compiler settings or the object address are displayed under
"Properties".

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 67 Introduction to programming with MCC
IA
D
Continuation
IN
Under "Active compiler options", differences in the settings for compilation of
displayed. This essentially corresponds to the "Compile" tab in the properties
N
dialog box of the source.
Differences in the result of the compilation are displayed under "Compilation
result". The following are incorporated in the compilation result:
• The source text of relevance to execution, i.e. everything apart from
AI

comments and formats


• The compiler settings (local and global) and the compiler version
(e.g. compilation with the new SCOUT)
• External references
 Interfaces of other sources used
TR

 Interfaces of libraries used


 Global device variables used
 I/O variables used
 TOs used
 Tasks used in the task control commands
• Message configuration (used symbols/IDs). If a different number has
been assigned to an alarmS configuration icon, and this icon has been used
SI

in this program, the source code is the same in both cases but the
compilation result is different.
• Data structure, retain data and non-retain data
• Exported interface (effective) export data and used data types, exported
POEs
Under "HMI-relevant data", differences in the structural setup (data type of
variables, number of variables) of the data which an HMI system can access are
displayed. If the setup changes, the HMI configuration must be updated. Data
included.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 68 Introduction to programming with MCC
IA
D
MCC blocks
IN
For differences in execution-relevant source text of blocks in MCC, in the
detailed comparison window, the MCC editor is opened and the offline and/or
N
online version of the blocks is displayed.
Differences in the commands or in the parameters to the commands are color-
coded The window for the parameter comparison can be opened by double
clicking on the corresponding command.
AI

The individual parameters for this command are then listed in this window.
Differences in the offline or online version are color-coded.
The values of the online parameter can be transferred into the offline project by
selecting the check boxes for the various parameters and then closing the
window with the "OK" button.
TR
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 69 Introduction to programming with MCC
IA
D
Data transfer
IN
Using the "Data transfer" function in the object comparison, you can transfer the
data of the comparison object (B) to the open project (A).
N
Rules When you transfer an object, the complete content of the object is transferred
from the comparison object and overwrites the data in the reference object.
This means that changes that you made in the reference project may be lost!
AI

Drive objects cannot be transferred.


Additional rules relating to data transfer in the object comparison are provided in
the manual of the SIMOTION control system.
TR
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 70 Introduction to programming with MCC
IA
D
Overview
IN
From V4.0, breakpoints can be set in an MCC chart at individual instructions.
When execution comes to an activated breakpoint, execution is stopped, and all
N
tasks in the associated "Debug task group" are held
The content of the local variables can be monitored in the detail window under
the "Variable status" tab.
AI

Procedure With the MCC chart open, proceed as follows:


1. Select the debug mode for the corresponding SIMOTION device.
2. Define the tasks of the "Debug task group", i.e. the tasks that should be
halted when a breakpoint is reached.
3. Display the "Breakpoint" toolbar.
TR

4. In the MCC chart, set your breakpoints at the required commands.


5. Define the call path for the MCC chart.
6. Activate the breakpoints.
7. Monitor the contents of the local variables.
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 71 Introduction to programming with MCC
IA
D
Overview
IN
Various SIMOTION device modes are available for the program test. How to
select the mode of a SIMOTION device:
N
1. Select the SIMOTION device in the project navigator.
2. In the shortcut menu, select the command: "Operating mode..."
3. Select the required mode and confirm with OK.
AI

For the debug mode, you must also acknowledge the safety notes.
Operating modes The following operating modes can be set:
• Process mode: Program execution in the SIMOTION device is optimized for
maximum performance. The following diagnostic functions are available:
 Monitoring variables in the Symbol Browser
TR

 Program status
 Trace tool with measuring functions for drives and function generator.
• Only 1 MCC chart can be monitored and 1 trace activated.
• Test mode: The same diagnostic functions are available as for process
mode. The restrictions have been resolved to a great extent.
However, only one MCC can be monitored for each task and 4 traces
can be initiated at each SIMOTION device.
SI

• Debug mode: This mode is available in SIMOTION kernelas of V3.2. In


addition to the diagnostic functions of the test mode, the "breakpoints"
function can also be used.
No more than 1 SIMOTION device can be switched to debug mode.
The selected debug mode is displayed in the status bar of the SCOUT
window.
Notice You must follow the relevant safety rules. Use the debug mode only with the
life-sign monitoring function activated with a suitably short monitoring time!

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 72 Introduction to programming with MCC
IA
D
Overview
IN
If program execution comes to an activated breakpoint, all of the tasks of the
associated "Debug task group" are halted.
N
Procedure After you have switched the corresponding SIMOTION device to debug mode,
you can then proceed as follows:
1. Select the required SIMOTION device in the project navigator.
AI

2. Select the "Debug task group" item in the shortcut menu. The dialog box to
define the "Debug task group" opens.
3. Select the tasks to be stopped on reaching the breakpoint:
• If you wish to specifically halt individual tasks in the RUN state, assign
these tasks to the "Tasks to be stopped" list:
TR

• If you wish to stop all tasks, select the "All tasks" option.
In this case, you can define as to whether the outputs will be activated
again after continuation

Property Debug task group All tasks


RUN HALT Operating mode
Halted tasks Only "Tasks All tasks
SI

to be stopped"
Output Active Inactive
Cycle monitoring Inactive Inactive
Axis technology Axes in position control No position control

Note The "Debug task group" can only be modified if no breakpoints are active.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 73 Introduction to programming with MCC
IA
D
Setting breakpoints
IN
Breakpoints can only be set in an MCC chart, if the following conditions are met:
• The MCC chart must be open and consistent.
N
• The required SIMOTION device has been brought into the debug mode.
• The "debug task group" was defined.
Proceed as follows to set breakpoints:
AI

1. Using the command: View-> Toolbar -> Breakpoints, display the breakpoint
toolbar.
2. Select the required instruction in the MCC chart.
3. Click the "Set/remove breakpoint" icon on the "Breakpoint" toolbar (shortcut
key: Ctrl+H). A breakpoint that has been set can be removed by clicking the
TR

"Set/remove breakpoint" icon.


An inactive breakpoint is shown as an open triangle at the top left hand
corner of the MCC command.

Note You can use other diagnostic functions, for example "Program Status" and the
"Breakpoints" function together in one MCC chart.
SI

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 74 Introduction to programming with MCC
IA
D
Defining a call path
IN
After you have set the breakpoint in the MCC chart, you can define the call path
for the breakpoint. Proceed as follows:
N
1. In the MCC chart, select a command with breakpoint.
2. Click the "Edit call path" button on the "Breakpoints" toolbar. In the "Call
path/breakpoint" window, the selected code location is displayed (with name
of the source, line number, name of the POE).
AI

3. If the code position is called from several tasks:


• Select the required task. This task must be in the debug task group.
4. Select the code position to be called (in the calling POU). You can select
from the following:
• The code positions to be called within the selected task (with the name of
TR

the program source, line number, name of the POU). If the selected
calling code position is, in turn, called by multiple code positions, further
lines are displayed in which you proceed similarly.
• 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
SI

reached several times, select the appropriate number of times.

Note You can view the call path with the "Display call stack" function, depending on
the task selected. To do this, place the cursor on the line of the ST source file
with the breakpoint and click the "Display call stack" button.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 75 Introduction to programming with MCC
IA
D
IN
Activating breakpoints Breakpoints must be activated before they are to have an influence on program
To activate/deactivate a single breakpoint, proceed as follows:
N
1. Select the command at which a breakpoint is set. Click the
Activate/deactivate breakpoints button on the Breakpoints toolbar
(shortcut F4).
2. To deactivate a breakpoint click the "Activate/deactivate breakpoint" button
AI

again.
To activate/deactivate all breakpoints, proceed as follows:
1. On the "Breakpoints" toolbar, click the "Activate all breakpoints" button.
2. To deactivate all breakpoints, click the "Deactivate all breakpoints button".
TR

An active breakpoint is shown as a solid triangle at the top left hand corner of
the MCC command.

Note Breakpoints can also be activated and deactivated in the debug table. To do
this, select the SIMOTION device in the project navigator and select "Debug
table" from the shortcut menu.
The windows that open execute the action below, depending on which
breakpoints you activate or deactivate:
SI

• Single breakpoints: Check or clear the corresponding check boxes.


• All breakpoints: Click the corresponding button.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 76 Introduction to programming with MCC
IA
D
IN
Reaching a breakpoint If program execution reaches a command with active breakpoint, stop all tasks
that are assigned to the debug task group. The associated command is
N
highlighted in red in the MCC chart. Program execution is located in front of the
command, i.e. the command highlighted in red has still not been executed. At
this point in time, in the detail window under the "Variable status" tab, the
present contents of all parameters and local variables of the MCC chart can be
AI

viewed. The instantaneous values of global "Unit variables" can be monitored


under the "Symbol browser" tab in the detail window.
Displaying
the call stack If the program is stopped at a breakpoint, the current call stack, including the
calling task and the specified number of repetitions, is displayed with the
"Display call stack" button. The call stack itself (call path) cannot be modified.
TR

Continue program Executing the selected command or continuing the program execution is
possible with the "Continue" button (Shortcut: Ctrl+F8) on the "Breakpoints"
toolbar. Program execution then stops when the next breakpoint is reached.

Next step In the MCC and LAD/FBD programming languages, the task in single steps that
was stopped at an activated breakpoint can be resumed. On a subprogram call,
the called subprogram is considered as an instruction and executed as such.
SI

Stepping through
a subprogram In the MCC and LAD/FBD programming languages, the task in single steps that
was stopped at an activated breakpoint can be resumed. On a subprogram call,
stepping is performed into the subprogram.

Note The "Breakpoints" function and the "Monitoring" function can be used together in
an MCC chart.

SITRAIN Page Course MC-SMO-PM


Training documentation 4 - 77 Introduction to programming with MCC
UA Client Digitally signed by UA Client
1500
DN: cn=UA Client 1500
1500 Date: 2024.04.04 10:57:29
+05'30'

You might also like