iec 61131-3 programming - multiprojekt 7.5...software r eference manual iec 61131 progra mming 5-3...

26
5 IEC 61131-3 PROGRAMMING

Upload: others

Post on 11-Mar-2020

26 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

5IEC 61131-3 PROGRAMMING

Page 2: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Trio Motion Technology

IEC 61131 PrograMMIng

5-2

Page 3: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Software reference Manual

5-3IEC 61131 PrograMMIngController and Project Trees

Introduction to IEC 61131-3

This help file covers program using IEC 61131 languages using Trio Motion Technology’s Motion Perfect v3 application when used in conjunction with a compatible Trio 4 range of Motion Coordinator. The system supports several of the IEC 61131-3 defined languages providing both editing and debugging support.

Controller and Project TreesIEC 61131 tasks are shown in the Controller and Project trees on the same level as a TrioBASIC program. This is because each represents an executable item which runs on a single controller process. All programs and spy lists in a task are shown as sub-items to the task in the tree.

The tree items have context menus to allow the user to perform associated operations.

CONTEXT MENUS

IEC TASK

Menu Item DescriptionAdd New IEC Program Displays a dialog where the user can enter the new IEC program name, the IEC

language and program run type

Add new spy list Adds a new spy list to the IEC task

Open IEC variables Opens the IEC variables editor tool

Open IEC types Opens the IEC custom types editor tool

Compile IEC 61131-3 programs

Compiles all the IEC programs in the IEC task and creates an executable. The IEC Build results tool window is automatically shown

Run Starts execution of the IEC task

Run on process Displays a dialog where the IEC task can be started on a particular process

Page 4: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Trio Motion Technology

IEC 61131 PrograMMIngLanguages

5-4

Menu Item DescriptionStop Stops execution of the IEC task

Executable info Displays information about executable – timestamps and version

Set AUTORUN Displays a dialog where AUTORUN properties of the task can be specified

Delete Deletes this IEC task

IEC 61131-3 settings Displays IEC task settings window, where the user can modify different properties of the IEC task

IEC PROGRAM

Menu Item DescriptionEdit Opens the selected program for editing

Open local IEC variables

Opens an editor for local program variables

Open IEC variables Opens the IEC variables editor tool, with the selected program variables grouped first

Open IEC types Opens the IEC custom types editor tool

Rename Opens a dialog, where a new name for the selected program can be specified. The program must not be open for editing in order to be renamed

Delete Deletes the selected program from the IEC task

IEC SPY LIST

Menu Item

Description

Edit Opens the selected spy list

Rename Opens a dialog, where a new name for the selected spy list can be specified. The spy list must not be open for editing in order to be renamed

Delete Deletes the selected spy list from the IEC task

DOUBLE CLICK ACTIONDouble clicking on any IEC program or Spy List in the tree will open it for viewing or editing.

LanguagesMotion Perfect v3 supports the following IEC 61131-3 defined languages:

• Ladder Diagram (LD)

• Structured Text (ST)

Page 5: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Software reference Manual

5-5IEC 61131 PrograMMIngThe IEC 61131 Environment

• Function Block Diagram (SFD)

• Sequential Function Chart (SFC)

Each of the languages has its own editor and can interact with the IEC 61131 environment shared between all programs running on the sane IEC 61131 task.

The IEC 61131 EnvironmentTASKSTrio 4 range of Motion Coordinators run programs in a pre-emptive multitasking environment with a limited number of processes. Normally IEC 61131 programs run on a single process (called a task) although it is possible to run more than one task in which case one process per task is used. Each task has its own IEC environment which holds “Task Variables” for that task.

VARIABLESIEC variables are defined as “Local” which only apply to a single program or “Task” which apply to all the variables in a task.

“Task Variables” are not shared between different tasks. IEC 61131 programs which need to share “Task Variables” must all be run in the same task.

