Lenze DDS User Manual

L
Show/Hide Bookmarks
Manual
Global Drive PLC Developer Studio
Global Drive
Drive PLC Developer Studio
Show/Hide Bookmarks
Important note
The software is supplied to the user as described in this document. Any risks resulting from its quality or use remain the responsibility of the user. The user must provide all safety measures protecting against possible malopera tion.
We do not take any liability for direct or indirect damage, e.g. profit loss, order loss or any loss regarding business.
ã 2005 Lenze Drive Systems GmbH
No part of this documentation may be copi ed or made available to third parties without the explicit written approval of Lenze Drive Systems GmbH.
All information given in this online documentation has been carefully selected and tested for compliance with the hardware and software described. Nevertheless, discrepancies cannot be ruled out. We do not accept any responsibility or liability for any damage that may occur. Any correc tions required will be implemented in subsequent editions.
Windows, Windows NT and MS-DOS are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A a nd/or other coun­tries. IBM and VGA are registered trademarks of International Business Machines, Inc. All other product names are trademarks of the c o rrespondi ng owners.
Version
:
2.3 01/2005
Drive PLC Developer Studio
Show/Hide Bookmarks
Contents
1 Preface and gener al information 1-1...........................................
1.1 About this manual 1-1................................................................
1.1.1 T erminology used 1-1.........................................................
1.2 Applied conventions 1-1...............................................................
2 Introduction 2-1...........................................................
2.1 Function overview 2-1................................................................
2.2 Project co mponents 2-2...............................................................
2.2.1 Project 2-2.................................................................
2.2.2 Organization unit (POU) 2-2.....................................................
2.2.3 Function 2-2................................................................
2.2.4 Function block 2-4............................................................
2.2.5 Program 2-6................................................................
2.2.6 PLC_PRG 2-7...............................................................
2.2.7 System POUs 2-7............................................................
2.2.8 Resources 2-8...............................................................
2.2.9 Libraries 2-8................................................................
2.2.10 Data types 2-8..............................................................
2.2.11 Visualization 2-8.............................................................
2.3 Debugging, online functionality 2-9.......................................................
2.3.1 Debugging 2-9...............................................................
2.3.2 Breakpoint 2-9..............................................................
2.3.3 Single step 2-9..............................................................
2.3.4 Single cycle 2-9..............................................................
2.3.5 Changing values online 2-10.....................................................
2.3.6 Monitoring 2-10..............................................................
2.3.7 Simulation 2-10...............................................................
2.3.8 Log 2-10....................................................................
3 Program example “Traffic light” 3-1...........................................
3.1 Introduction 3-1.....................................................................
3.2 Programming 3-2....................................................................
3.2.1 Starting the DDS 3-2..........................................................
3.2.2 Creating a new project 3-2......................................................
3.2.3 Selecting PLC 3-2............................................................
3.2.4 Creating organization units 3-2...................................................
3.2.5 The organization unit TRAFFICLIGHT 3-3............................................
3.2.6 The organization unit WAIT 3-6...................................................
3.2.7 The main program PLC_PRG 3-8.................................................
3.2.8 Extending the program with an alternative branch 3-11..................................
3.3 Simulation 3-14......................................................................
3.4 Visualization 3-15....................................................................
3.4.1 Creating a new visualization 3-15.................................................
3.4.2 Inserting and configuring elements in the visualization 3-15..............................
3.4.3 Visualization in online mode 3-16..................................................
l DDS EN 2.3
i
Drive PLC Developer Studio
Show/Hide Bookmarks
Contents
4 Programming languages 4-1.................................................
4.1 The standard IEC 61131-3 4-1..........................................................
4.2 Instruction list (IL) 4-2................................................................
4.2.1 Operators and modifiers 4-2.....................................................
4.3 Structured text (ST) 4-4...............................................................
4.3.1 Expressions 4-4..............................................................
4.3.2 Evaluating expressions 4-4.....................................................
4.3.3 Instructions (overview) 4-5......................................................
4.3.4 Assignment operator 4-5.......................................................
4.3.5 Calling a function block in ST 4-6.................................................
4.3.6 RETURN instruction 4-6........................................................
4.3.7 IF instruction 4-6.............................................................
4.3.8 CASE instruction 4-7..........................................................
4.3.9 FOR loop 4-8................................................................
4.3.10 WHILE loop 4-9..............................................................
4.3.11 REPEAT loop 4-10.............................................................
4.3.12 EXIT instruction 4-10...........................................................
4.4 Sequential Function Chart (SFC) 4-11......................................................
4.4.1 Step 4-11...................................................................
4.4.2 Action 4-11..................................................................
4.4.3 Entry and exit action 4-12.......................................................
4.4.4 Transition/transition condition 4-12................................................
4.4.5 Active step 4-12..............................................................
4.4.6 IEC step 4-13................................................................
4.4.7 Qualifiers 4-14...............................................................
4.4.8 Implicit SFC variables 4-15......................................................
4.4.9 SFC flags 4-15...............................................................
4.4.10 Alternative branch 4-17.........................................................
4.4.11 Parallel branch 4-17...........................................................
4.4.12 Jump 4-17..................................................................
4.5 Function block diagram (FBD) 4-18........................................................
4.6 The Continuous Function Chart editor (CFC) 4-19..............................................
4.7 Ladder diagram (LD) 4-20...............................................................
4.7.1 Contact 4-20.................................................................
4.7.2 Coil 4-20....................................................................
4.7.3 Set/Reset coil 4-21............................................................
4.7.4 Function blocks in LD 4-21......................................................
4.7.5 LD as FBD 4-21...............................................................
5 Desktop 5-1..............................................................
5.1 User interface 5-1...................................................................
5.1.1 Menu bar 5-1...............................................................
5.1.2 Tool bar 5-2................................................................
5.1.3 Object Organizer 5-2..........................................................
5.1.4 Vertical screen divider 5-3......................................................
5.1.5 Desktop 5-3................................................................
5.1.6 Message window 5-3.........................................................
5.1.7 Status bar 5-4...............................................................
5.1.8 Shortcut menu 5-4............................................................
ii
DDS EN 2.3
l
Drive PLC Developer Studio
Show/Hide Bookmarks
Contents
5.2 Arrange windows 5-5.................................................................
5.2.1 Commands in the “Window” menu 5-5.............................................
5.3 Basic settings 5-6...................................................................
5.3.1 DDS options 5-6.............................................................
6 Working with projects and objects 6-1.........................................
6.1 Managing projects 6-1................................................................
6.1.1 Commands in the “File” menu 6-1................................................
6.1.2 Commands in the “Project” menu 6-8.............................................
6.1.3 User groups 6-21..............................................................
6.2 Working with objects 6-24..............................................................
6.2.1 Object 6-24..................................................................
6.2.2 Folders 6-25.................................................................
6.2.3 Commands in the shortcut menu 6-25..............................................
6.2.4 Commands in the “Project” menu 6-26.............................................
6.3 Working in online mode 6-32............................................................
6.3.1 Commands in the “Online” menu 6-32..............................................
6.4 Log 6-42...........................................................................
6.4.1 Log characteristics 6-42........................................................
7 Editors 7-1...............................................................
7.1 General edit functions 7-1.............................................................
7.1.1 Commands in the “Edit” menu 7-1................................................
7.2 Declaration editor 7-10.................................................................
7.2.1 Declaration part 7-11...........................................................
7.2.2 Input variables 7-11............................................................
7.2.3 Output variables 7-11..........................................................
7.2.4 Input / output variables 7-12.....................................................
7.2.5 Local variables 7-12...........................................................
7.2.6 Retentive variables 7-12........................................................
7.2.7 Constants, typed literals 7-13....................................................
7.2.8 Retentive constants 7-13........................................................
7.2.9 Keywords 7-13...............................................................
7.2.10 Identifiers 7-14...............................................................
7.2.11 Variable declaration 7-14........................................................
7.2.12 AT declaration 7-15............................................................
7.2.13 Syntax colouring 7-15..........................................................
7.2.14 Short mode 7-16..............................................................
7.2.15 Auto declaration 7-16..........................................................
7.2.16 Line numbers in the declaration editor 7-18..........................................
7.2.17 Declarations as tables 7-18......................................................
7.2.18 Declaration editor in online mode 7-19..............................................
7.2.19 Comment 7-19...............................................................
7.3 Text editors 7-22.....................................................................
7.3.1 Commands in the “Insert” menu 7-22..............................................
7.3.2 Text editors in online mode 7-23..................................................
7.3.3 Breakpoint positions 7-24.......................................................
7.3.4 What happens at a breakpoint? 7-25...............................................
7.3.5 Line numbers of the text editor 7-25...............................................
l DDS EN 2.3
iii
Drive PLC Developer Studio
Show/Hide Bookmarks
Contents
7.4 Network editors (general) 7-26...........................................................
7.4.1 Jump labels 7-26.............................................................
7.4.2 Network comments 7-26........................................................
7.4.3 Inserting a new network 7-26....................................................
7.4.4 Inputs/Outputs on the fly 7-27....................................................
7.4.5 Network editors in online mode 7-28...............................................
7.5 Function block diagram editor 7-29.......................................................
7.5.1 Cursor positions in FBD 7-29.....................................................
7.5.2 Placing the cursor 7-30.........................................................
7.5.3 Commands in the “Insert” menu 7-30..............................................
7.5.4 Commands in the “Extras” menu 7-33..............................................
7.5.5 Commands in the “Edit” menu 7-34................................................
7.5.6 The FBD editor in online mode 7-35................................................
7.6 Ladder diagram editor 7-36.............................................................
7.6.1 Cursor positions in LD 7-36......................................................
7.6.2 Commands in the “Insert” menu 7-37..............................................
7.6.3 Organization units with EN inputs 7-38..............................................
7.6.4 Commands in the “Extras” menu 7-39..............................................
7.6.5 The LD in online mode 7-41......................................................
7.7 CFC editor 7-42......................................................................
7.7.1 Cursor positions in CFC 7-43.....................................................
7.7.2 Selecting elements 7-43........................................................
7.7.3 Copying and deleting elements 7-43...............................................
7.7.4 Moving elements 7-44..........................................................
7.7.5 Commands in the “Insert” menu 7-44..............................................
7.7.6 Commands in the “Extras” menu 7-46..............................................
7.7.7 Creating connections 7-48.......................................................
7.7.8 Changing connections 7-49......................................................
7.7.9 Deleting connections 7-49.......................................................
7.7.10 Feedbacks 7-50..............................................................
7.7.11 Processing sequence 7-50.......................................................
7.7.12 Commands in the “Extras” menu, submenu “Order” 7-51................................
7.7.13 CFC in online mode 7-55........................................................
7.8 SFC editor 7-56......................................................................
7.8.1 Selecting blocks 7-56..........................................................
7.8.2 Commands in the “Insert” menu 7-57..............................................
7.8.3 Commands in the “Extras” menu 7-59..............................................
7.8.4 Commands in the “Project” menu 7-63.............................................
7.8.5 SFC flags 7-63...............................................................
7.8.6 Sequential function chart in online mode 7-65........................................
8 Resources 8-1............................................................
8.1 Global variables 8-2..................................................................
8.1.1 Several variable lists 8-2.......................................................
8.1.2 Document template 8-3........................................................
8.2 Code initialization values 8-4...........................................................
8.3 Parameter monitor 8-6................................................................
8.3.1 System codes/User codes 8-7...................................................
8.3.2 Parameterizing codes 8-7......................................................
8.3.3 Differentiating between online and o ffl ine mode 8-7...................................
iv
DDS EN 2.3
l
Drive PLC Developer Studio
Show/Hide Bookmarks
Contents
8.4 Parameter Manager 8-8...............................................................
8.4.2 Terminology used by the Parameter Manager 8-10.....................................
8.4.3 Instance Parameter Manager 8-11.................................................
8.4.4 Type Parameter Manager 8-18....................................................
8.4.5 Scale functions 8-18...........................................................
8.5 Process image 8-20...................................................................
8.5.1 Generating the process image 8-21................................................
8.6 PLC configuration 8-23.................................................................
8.6.1 Working in the PLC configuration 8-24..............................................
8.6.2 Touch probe interface 8-26......................................................
8.6.3 Configuring an I/O module 8-26...................................................
8.6.4 Configuring a channel 8-26......................................................
8.7 Task monitor 8-28....................................................................
8.8 Task configuration 8-29................................................................
8.8.1 Task definition 8-29............................................................
8.8.2 Data consistency 8-30..........................................................
8.8.3 Normal data processing/IPO principle 8-30...........................................
8.8.4 If a task overflow leads to a system error 8-31........................................
8.8.5 Task declaration 8-31..........................................................
8.8.6 Working in the task configuration 8-32..............................................
8.9 Watch and Receipt Manager 8-35.........................................................
8.9.1 Watch and Receipt Manager in offline mode 8-35......................................
8.9.2 Watch and Receipt Manager in online mode 8-36......................................
8.9.3 Command overview 8-36........................................................
8.10 Target Settings 8-38...................................................................
8.11 Library Manager 8-41.................................................................
8.11.1 Library Manager window 8-41....................................................
8.11.2 Included libraries 8-43..........................................................
8.11.3 User-defined libraries 8-43......................................................
9 Visualization 9-1...........................................................
9.1 Inserting visualization elements 9-2......................................................
9.1.1 Commands in the “Insert” menu 9-2..............................................
9.2 Editing visualization elements 9-5........................................................
9.2.1 Information in the status bar 9-5.................................................
9.2.2 Expressions 9-5..............................................................
9.2.3 Selecting visualization elements 9-6...............................................
9.2.4 Changing size and shape of visualization elements 9-7.................................
9.2.5 Moving visualization elements 9-7................................................
9.2.6 Copying, cutting, inserting visualization elements 9-7..................................
9.2.7 Deleting visualization elements 9-7...............................................
9.2.8 Commands in the “Extras” menu 9-8..............................................
9.3 Configuring visualization elements 9-10....................................................
9.3.1 Commands in the “Extras” menu 9-10..............................................
9.3.2 Formatted text display 9-14......................................................
9.4 Visualization in libraries 9-21............................................................
l DDS EN 2.3
v
Drive PLC Developer Studio
Show/Hide Bookmarks
Contents
10 IEC 61131-3 data types 10-1..................................................
10.1 Standard data types 10-1...............................................................
10.1.1 BOOL 10-1..................................................................
10.1.2 Integer data types 10-1.........................................................
10.1.3 REAL and LREAL 10-1..........................................................
10.1.4 String 10-2..................................................................
10.1.5 Time data types 10-2...........................................................
10.2 Defined data types: 10-2...............................................................
10.2.1 Array 10-2...................................................................
10.2.2 Pointers 10-4................................................................
10.2.3 Enumeration type 10-5.........................................................
10.2.4 Structures 10-6...............................................................
10.2.5 References 10-7..............................................................
10.2.6 Subrange types 10-7...........................................................
11 Operator list 11-1...........................................................
11.1 DDS-integrated IEC operators 11-1........................................................
11.2 Standard.lib-integrated IEC operators 11-3..................................................
12 IEC 61131-3 operators 12-1...................................................
12.1 Arithmetic operators 12-1...............................................................
12.1.1 ADD 12-1...................................................................
12.1.2 MUL 12-1...................................................................
12.1.3 SUB 12-1...................................................................
12.1.4 DIV 12-1....................................................................
12.1.5 MOD 12-3...................................................................
12.1.6 INDEXOF 12-3................................................................
12.1.7 SIZEOF 12-4.................................................................
12.2 Bit-string operators 12-4...............................................................
12.2.1 AND 12-4...................................................................
12.2.2 OR 12-5....................................................................
12.2.3 XOR 12-5...................................................................
12.2.4 NOT 12-5...................................................................
12.3 Bit-shift operators 12-6................................................................
12.3.1 SHL 12-6...................................................................
12.3.2 SHR 12-6...................................................................
12.3.3 ROL 12-6...................................................................
12.3.4 ROR 12-7...................................................................
12.4 Selection operators 12-8...............................................................
12.4.1 SEL 12-8....................................................................
12.4.2 MAX 12-8...................................................................
12.4.3 MIN 12-9...................................................................
12.4.4 LIMIT 12-9..................................................................
12.4.5 MUX 12-10...................................................................
12.5 Comparison operators 12-10.............................................................
12.5.1 GT 12-10....................................................................
12.5.2 LT 12-11.....................................................................
vi
DDS EN 2.3
l
Drive PLC Developer Studio
Show/Hide Bookmarks
Contents
12.5.3 LE 12-11.....................................................................
12.5.4 GE 12-11....................................................................
12.5.5 EQ 12-11....................................................................
12.5.6 NE 12-11....................................................................
12.6 Addressing operators 12-12..............................................................
12.6.1 ADR 12-12...................................................................
12.6.2 Contents operator 12-12.........................................................
12.7 Call operator 12-12....................................................................
12.7.1 CAL 12-12...................................................................
12.8 Assignment operator 12-13..............................................................
12.8.1 MOVE 12-13..................................................................
13 IEC 61131-3 operands 13-1...................................................
13.1 Constants 13-1......................................................................
13.1.1 Number constants 13-1.........................................................
13.1.2 BOOL constants 13-1...........................................................
13.1.3 TIME constants 13-1...........................................................
13.1.4 DATE constants 13-2...........................................................
13.1.5 TIME_OF_DAY constants 13-2....................................................
13.1.6 DATE_AND_TIME-Konstanten 13-2................................................
13.1.7 REAL and LREAL constants 13-3..................................................
13.1.8 STRING constants 13-3.........................................................
13.1.9 Type constants (Typed Literals) 13-3...............................................
13.2 Variables 13-4.......................................................................
13.2.1 System variable 13-4...........................................................
13.2.2 Access to variables of arrays, structures and organization units 13-4........................
13.2.3 Addressing bits in variables 13-4..................................................
13.2.4 Identifiers 13-4...............................................................
13.3 Addresses 13-5......................................................................
13.3.1 Address 13-5................................................................
13.3.2 Flags 13-6..................................................................
13.4 Function calls 13-7...................................................................
14 IEC 61131-3 standard functions 14-1...........................................
14.1 Type conversion functions 14-2..........................................................
14.1.1 Converting between integer number types 14-2.......................................
14.1.2 BOOL_TO 14-2...............................................................
14.1.3 TO_BOOL 14-3...............................................................
14.1.4 TIME_TO / TIME_OF_DAY 14-3....................................................
14.1.5 DATE_TO / DT_TO 14-4.........................................................
14.1.6 STRING_TO 14-4..............................................................
14.1.7 TRUNC 14-4.................................................................
14.2 Numerical functions 14-5...............................................................
14.2.1 ABS 14-5...................................................................
14.2.2 SQRT 14-5..................................................................
14.2.3 LN 14-5....................................................................
14.2.4 LOG 14-5...................................................................
14.2.5 EXP 14-5....................................................................
l DDS EN 2.3
vii
Drive PLC Developer Studio
Show/Hide Bookmarks
Contents
14.2.6 SIN 14-6....................................................................
14.2.7 COS 14-6...................................................................
14.2.8 TAN 14-6...................................................................
14.2.9 ASIN 14-6...................................................................
14.2.10 ACOS 14-6..................................................................
14.2.11 ATAN 14-7...................................................................
14.2.12 EXPT 14-7...................................................................
14.3 STRING functions 14-7.................................................................
14.3.1 LEN 14-7...................................................................
14.3.2 LEFT 14-7...................................................................
14.3.3 RIGHT 14-8..................................................................
14.3.4 MID 14-8...................................................................
14.3.5 CONCAT 14-8................................................................
14.3.6 INSERT 14-8.................................................................
14.3.7 DELETE 14-9.................................................................
14.3.8 REPLACE 14-9................................................................
14.3.9 FIND 14-9...................................................................
14.4 Bistable function blocks 14-10............................................................
14.4.1 SR 14-10....................................................................
14.4.2 RS 14-10....................................................................
14.4.3 SEMA 14-11..................................................................
14.5 Edge detection 14-12...................................................................
14.5.1 R_TRIG 14-12.................................................................
14.5.2 F_TRIG 14-13.................................................................
14.6 Counters 14-14.......................................................................
14.6.1 CTU 14-14...................................................................
14.6.2 CTD 14-14...................................................................
14.6.3 CTUD 14-15..................................................................
14.7 Timers 14-16.........................................................................
14.7.1 TP 14-16.....................................................................
14.7.2 TON 14-17...................................................................
14.7.3 TOF 14-18...................................................................
15 Appendix 15-1.............................................................
15.1 Command line commands 15-1..........................................................
15.2 Command file (Cmdfile) commands 15-2....................................................
15.3 IEC keywords 15-5....................................................................
15.4 Key combinations and function keys 15-7...................................................
15.5 Error messages 15-10..................................................................
15.5.1 Warnings 15-10................................................................
15.5.2 Compile errors 15-11...........................................................
15.5.3 Communication errors 15-20......................................................
15.5.4 System-oriented communication error 15-22..........................................
15.6 Glossary 15-23.......................................................................
16 Index 16-1................................................................
viii
DDS EN 2.3
l
Drive PLC Developer Studio
Show/Hide Bookmarks
Preface and general information