�� Run all IEC 61131 programs should be run in the same task unless there is a compelling reason to do otherwise.

During debugging variables can be monitored using task based “Spy Lists”, more than one of which can be defined for the each task.

COMPILATIONWhen an IEC 61131 program is compiled, all the programs in that task are compiled into a single executable entity which can be executed on the controller and controlled using the usual Motion Perfect RUN/STOP/AUTORUN etc. functionality.

Adding a New IEC 61131 Program

ADDING VIA THE “ADD NEW PROGRAM” MENUA new IEC 61131 program can be added to a Motion Perfect project in one of two ways:

1. From the context menu associated with the “Programs” item in the Controller or Project tree, select “New...”

1. From Program main menu, select “New Program...”

The “Add New Program” dialog will be displayed.

Page 6: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Trio Motion Technology

IEC 61131 PrograMMIngadding a new IEC 61131 Program

5-6

If IEC 61131 task is selected, this will add a new empty IEC task to the project.

If one of the IEC 61131 program types is selected the “Select Task” dialog is displayed.

This allows the user to create the program on an existing task (by selecting the task from the list) or a new one (by clicking the “Add New” button).

After selecting a task an closing the dialog the “Add Program” dialog will be displayed.

Page 7: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Software reference Manual

5-7IEC 61131 PrograMMIngadding a new IEC 61131 Program

The fields and options in this dialog are as follows:

Field / Option DescriptionName The name of the new IEC program

Description Optional. Description of the new IEC program

Execution type

Main program The program will be called on each cycle during IEC execution

Sub-program The program will be called by other programs in the IEC task.This type of execution is not allowed for SFC programs.

User defined function block

The program will be custom “User defined function block”

Open variables editor when this dialog is closed

When checked, displays an editor for local variables for the new program. This editor is also available from the context menus of the program

ADDING TO AN EXISTING IEC 61131 TASKTo add a program to an existing IEC task right click on the task in the Controller or Project tree. This will display the “Add Program” dialog.

Page 8: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Trio Motion Technology

IEC 61131 PrograMMIngEditing Programs

5-8

The fields and options in this dialog are as follows:

Field / Option DescriptionName The name of the new IEC program

Description Optional. Description of the new IEC program

Language The IEC 61131 language used for the program

Execution type

Main program The program will be called on each cycle during IEC execution

Sub-program The program will be called by other programs in the IEC task.This type of execution is not allowed for SFC programs.

User defined function block

The program will be custom “User defined function block”

Open variables editor when this dialog is closed

When checked, displays an editor for local variables for the new program. This editor is also available from the context menus of the program

Editing ProgramsTo Edit an IEC program; double click on its entry in the Controller or Project Tree.

All IEC editors support standard edit operations, like CUT,COPY and PASTE. All of the editors support printing, which is available from the toolbar buttons.

When editing a larger program, it is sometimes useful to mark some pieces of code, so the user can easily navigate through the program. For this purpose, all IEC editors support Bookmarks.

Page 9: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Software reference Manual

5-9IEC 61131 PrograMMIngEditing LD Programs

All editors also support Find and Replace functionality. Find and replace window is accessible by pressing the “Ctrl+F” key combination on the keyboard.

All of the editors support drag and drop operations( from other IEC editors, from the variables tool and from spy lists ). All of the editors, except SFC editor, support drag and drop of function blocks from the toolbox.

For information on editing a specific type of IEC program see one of the following:

• Editing ST Programs

• Editing LD Programs

• Editing FBD Programs

• Editing SFC Programs

Editing LD ProgramsIEC 61131-3 LD language is a graphical programming language. Ladder logic is a programming language that represents a program by a graphical diagram based on the circuit diagrams of relay logic hardware.

The language itself can be seen as a set of connections between logical checkers (contacts) and actuators (coils). If a path can be traced between the left side of the rung and the output, through asserted (true or “closed”) contacts, the rung is true and the output coil storage bit is asserted (1) or true. If no path can be traced, then the output is false (0) and the “coil” by analogy to electro-mechanical relays is considered “de-energized”.