1 Preface and general information

1.1 About this manual

This Manual offers detailed information on the Drive PLC Developer Studio (DDS).
The Drive PLC Developer Studio is a powerful development environment for your PLC programs on Lenze IEC 61131 systems.
The Drive PLC Developer Studio utilizes the powerful IEC language tools, offering individual editors for the six IEC 61131-3 languages as well as commissioning support through monitoring and debugging functions. The Drive PLC Developer Studio provides all the comfort and ease of fully matured development environments offered by higher-level programming languages under Windows.

1.1.1 Terminology used

Term In the following text used for DDS Drive PLC Developer Studio GDC Global Drive Control
GDO Global Drive Oscilloscope (for servo PLC devices) SB System block FB Function block Parameter codes Codes for setting the functionality of function blocks

1.2 Applied conventions

This Manual applies the following conventions to distinguish between different types of information:
Type of information Print Example
Names of dialog boxes, input fields and selection lists
Buttons bold Click OK to... Menu commands bold Use the command Messages to ...
Keyboard commands <fett> Use <F2> to open the Help Manager.
Program listings Courier IF var1 < var2 THEN... Keywords Courier bold ...starts with FUNCTION and ends with END FUNCTION. Important note Caution!
italics The dialog box Options
(parameter setting program for Lenze PLCs/Lenze automation systems)
If the execution of a function requires several commands, the individual commands are separated by an arrow: Select File
If a command requires a combination of keys, a ”+” is placed between the key symbols: Use <Shift>+<ESC> to ...
Do not use the command Online PC since this command reaches the controller with a time delay.
WOpen to...
WController inhibit for an emergency stop through the
l DDS EN 2.3
Tip TIP!
Positioning the mouse pointer briefly over an icon in the tool bar will display a ”tool tip” with the associated command.
1-1
Drive PLC Developer Studio
Show/Hide Bookmarks
Preface and general information
1-2
DDS EN 2.3
L

2 Introduction

Show/Hide Bookmarks

2.1 Function overview

Project structure
The project is saved in a file that is named after the project. The first organization unit created in the new project is automatically called PLC_PRG. Other
organization units (programs, function blocks and functions) can be called from here. The DDS uses the Object Organizer to differentiate between the different object types within a
project:
Organization units
Data types
Visualization elements (visualization)
Resources.
Object Organizer
The
following objects, among others:
Libraries
Codes
Task configurations
etc.
allows fast access to all objects of your project. Resource structuring uses the
Drive PLC Developer Studio
Introduction
Project generation
Addresses not included in the PLC configuration cannot be used. First configure the control to facilitate access to the system organization units during programming. Then generate the organization units required for your application, or copy them from existing
projects. Program the required organization units in the desired language. On completion of the programming process, compile the project and eliminate any reported errors.
Simulation with the DDS
Once allerrors have been eliminated, activate the simulation, log in to the simulated control and start the project. The DDS is now in online mode.
The window with the PLC configuration can now be opened, and the project can be checked for correct operation. For this purpose, assign the inputs manually and check that the outputs are set as required. The organization units also allow a monitoring of local variable current values. Use the Watch and Receipt Manager to configure the data records to be monitored.
Note!
Lenze function blocks are not simulated. Simulation is generally restricted.
Debugging with the DDS
In the event of a programming error, breakpoints can be set. If program execution stops at a breakpoint, the values of all project variables as at that time can be inspected. Logical correctness of the program can be checked by step-by-step processing (single-stepping).
Program variables and inputs / outputs can be set to specific values.
(^ 6-37)
l DDS EN 2.3
Project documentation using the DDS
The entire project can be documented or exported to a text file at any time.
2-1
Drive PLC Developer Studio
Show/Hide Bookmarks
Introduction