Ladder logic has contacts that make or break circuits to control coils.

Each rung of ladder language typically has one coil at the far right.

—( )— A regular coil, energized whenever its rung is closed.

—[ ]— A regular contact, closed whenever its corresponding coil or an input which controls it

The “coil” (output of a rung) may represent a physical output which operates some device connected to the controller, or may represent an internal storage bit for use elsewhere in the program.

Double-clicking on a contact or a coil displays a dialog for selecting the input/output for the element.

Double-clicking on a function/function block displays a dialog for selecting the function/functional block for the element.

The editor contents can be zoomed in and out via the toolbar buttons, or using the shortcut combinations “Ctrl +” for zoom in and “Ctrl -” for zoom out.

The LD editor context menu has the following functionality:

Menu Item ActionSelect variable Displays a dialog for inserting/selecting a variable

Select function Displays a dialog for inserting/selecting function block

Open IEC 61131-3 variables

Open the IEC variables tool

Open IEC 61131-3 types Open the IEC types tool

Page 10: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Trio Motion Technology

IEC 61131 PrograMMIngEditing LD Programs

5-10

Menu Item ActionEdit local program variables

Open local variables editor

Breakpoints Open breakpoints manager window

Toolbox Open toolbox control, from where using drag and drop functions and function blocks can be added to the program

Align coils Align the coils in program

Insert contact before Inserts a contact before the selection

Insert contact after Inserts a contact after the selection

Insert contact parallel Inserts a contact parallel to the selection

Insert coil Inserts new coil

Insert FB before Inserts a new function block before selection

Insert FB after Inserts a new function block after selection

Insert FB parallel Inserts a new function block parallel to selection

Insert Jump Inserts a new jump

Insert Rung Inserts a new rung

Insert comment Inserts a new comment

Insert horizontal line Inserts a new horizontal line

Page 11: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Software reference Manual

5-11IEC 61131 PrograMMIngEditing ST Programs

Editing ST ProgramsIEC 61131-3 ST language is a text-based programming language. It supports most of the traditional procedural programming language paradigms. t is a high level language that is block structured and syntactically resembles Pascal. All of the languages share IEC 61131 Common Elements. The variables and function calls are defined by the common elements so different languages can be used in the same program.

Complex statements and nested instructions are supported:

• Iteration loops (REPEAT-UNTIL; WHILE-DO)

• Conditional execution (IF-THEN-ELSE; CASE)

• Functions (SQRT(), SIN())

The ST editor’s context menu has the following commands:

Menu Entry ActionSelect variable Displays a dialog for inserting/selecting a variable

Select function Displays a dialog for inserting/selecting function block

Open IEC 61131-3 variables

Open the IEC variables tool

Open IEC 61131-3 types Open the IEC types tool

Edit local program variables

Open local variables editor

Breakpoints Open breakpoints manager window

Toolbox Open toolbox control, from where using drag and drop functions and function blocks can be added to the program

Page 12: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Trio Motion Technology

IEC 61131 PrograMMIngEditing FBD Programs

5-12

Editing FBD ProgramsIEC 61131-3 FBD language is a graphical programming language. The FBD editor is a powerful graphical tool that enables you to enter and manages Function Block Diagrams according to the IEC 61131-3 standard. The editor supports advanced graphic features such as drag and drop, object resizing and connection lines routing features, so that you can rapidly and freely arrange the elements of your diagram. It also enables you to insert in a FBD diagram graphic elements of the LD (Ladder Diagram) language such as contacts and coils

A functional block diagram is a block diagram that describes a function between input variables and output variables. A function is described as a set of elementary blocks. Input and output variables are connected to blocks by connection lines. An output of a block may also be connected to an input of another block: Inputs and outputs of the blocks are wired together with connection lines, or links. Single lines may be used to connect two logical points of the diagram:

An input variable and an input of a block

An output of a block and an input of another block

An output of a block and an output variable

The connection is oriented, meaning that the line carries associated data from the left end to the right end. The left and right ends of the connection line must be of the same type.

Double-clicking on a contact or a coil displays a dialog for selecting the input/output for the element.

Double-clicking on a function/function block displays a dialog for selecting the function/functional block for the element.

The editor contents can be zoomed in and out via the toolbar buttons, or using the shortcut combinations “Ctrl +” for zoom in and “Ctrl -” for zoom out.

The FBD editor context menu has the following functionality:

Menu Entry ActionSelect variable Displays a dialog for inserting/selecting a variable

Select function Displays a dialog for inserting/selecting function block

Open IEC 61131-3 variables Open the IEC variables tool

Open IEC 61131-3 types Open the IEC types tool

Edit local program variables Open local variables editor

Breakpoints Open breakpoints manager window

Toolbox Open toolbox control, from where using drag and drop functions and function blocks can be added to the program

Select Enters in selection mode

Add function block Enters in add function block mode

Add variable Enters in add variable mode

Add comment Enters in add comment mode

Add arc Enters in add arc mode

Add corner Enters in add corner mode

Page 13: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Software reference Manual

5-13IEC 61131 PrograMMIngEditing SFC Programs

Menu Entry ActionAdd break Enters in add break mode

Add label Enters in add label mode

Add jump Enters in add jump mode

Add left rail Enters in add left rail mode

Add contact Enters in add contact mode

Add OR Enters in add OR mode

Add coil Enters in add coil mode

Add right rail Enters in add right rail mode

Add rule Enters in add rule mode

Editing SFC ProgramsIEC 61131-3 SFC language is a graphical programming language. Main components of SFC are:

• Steps with associated actions

• Transitions with associated logic conditions

• Directed links between steps and transitions

Steps in an SFC diagram can be active or inactive. Actions are only executed for active steps. A step can be

Page 14: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Trio Motion Technology

IEC 61131 PrograMMIngEditing SFC Programs

5-14

active for one of two motives: (1) It is an initial step as specified by the programmer (2) It was activated during a scan cycle and not deactivated since

The editor contents can be zoomed in and out via the toolbar buttons, or using the shortcut combinations “Ctrl +” for zoom in and “Ctrl -” for zoom out.

The SFC editor context menu has the following functionality:

Menu Entry ActionOpen IEC 61131-3 variables Open the IEC variables tool

Open IEC 61131-3 types Open the IEC types tool

Edit local program variables Open local variables editor

Breakpoints Open breakpoints manager window

Insert step Inserts a new step in the program

Insert transition Inserts a new transition element in the program

Insert init step Inserts an initialization step

Insert jump Inserts a jump element in the program

Renumber Renumbers the steps and transitions, starting from the selected one

Next item Navigates to the next logical element of the program

SFC programs are divided into 2 levels:

LEVEL 1level 1 is the main SFC chart, which describes the steps and transitions and is edited by the SFC editor.

A step represents a stable state. It is drawn as a square box in the SFC chart. At runtime a step can be either active or inactive. All actions linked to the steps are executed depending on the activity of the step. Initial steps represent the initial situation of the chart when program is started. There must be at least one initial step in each SFC chart.They are marked with a double line.

Transitions represent a condition the changes the program activity from one step to another. It is marked by a small horizontal line that crosses a link drawn between the two steps. The condition must be a BOOL expression. Transitions define the dynamic behaviour of the SFC chart, according to the following rules:

A transition in crossed if:

• its condition is TRUE.

• and if all steps linked to the top of the transition (before) are active.

When a transition is crossed:

• all steps linked to the top of the transition (before) are de-activated.

• all steps linked to the bottom of the transition (after) are activated.