2.2 Project components

2.2.1 Project

A project includes all objects of a control program. Links with the libraries are saved in a file bearing the project name.
A project includes the following objects that can be accessed via the Object Organizer:
Organization units
Data types
Visualizations
Resources
LibrariesCodes

2.2.2 Organization unit (POU)

Functions, function blocks and programs are organization units of a project and referred to as program organization units (POU) in the IEC 61131 programming language.
Every organization unit consists of a declaration part and a body. The body is written in one of the IEC programming languages (IL, ST, SFC, FBD, LD or CFC).
The DDS supports all IEC standard organization units as well as Lenze-specific organization units. Use of these organization units in your project requires the associated function library to be linked to your project with the help of the Library Manager.
Organization units can call other organization units. Recursions cause a compiler error and must be avoided.

2.2.3 Function

A function is asoftware organization unit that returns exactly one data element (that may also consist of several elements such as fields or structures, for example) on execution and whose call may occur in textual languages as an operator in expressions.
Note when declaring a function that a type must be assigned to the function, i.e. the function name must be followed by a colon plus type.
The names of function and function output are identical.
Example of a correct function declaration:
FUNCTION Fct: INT
A function declaration starts with the keyword FUNCTION.
A result must be assigned to the function, i.e. the function name is used like an output
variable.
In ST, a function call may occur as an operand in expressions.
Functions cannot save their internal statuses. Function calls using the same input parameters
always return the same value.
No functions can be programmed in SFC.
2-2
DDS EN 2.3
l
Drive PLC Developer Studio
Show/Hide Bookmarks
Introduction
Function CheckBounds
Tip!
Definition of a function with the name CheckBounds in your project will automatically check whether the boundaries have been exceeded on access to an array in your project! (refer example below). Also refer the Checkbound library (Checkbound.lib).
The function name is defined and must not be changed.
The following program example to test the CheckBoundsfunction corrects access outside defined array boundaries.
The function CheckBounds ensures that the value TRUE is not assigned to position A[10],butto the upper permissible range limit A[7].
Use the function CheckBounds to correct accesses outside array boundaries.
2.2.3.1 Example of a function
Example of a function in IL: Example of the function call of the function shown on the left:
IL LD 7
Fct 4,2 ST result
ST result := Fct(7, 4, 2);
FBD
l DDS EN 2.3
2-3
Drive PLC Developer Studio
Show/Hide Bookmarks
Introduction

2.2.4 Function block

A function block is a software organization unit whose execution returns one or several values.
Unlike a function, a function block does not supply a return value.
A function block declaration starts with the keyword FUNCTION_BLOCK.
The creation of instances (data records) of a function block is a prerequisite.
2.2.4.1 Function block instances
Every instance has its own identifier (instance name) and a data structure which includes its
inputs, outputs and internal variables.
Instances are locally or globally declared like variables by giving the function block name as
identifier type.
Example of an instance named INSTANZ of function block FUB:
INSTANZ: FUB;
The instances described above are always used to call function blocks.
Only input and output parameters can be accessed from outside an instance of a function
block, not its internal variables.
Example with the help of a data model:
Instances L_ABS1 ... L_ABSn are instances of the function block type L_ABS. Instance as many instances as required.
2-4
DDS EN 2.3
l
Drive PLC Developer Studio
Show/Hide Bookmarks
Introduction
Example of access to an input variable:
(* The function block fb has an input variable in1 of type int. *) PROGRAM prog VAR
inst1:fb;
END_VAR
LD 17 ST inst1.in1 CAL inst1
END_PROGRAM
The declaration parts of function blocks and programs may contain instance declarations.
Instance declarations are not allowed in functions. A function cannot call a function block.
Access to the instance of a function block is restricted to the organization unit in which it was
instanced, unless it was globally declared. Function blocks should never be globally declared as this would lead to logical errors.
The instance name of a function block may be used as input for a function or a function
block.
Counter
bExecute
byNodeAdr
byAnalogModuleNr
byFunction_CH1
byFunction_CH2
L_IOParCounterModule
CTRL
nState
EPM-T110
Ixxxh
Counter is the instance name of function block L_IOParCounterModule and can be used as input in the code.
PROGRAM Counter VAR
Counter: DINT;
END_VAR
Note!
All values remain the same from one execution of the function block to the next. Therefore function block calls with the same arguments do not necessarily return the same output values!
Should the function block include at least one Retain variable, the whole instance is stored in the Retain area.
2.2.4.2 Calling a function block
The input and output variables of a function block can be approached by another organization unit. For this purpose, a function block instance must be generated and the desired variable specified with the help of the following syntax:
<Instance name>.<Variable name>
Input writes only
Input and output reads
To set the input parameters on call in the IL and ST text languages, assign values to the
parameters in brackets after the function block instance name (assignment via := as for the initialization of variables at the point of declaration).
Tip!
SFC allows function block calls in steps only.
l DDS EN 2.3
2-5
Drive PLC Developer Studio
Show/Hide Bookmarks
Introduction
Declaration part: Instruction part:
PROGRAM test VAR
quad: BOOL; instanz: fub; value: INT:=0;
END_VAR