DIVERGENCESIt is possible to link a step to several transitions and thus create a divergence. The divergence is represented by a horizontal line. Transitions after the divergence represent several possible changes in the situation of the program.

Page 15: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Software reference Manual

5-15IEC 61131 PrograMMIngEditing SFC Programs

All conditions are considered as exclusive, according to a left to right priority order. It means that a transition is considered as FALSE if at least one of the transitions connected to the same divergence on its left side is TRUE

LEVEL 2level 2 is the code for the actions, transitions and text for notes for level 1 elements

Each level 1 step has 5 level 2 elements, which can be open for editing by double-clicking on the corresponding element.

1. Actions – Simple actions entered as text

2. P1 actions, that can be programmed in ST,LD or FBD, are executed only once when the step becomes active

3. N actions, that can be programmed in ST,LD or FBD, are executed on each cycle while the step is active

4. P0 actions, that can be programmed in ST,LD or FBD, are executed only once when the step becomes inactive

5. Text notes

While a level 2 item is open for editing, the contents of the parent level 1 SFC program is locked for editing. This is done to prevent renumbering or deleting of the parent level 1 element, for which the level 2 editor is open. Once the editing of the level 2 element is complete, and the user closes the child editor, the SFC editor is unlocked and its normal operation is restored.

When editing a level 2 SFC program, an additional combo box will appear in the status bar of the program editor

From this combo box the language of the level 2 element can be chosen. The default is ST. When the language is changed, a prompt will appear, notifying that the current contents of the program will be cleared.

Page 16: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Trio Motion Technology

IEC 61131 PrograMMIngIEC Types Editor

5-16

IEC Types EditorThe types editor tool is an editor, where the user can define, delete and modify custom types. It is a tab panel, which has 3 tabs : one for the IEC structures, one for the IEC enumerated types and one for the IEC bit fields.

STRUCTURES TABThe structures tab displays the custom structure types:

The description of the fields available for editing is the same as for the variables editor tool.

To add a new structure, press the “Insert new structure” button. To delete an existing structure, select it and press the “Delete” key on the keyboard, or press the “Remove” button.

Double-click on a selected structure displays the “Type properties” dialog, where a type name, comment and description can be edited.

To add a new field in an existing structure, press the “Insert” key on the keyboard, or press the “Insert new variable” button. To delete an existing field in a structure, select it and press the “Delete” key on the keyboard, or press the “Remove” button.

ENUMERATED TABThe enumerated tab displays the custom enumerated types:

Page 17: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Software reference Manual

5-17IEC 61131 PrograMMIngIEC Types Editor

This tab editor has 2 columns:

Column DescriptionName The name for the enumerated type

Value A coma separated list of symbolic values which will be the enumerated type values available for use in programs

To add a new enumerated type, press the “Add new IEC type” button. To remove an existing enumerated type, select it and press the “Remove” button.

To edit the name of an existing enumerated type, double-click on the selected type’s Name column in the editor.

To edit the enumerated values, double-click on the selected type’s Value column.

1. BIT-FIELDS TABThe bit-fields tab displays the custom bit-field types:

This tab editor has 2 columns:

Column DescriptionType The name for the bit-field type. Below the name, is the list with bits( number of bits depends

on the base type ). The list can be expanded/collapsed via the “+” button in front of the type name.

Value A combo box with the available base types for the bit-field type. Depending on the base type, the bit-field can have different number of bits. For example, a bit-field, based on INT, has 16 bits. A bit-field, based on SINT, has 8 bits. Each bit can be specified a symbolic name for use in code. For example, user-friendly names can be assigned, like “Shared”, “None”, etc.

To add a new bit-field type, press the “Add new IEC type” button. To remove an existing bit-field type,

Page 18: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Trio Motion Technology

IEC 61131 PrograMMIngProgram Local Variables

5-18

select it and press the “Remove” button.