2.2.5 Program

A program is an organization unit that returns one or several values on execution.
A program declaration starts with the keyword PROGRAM.
Programs are known globally throughout the entire project.
Programs can be called by programs and function blocks. Program calls in a function are not
allowed. Programs do not have instances.
If an organization unit calls a program, thus changing program values, these changes remain
active for the next program call, even if the program is called by another organization unit.
IL CAL instanz(par1:=5,par2:=5)
LD instanz.varout2 ST quad LD instanz.varout1 ST value
ST instanz(par1:=5,par2:=5);
quad:=instanz.varout2; value:=instanz.varout1;
FBD
Tip!
Only the values in the associated instance of a function block are changed on function block call.
These changes are significant only if the same instance is called.
2.2.5.1 Program example
Example of a program in IL: Examples of calling the program shown on the left:
Example of a possible call sequence from a main program:
LD 0 ST PRGexample.par (* par is preset with 0 *) CAL AWLexample (* result in AWLexample=1*) CAL STexample (* result in STexample=2*) CAL FUPexample (* result in FUPexample=3*)
If the variable par of the program PRGexample is initialized with 0 from the main program, and programs are then called successively
by means of the above program calls, the
Changing the call sequence will also change the values of the associated result parameters.
IL CAL PRGexample
LD PRGexample.par ST result
ST PRGexample;
result:=PRGexample.par;
FBD
result will have the values 1, 2, and 3 in the programs.
Note!
The string length is limited by the applied automation system.
2-6
DDS EN 2.3
l
Drive PLC Developer Studio
Show/Hide Bookmarks
Introduction
Restrictions occur through limited lengths in the string routines. Only 20 characters can be processed before the string is cut.
The example below illustrates the restriction in online mode.

2.2.6 PLC_PRG

PLC_PRG is a special predefined organization unit for a cyclical task. This organization unit is called exactly once per control cycle.
If Project
dialog box Program. This pre-assignment should not be changed!
Insert object is run for the first time after a new project has been created, the
➞➞
Organization unit
Caution!
Do not delete or rename the organization unit PLC_PRG if you do not use a task configuration. Do not attach PLC_PRG to an already created task as PLC_PRG will then be called several times, leading to logical errors.
PLC_PRG is generally the main program in a single task program.

2.2.7 System POUs

System POUs are hardware-dependent POUs (program organization units) with special functions which are provided by the associated PLC (e.g. 9300 Servo PLC, Drive PLC). (Also refer associated PLC manual)
is pre-assigned with an organization unit called PLC_PRG of type
l DDS EN 2.3
2-7
Drive PLC Developer Studio
Show/Hide Bookmarks
Introduction

2.2.8 Resources

Resources are required to configure and organize your project and to trace variable values:
Global variables to be used throughout the entire project.
PLC configuration to configure your hardware.
Task configuration to control your program through tasks.
Task monitoring to monitor the task runtimes.
Watch and Receipt Manager to display and pre-assign variable values
Automation system settings for selection and, if appropriate, for final configuration of the
automation system

2.2.9 Libraries

The Library Manager can link your project to several libraries whose organization units, data types and global variables can be used in addition to the user-defined ones.
The register card Global Variables contains the variable
Depending on the selected PLC, some libraries are automatically linked when a new project is created (the library standard.lib, for example).

2.2.10 Data types

In addition to the standard data types, users can define some data types of their own. Structures, enumeration types and references can be created.

2.2.11 Visualization

The DDS provides visualization to monitor and modify project variables. The visualization allows offline drawing of geometrical elements that can then change their
shape/colour/text output online, depending on certain variable values.
g_ErrorCheckBounds
.
2-8
DDS EN 2.3
l
Drive PLC Developer Studio
Show/Hide Bookmarks

2.3 Debugging, online functionality

2.3.1 Debugging

The DDS debugging functions assist troubleshooting.
Introduction
To allow debugging, go to dialog box
Debugging.
Note!
The check box Debugging should be ticked for debugging only. Breakpoint on, Single step or Single cycle are possible only if Debugging is active.

2.3.2 Breakpoint

A breakpoint is a point in the program where processing stops.
Breakpoints enable the user to look at variable values at a certain program location.
Breakpoints can be set in all editors. In the text editors, breakpoints are set to line numbers,
in FBD and LD to network numbers, in CFC to organization units, and in SFC to steps.
Breakpoints may be set in the implementation of an initialized function block. No breakpoints
may be set in function block instances.

2.3.3 Single step

Single step means in:
Options
, category
Build options
and tick check box
IL: Execute program to next CAL, LD or JMP command.
ST: Execute next instruction.
FBD, LD: Execute next network.
SFC: Execute action to next step.
CFC: Execute next organization unit (box) in the CFC program.
The logical correctness of a program can be checked by step-by-step processing.