To edit the name of an existing bit-field type, double-click on the selected type’s Type column in the editor.

To change the base type of the selected bit-field type, use the combo box with available types.

To edit the bit-field names, double-click on the selected bit-field bit in the value column.

Program Local VariablesAll IEC programs have local variables, which are “private” to the programs only. User defined function block programs, have also input and output variables, which are also local program variables.

The editor for the local variables, provides an easy way of adding/removing and setting properties of local variables.

For normal IEC programs, only the “Private variables” are available. For FBD programs additional sections for “Input Variables” and “Output Variables” are available.

Variable Editor

The Variable Editor displays all the variables that are in use in the IEC task. The variables are grouped in variables groups. There are 2 predefined variables groups – the “Task” and “Retain” variables. Then for each IEC program in the IEC task, a variable group with the same name as the program exists.

Variables in the “Task” group are accessible from all programs. The values of the variables in the “Retain” group are stored upon IEC execution stop and are restored upon next start of the IEC executable. The

Page 19: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Software reference Manual

5-19IEC 61131 PrograMMIngVariable Editor

variables in the rest of the groups are “private” for the corresponding program.

A new variable can be added, by selecting the corresponding group, and pressing the “Insert” key on the keyboard. A new variable will be inserted in the selected group and will have default name, type, initial value, etc.

The variable has the following properties, which are separated as columns in the variables editor:

Property DescriptionName The name of the variable. To edit this property, double-click on it.

Type The type of variable. Can be some of the predefined IEC types, or some user-defined type. To edit this property, double-click on it.

Dim Dimensions of the variable. For example, arrays are created by specifying the size of the array in this field. To edit this property, double-click on it.

Attrib Attributes of the variable. Depends on the variable type and profile. For example, an IO-mapped. To edit this property, double-click on it. variable can have the “Read-only” attribute set.

Syb Embed variable symbol. Not supported( On-line change must be enabled ). To edit this property, double-click on it.

Init value The initial value of the variable, depending on its type. To edit this property, double-click on it.

User group The user can specify additional grouping for a variable. To edit this property, double-click on it.

Tag A short comment text for the variable. To edit this property, double-click on it.

Description A long comment text for the variable. To edit this property, double-click on it.

Each variable has a set of properties attached. The properties editing dialog is displayed, when a variable is selected and the properties toolbar button is pressed, of from the context menu for the selected variable.

VARIABLE PROPERTIES EDITING

The Variables Properties dialog provides an editable text box, where the user can change the name of the variable and its mapping (if any) physical memory or I/O on the controller, by selecting one of the binding methods.

Property DescriptionNone default – the variable is not mapped to anything

IO Point the variable can be mapped to a Digital or Analogue Input or Output, by specifying the I/O point index

Page 20: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Trio Motion Technology

IEC 61131 PrograMMIngSelecting or Inserting a Variable

5-20

Property DescriptionTABLE the variable can be mapped to a TABLE location, by specifying the index in the table memory

VR the variable can be mapped to a VR variable, by specifying the index in the VR memory

Selecting or Inserting a VariableThis applies to ST, LD and FBD programs.

When the “Select variable” command is chosen from the context menu, a popup dialog appears in which the user can select an existing variable to replace the variable in the current selection, or to create a new variable. Type the name of the variable into the edit box and, if the variable already exists in the current scope, it will be selected. Pressing the Enter key, or the small green check on the dialog will replace the variable with the selected one. If a variable with the typed name does not already exist, a prompt will appear for creating this variable, setting its type and group.

Selecting or Inserting a Function BlockThis applies to ST, LD and FBD programs.

When the “Select function” command is chosen from the context menu, a popup dialog appears, where the user can select from a list of available functions and function blocks. Type the name or symbol of the function/function block into the edit box and if it exists, it will be selected in the list. Pressing the Enter key or the small green check box will replace/insert the selected function in the editor with the selected

Page 21: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Software reference Manual