2.3.4 Single cycle

Selection of Single cycle will stop processing after every cycle.
Caution!
If a breakpoint isset, the useof tasks will lose the real-time response. A 1ms-cycle task will no longer be started every millisecond. If breakpoints are set, all tasks will be started one after the other after the main program PLC_PRG has been processed. Event-controlled tasks will be started upon a valid start event only. This, among other aspects, influences the functionality of the generated overall project.
l DDS EN 2.3
2-9
Drive PLC Developer Studio
Show/Hide Bookmarks
Introduction

2.3.5 Changing values online

Variables can be set once-only to a specific value during operation after the command Write values was transmitted to the control. The value of a variable can also be changed online by simply double-clicking it. Boolean variables thus change from TRUE to FALSE and viceversa. For the other variables, the system will display a dialog box

2.3.6 Monitoring

In online mode, the current valuesfor all variables displayed on screen will be continuously read from the control and displayed. Refer declaration and program editor for this display.
Current variable values may be output in the Watch and Receipt Manager and in a visualization. The display and monitoring of variables from function block instances requires the associated
instance to be opened. The implementations show the pointer value. The dereferenced value is shown for dereferenced
variables.
Monitoring VAR_IN_OUT variables
When monitoring VAR_IN_OUT variables, the de-referenced value is output in the declaration part and the program part.
Write variable xy
to edit the variable value.
Monitoring Pointers
Warning!
Monitoring of de-referenced pointer values is not supported by all Lenze target systems. In online mode, it depends on the target system which de-referenced pointer values (pointer
variable^ ) are indicated. Some Lenze target systems indicate the pointer value itself.
During monitoring the pointer and the de-referenced value are output in the declaration part. In the program part, only the pointer is output.
pointervariable= <pointer value>
Pt= <value>
The value of the pointer is indicated in the implementations, whereas in the case of de-referencing only the de-referenced value is indicated.
Monitoring ARRAY components
The following components are displayed:
Array components indexed via a constant. anarray[1] = 5
The following components are not displayed:
Array components with extended index. anarray[i+j] = 5 or anarray[i+1] = 5

2.3.7 Simulation

During a simulation onthe processor,the generated control program will be processed together with the DDS, offering complete online functionality. Thelogical correctness of the program can be tested to a limited extent only without control hardware.

2.3.8 Log

The log records user actions, internal processes, status changes and exceptions chronologically in online mode and serves monitoring and error tracing.
2-10
DDS EN 2.3
(^ 6-37)
(^ 6-42)
l
Drive PLC Developer Studio
Show/Hide Bookmarks
3 Program example “Traffic light”

3.1 Introduction

This chapter includes a program tutorial for an easier start with the DDS.
The setup calls for the programming of a mini traffic control system for two traffic lights at an intersection.
Both traffic lights will alternate their red/green phases.
To avoid accidents, the traffic lights will also include amber and amber/red between the red
and green phases, with the amber/ red phase being shorter than the amber phase.
This example illustrates
how to implement time-controlled programs using IEC 61131-3 language tools.
how to edit the various standard languages using the DDS.
how to link the different languages.
how to simulate a program in the DDS and visualize it on screen.
Program example
l
DDS EN 2.3
3-1
Drive PLC Developer Studio
Show/Hide Bookmarks
Program example

3.2 Programming

3.2.1 Starting the DDS

1. In the Windows Start menu, select submenu
Programs➞➞➞LenzeWDrive PLC Developer Studio and click Drive PLC Developer Studio to
start the DDS.
Tip!
If under Project➞➞➞Options, category the project last edited is opened automatically on DDS start.

3.2.2 Creating a new project

2. Select File➞➞➞New to create a new project.
Load & Save
, the check box Automatic loading is selected,

3.2.3 Selecting PLC

3. Open dialog box Configuration (e.g.the9300 Servo PLC) and confirm with OK:
Automation system settings

3.2.4 Creating organization units

4. The dialog box do not change name and type of the organization unit (Program).
New POU
already displays the name of the first organization unit as PLC_PRG;
and select a PLC from the combination box
3-2
DDS EN 2.3
l
Drive PLC Developer Studio
Show/Hide Bookmarks
Program example
Tip!
Only the organization unit named PLC_PRG of type Programwill be processed by the cyclical task. The cyclical task does not need to be explicitly created.
5. Select Sequential function chart (SFC) as the language for this organization unit and confirm with OK.
6. Now create two further objects in the of Project➞➞➞ObjectWInsert:
TRAFFICLIGHT type Function block in the language Function block diagram (FBD)WAIT type Function block in the language Instruction list (IL)
Object Organizer
on tab
Organization units
with the help
TRAFFICLIGHT
In the organization unit TRAFFICLIGHT, the individual light phases will be assigned to the traffic lights, i. e., the red light will be on during the red and amber/red phases, the amber light will be on during the amber and amber/ red phases, etc.
WAIT
In the organization unit WAIT, a simple timer will be programmed to receive as input the phase duration in milliseconds and to return an output TRUE as soon as the time has expired.
PLC_PRG
The organization unit PLC_PRG links the organization units with each other so that the traffic light emits the correct colour at the correct time and for the specified time. It processes the entire project during the cyclical task.

3.2.5 The organization unit TRAFFICLIGHT

7. To edit the organization unit TRAFFICLIGHT, activate its editor window by selecting
Object Organizer
,tab
Organization units
and double-clicking TRAFFICLIGHT.
3.2.5.1 Declaration
8. In the declaration editor, declare – as input variable (between the keywords VAR_INPUT and END_VAR) a variable named
STATE of type INT.
as output variables (between the keywords VAR_OUTPUT and END_VAR) the variables RED,
AMBER, GREEN and OFF of type BOOL.
l DDS EN 2.3
3-3
Drive PLC Developer Studio
Show/Hide Bookmarks
Program example
Thestatusof thevariableSTATE is used to switch the output variables for the associated light colour:
Traffic light phase Input variable Output variables
STATE RED AMBER GREEN OFF
Green 1 FAL SE FA LSE TRUE FAL SE Amber 2 FALSE TRUE FALSE FAL SE Red 3 TRUE FALSE FALSE FAL SE Amber/red 4 TRUE TRUE FAL SE FALS E Off 5 FALSE FA LSE FALS E TRUE
The declaration part of the function block TRAFFICLIGHT nowlooksasfollows:
3.2.5.2 Function block diagram
Now use the input variable STATE of the organization unit to determine the values of the output variables.
9. In the lower half of the editor window for the organization unit TRAFFICLIGHT, click the field to the left of the first network (grey field with number 1) to select the network.
10.Select Insert➞➞➞Operator.
A box with the operator AND and two inputs is inserted in the first network:
11.Click ANDand change the text to EQ”.
12.Select the text ???of the upper input and enter the variable STATE .
13.Select the three bottom question marks and name the input 1.
3-4
DDS EN 2.3
l
Drive PLC Developer Studio
Show/Hide Bookmarks
14.Click behind the EQ box to select the output.
15.Select Insert➞➞➞Assignment.
16.Change the text ???at the output to GREEN”.
Program example
STATE is compared to 1. If the result is TRUE, GREEN will be assigned.
This network will switch the traffic light to green if the status value input is 1.
The other traffic light colours RED, AMBER and OFF require three more networks.
17.Select Insert➞➞➞Network (after) to create a new network.
18.Select Insert➞➞➞Operator.
19.Click ANDand change the text to OR”.
20.Click behind the OR box to select the output.
21.Select Insert➞➞➞Assignment.
22.Change the text ???at the output to AM BER”.
23.Select the upper input of the OR box and then Insert➞➞➞Operator to insert another operator before the selected input.
l DDS EN 2.3
3-5
Drive PLC Developer Studio
Show/Hide Bookmarks
Program example
24.Use the above procedures and commands to complete the organization unit as follows:
The first organization unit is complete. TRAFFICLIGHT controls the traffic light colours depending on the input of value STATE.

3.2.6 The organization unit WAIT

The organization unit WAIT is to be a timer to control the duration of the different traffic light phases.
25.To edit the organization unit WAIT, activate its editor window by selecting tab
Organization units
and double-clicking WAIT.
3.2.6.1 Declaration
26.In the declaration editor, declare – as input variable (between the keywords VAR_INPUT and END_VAR) a variable named
SETTIME of type TIME.
– as output variable (between the keywords VAR_OUTPUT and END_VAR) a variable named
OK of type BOOL.
27.Pre-assign the output variable OK with FALSE by inserting :=FALSE” at the end of the declaration (but before the ;).
The output variable OK is to output the value TRUE as soon as the time specified with SETTIME has expired. For this function use the organization unit TP, a pulse encoder.
Object Organizer,
3-6
DDS EN 2.3
l
Drive PLC Developer Studio
Show/Hide Bookmarks
Program example
Pulse encoder TP
The pulse encoder TP has two inputs ( IN, PT) and two outputs ( Q, ET).
If at the input IN TRUE is applied, the output Q ,forthetimePT (in milliseconds) will return the
value TRUE.
ET outputs the time already expired in milliseconds.
Input variable Status Output variables Status/value
IN FAL SE
IN TRUE (ET < PT)
IN (ET = PT)
* The output ET counts the t ime in milliseconds.
To use the pulse encoder TP in the organization unit WAIT we must create a local instance of TP :
28.Use the declaration editor to declare as local variable (between the keywords VAR and END_VAR) a variable named DELAY of type TP.
Q FAL SE ET 0 Q TRUE ET 0 ì PT* Q FAL SE ET PT
3.2.6.2 Instruction list
To implement the timer, the instruction list for the organization unit WAIT must be as follows:
l DDS EN 2.3
3-7
Drive PLC Developer Studio
Show/Hide Bookmarks
Program example
Process
The first interrogation establishes whether Q is already set to TRUE ( TRUE: timer running). [
If QisTRUE, we will not change the assignment of DELAY but instead call function block
DELAY without input (to check whether the time has already expired). [
If QisFALSE, we will set the variable IN in DELAY to FALSE and thus at the same time ET
to 0 and Q to FALSE.[ All variables are now set to the desired initial status.
– Now save the time required from variable SETTIME in variable PT [
with IN:= TRUE.[
– In the function block DELAY , the variable ET will now be counted up until it reaches the
value SETTIME ; then Q will be switched to FALSE .
The negated value of Q will be saved after every WAIT cycle in OK [
As soon as Q becomes FALSE, OK becomes TRUE.
The timer is complete.

3.2.7 The main program PLC_PRG

Line 4
Line 7
]
]
Line 10
Line 5/6
Line 14/15
Line 1
]
], and call DELAY
]
]
The organization unit PLC_PRG is the main program for calling the two function blocks WAIT and TRAFFICLIGHT .
29.To edit the organization unit PLC_PRG, activate its editor window by selecting
Object Organizer,
tab
Organization units
3.2.7.1 Declaration
To ensure that the function blocks created before can be used inPLC_PRG , it is necessary to declare instances of these function blocks. The traffic light example requires two instances of the function block TRAFFICLIGHT ( LIGHT1, LIGHT2) and one instance of the function block WAIT ( WAIT1).
30.Use the declaration editor to declare as local variable (between the keywords VAR and END_VAR) the variables for the required instances.
3.2.7.2 Sequential function chart
The start-up diagram of an organization unit in SFC always consists of an action Init, a subsequent transition Tr a ns0 and a jump back to Init.
and double-clicking PLC_PRG .
3-8
DDS EN 2.3
l
Loading...
+ 310 hidden pages