5-21IEC 61131 PrograMMIngCompiling

one from the list box.

CompilingWhen the “Build” command is executed, the “IEC 61131-3 Compilation” tool is automatically displayed. It contains a list with the build results from compiling the IEC task into an executable.

If the project compilation have been successful, there should be no errors, and the executable is downloaded on the controller.

If any errors occurred, the error description is displayed as a hint, so the error can be removed by the user.

Double-clicking on an item opens the source editor, relevant to the item. In the example below, double-clicking on the second line( Variable, constant expression or function call expected), will open an editor for the “LADDER1” program, and will position the caret on line 1, column 9 (which is the source of the error).

To show and hide different types of messages, the user can use the “Errors”, “Warnings” and “Messages” buttons respectively.

Page 22: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Trio Motion Technology

IEC 61131 PrograMMIngrunning and Debugging a Program

5-22

Running and Debugging a ProgramWhen an IEC task is compiled, it can be executed by several ways:

1. From the toolbar of the IEC item in the project tree

2. From the context menu of the IEC item in the project tree

3. From the toolbar of some of the IEC programs, belonging to that IEC task

4. From the command line, by typing “RUN <IEC task name>”

5. From a BASIC program, using RUN basic command

It is possible that an IEC task can be started more than once (e.g. from a BASIC program) but this is not a typical scenario. Motion Perfect’s support for IEC programs is designed in a way that only one instance of an IEC task can be debugged at a time. Different IEC tasks can be debugged simultaneously, however, when connecting to a controller with more than one instance of the same IEC task running, Motion Perfect will prompt to which instance the debugger should connect.

It is also possible to set an IEC task to automatically start when the controller boots up, from the context menu of the IEC task, selecting the command “Set AUTORUN”, or using the standard command RUNTYPE.

Spy List windowA spy list window can be opened for each spy list, defined in the IEC task by double-clicking on the spy list in the project tree, or from its context menu.

Page 23: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Software reference Manual

5-23IEC 61131 PrograMMIngIEC Settings

The Spy List is a list of variables and their values:

Column DescriptionName The name of the variable to be spied

Value The current value of the variable being spied

To add a new variable directly to the list of variables, drag and drop from an open editor, or the variables editor, or the structures editor. Alternatively press the “Insert” key on the keyboard or click on the Add Variable button in the toolbar, which will pop-up a dialog allowing the user to select the variable from a list.

To remove a variable from the list, select the variable, and press the “Delete” key on the keyboard.

As spy lists are part of the IEC task, when variables are added to, or removed from a spy list, the IEC task has to be recompiled.

IEC SettingsThe IEC Settings dialog can be accessed from the context menu of task in the Controller or Project Tree. It allows the user to adjust what type of code is generated and how it is run.

Page 24: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Trio Motion Technology

IEC 61131 PrograMMIngIEC Settings

5-24

CODE GENERATIONThe Code Generation setting controls which type of code is produced:

• Debug Code: allows the user to use Spy Lists to view variables and to step through the code in order to debug it. The generated code is larger and will run more slowly than the release code.

• Release Code: contains no debugging information.

EXECUTION MODEThis determines how the code is executed:

• Run as fast as possible: Cycles are executed with the fastest possible speed of the hardware platform.

• Triggered: Cycles are executed with respect to the specified cycle time. The cycle time is the time between 2 consecutive cycles, in milliseconds. If for example, the user wants to execute code twice each second, the cycle timing should be specified as 500 ms( here the time needed for executing the instructions is ignored. In real-world scenarios, more precise timing might be needed )

Page 25: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program

Software reference Manual

5-25IEC 61131 PrograMMIng

Page 26: IEC 61131-3 PROGRAMMING - Multiprojekt 7.5...Software r eference Manual IEC 61131 Progra MMIng 5-3 Controller and Project Trees Introduction to IEC 61131-3 This help file covers program