infoteam OpenPCSProgramming SystemVersion 4.1 English
User Manual1. Edition
1 OpenPCS 4.1 - Overview
2 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Contents
1 OpenPCS 4.1 - Overview 3
2 Introduction 15
3 The Project Manager 44
4 The POU-Editor 82
5 ControlX Editor 160
6 Ladder Diagram Editor 197
7 The SFC-Editor 246
8 The CFC-Editor 263
9 Introduction into IEC1131 290
10 Forms Editor 391
11 FXF Import/Export 393
12 IEC1131-3 Compliance Statement 399
13 Index 421
1 OpenPCS 4.1 - Overview
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3
1 OpenPCS 4.1 - Overview
You are holding in your hands the user manual to the software OpenPCS, version 4.1. This firstchapter will give you an overview over the structure and contents of this manual.
This manual consists of individual chapters:
OverviewThis chapter, describing contents and structure of the manual
IntroductionA short introduction into the most important tools of OpenPCS, using a short sample.
The Project BrowserManual for the tool “Project Browser”.
POU-EditorManual for the tool “POU-Editor” for programming languages IL, LD, FBD and ST.
SFC-EditorManual for the tool “SFC-Editor” for the programming language Sequential FunctionChart.
OpenCFCManual for the tool “OpenCFC” for the programming language Continuous FunctionChart.
Introduction to IE C1131-3If you never worked with IEC1131 before, consult this chapter.
Forms EditorManual for the tool “forms editor”.
FXF Import/ExportManual for the FXF import- and export-utility.
Compliance Stat ementIEC1131-3 compliance statement.
1.1 More informationYou can’t find what you’re looking for in this manual? There are other sources you can use:
• OpenPCS provides a “help” function. In each tool, there is a menu item “help”. It is easier tosearch for items in the electronic help than in this printed manual
• There are several books on the market, dealing with IEC1131. We recommend the germanbook. "SPS-Programmierung mit IEC 1131-3" from Springer Verlag, ISBN 3-540-62639-5.
• Training on IEC1131 is available from different sources. To get training covering thespecial features of your hardware, consult the vendor of your hardware. The provider ofOpenPCS, infoteam Software GmbH, does offer in-house training seminars on IEC1131 andOpenPCS.
1 OpenPCS 4.1 - Overview
4 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
• If you want to keep track of current developments in IEC1131, think about a membershipwith PLCopen:http://www.plcopen.org/.
• Assistance with individual problems related to the use of OpenPCS is offered by the manu-facturer of OpenPCS, infoteam Software GmbH, solely after advance agreement
• This is the user manual. For manufacturers of programmable controllers, moredocumentation covering internal details, interfaces etc. is available. This additionaldocumentation is not made available to end-users.
1.2 Comprehensive Table of Contents
1 OpenPCS 4.1 - Overview 3
1.1 More information 3
1.2 Comprehensive Table of Contents 4
2 Introduction 15
2.1 Styles and Symbols 15
2.2 Installation 15
2.3 Hardware and Software Requirements 15
2.4 Programming Example 16
2.5 Starting OpenPCS 17
2.6 Create a new project 18
2.7 Creating a Program 192.7.1 The Program Organisation Unit (POU) 192.7.2 The POU-Editor 212.7.3 Syntax controlled declaration editor 222.7.4 Declaring in syntax controlled mode 232.7.5 Entering the Program in IL 242.7.6 Syntax check 252.7.7 Error correction 252.7.8 Print a Program 26
2.8 Defining the Resource 262.8.1 Overview 262.8.2 Adding a resource 282.8.3 Defining a Task 292.8.4 Create the executable program 30
2.9 Test and Commissioning 312.9.1 Overview, SmartSIM 312.9.2 Starting and Stopping the Program 332.9.3 Testing the program 332.9.4 Variable Status 33
2.9.4.1 Watching variables 332.9.4.2 Setting a Variable 35
2.9.5 Program Status 35
2.10 Other Features of OpenPCS 372.10.1 Other programming languages 37
1 OpenPCS 4.1 - Overview
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
5
2.10.1.1 LD Ladder Diagram 372.10.1.2 FBD Function Block Diagram 382.10.1.3 Structured Text ST 382.10.1.4 CFC 39
2.10.2 Block Types 392.10.2.1 FUNCTION 392.10.2.2 FUNCTION_BLOCK 392.10.2.3 PROGRAM 41
2.10.3 Free Declaration Editor 412.10.4 Additional Features of the project browser 42
2.10.4.2 Libraries 422.10.5 Conclusion 42
3 The Project Manager 44
3.1 Introduction 44
3.2 Start of the project browser 45
3.3 Managing projects 463.3.1 Create a new project 463.3.2 Open an existing project 463.3.3 Copying a project 483.3.4 Create a backup copy 483.3.5 Restore a project 493.3.6 Deleting projects 503.3.7 Rename project 50
3.4 The project tree 513.4.1 Libraries 513.4.2 The project directory 51
3.5 Creation of POU- and CFC-Modules 52
3.6 Editing of POU- and CFC-Modules 53
3.7 Global resource variables 533.7.1 Creation of [direct] global variables 543.7.2 Editing of [direct] global variables 54
3.8 Type definitions 553.8.1 Creation of new type definitions 553.8.2 Editing of type definitions 56
3.9 Resources 563.9.1 Creation of a resource 563.9.2 Edit a resource 573.9.3 Adding a task 583.9.4 Adding of [direct] global variables 583.9.5 Adding type definitions 603.9.6 Generate executable code 60
3.10 The Connection Setup tool 623.10.1 About Connection Setup 623.10.2 Components of a connection 623.10.3 Run Connection Setup 623.10.4 Create a new connection 633.10.5 Edit connection properties 653.10.6 Delete a connection 653.10.7 Finish Connection Setup 653.10.8 Select a connection in the browser 65
1 OpenPCS 4.1 - Overview
6 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.11 Libraries 663.11.1 Create a library 663.11.2 Installing a library 683.11.3 Adding a library to a project 693.11.4 De-Install a library 69
3.12 Registration of foreign files 70
3.13 Test and commissioning 713.13.1 Start of the SmartSIM32 713.13.2 Go online 713.13.3 Download of a resource 733.13.4 Up load of a resource 733.13.5 The Test and commissioning 733.13.6 Watching variables 743.13.7 Set variables 753.13.8 The online-editor 753.13.9 Hardware info 763.13.10 Resource info 77
3.14 Configuration of the project manager 783.14.1 Settings 783.14.2 Printer set up 80
4 The POU-Editor 82
4.1 Overview 824.1.1 Program overview 834.1.2 Function blocks overview 834.1.3 Functions overview 83
4.2 Declaration part 844.2.1 Sections of variables 844.2.2 Elements of a declaration of variables 874.2.3 Variable-editor 884.2.4 Variable-editor: Syntax-mode 89
4.2.4.1 Selection of the variable-section 894.2.4.2 Entry of lines 89
4.2.5 Variable-editor: Free mode 924.2.5.1 Variable-sections 934.2.5.2 Declaration lines 93
4.3 Instruction part 95
4.4 The instruction part in IL 964.4.1 The structure of an IL-line 964.4.2 Input helps 97
4.4.2.1 Insert of variables and instance-calls 974.4.2.2 Insert operators 984.4.2.3 Insert functions 99
4.5 The instruction part of the programming in LD 1004.5.1 Overview 1004.5.2 Create the POU in LD 102
4.5.2.1 Display and Accept operators 1034.5.2.2 Create new network 1034.5.2.3 Insert function blocks 1044.5.2.4 Insert function 1054.5.2.5 Edit a POU in LD 105
1 OpenPCS 4.1 - Overview
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
7
4.5.2.6 Mark a network as branch label 1064.5.2.7 Edit logical operation 1074.5.2.8 Insert of an AND-operation 1074.5.2.9 Insert of an OR-operation 1074.5.2.10 Insert of a conditional termination 1084.5.2.11 Modify an expression 1094.5.2.12 Negate a contact or an output 1104.5.2.13 Delete elements 1114.5.2.14 Name elements 1114.5.2.15 Name a label 1124.5.2.16 Enter a network-comment 1134.5.2.17 Create function blocks in LD 1134.5.2.18 Create functions in LD 113
4.6 The instruction part on programming in FBD 1144.6.1 Overview 114
4.6.1.1 Network label 1154.6.1.2 Network comment 1154.6.1.3 Network graphic 115
4.6.2 Create a POU in FBD 1164.6.2.1 Operators 1184.6.2.2 Create new network 1194.6.2.3 Insert a function block 1194.6.2.4 Insert function 1214.6.2.5 Delete function block or function 1224.6.2.6 Edit a POU in FBD 1224.6.2.7 Mark POU-elements 1224.6.2.8 Insert a network 1234.6.2.9 Delete network 1234.6.2.10 Mark a network as a branch label 1234.6.2.11 Edit a network 1244.6.2.12 Insert a circuit symbol 1244.6.2.13 Delete circuit symbol 1264.6.2.14 Insert input 1284.6.2.15 Delete input 1294.6.2.16 Insert output 1304.6.2.17 Delete output 1324.6.2.18 Negate input 1344.6.2.19 Negate output 1354.6.2.20 Name element 1364.6.2.21 Enter a label for a jump instruction 1384.6.2.22 Enter network-comment 139
4.7 The instruction part in ST 1404.7.1 Create ST-POU 1404.7.2 Instructions in ST 1404.7.3 Assignments 1414.7.4 Conditional instructions 141
4.7.4.1 IF-instruction 1424.7.4.2 CASE-instruction 143
4.7.5 Repetitions 1434.7.5.1 WHILE-loop 1444.7.5.2 FOR-loop 1444.7.5.3 REPEAT-loop 1454.7.5.4 EXIT 145
4.7.6 Cyclic Execution and Structured Text 1454.7.7 Calling function block instances 146
1 OpenPCS 4.1 - Overview
8 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.7.8 RETURN 1464.7.9 Expressions and operators 1474.7.10 Function call as operator 1474.7.11 Comments 1484.7.12 Input helps 148
4.7.12.1 Calling function block instances 1484.7.12.2 Calling functions 148
4.8 Switching Programming Languages 1504.8.1 Conditional function block call 1504.8.2 Intermediate Stores 1524.8.3 Line comments 153
4.9 Editor for global types 154
4.10 Syntax check and error correction 155
4.11 Create cross-reference list 156
4.12 Edit POU 157
4.13 Save POU 157
4.14 Change POU-Type 157
4.15 Printing 1584.15.1 Print a POU 158
5 ControlX Editor 160
5.1 Survey 1605.1.1 The standard IEC-61131-3 1605.1.2 General Information 1605.1.3 Components 160
5.1.3.1 Output Window 1605.1.3.2 Variable Editor 1615.1.3.3 Instruction Editor 161
5.2 Output Window 1625.2.1 Presentation 1625.2.2 Function of the Output Window 163
5.3 Variable Editor 1655.3.1 Introduction 1655.3.2 Available variable types 1665.3.3 Declarations 166
5.4 Menus 1675.4.1 Basic Commands 167
5.4.1.1 Restore 1675.4.1.2 Move 1675.4.1.3 Change Size 1675.4.1.4 Minimize (Basic Commands) 1685.4.1.5 Maximize (Basic Commands) 1685.4.1.6 Close (Basic Commands) 1685.4.1.7 Next (Basic Commands) 168
5.4.2 Menus in the SFC Editor 1695.4.2.1 Survey of menus (SFC Editor) 1695.4.2.2 Commands "File" Menu 1695.4.2.3 Commands "Edit" Menu 1725.4.2.4 Commands "Insert" Menu 176
1 OpenPCS 4.1 - Overview
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9
5.4.2.5 Commands "View" Menu 1785.4.2.6 Commands "Online" Menu 1825.4.2.7 Commands "Window" Menu 1835.4.2.8 Commands "Help" Menu 184
5.4.3 Menus in the Ladder Editor 1855.4.3.1 Survey of Menus (Ladder-Editor) 1855.4.3.2 Commands "File" Menu 1855.4.3.3 Commands "Edit" Menu 1895.4.3.4 Commands "Insert" Menu 1925.4.3.5 Commands " View" Menu 1955.4.3.6 Commands "Options" Menu 1955.4.3.7 Commands "Online" Menu 1955.4.3.8 Window (Ladder) 1965.4.3.9 Help (Ladder) 196
6 Ladder Diagram Editor 197
6.1 Introduction 1976.1.1 General information on Ladder Logic 1976.1.2 General Information on Ladder Diagram Editor 1976.1.3 Informations on handling 197
6.1.3.1 Menu 1976.1.3.2 Toolbar 198
6.2 Quickstart 1986.2.1 Create Ladder Diagramm 1986.2.2 Create Ladder Logic 1986.2.3 Save 1996.2.4 Syntax Check 2006.2.5 Online 200
6.3 Working on Ladder Diagrams 2016.3.1 Ladder Diagram 2016.3.2 Comments 2026.3.3 Network 2026.3.4 Instructions 203
6.3.4.1 Operators 2036.3.4.2 Functions and Function Blocks 2046.3.4.3 Logical Connections 204
6.4 Ladder Logic 2056.4.1 Operators 205
6.4.1.1 Contacts 2056.4.1.2 Coils 2056.4.1.3 Control Relays 206
6.4.2 Blocks 2076.4.2.1 Function Blocks 2076.4.2.2 Functions 218
6.4.3 Combinations 2416.4.3.1 AND 2416.4.3.2 OR 2426.4.3.3 Mixed combinations 243
6.5 Online 2446.5.1 General Information on the Online Editor 2446.5.2 Using the Online Editor 244
7 The SFC-Editor 246
1 OpenPCS 4.1 - Overview
10 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
7.1 Elements of Sequential Function Chart 246
7.2 A program example 248
7.3 Use of the SFC-Editor 2497.3.1 Start of the editor from the browser 2497.3.2 SFC-Editor User Interface 2507.3.3 Creation of a new document 2507.3.4 Opening a chart 2517.3.5 Saving 2517.3.6 Printing 2517.3.7 Form 2517.3.8 Page view 2517.3.9 Setting of marks 251
7.3.9.1 Single marks 2517.3.9.2 Region marks 252
7.3.10 Editing of the graph-layout 2527.3.10.1 Cut to the clipboard 2527.3.10.2 Copy into the clipboard 2527.3.10.3 Insert of elements from the clipboard 2537.3.10.4 Deleting of the marked region 2537.3.10.5 Divergence of sequence selection branches shift left/right 2537.3.10.6 Replacing of the mark by a step–transition–pair 2537.3.10.7 Insert a jump 254
7.3.11 Declaration of variables 2547.3.12 Exception handling 2557.3.13 Editing of the program blocks 255
7.3.13.1 Transitions 2567.3.13.2 Steps and initial steps 2567.3.13.3 Jumps 256
7.3.14 Syntax control 2567.3.15 The SFC-editor in online-mode 260
7.4 The buttons of the toolbar 260
8 The CFC-Editor 263
8.1 Styles and Symbols 263
8.2 Structure of the OpenCFC-Editor 2638.2.1 Creating a Program 266
8.2.1.1 Creating a new CFC program 2668.2.1.2 Show/Hide Grid 2678.2.1.3 Adding Blocks to a Function Chart 2688.2.1.4 Connecting Blocks in a Function Chart 2698.2.1.5 The Connection Tool 2728.2.1.6 The Margin Bar 2728.2.1.7 Assigning a Constant to an Input Connector 2778.2.1.8 Zooming in and out 278
8.2.2 Editing a Program 2798.2.2.1 Opening a program 2798.2.2.2 Moving a block to an empty block field 2798.2.2.3 Dragging a block to an empty field 2808.2.2.4 Shifting a Group of blocks 2818.2.2.5 Copying or Shifting Blocks Using the Clipboard 2828.2.2.6 Deleting a Block 2838.2.2.7 Changing Connections 283
1 OpenPCS 4.1 - Overview
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
11
8.2.2.8 Saving a program 2858.2.2.9 Documenting a Program 2858.2.2.10 Using the help function 285
8.3 Advanced Topics 2858.3.1 Online – Debugging Programs 2858.3.2 Execution Sequence 2868.3.3 Modifying a block interface 2868.3.4 Using forms for printing 2888.3.5 Compound Blocks 288
8.3.5.1 Compound Blocks: Introduction 2888.3.5.2 Insert a new empty Compound Block 2898.3.5.3 Converting Blocks to a Compound Block 2898.3.5.4 Adding an input or output to a Compound Block 289
9 Introduction into IEC1131 290
9.1 Program Structure 290
9.2 Declarations 2919.2.1 Datatypes 2919.2.2 Variables 2959.2.3 Instantiating Function blocks 298
9.3 Instruction part of a POU 2989.3.1 Instructions 298
9.3.1.1 Load Instructions 3019.3.1.2 Assignments 3029.3.1.3 Logical Operations 3049.3.1.4 Arithmetic Operations 3079.3.1.5 Comparisons 3099.3.1.6 Conditional and unconditional Jump 3119.3.1.7 Conditional and unconditional Return 3129.3.1.8 Function block invocation 3139.3.1.9 Calling Functions 314
9.3.2 Constants 3149.3.3 Program 3159.3.4 Functions 3169.3.5 Function blocks 317
9.4 Other Programming Languages 3199.4.1 Other Programming Languages 3199.4.2 LD and FBD: Introduction 3199.4.3 Programming in Ladder Diagram 3209.4.4 Programming in Function Block Diagram 324
9.5 Functions (IEC1131) 328
9.6 Function blocks (IEC1131) 377
9.7 Functions (OpenPCS) 388
9.8 Language Extensions 390
10 Forms Editor 391
10.1 Overview 391
10.2 Design a form 391
10.3 Using fixed text in a form 392
1 OpenPCS 4.1 - Overview
12 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
10.4 Form preview 392
10.5 Editing elements 392
11 FXF Import/Export 393
11.1 Export to FXF 393
11.2 Import from FXF 397
12 IEC1131-3 Compliance Statement 399
12.1 Common Elements 40012.1.1 Table 1: Character set features 40012.1.2 Table 2: Identifier features 40012.1.3 Table 3: Comment features 40012.1.4 Table 4: Numeric Literals 40012.1.5 Table 5: Character string literal features 40112.1.6 Table 6: Two character combinations in character strings 40112.1.7 Table 7: Duration literal features 40112.1.8 Table 8: Date and time of day literals 40212.1.9 Table 10: Elementary data types 40212.1.10 Table 12: Data type declaration feature 40312.1.11 Table 13: Default initial values 40312.1.12 Table 14: Data type initial value declaration features 40312.1.13 Table 15: Location and size prefix features for directly representedvariables 40412.1.14 Table 16: Variable keywords for variable declaration 40412.1.15 Table 17: Variable type assignment features 40412.1.16 Table 18: Variable initial value assignment features 40512.1.17 Table 19: Graphical negation of Boolean signals 40512.1.18 Table 20: Use of EN input and ENO output 40512.1.19 Table 21: Typed and overloaded functions 40512.1.20 Table 22: Type conversion function features 40512.1.21 Table 23: Standard functions of one numeric variable 40612.1.22 Table 24: Arithmetic standard functions 40612.1.23 Table 25: Standard bit shift functions 40612.1.24 Table 26: Standard bitwise Boolean functions 40612.1.25 Table 27: Standard selection functions 40712.1.26 Table 28: Standard comparison functions 40712.1.27 Table 29: Standard character string functions 40712.1.28 Table 30: Functions of time data types 40812.1.29 Table 31: Functions of enumerated data types 40812.1.30 Table 33: Function block declaration features 40912.1.31 Table 34: Standard bistable function blocks 40912.1.32 Table 35: Standard edge detection function blocks 40912.1.33 Table 36: Standard counter function blocks 40912.1.34 Table 37: Standard timer function blocks 41012.1.35 Table 39: Program declaration features 41012.1.36 Table 40: Step features 41112.1.37 Table 41: Transitions and Transition conditions 41112.1.38 Table 42: Declaration of actions 41112.1.39 Table 43: Step/action association 41212.1.40 Table 44: Action block features 41212.1.41 Table 45: Action qualifiers 41212.1.42 Table 46: Sequence evolution 412
1 OpenPCS 4.1 - Overview
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
13
12.2 IL Language Elements 41312.2.1 Table 52: Instruction list (IL) operators 41312.2.2 Table 53: Function block invocation feature for IL language 414
12.3 ST Language Elements 41412.3.1 Table 55: Operators of the ST language 41412.3.2 Table 56: ST language statements 414
12.4 Common graphical Elements 41512.4.1 Table 57: Representation of lines and block 41512.4.2 Table 58: Graphic execution control elements 416
12.5 LD language Elements 41612.5.1 Table 59: Power rails 41612.5.2 Table 60: Link Elements 41612.5.3 Table 61: Contacts 41612.5.4 Table 62: Coils 417
12.6 FBD language elements 417
12.7 Annex D Implementation-dependent parameters 41712.7.1 Table D.1: Implementation-dependent parameters 417
12.8 Appendix E (normative): Error conditions 41912.8.1 Table E.1: Error conditions 419
13 Index 421
13.1 Table of figures 421
13.2 Keywords 426
1 OpenPCS 4.1 - Overview
14 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
15
2 IntroductionThis manual will give you an introductory overview over OpenPCS. With a simple example, youwill learn how to create own projects, own programs, down to the very test with your controller orSmartPLC.A basic knowledge of Microsoft Windows and PLC programming is assumed.
2.1 Styles and SymbolsThe notationProject�New is used to denote the selection of item “New” in menu “Project”. Thearrow➨ is used to mark individual steps you should follow.
�OpenPCS is a portable, configurable programmingsystem. You should be aware that not allfunctions, data types, instructions and featuresdescribed here are available with all controllers. Ifyou are in doubt, ask the vendor of the PLC thatyou are using OpenPCS with.
2.2 InstallationOpenPCS is delivered on CD-Rom. Start the installation as you are used to with most Windowsprograms by launching SETUP.EXE. If the CD contains more than one language version ofOpenPCS, select the proper language version by launching the SETUP.EXE from it’ssubdirectory, e.g. ENGLISH\SETUP.EXE.
When installing OpenPCS, you will be asked to enter your licence information. If you boughtOpenPCS, you will have a licence information sheet giving you the requested information. If youdo not have a licence, just keep the default information provided (i.e. serial number DEMO andlicence code DEMO). This will give you 30 days to evaluate OpenPCS, after which OpenPCS willcease to work.
2.3 Hardware and Software RequirementsAs a programming system, you will need an IBM compatible PC with
1) At least an 80486 microprocessor (we recommend at least a Pentium 166) and aCD-ROM-drive
2) A hard disk drive with at least 25 Mbytes of free space
3) At least 8 Mbytes of RAM (we recommend 32MB), and
4) A VGA graphics card
5) As with any Windows application, a mouse will be helpful
Besides OpenPCS, you will need an operating system as:
6) Windows 95/98 or
7) Windows NT 4.0
2 Introduction
16 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
To support your specific PLC, more requirements may hold (e.g. more memory), and you mayneed additional hard- or software (e.g. interface cards, cables). If in doubt, consult the vendor ofyour PLC.
2.4 Programming ExampleTo introduce you to OpenPCS, we will use a simple example. This chapter will describe the prob-lem and the solution. The rest of this manual will then implement the solution with OpenPCS.
Problem: A robot arm shall be moved into position A when button “START” is being pressed.Another button “HALT” shall interrupt that movement anytime.
Solution The solution might look like:
PROGRAM� position�VAR�
initial� AT %I0.0 : BOOL; (*initial state�*)key_start AT %I0.1 : BOOL; (*key start*)key_halt AT %I0.2 : BOOL;position_A AT %I0.3 : BOOL; (*Position A reached*)motor AT %Q0.0 : BOOL;
END_VARLD� initialAND key_startS motor (*switch motor on�*)LD key_haltOR position_AR motor (*switch motor off*)
END_PROGRAM�
� The program starts with the keyword PROGRAM, and ends with the other keywordEND_PROGRAM. When working with OpenPCS, you will not type in these keywords, butrather the editor will create them automatically for you.
� OpenPCS will prompt you for the name of the program when you create a new program
� In contrast to traditional PLC programming languages, IEC1131 requires that you declareall variables that you use.
� This line declares a variable of name “initial” of data type “BOOL”, to be mapped to hard-ware address “%I0.0”, i.e. this variable shall denote the lowest bit of the first input byte.
� Almost everywhere in IEC1131 you can use comments to describe your programs.
� The instruction part of the program starts with a load-instruction. As you will notice, mostinstructions (all in this simple program) will consist of a one-word instruction followed byan operand.In this sample program, we have instructions LD (load current result with operand), OR (or-connect operand to current result), AND (and-connect operand to current result), S (setoperand to 1 if current result is 1), and R (set operand to 0 when current result is TRUE).
Please note: which hardware addresses are valid is strongly dependent on the PLC you are us-ing.
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
17
2.5 Starting OpenPCSStart Windows and choose “start� programs� OpenPCS�OpenPCS” in the start-menu; thewindow “project browser” will be opened: In general, one project was pre-selected, otherwise yousee an empty window:
fig. 1:Project management (demo-project pre-selected)
(See chapter §3 for a more detailed description of the browser).
With OpenPCS, you will structure your work in projects. It is very easy to reuse software withinone project, and this is one of the great advantage of OpenPCS. Be sure to structure your work ina way to take best advantage of this feature:- avoid to use more than one project for related work. One machine, one network of CANopen
nodes, or even one plant might be one project- Use separate projects for unrelated work; this increases your overview and prevents you from
mistakenly modifying wrong code.
The Project Browser is the File Manager of OpenPCS. When you create files within an OpenPCSproject, internal information is kept on these files. You cannot replace the Project Browser with astandard Windows File Manager (like the Windows Explorer).
2 Introduction
18 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
2.6 Create a new project
Create a new project by selectingProject�New. A dialogbox will be shown to prompt you for thename and directory path of this new project:
fig. 2:Dialogbox „New Project“
�You may use a path on a non-local, networked drive, but youcannot use this to work with more than one copy of OpenPCSat once with the same project!
�The length of a project path is limited, try to use as few char-acters for the directory name as possible. You will see anerror message if the name is too long.
Select directory C:\OpenPCS and enter “bsp” as the project name:• bsp
• Close the dialogbox with „OK“. The path „c:\OpenPCS\bsp“ will be created and the minimumproject structure will be shown:
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
19
fig. 3: Minimum Project Structure
With a new, empty project, only the three default entries “Forms”, “Libraries” and the project (inthis case “Bsp”) will exist. In the project, you will find the branches “Configuration” and “ProjectFiles”, a file „Usertype.typ“ already existing under “Project Files”.During the course of this manual we will create more entries to be shown in this tree.
2.7 Creating a Program
2.7.1 The Program Organisation Unit (POU)
At first, create a new POU
• Select the action “File ➜➜➜➜ New➜➜➜➜” .
• Choose the program organisation unit which you want to create. The keywords “➜➜➜➜POUfunction” or “ ➜➜➜➜POU function block” are selected for program parts which are used moreoften. For our example, you need an executable program. Therefore, the type„ ➜➜➜➜POUprogram“ must be selected.
The following dialog box is opened:
2 Introduction
20 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 4: Creating a new POU
In the right part of the window you can select the path under which the POU should be saved.This one must always be located under the project folder. In our case, the right path,„c:\openpcs\bsp“, is already selected. Pre-selected is always this project which has beenopened or created last.
Use “position” as file name ( the file extension “POU” can be omitted ) and confirm the selectionby the “OK" -button”.
The POU „Position.poe“ will be added to the project structure under “Project Files”.
�Note the plus- or minus sign ahead of the word“project files”. Press this one with the mouse tosee the effect.
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
21
fig. 5: Project structure after insert of a POU
2.7.2 The POU-Editor
The POU “position” does not have source code yet. This will be written with the POU-editor. ThePOU-editor is open after the creation of a new program. To open the POU-editor later you have todouble click on “Position.poe”.
The window “POU-editor” appears on the screen which you will need for program development.There are two more windows, the so-called “syntax controlled declaration editor” (upper part) forthe declaration of variables, and the “IL-editor” (lower part) for the instruction part (If the“syntax controlled declaration editor” is on the left side and the “IL-editor” is on the right sideYou can rotate them with “Window➜➜➜➜ Rotate”) :
2 Introduction
22 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 6: POU-editor with syntax driven declaration editor, and IL-editor
2.7.3 Syntax controlled declaration editorYou will enter your program in two stages. First, declare all variables you are going to use. Youhave two options to do so:1. The syntax controlled declaration editor, using a comfortable, guided interface.2. The free declaration editor, giving you much less guidance but more liberty; this is more
suited to the experienced programmer and will not be covered in this chapter.
�If you are new to programming, IEC1131 and/orOpenPCS, we recommend that you use the syntaxcontrolled editor first.
Then, enter the instructions of your program in Instruction List.
�It is just for this manual that we enter declarationsfirst, and then instructions. You may do this inany order, switching back and forth as you like.
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
23
2.7.4 Declaring in syntax controlled modeTo declare a variable in syntax controlled mode, first select the proper type of declaration:• Select the type of declaration you want to do. If, e.g. you want to declare a local variable,
select local declarations by pressing button „local“.
• Declare all variables of this type, then choose another type of declaration if necessary. Watchthe set of edit fields change as you select different types of variables.
fig. 7: Buttons to select declaration types (from function blocks)
In our example, we will only need local declarations. This is the default, but to be sure, select“Local” again.
fig. 8: Declaration Edit Fields
To declare the first variable, enter information as follows in the edit fields provided in the toppart of the syntax controlled declaration editor (use TAB or your mouse to get there).
• Name: „initial“. If the name is too long to be shown, it will be shifted accordingly. UsePOS1to see the first part again.
• Type: Select BOOL from the drop-down list, or just type in „BOOL“.
• Initial value : You need not enter a value here, because the default initial value „0“ is ok forour example.
• Attribute : Do not enter a value here.
• Address: enter „I0.0“ here, which is the physical address this variable shall be mapped to. Inthe syntax controlled editor the address will be entered without “%”-sign, but if you switch tothe free editor, this sign will be added automatically.
• Comment: Enter a comment to describe the usage of this variable. Enter: „robot arm in initialstate“
• Finish this declaration with "Return".
Declare the remaining variables of this example program by the same manner as shown in thefigure below. If you make a typing mistake, you can delete this mistake with the DEL-buttonor the backspace until you change to the next input field. If you want to correct a field later,you only need to place the cursor by mouse accordingly.
Now, the declaration list is complete.
2 Introduction
24 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 9: Declaration list
2.7.5 Entering the Program in IL
After declaring all variables, we will now start to enter the program into the lower part of thewindow ( that is the IL-editor).
One IL line can consist of operator, operand, comment; between them a tabulator or a blank. Starteach instruction on a new line.Use „(*“ and „*)“ to enclose your comments, and insert the comment between them.
Under the menu item “Insert�Operators ...” you find a list of available operators. From this listyou can put an operator directly into your program by marking and confirming the selection withthe button “OK”. The operator will be inserted at the current cursor position. With some experi-ence you will find it much faster to key in operator names directly.
During the input of the program you can switch between the declaration-editor and the IL-editorby selecting with the mouse button.
Now, for our example, enter the IL program as follows. If you mistype, use the backspace key orthe DEL-button to correct:
LD initialAND key_startS motor (*switch motor on *)LD key_haltOR position_AR motor (*switch motor off*)
As you see, valid instructions are marked by colours, easing understanding of the program struc-ture.
After the program input, the window “IL-editor” has following content:
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
25
fig. 10 The completed sample program
Save the completed program by the action„File ➜➜➜➜ Save“.
2.7.6 Syntax check• SelectFile�Syntax Checkto invoke a syntax check on your program. If you modified the
POU since you last saved it, you will be asked to save it again, as the syntax check will alwayswork on the saved version of the POU.
If you typed in the program properly, you will just see a message “No syntaxerror ”. If youaccidentally introduced errors, you will be informed. See the next chapter on how to use theinformation provided to correct the errors.
2.7.7 Error correctionShould you receive error messages, these are displayed in the window “Error Messages”:
fig. 11:Dialog box „Error Messages“
This dialog box lists one error in each line, displaying (from left to right):• Location of the error ( In this case “Instruction part” )• Line number• Row number• Short error description
2 Introduction
26 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
�Double-click the line displaying the error mes-sage to be transferred into the editor close to theerroneous line
�Detailed error information are available by se-lecting the error message and pressing F1.
2.7.8 Print a ProgramSelect in the POU-editor “File�Print”, or if the selected file is in the branch “Project Files”,
click with the right mouse button on it, and select in the context menu “Print” .
The print dialog will be opened.
Accept by the “OK”-button.
�The use of forms is not supported currently!
2.8 Defining the Resource
2.8.1 OverviewYou use the editor to create POUs of different types (PROGRAM, FUNCTION_BLOCK,FUNCTION) in different languages. To have these POUs running on your controller, you willneed a resource definition:
“Resource” is an abstract term defined by IEC1131. In general, you can substitute “PLC” or “con-troller” for “resource. The definition of a resource consists of- A name, identifying the resource. You may freely choose this name- A hardware description, telling OpenPCS about the properties of the hardware of the control-
ler. Depending on your controller, this will be a fixed list of controllers available, or youmight have a tool to define your own controller.
- A communication definition, telling OpenPCS how to communicate with this controller. ForCANopen, e.g. this could be a node ID, or for V24 it could be a COM port.
- A list of tasks to be run on that controller.
“Task” is another abstract term defined by IEC1131. In general, you can assume a task to beequivalent to a program plus information telling the controller how to run that program. Thedefinition of a task consists of:- A name, identifying the task. Again, you may freely choose that name.- Information about how to execute that task (cyclically, interrupt driven – the choices you
have strongly depend on your controller.- A POU of type PROGRAM which defines the program which is executed in that task.
OpenPCS delivers to you the freedom of IEC1131 in defining resources and tasks. If you haveexperience in programming traditional PLCs, or with other IEC1131 systems, you might not beaware of this freedom:
• One project may contain more than one resource. This is extremely useful if your problemrequires more than one controller. Re-use of software among these controllers is intuitive.
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
27
• A program (more precisely: a POU of type PROGRAM), can be linked to more than one re-source. This means that this one source will be compiled more than once in this project, firstfor controller one, second for controller two.
• The same is true, of course, for POUs of types FUNCTION and FUNCTION_BLOCK. Re-use of such blocks in one task, different tasks in one resource, or in different resources isstrongly encouraged.
• One controller can use more than one resource. If you want to have different versions of yourproject readily at hand, another resource for the same controller can be a convenient way.
2 Introduction
28 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
2.8.2 Adding a resourceTo define a resource, switch back to the Project Browser. SelectFile�New� Resource. Adialog box similar to the following will be shown, prompting you for the properties of the newresource.
fig. 12: Definition of a resource
• In the field "name", enter a name for the new resource. In our example, enter BSP_RES.
• In the combobox at the right top, select the hardware to describe your controller. In ourexample, select SmartPLC.
Now, your project browser should look like:
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
29
fig. 13: Project Tree with a resource
The branch “Configuration” has a new entry representing the resource we just defined.
2.8.3 Defining a Task
To add a task, you have two options:a) Select the resource and selectFile�New�Taskb) Or, Select the POU of type PROGRAM you want to have executed in the new task, drag it
with the mouse button pressed and drop it onto the resource node (Drag-and-Drop).
We will employ the second option: select POU “Position.poe” with your mouse, keep the mousebutton pressed and drag the POU onto the node “Bsp_res”, releasing the mouse button there. Adialogbox will be shown, prompting you for the properties of the task to create. In our example,we are happy with the defaults, so just close this dialog by pressing “OK”.
2 Introduction
30 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 14: Task Properties
�To delete a task or resource, have it selected andpress the DEL key.
�To later see or modify the properties of a task orresource, double-click it
2.8.4 Create the executable programTo compile your program into executable code, select the node of the resource and press the“Generate Code” button in the toolbar:
The compiler output window will be shown, displaying progress information. If your program isfree from errors, the last line will read “ All in all 0 errors occured while compiling !”.
�With most errors, a double-click on the line dis-playing the error message will transfer you intothe editor to the very location of the error.
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
31
fig. 15: Compiler-Messages
The icon of the resource is marked by green colour which indicates that this is the "active" re-source.
�For the most errors, a double click by mouse onthe error messages is enough to open the editorat the incorrect place.
2.9 Test and Commissioning
2.9.1 Overview, SmartSIMIn order to test a program, you need a PLC. You can use the real control system which youbought together with OpenPCS. To be independent of the different control systems in thismanual, with which OpenPCS is distributed, we use only the SmartSIM32 here.
The SmartSIM32 is an easy simulation of a PLC under Windows. Start the SmartSIM32 with themenu item „Tools� SmartSIM“ in the project manager.
2 Introduction
32 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 16: The SmartSIM32
To switch digital inputs, click them with the mouse. Outputs are just displayed and activated bythe application program. The program will be stored on disk and re-loaded automatically at start-up of SmartSIM.
�To prevent SmartSIM from loading the programstored on disk, keep CTRL and SHIFT pressedat start of SmartSIM.
For the transformation and the commissioning of the executable program, you use the tool “testand commissioning”:• Select the resource „Bsp_res“ in the project management.• Select now the menu item„Online � Go Online“ .
The window “Test and Commissioning” will be opened now
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
33
fig. 17: Test and Commissioning
After that you will be asked, if you want download the program to the PLC. Accept it with the“Yes”-button.
Messages of the PLC are displayed in the lower part of the project browser.
Fig 18: Messages of the PLC
2.9.2 Starting and Stopping the ProgramYou may remote-control the program running in the PLC with the following commands:
PLC ➜➜➜➜ STOP SelectPLC�Stopto immediately stop the programPLC�Coldstart SelectPLC�Coldstartto perform a cold start. All variables will
be initialised to the initial value as programmed.PLC�Warmstart SelectPLC�Warmstartto initialise all normal variables, but
keep the values of all variables programmed as RETAIN.PLC�Hotstart SelectPLC�Hotstart to continue execution where it stopped,
not initialising any variable.
2.9.3 Testing the programOpenPCS provides two major ways of testing your program:• Variable status: watching variables, setting variables,• Program status: in IL, LD, FBD, and CFC
2.9.4 Variable Status
2.9.4.1 Watching variablesTo display and periodically update the value of selected variables, use the watch window in T+C:
• Open the branches “BSP_res” and “POSITION” of the T+C’s instance tree in the projectbrowser. There you can find the variables which you want to monitor.
• Mark the variable which you want to monitor
• Select “Online�Watch variable(or click the variable with the right mouse button and select“Watch variable”). The variable appears in the T+C-window.
2 Introduction
34 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 20: TUI window with watch variables
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
35
2.9.4.2 Setting a VariableIn the T+C-window double-click the variable which you want to set. The window “Set variable”
is opened.
Enter the new value into the input field “Value”.
fig. 21: Set variable
In the project browser select„Online ➜➜➜➜ Go Offline“ to finish the online-mode.
2.9.5 Program StatusWithin the browser's treeview of the resource in the configuration branch, select not a variable,but rather a function, an instance of a function block, or the program itself.
• Go Online by selection of the menu item„Online ➜➜➜➜ Go Online“ .• Mark the program “POSITION” in the instance window of the project browser.
fig. 22: „POSITION“ marked
Select the menu item„Online ➜➜➜➜ Online Editor“ or click with the right mouse button on the pro-gram and select „Online Editor“ .
The online editor will be opened.
2 Introduction
36 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 23: Online editor
Activate the status display in the menu„Online ➜➜➜➜ Status display“.
The current results (CR) appear in the lower left window which result after the execution of thecommand of the respective line.
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
37
2.10 Other Features of OpenPCSThis short introductory manual is not meant to cover all details and features of OpenPCS. To pre-serve readability and conciseness, many things have been left out. Consult the other chapter to getmore information.
2.10.1 Other programming languagesIn this chapter, we only used instruction list (IL). OpenPCS comes with a variety of other pro-gramming languages:- Ladder Diagram (LD)- Function Block Diagram (FBD),- Structured Text (ST)),- Continuous Function Chart (CFC)The following chapters will give you just an impression of these languages, see the in-depth chap-ters for a deeper coverage.
In the symbol board of the POU-editor you can select the language which you want to use for theprogramming:
IL
LD
FBD
ST
You can edit or print a POU with a language of your choice even if it was created with anotherlanguage.
In contrast to the other programming languages ( IL, LD, FBD ) you can’t switch to ST later.
2.10.1.1 LD Ladder DiagramAn application can be represented by LD as follows:
fig. 24: Programming Language LD
2 Introduction
38 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
2.10.1.2 FBD Function Block DiagramOur previous example can also be represented by FBD as follows:
fig. 25: Programming Language FBD
2.10.1.3 Structured Text STOur previous example would look like this if you wrote it in ST:
PROGRAM positionVAR
initial AT %I0.0 : BOOL; (* robot arm in initial state *)key_start AT %I0.1 : BOOL; (* start key *)key_halt AT %I0.2 : BOOL; (* stop key *)position_A AT %I0.3 : BOOL; (* Position A *)motor AT %Q0.0 : BOOL;
END_VAR
if (initial AND key_start) thenmotor := TRUE;
end_if;if (key_halt OR position_A) then
motor := FALSE;end_if;
END_PROGRAM
Remark: Every ST-program can be transformed into the other languages, but not vice versa.
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
39
2.10.1.4 CFCWhile all other languages are meant to be used for programming, CFC is intended to configurefunctionality encapsulated in already pre-programmed blocks. Use the IEC1131 languages (IL,LD, FBD and ST) to build a library of function blocks. Use CFC to interconnect these blocks toimplement your application without having to go into the details of programming. A sample CFCis:
fig. 26: Programming Language CFC
2.10.2 Block TypesIn the simple example of this manual, we only used one POU, which was of type PROGRAM.Besides a PROGRAM, OpenPCS offers POU types FUNCTION and FUNCTION_BLOCK. Toget the best of OpenPCS, it is essential that you understand these block types.
The block type is completely independent of the programming language.
2.10.2.1 FUNCTIONA function, as defined by IEC1131, has the following characteristic properties:- It has one or more inputs (but no input is not allowed)- It has exactly one output value (which may be a structure)- A function has no “memory” from one call to the next, and it will return always the same
output when given the same inputs- On every call to a function, all inputs have to be supplied- A function may use local variables for intermediate storage, but the value of these local vari-
ables will not be kept from one call to the next- A function may call other functions, but it is not allowed to call instances of function blocks
2.10.2.2 FUNCTION_BLOCKA function block, as defined by IEC1131, has the following characteristic properties:- It may have one, more than one, or no inputs- It may have one, more than one, or no outputs- Multiple instances can be created of a function block, and each instance will keep a private
copy of all data associated with that function block (input, output, intermediate data); a func-tion block cannot be called, only instances can be called.
- The function block has a “memory”, i.e. all data (input, output, local) will keep it’s valuefrom one call to the next.
- On a call, it is not necessary to supply all input data; those not provided will simply keep thevalue from the previous call (or the default value if there was no call before).
2 Introduction
40 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
- A function block can call functions and instances of other function blocks.
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
41
2.10.2.3 PROGRAMA program in OpenPCS has the following characteristic properties, as defined by IEC1131:- Only the program is allowed to declare variables to be mapped to physical addresses- A program is allowed to call functions and instances of function blocks.
2.10.3 Free Declaration EditorIn this manual, we only used the syntax controlled declaration editor, but OpenPCS provides an-other declaration editor, called the “free declaration editor”. The free declaration editor presents aline-oriented text edit window. To a beginner, this is rather unsuited as you would have to knowand remember the exact syntax of each flavour of declaration by heart. To the experienced pro-grammer, the free declaration editor has some benefits:- You can see multiple declaration sections (INPUT, OUTPUT, LOCAL) at once- Some advanced features, like initialised structures, are not possible in the syntax controlled
mode- The clipboard allows more intuitive copy and paste operations for more than one variable at a
time in the free mode.
You may always switch between the free mode and the syntax controlled mode, just selectExtras�Variable Editor�Free Mode, or Extras�Variable Editor�Syntaxcontrolled Mode. Inthose rare cases where the syntax controlled mode cannot be used, you are just given an errormessage.
fig. 27: Free Declaration Editor
2 Introduction
42 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
2.10.4 Additional Features of the project browser
2.10.4.2 LibrariesLibraries allow you to write and distribute re-usable code. Write and test your functions andfunction blocks, then distribute them to other users of OpenPCS and allow them to re-use yourcode. See chapter 3 for more details.
2.10.5 ConclusionThis concludes our short trip through the most notable features and tools of OpenPCS. Be sureyou didn’t see everything, and have a look at the more detailed manuals to learn about morefeatures.
2 Introduction
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
43
3 The Project Manager
44 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3 The Project Manager
3.1 Introduction
The tool “Project manager” is used for the management of projects and the files belonging toprojects. It is similar to the well-known Windows-Explorer, but has some additional functionalityrequired by OpenPCS. This is why you should not try to replace the Project Manager by anotherfile management tool; internal links are generated by the project manager automatically whichare absolute necessary for a correct work with OpenPCS.With the project manager you can structure your work into projects. A great advantage ofOpenPCS is the reuse of blocks in other projects. Please note the following hint:
- Avoid to create several OpenPCS-projects for related work. One machine, one network ofCANopen nodes, or even one plant might be one project.
- Use separate projects for unrelated work; this increases your overview and prevents you frommistakenly modifying wrong code.
Overview:
The project management window consists of four parts:
2
1
3
4
fig. 28: The project manager
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
45
(1) The project treeAll parts of a project are combined in a tree here. Further details in chapter 3.4.
(2) The menu panel and the toolbar
The toolbar:Create new project
Open an existing project
Generate executable code
Add file
Edit resource
Edit the task properties
Add task to the selected resource
Separate the desktop for applications
(3) The output window:Output of the compilation or the online operation are shown here.
(4) The Application BarClick one of the icons to start the respective application. The Editors will be launched withthe file currently selected in the browser's tree.
In the following chapters the functionality of the project management should be explained indetail.
3.2 Start of the project browser
Start OpenPCS from the start menu: Select„Start →→→→ Programs→→→→ OpenPCS→→→→ OpenPCS“.
3 The Project Manager
46 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.3 Managing projects
3.3.1 Create a new project
If you have opened the project browser, you can start with the work. The first step is the creationof a new project. This can be done by two ways:
• By the toolbar: Click on the button„New project“:• By the menu: Click in the file menu on„Project →→→→ New Project“.
Please note:
• The project name has a maximum length of eight characters. If you try to enter a name withmore characters, the cursor will jump to the initial position again.
• You can create the project in any directory, but it is recommended to hold the projects inyour OpenPCS-directory.
• A subdirectory, which has the same name as your project, will be created automatically. Thisdirectory contains all files which belong to your project.
fig. 29: Dialog box „Create new project“
3.3.2 Open an existing project
You have three possibilities to open a project:
• In the “File”-menu: Here you find a list of the last opened project; the file, which you arelooking for, could be contained in this list.
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
47
• By the toolbar: Click on the button„Open Project“:
• By the menu: Click on„Project →→→→ Open Project“ in the main menu.
fig. 30: Open project
• In the dialog box you can see a list of the last opened projects. If you can’t find the searchedproject in this list, you can search for it with the button “Browse”. The project files have thesuffix “.var”.
• Not used projects can be removed from the list with the button „Remove from list“. The listcontains only references to the projects, therefore, the remove means not that the project willbe deleted from the hard disk drive.
• If the Checkbox „Show full path“ is activated, the entire project path will be shown in thelist, through projects with the same name can be distinguished:
fig. 31: Display of entire paths
3 The Project Manager
48 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.3.3 Copying a project
For different reasons, it could be that you want to copy all files of a project to another place.To do this, select the menu item “Project→→→→ Copy Project” in the project browser.
Then you get the following dialog box:
fig. 32: Copying a project
Enter the destination path, and start with the button “Copy”.
3.3.4 Create a backup copy
Select the menu item„Project →→→→ Backup Project“ to create a safe copy of the current project.
Following dialog appears:
fig. 33: Create backup copy
• Enter the name of your safe copy in the field “File name”, or select an existing safe copy fromthe list which will be overwritten then.
• Select the folder in which the file will be created.
• Accept your entry by the “OK”- button.
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
49
The safe copy will be created.
3.3.5 Restore a project
If you created a safe copy, you have the possibility to restore your project.• Select the menu item “Project→→→→ Restore project”.• Enter the name of your safe copy into the field “File name”, or select a name from the list
below:
fig. 34: Selection of the safe copy of a project which must be restored
• Accept by the „OK“- button.
A dialog box will be opened in which you can select the target directory:
fig. 35: Selection of the project directory
• Select a project directory in which you want to restore your project.
• Accept your selection by the „OK“- button.
The project is restored. Messages will be displayed in the output part of the project browser win-dow.
3 The Project Manager
50 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.3.6 Deleting projects
You can delete the current project by the menu item “Project→→→→ Delete Project”.
fig. 36: Additional accepting for deleting the project
3.3.7 Rename project
If you want to give the current project another name, select the menu item “Project→→→→RenameProject”.
fig. 37: Rename project
Hint: When renaming a project, please consider the restrictions given in chapter 3.3.1 for namesand paths of projects.
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
51
3.4 The project tree
The project tree is generated automatically for the project.
fig. 38: Project tree of the project „Bsp“
Hint: Only the variables of compiled resources can be displayed.
The individual branches of the project tree will be described in the following chapters.
3.4.1 LibrariesLibraries are a way to redistribute re-usable blocks of software. In the library branch, the ProjectManager will display all libraries which are used with the current project. See chapter §3.10 fordetails.
3.4.2 The project directoryA project (in this case “Bsp”) consists of two subdirectories:
fig. 39: Subdirectory of a project (in this case „Bsp“)
These subdirectories are the same for all projects, and are generated automatically together withthe project.
The resources of the project are in the branch “Configuration”. We examine the subject “Re-sources” more closely in the chapter 3.9: “Resources“.
fig. 40: The branch „Configuration“ consists the resources of the project
3 The Project Manager
52 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
The files, e.g. POUs, CFCs, variable- or type declarations, can be found under “Project files”. Weexamine these in the chapters 3.5: “Creation of POU- and CFC-Modules“ and 3.8: „Typedefinitions“:
fig. 41: The branch „Project files“
3.5 Creation of POU- and CFC-Modules
The different types of POU- and CFC-files (CFC = Continuous Function Chart) can be created bythe project browser as follows:Select “File→→→→New→→→→” from the menu, and select the type of module which you want to create:
„ →→→→ POU-Program“,„ →→→→ POU-Function block“,„ →→→→ POU-Function, CFC-Program“,„ →→→→ CFC-Function block“ or„ →→→→ CFC-Function“.
Enter in the next dialog the name of your module:
fig. 42: Create new module
Hint: The window region „Format“ is only available in CFC-Modules, there, the sheet size(A4/A3) and the orientation (Portrait/Landscape) can be selected.
The new module is added to the project tree under “Project files”:
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
53
fig. 43: POU-and CFC- Modules in the branch „Project files“
3.6 Editing of POU- and CFC-Modules
Modules can be edited as follows:• Double click the module
or• Right click on the module and select„Open“ from the context menu
or• Mark the module and select the menu item„File →→→→ Open“.
The corresponding editor will be opened according to the type of the file. You can graphicallycreate programs by the CFC-editor. See the chapters on the respective editors for more details onhow to edit files.
3.7 Global resource variables
Variables are names which are used to represent memory locations holding data. Variables can beclassified as follows:• Variables, which are assigned to physical input- or output-locations, or PLC-memories.• Variables, which are only used internally to store intermediate results.Global resource variables are accessibly from all locations of the resource.
In OpenPCS, there are two kinds of global resource variables:
• Global variables:
These are variables without hardware-addresses, e.g. for intermediate results.• Direct global variables:
These are variables with direct hardware-addresses together with the IO-declarations.These represent the interface to the hardware.
3 The Project Manager
54 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.7.1 Creation of [direct] global variables
• Select the menu item„File →→→→ New→→→→ [Direct] Global Variables“
fig. 44: Creation of a new declaration of global variables
• Enter the name of the variable declaration, and accept by the „OK“- button.
• The new declaration appears in the branch “Project files” of the project tree:
fig. 45: Declaration of variables in the branch „Project files“
3.7.2 Editing of [direct] global variables
You have three possibilities to edit [direct] global variables:• Double click on the declaration in the branch “Project files”.• Right click on the declaration, and select “Open” from the context menu.• Mark the declaration, and select the menu item “File→→→→ Open”.
The POU-editor will be opened, and you can declare your variables. Only variables of typeGLOBAL can be declared. We refer for detailed information to the chapter 4.
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
55
3.8 Type definitions
Data types can be either elementary or derived. Elementary data types are defined either in theIEC 1131 or by the manufacturer of the control system. On the other hand, derived data types aredefined by the programmer or by the manufacturer.By creation of the project, a standard type definition „Usertype.typ“ will be generated. This onecan’t be deleted and is assigned to all resources:
fig. 46: Standard-type definition „Usertype.typ“
3.8.1 Creation of new type definitions
• Select a menu item„File →→→→ New→→→→ Type definition“ :
fig. 47: Create new type definition
• Enter the name of the type definition and accept by „OK“- button.
The new type definition will be located in the project tree under “Project files“:
fig. 48: Type definitions in the branch „Project files“
3 The Project Manager
56 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.8.2 Editing of type definitions
You have three possibilities to edit a type definition:• Double click on the definition in the branch “Project files”.• Right click on the definition, and select “Open” from the context menu.• Mark the definition, and select the menu item “File→→→→ Open”.
The POU-editor will be opened, and you can declare your types.
3.9 Resources
If a POU was created, you must define a resource in order to execute it on your control system. Ingeneral, a resource is equivalent to a PLC or a micro controller.A resource definition consists of the following:
1. A name for identification.2. The hardware description: Information about the properties of your PLC which will be used
by OpenPCS.3. Information about the kind of communication between OpenPCS and the control system.4. A list of tasks which are to be run on the control system.
3.9.1 Creation of a resource
In order to create a new resource, click on “File →→→→ New→→→→ Resource” in the menu. A dialog boxappears in which you can define the properties of the resource.
fig. 49: Create new resource
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
57
• You can select a resource name with a maximum size of eight characters.• In this version, the default-Hardware type is the SmartPLC, but you can add further modules.
In this case, you can select that module which describes your control system.• If you select the checkbox „Enable Upload“, additional information will be transferred to the
control system to allow the re-compilation.
3.9.2 Edit a resource
• Right click on the resource, and select “Open” from the context menuOr• Mark the resource, and select the menu item “File→→→→ Open”Or
• Mark the resource, and click in the toolbar on the icon “Edit resource”:
The dialog “Editing Resource properties” will be opened:
fig. 50: Editing resource
To change the network settings, click on the button„Network settings“. The following dialogwill appear:
3 The Project Manager
58 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 51: Define a network protocol of a resource
Select in this dialog box the communication protocol of the control system.
3.9.3 Adding a task
In general, a task is equivalent to a program plus the information how the program can beexecuted. The definition of a task consists of:• The name• The Information about the execution of the task• A POU of type PROGRAM which should be executed in this task
You can add a task in different ways:• By Drag and Drop: Click on the block and hold pressed the mouse button, and put it to the
resource
• Mark the resource, and select the menu item “File →→→→ New→→→→ Task”
• Right click on the resource, and select context menu item “New task”
• Mark the resource, and click on the icon “Add task to the selected resource” of the tool-bar:
After adding of the task, the task-properties-window will be opened:
fig. 52: Task properties
Note that the task name depends on the program name, and can’t be changed. To complete thetask definition, you must specify the information, how the task can be executed:
• Cyclic• Timer controlled• Interrupt controlled
3.9.4 Adding of [direct] global variables
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
59
Global variables, which are added to a resource by this form, are global for resources. These canbe added by different ways:• Drag and Drop:
Click on the icon of the [direct] global variable definition, hold pressed the mouse button,and put it to the resource to which it should be added.
• From the Edit-menu:Mark the resource, and select the menu item„Edit →→→→ Add [Direct] Global Variables“.
fig. 53: Selection of the files which will be added
Select the file which you will assign to the resource, and accept this by the button„Open“ .
3 The Project Manager
60 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.9.5 Adding type definitionsType definitions are added as follows:• Per Drag and Drop:
Click on the icon of the type definition, hold pressed the mouse button, and put it to the re-source to which it should be added.
• By the Edit-menu:Mark the resource, and select the menu item„Edit →→→→ Add Typedef“.
fig. 54: Selection of the type definition file
Mark the type definition, which you want to add to the resource, and accept by „Open“-button.
3.9.6 Generate executable code
You have three possibilities to generate executable code of a resource:
• Mark the resource, and click on the icon „Generate code“ in the toolbar.
• Mark the resource, and select the menu item„Project →→→→ Build [All]“ .
• Right click on the resource, and select “Build [All] ” from the context menu.
The menu itemBuild All will recompile even unmodified portions of your application.
The compiler messages can be read in the lower window of the project browser.
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
61
fig. 55: Compiler messages during the compilation of the resource „Bsp_res“
If errors occurs, they will be displayed:
fig. 56: Error messages during compilation
If you double click on an error messages, the corresponding editor will be opened, and the cursoris placed at the line at which the error occurred.
3 The Project Manager
62 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.10 The Connection Setup tool
3.10.1 About Connection Setup
Connection Setup enables configuring connections from OpenPCS to a PLC.Connection Setup provides three options for you:You can ...• create new connections on your own.• change connection properties.• delete connections.
3.10.2 Components of a connection
A connection is a particular composition of a connection name, a driver and the driver´s settings.
Connection Setup shows not only the connection name, the driver and the driver´s settings, butalso the file path – called „Code-Repository path“ - of the .PCD file loaded in the PLC during thelast session.
If a .PCD file has not already been loaded via a particular connection, a question mark („?“)willappear as Code-Repository path.
3.10.3 Run Connection Setup
Open Connection Setup by left-clicking on the corresponding icon from the browser.
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
63
Note: „Click“ in the following text means – if not otherwise specified – „left-click“.Then the Connection Setup window containing the list of available connections appears.
3.10.4 Create a new connection
When the Connection Setup window appears, click on thenew button.The Connection Properties dialog box opens:
Now enter the name of the connection to be created. Take care that the connection name has notgot any spaces in it. Use the underscore („_“) instead of space.Select a driver by clicking on theselectbutton, the Driver Select window showing driver settingsopens:
3 The Project Manager
64 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Click the desired driver and then theOK button.
The Connection Properties window now becomes active again. Click thesettingsbutton.The Driver´s Settings dialog box opens:
You can modify the settings individually. When you agree with the adjusted settings, just clickOK , otherwise clickcancel.
If you want to place a remark, you can do this at the Connection Properties window.
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
65
Finally, click OK from the Connection Properties window.
3.10.5 Edit connection properties
By clicking on the connection´s name from the Available Connections List, it will becomeselected. Click on theProperties button and the Connection Properties dialog box appears.Go on like as creating a new connection (see above).
3.10.6 Delete a connection
Select a connection by clicking on the connection´s name from the Available Connections list. Ifyou then click thedeletebutton, the selected connection is deleted and disappears from the list.
3.10.7 Finish Connection Setup
Click theExit button from the Connection Setup window.
3.10.8 Select a connection in the browser
Double-click the resource icon from the browser, the Edit Resource Specifications dialog boxopens:
3 The Project Manager
66 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
To select the current connection, clickNetwork Settings from the Edit Resource Specificationswindows, the Select Connection window opens.
Select the desired connection by clicking its name and then clickOK .
Back in the Edit Resource Specifications window, clickOK to apply the modified settings.
3.11 Libraries
The Project Browser features functions required to use libraries, so you can re-use commonly usedfunctionality by putting functions and function blocks into a library of POUs.
3.11.1 Create a libraryTo create a library, proceed just like creating any normal OpenPCS project. Be sure to perform asyntax check when finished creating POUs (functions or function blocks) in your library project.
�If you receive a library from your supplier, youwill not have to "create" that library. Proceed with"installing" this library instead!
Example:• Start the Browser and create a new project named "MyLib" usingProject�New...• Create a function block named "det_edge" (for edge detection). Implement this function
block as shown below:
VAR_INPUTinput : BOOL ;
END_VARVAR_OUTPUT
output : BOOL ;END_VARVAR
tempvar : BOOL ;END_VAR
LD inputANDN tempvar
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
67
ST output
LD inputST tempvar
• Invoke a syntax check in the POU editor withFile�Syntaxcheck.
3 The Project Manager
68 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.11.2 Installing a library
Before you can use a library, you have to install it on your PC. UseLibrary�Install within theBrowser:
fig. 57: Install Library
Use the ”browse”-button to locate the .VAR file representing your project. If you created thelibrary yourself, this will be in the directory you specified when creating the library project withProject�New. If you received the libary on a disk, this can be something beginning with "A:\ ".During installation, the library project will be copied into a sub-directory of <windows>\openpcs.401\Lib.
Example:• Create a new project in the Browser usingProject�New.... Name that new project "TEST".• SelectLibrary� Install.• Now use the browse-button to locate the MyLib-project you created just before and press
"Install".
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
69
3.11.3 Adding a library to a project
After installation, all files needed for the library will be present on your computer. But thefunctions and function blocks in that library will not be automatically available in your projects.You have to "add" the library to the project first usingLibrary�Add.
Example:• SelectLibrary�Add,and in the dialog shown find your library "MyLib", then press OK.• Create a new POU of type PROGRAM, named "main". SelectInsert�User
Functionblocks....Press "Update" to see your library functions. To use your function blockDET_EDGE, implement program "main" as shown below:
VARsig1 AT %I0.0 : BOOL ;anEdge : DET_EDGE;count : UINT ;
END_VAR
CAL anEdge (input := sig1|:=output
)
LDN anEdge.outputJMPC ende
LD countADD 1ST count
ende:
• Compile that program, add it to a resource of your choice and execute it. Change input %i0.0and see variable count incremented
3.11.4 De-Install a library
If you want to get rid of a library installed on your PC, selectLibrary�Uninstall. In the dialogshown, select the library to get rid of and press OK.
Example:
• SelectLibrary�Uninstall. In the dialog, select <Windows>\ openpcs.401\MyLib”.• Press OK, and "MyLib" is no longer available as a library
3 The Project Manager
70 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.12 Registration of foreign files
Files, which you have written with the editors of OpenPCS ( IL, LD, FBD, ST, CFC), will be“registered” and displayed automatically by the browser. You can register files in one project,even if they were created by other programs, for example by:• Microsoft Word• Microsoft Excel• Microsoft Project• AutoCADThey will be displayed in the browser, and can be edited by a double click. To register a file,which was created by a tool, you can do as follows:• Save the file under the root directory of the current project. Files, which are not saved under
the root directory of the current project, can not be registered.
• Select “Project→→→→ Add file” or click on the icon “Add file” from the toolbar.
• Mark the file which you want to add.
• Accept by the “OK”-button.
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
71
3.13 Test and commissioning
To check a program, you need a PLC. You can use the real control system which you bought to-gether with OpenPCS. But in this manual, we will give a general example, and for that purposewe use a simulator ( the SmartSIM32 ) which is distributed with OpenPCS.
3.13.1 Start of the SmartSIM32
The SmartSIM32 is a simple simulation of a PLC under Windows.• Start the SmartSIM32 by selection of the menu item„Tools →→→→ SmartSIM“ in the project
browser.
The SmartSIM32 will be started:
fig. 58: The SmartSIM32
3.13.2 Go online
Before you go into the online-mode, you must assure that a PLC is running, e.g. the SmartSIM32,to which you want to create the connection.You have two possibilities to go online:
• Mark the resource which you want to test, and select menu item„Online →→→→ Go online“
Or• Right click on the resource, and select “Go online” from the context menu.The window “Test and commissioning” will be opened:
3 The Project Manager
72 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 59: Test and commissioning
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
73
3.13.3 Download of a resource
If you have changed your resource and the “Test and commissioning”-window is open, you cantransfer the resource to the PLC by:• Mark the resource which you want to download, and select the menu item„Online →→→→ PC-
>PLC“
Or• Right click on the resource, and select “Download” from the context menu.The messages are displayed in the lower window of the project browser.
3.13.4 Up load of a resource
If you are online, you can load a resource from the PLC into a project. This is only possible ifadditional information was also loaded to the PLC (see 3.9.1: „Creation of a resource“, checkbox"Enable Upload").
We recommend that you create a new project before doing the upload, so you will be sure not tointermix files uploaded with files already existing on the PC. Create a new Project withProj-ect�New..., then create a new resource in that new project, then start the upload:
• Mark the resource which you want to load, and select the menu item„Online →→→→ Upload“ inthe project browser
Or• Right click on the resource, and select “Upload” from the context menu.The messages are displayed in the lower window of the project browser.
3.13.5 The Test and commissioning
In the TUI, the watched variables will be displayed (see 3.13.6: „Watching “). This window canbe used as a remote control for the PLC by selection of the menu„PLC →→→→“ or the toolbar:
PLC ➜➜➜➜ STOP The program execution will immediately be interrupted.
PLC ➜➜➜➜ Coldstart The program of the user will be started with the initialvalues of the variables. Existing process data will beoverwritten eventually after a program interruption. The firstprogram execution after transfer to the PLC (or after switchon of the PLC) can only be done as cold start:The program execution will be started.
PLC ➜➜➜➜ Warmstart By warm start, retain variables will be reset to their initialvalues, durable variables keep their current value. (Programcontinuation after power blackout)
PLC ➜➜➜➜ Hotstart By hot start, the execution of the program will continue atthe location where was interrupted. The variables keep theirvalues which they had got before the stop. A hot start is onlypossible after a program stop.The program execution will continue.
3 The Project Manager
74 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.13.6 Watching variables
During a program test, it is important to know which values the variables have, or which valueproduce an error. Therefore, we have the possibility to watch variables.
• Change to the project browser.
• Open the branch of the resource in the project tree by click on the knot () in front of the re-source.
• Make the same with the branch of the task in the resource, then you will get the variables ofthe task in a listed form:
fig. 61: Variable listing of the task „POSITION“
You have three possibilities to select the variables which you want to watch:• Double click on the variable which you want to watch.• Right click on the variable, and select “Watch variable” from the context menu.• Mark the variable, and select the menu item„Online →→→→ Watch variable“.
The variable appears in the “Test and commissioning”-window where instance path, type, value,and status are displayed. These variables are permanently updated during the program executionon the PLC.
fig. 62: „Test and commissioning“-window with watched variables
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
75
3.13.7 Set variablesTo influence the behaviour of your control program for test cases, you can set variables to specificvalues.
You have three possibilities to set variables for test cases:
• Mark the variable in the T+C, and select the menu item„Debug →→→→ Set variable“.• Double click on the variable in the T+C.
• Set the corresponding input bits in the SmartSIM32 directly by mouse click.
fig. 63: Set variable
• Enter the new value and accept by „Set“-button.
3.13.8 The online-editor
With the online-editor you can watch entire programs or function blocks. The online-editor isonly available if you are online. The program or function block, which you want to watch, mustbelong to the resource that you loaded into the PLC.
fig. 64: Resource „Bsp_res“ with the task „POSITION“ was compiled and transmitted to the PLC
You have two ways to start the online-editor for a program:• Mark the POU, which you want to watch, in the branch under the corresponding resource,
and select the menu item„Online →→→→ Online Editor“Or• Right click on the POU, and select “Online Editor” from the context menu.
The online-editor will be opened.
You can display the values of the accumulator in the lower left column (which results from theexecution of the corresponding lines) by selection of the menu item„Online →→→→ Statusdisplay“.
3 The Project Manager
76 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 65: Online-editor with state display
3.13.9 Hardware info
This menu is only available in the online-mode. You get information about the used hardware.Mark the active resource and select the menu item„ Online →→→→ Hardware Info“ in the project
browser.
fig. 66: Information about the used hardware
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
77
3.13.10 Resource info
This menu is only available in the online-mode. The project name, the resource name, and theversion number (which is internal created and assigned to a specific compilation) are displayed.You can display the resource info by marking the resource and selecting the menu item„Online→→→→ Resource Info“ in the project browser.
fig. 67: Information about the resource
3 The Project Manager
78 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.14 Configuration of the project manager
This section gives you an overview about the settings of the project manager.
3.14.1 Settings
Select in the project browser the menu item “Extras→→→→ Options”.
The following window will be opened:
fig. 68: Settings
Online settings:• Query if resource is not up to date:
When trying to download a resource which needs re-compilation, OpenPCS will prompt forre-compilation.
• Query if program on PLC is not up to dateIf the code on the control system is not the same as the code of the resource which you wantto load, you will be asked if you want to transfer the new code.
Browser settings:• Display directory structure:
With this you can switch between the logical structure and the directory structure of the proj-ect. In the directory structure, the structure is displayed in the manner files are stored ondisk. In the logical structure, files are grouped to functionality.
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
79
fig. 69: Directory structure fig. 70: Logical structure
• Hide variable nodes:The listing of variables of a resource block can be shown or hidden. Only variables of com-piled resources can be displayed.
fig. 71: With variable knots fig. 72: Without variable knots
• Auto arrange tools:When the Browser is being minimized, all other tools of OpenPCS will be minimized with it.Resize the browser again and all other tools of OpenPCS will be resized with it. Disable thisoption to minimize the browser and keep other tools open.
3 The Project Manager
80 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
3.14.2 Printer set up
Before you can print, you must set up a printer at first that means you must give the informationwhich printer should be used, and how should be printed.• Select the menu item “File→→→→ Printer Setup ...”.
The window „Printer settings“ appears (please note that the layout and contents of this box mayvary widely depending on the Windows- and network-version you are using):
fig. 73: Printer settings
3 The Project Manager
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
81
4 The POU-Editor
82 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4 The POU-Editor
4.1 Overview
The POU-editor is a tool by which you can create POUs, check them for syntactical correctness,and compile. The POU-editor allows you to define “Global Data types“ for your special require-ments, to create a cross-reference list, and to print.
A POU always consists of a declaration- and an instruction part. Corresponding to this POU-structure, the POU-editor is subdivided into a declaration part (at the top), represented by thevariable-editor which is used to declare variables, and an instruction part (at the bottom) bywhich you create your application program using the declared variables:
fig. 74: POU-Editor with declarations part (at the top), and instruction part (at the bottom)
The expression “POU” is the abbreviation of ProgramOrganisationUnit, and represents the threePOU-types: program, function block, and function from which a PLC-program is constructed.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
83
fig. 75: Create new POU
Please note that a POU, created or saved by OpenPCS Version 4.1, can’t be used byearlier versions of OpenPCS, because the structure of the files has changed.
4.1.1 Program overviewThe POU-type “program” represents the main program. All project variables with a reference to aphysical address (e.g., marker, and inputs /outputs ) must be declared here. A program uses staticvariables for which the operating system of the PLC, henceforth called “system”, reservesmemory.
A program should have an easy to grasp size. If a complex program must be developed, asplitting into several subprograms, which are developed separately, could make the problemeasier. This kind of programming is called “structured programming”. The subtasks are treated infunction blocks or functions.
4.1.2 Function blocks overviewFunction blocks (FBs) are important elements for the structuring of your PLC-program. They areused by programs or other FBs, and can call other FBs or functions. The system reserves perma-nent memory for each instance of a FB. Because of this memory the instance keeps their localdata, and all input /output parameters (comparable with an object in other languages) from a callto the next one. An FB-instance is only usable inside the POU in which it was declared, unless itwas declared as “global”.
OpenPCS offers several standard functions and standard function blocks for common problems.As mentioned, you can define your own FBs, and declare an instance and use them in yourinvoking POU like the standard FBs.
4.1.3 Functions overviewFunctions are elements for the structuring of your PLC-program. They are used by programs orFBs, and can call other functions. A function can have one input-parameter, no input-parameter,
4 The POU-Editor
84 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
or several input-parameters which will be used to compute the return-value. In contrast to theFBs, a function returns only one element, and has no memory. A function, when called with thesame input-parameters, always returns the same return-value.
Functions are valid in the whole project, and can be invoked by every POU.
An existing POU (program, function , or function block) can be converted into a POU of anothertype. To do this, use the option “Convert POU-type”, see section “Convert POU-type”.
4.2 Declaration part
In the declaration part you define the variables which you want to use in the instruction part. In-stances of function blocks are declared like variables (“Instantiation”).
Delete declarations of variables and function block instances which you don’t needanymore. Otherwise you waste memory on your PLC.
4.2.1 Sections of variablesAccording to the application case, variables are declared in different sections of variables, so-called declaration blocks. A declaration block starts with a keyword and ends with END_VAR(e.g., VAR_GLOBAL ... END_VAR). An exception is „Type“: TYPE ... END_TYPE.
Input If a variable block should only be read inside a POU, you must declare this variableas input-variable. It thereby isn’t allowed to modify this variable in this POU. Aninput-variable can be used for the parameter transfer in a function or function block.
Keyword: VAR_INPUT
In_Out An input-/ output-variable is accessed under the same name by a function block. Thevariable gets a reference (pointer) to the transferred variable and its memory locationduring the parameter transfer by the block-call. Because a write-operation has adirect effect to the content of an In_Out-variable, it isn’t allowed to use a write-protected type for the transferred variable as INPUT-variables or variables withattribute CONSTANT.
Keyword: VAR_IN_OUT
Output The Output-variables are declared in the function block that use them for the returnof values. The calling POU can access them.
Keyword: VAR_OUTPUT
Global A variable should be declared as global variable in the POU “program” if this vari-able should be valid in this POU and in the function blocks called by this POU. Thisvariable must be declared as external variable (VAR_EXTERNAL) in all functionblocks which intend to use this variable.If a variable is declared in a global or direct global variable declaration, it must belocated in the variable-section “GLOBAL”. In this case, the variable is “resourceglobal” (see §3.7).The declaration of global variables can be supplemented by the attributes “RETAIN”
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
85
or “CONSTANT” (see “Attributes” ) , or by an address (see “Address” ).
Keyword: VAR_GLOBAL
External If a declared global variable of POU-type “program” will be used inside a functionblock which is called by this POU, this variable must be declared as external variableinside this function block.
Keyword: VAR_EXTERNAL
Type The keyword “TYPE” is used for declaration of user defined (derived) data typeswith local scope in the POU-types “program” and “function block”, or with globalscope in the type definitions (see “Type definitions” in chapter “Projectmanagement”). Derived data types are special data types which you can derive fromelementary data types.
Example:By appropriate declaration of a derived data type “Pressure” as data type INT withsubrange, the new data type can be used for the declaration of variables:
TYPEPressure : INT (0..100);
END_TYPEVAR
Chamber_pressure : Pressure;END_VAR
The variable “Chamber_pressure” thereby is of data type INT, and can only havevalues in the range 0..100.
Keyword: TYPE
Local A local variable is only valid inside the POU in which it was declared. Thedeclaration of local variables can be supplemented by the attributes “RETAIN” or“CONSTANT” (see “Attributes” ) , or by an address (see “Address” ).
Keyword: VAR
According to the POU-type only certain variable-sections can be used:
Program:TypeLocalGlobal
Function block:TypeInputOutputIn_OutLocalExternal
Function:TypeInput
4 The POU-Editor
86 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Local
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
87
4.2.2 Elements of a declaration of variables
A declaration of variables consists of following elements:
Element
Name (name of thevariable)
Necessary Enter the name of the variable. The length is limited to 64characters.
Type (Data type) Necessary Enter the data type of the variable, for example an elemen-tary data type as BOOL, UINT, etc., or a derived data typeor a function block.
Initial value Optional On program start the initial values will be assigned to thevariables. If no initial values are set, the variables get thedefault-values (for numerical variables is usually this thevalue “0”).
Attribute Optional Enter the attribute of a variable. You can choose betweenthe attributes RETAIN or CONSTANT (or none).
RETAIN: With the keyword RETAIN you indicate that thevariable should be permanent, i.e. this variable will bestored in a buffer if a power black-out or a stop of the con-trol system happen. Use RETAIN to declare a permanentlocal or global variable.
CONSTANT: With the keyword CONSTANT you indicatethat the PLC can’t modify the value of this data element.
Address Optional If you need a variable with a fix assignment to a physicaladdress (a directly represented variable), you make thisassignment by giving a code letter for the memory location,and code letter for the data format into the cell “address”.
Code letter for the memory location:I: Digital-inputQ: Digital-outputM: Marker
Code letter for the data size:X or without letter: Bool (1 Bit)B: ByteW: WordD: Double word
Example:%I0.0 in the “Free variable-editor”I0.0 in the “Syntax controlled variable-editor”(indicate a boolean input at the address 0.0)
Comment Optional Give addition information about the variable. In thesyntax-mode, the variable-editor sets the opening bracket
4 The POU-Editor
88 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
with asterisk "(*" in front of the comment, and the asteriskthe closing bracket "*)" behind the comment,automatically.You can see this only if you switch to the free variable-editor.
Example: (*This is a comment*)
fig. 76: Elements of a declaration
4.2.3 Variable-editor
You can use the variable-editor in the “syntax-mode” or “free-mode”. At start up of the POU-edi-tor, the syntax-mode is the default. You can switch to the both modes by „Extras�VariableEditor�Free Mode“ and „Extras�Variable Editor�Syntaxcontrolled Mode“ respectively, orby the buttons of the standard-toolbar:
Free-mode
Syntaxcontrolledmode
fig. 77: Tool buttons free-mode and syntax-mode
In the case of incorrect declaration in the free variable-editor and existence of complex, deriveddata types, switching into the syntax controlled mode is not possible.
The basic set-up of the variable-editor on the creation of a new POU can be modified under „Ex-tras�Options...“. Thereby, it was also selected in which mode the editor will be opened.
fig. 78: Editor options to adjust free/syntax-mode
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
89
4.2.4 Variable-editor: Syntax-modeIn the syntax controlled mode, the variable-editor allows a comfortable variable declaration. Youdon’t need to know the keywords for the variable declaration, these will be inserted automatically.The input of the variables is done separately for every variable-section under an own index card.
4.2.4.1 Selection of the variable-sectionThe variable-section is selected by a click on a displayed index card button at the lower windowframe; only index cards are available which are permitted in the selected POU-type. On the POU-type “program” for example, you can only select between the variable-sections “Type”, “Local”,and “Global” (see 4.2.1: Sections of variables).
fig. 79: Possible variable sections for the POU-type „Program“
4.2.4.2 Entry of linesThe input of variables is done by editing the columns. Between the columns you change left/rightby cursor and TAB / Ctrl+TAB respectively, and between the lines you change up/down and pageup/page down by cursor or simple by mouse click, respectively (see 4.2.2: Elements of adeclaration) .
You finish the input of a cell by changing to another one. A faulty or incomplete input of a cell isidentified automatically by the syntax check if it’s possible. A faulty cell will be indicated by thefollowing box:
fig. 80: Message after incorrectly edited line
Accept this message by „OK“, and correct the line.
4.2.4.2.1 Enter lines by menu systemOn the cells under “type” and “attribute”, you can select the input from a list. This list field isopened by a click with the left mouse button on the empty cell and then on the displayed arrow▼. With the keyboard, press ALT and cursor-down simultaneously to open the list.
4 The POU-Editor
90 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 81:Declaration part in syntax-mode: Selection of the data type
Only elementary data types can be selected from the list field. Further data types and functionblocks can be selected by the context menu and the menu “Insert” respectively.
• Click right on the relevant line, or mark the line and select the menu “Insert”
The context menu and the „Insert“-menu will be opened respectively:
fig. 82: Context menu in the declaration part
fig. 83: Menu „Insert“
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
91
Select the category from which you want to select a data type and function block respectively:
(1) Elementary Datatypes...See fig. 84: Example: Insert of elementary data types
(2) User Datatypes...... are data types which are either locally defined in the POU or are globally definedin a global type definition.
(3) Manufacturer Datatypes...... are defined by the manufacturer, and are distributed with OpenPCS as standardtypes.
(4) User Functionblocks...... are POU-function blocks which are written by the user, and belong to the project.
(5) Manufacturer Functionblocks...... are standard function blocks which are distributed by the manufacturer withOpenPCS.
fig. 84: Example: Insert of elementary data types
fig. 85: Example: Insert of manufacturer-function-block
Select the data type and the function block from the list respectively, and accept by „OK“.
4 The POU-Editor
92 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
The data type and the function block will be inserted under “Type” in the corresponding line.
4.2.4.2.2 Line operationsIn addition to the standard Windows functions for the editing of texts as copy, cut, insert, and de-lete, you can also insert or delete one or more lines at arbitrary position in the table by the func-tions “Insert Row” and “Delete Row”.
A line will be marked by click on the line number at the left edge.
Insert lines:• Mark the line in front of which a new line should be inserted.
• Select the menu item„Edit � Insert Row” , or click right on the line and select“InsertRow” from the context menu.
Delete line:• Mark the line which should be deleted.
• Select the menu item„Edit � Delete Row”or click right on the line and select“DeleteRow” from the context menu.
4.2.5 Variable-editor: Free mode
In “free mode”, the variable-editor is suited for trained programmers, demanding quick input andoverview, but less guidance. Every declaration line must be entered syntactically correct – errorswill only be reported on the syntax check of the entire POU.
In the “free mode”, the variable-editor displays all declared variables simultaneously – in contrastto the “syntax mode”. You get a better overview over the declared variables.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
93
fig. 86: Free variable-editor
4.2.5.1 Variable-sectionsIn this mode you declare the variables of a section in each case in a separate declaration block.For a better overview you can separate the single components of a declaration line by tabulators.For the declaration use the keywords of the different variable-sections, for exampleVAR/END_VAR for local variables. The syntax check is not done during input, possible errorswill only be displayed on the syntax check of the entire POU.
Pay attention to the order of the declaration blocks in the free variable-editor. INPUT-variables must be declared in front of IN_OUT-variables, IN_OUT-Variables must bedeclared in front of OUTPUT-variables, etc. (see IEC 1131-3):
Order of the declaration blocks:
(1) VAR_INPUT Input variables(2) VAR_IN_OUT Input-/output variables(3) VAR_OUTPUT Output variables(4) VAR_GLOBAL Global variables(5) VAR_EXTERNAL External variables(6) TYPE Derived data types(7) VAR Local variables
4.2.5.2 Declaration linesA declaration line has the following form, where optional parts are set in [square] brackets, andexpressions are set between <sharp> brackets:
<variable name> [AT <Address>]: <Type> [:= <Initial value>]; [(* <Comment> *)]
fig. 87: Declaration line in the free mode
First the variable name is given, followed by a colon. Behind the colon is the type, and eventuallythe hardware address introduced by the attribute “AT”. Should the variable have a definite valueon start, this value will be given after a “:=”. A line ends always with a semicolon (;). The linecan be commented, and comments are set between (* and *).
Example:
Expvariable1 AT %I0.0: BOOL; (* variable of type BOOL at the address %I0.0 *)Expvariable2 : BOOL := TRUE; (* variable of type BOOL with the start value TRUE *)
An exception is the direct address without variable names (these variables will be referenced bythe address):
AT <Address> : <Type> [:= <Initial value>]; [(* <Comment> *)]
fig. 88: Exception: Address without variable name
In this case the variable name is omitted, therefore the address statement is not optional.
Example:
AT %I0.0 : BOOL (* At the address %I0.0 is a data of type BOOL *)
4 The POU-Editor
94 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
The second way of addressing should be avoided for the sake of clarity, because the meaning ofthe variable relates to the variable name mostly. This is important if other people should read oredit this POU.
SomeExamples:
Variable with no initial value InterMedSum : INT;
Variable with initial value Pieces : INT := 5;
Directly represented variable withoutname and with no initial value
AT %Q0.0 : BOOL;
Directly represented variable with nameand with no initial value
Valve AT %Q0.2 : BOOL;
Example function block Counter1 : CTU;
fig. 89: Example for the variable declaration in the „Free-mode“
On declaration of variables you can find information and hints for the use of vari-able-sections, data types, and function blocks in the sections 4.2.1: „Sections ofvariables“ and 4.2.2: „Elements of a declaration“.
Input with menu system:
For the simplified selection of data types, OpenPCS offers a list of all available data types. Hereyou can use a special help.
Set the cursor at the location where you want to insert the abbreviation for the type identifier andfunction block identifier respectively.
Select the menu “Insert”, or click right in the declaration window and select a domain fromwhich you want to insert an identifier:
(1) Elementary Datatypes...See fig. 84: Example: Insert of elementary data types
(2) User Datatypes...... are data types which are either local defined in the POU or are global defined in aglobal type definition.
(3) Manufacturer Datatypes...... are defined by the manufacturer, and are distributed with OpenPCS as standardtypes.
(4) User Functionblocks...... are POU-function blocks which are written by the user, and belong to the project.
(5) Manufacturer Functionblocks...... are standard function blocks which are distributed by the manufacturer withOpenPCS.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
95
fig. 90: Example: Elementary data types
Select the data type or the function block respectively, and accept by “OK”. You can get adescription by selection of the abbreviation and press of the “Help”-Button.
4.3 Instruction part
In the instruction part of a POU you program the logic which the PLC has to execute. Selection ofthe programming language (IL, LD, FBD, ST, SFC, CFC) is left to your choice, depending onyour experience or the task to be solved you may pick one or more of these languages.
The menu bar offers all necessary commands for the creation and editing of a program. For fre-quently used actions you can select buttons from the toolbar additionally:
Save current POU
Find
Replace
Cut into the clip board
Copy into the clip board
Insert into the clip board
Select from all variables
Switch to the free variable-editor
Switch to the syntax controlled variable-editor
Switch to the language IL
Switch to the language LD
Switch to the language FBD
4 The POU-Editor
96 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Switch to the language ST
Check syntax
Direct help
4.4 The instruction part in IL
The programming language IL is close to a machine code, and therefore an efficient languageonto which the graphical languages are mapped. IL is a textual, line oriented language.
Condition: The POU-editor is opened.
Display the standard-toolbar with the menu item “View�Standard-Toolbar”:
.
fig. 91: Standard-toolbar
Declare the variables as described in chapter 1.2, press the toolbar-button “Use of the IL-editor”from the toolbar:
fig. 92: „Use of the IL-editor“
4.4.1 The structure of an IL-lineAn IL-line has the following form, when optional parts are set in [square] brackets, andexpressions are set between <sharp> brackets:
[<Label>:] <Operator> <Operand1> [,<Operand2>,<Operand3>,...] [(* <Comment> *)]
fig. 93: Syntax of an IL-line with operator
At the beginning is a label if the line represents a jump target. After that an operator is placedfollowed by the operands and separated by commas. Comments are enclosed by (* and *).
Example:Start: LD a (* Load a in the register *)ADD b (* Add b to the register *)ST c (* store result to variable c *)
A call to a function block instance is done using operator CAL and CALC respectively; the oper-and is the instance name, followed by arguments supplied in parentheses:
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
97
[<Label>:] CAL/CALC <Instance name>([<Input1>:=<Value1>,<Input2>:=<Value2>,...]|
[<Variable1>:=<Output1>,<Variable2>:=<Output2>,...])
fig. 94: Syntax of a call of a function block instance
The parameter transfer consists of two parts. In the first part the parameters are transferred to thefunction block by setting values to the INPUT- and IN_OUT-variables respectively. Thevariables, which get no value, retain the value of their last call and their initial value respectively.Separated by a “|” from the first part, output parameters are specified.
Example:In the declaration part:VAR
FB: TON; (* Declaration of the function block instance FB of type TON *)a : BOOL;b : TIME;c : BOOL;d : TIME;
END_VAR
In the instruction part:CAL FB (
IN :=a,PT :=b|c:=Q,d:=ET)
(* Call of the function block instance FB with input-parameter a and b, and output-value-transmission to c andd *)
operands and comments are displayed in different colours, so your POU getsmore clarity.
CAL Counter_3(CU :=Photosensor assembly,RESET:=RES_Button,PV := 120|full := Q)
fig. 95: Calls can be spread out over several lines
4.4.2 Input helpsTo realise an easy use of OpenPCS many helpful tools like the toolbox, context menu, and “In-sert”-menu are available.
4.4.2.1 Insert of variables and instance-callsPreviously declared variables or FB-instances can be inserted as follows:Place the cursor to the position at which you want to insert the variable or instance-call respec-tively.
4 The POU-Editor
98 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Either click right into the IL-window to open the context menu or select the menu “Insert”.Select “Variable� ” and the variable-section in which the variable or instance was defined.A menu window with an alphabetic ordered list of all declared variables and function block in-stances of this selected variable-section will be opened, respectively:
fig. 96: Insert of a variable or function block instance
If you select a function block instance, you can adjust by the checkbox “FB-Instances withparameters” if the parameter passing part should be inserted. You only have to enter the valuesand variables into the template, respectively, and if necessary change CAL to CALC if you wish aconditional call.Mark the variable and function block, respectively, which you want to insert and accept by thebutton “OK”.
fig. 97: FB-Instance with call-template
4.4.2.2 Insert operatorsThe frequently used operators can be inserted by the toolbox.Select the menu item “View� Toolbox” if the toolbox is not yet displayed.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
99
fig. 98: The toolbox
• In the toolbox you can click on the field with the operand which you want to insert at cursorposition.
The operand will be inserted at cursor position.
You can select from a list of all operators by the context menu or the “Insert”-menu:
• Place the cursor to the position at which you want to insert the operator.• Either click right into the IL-window to open the context menu or select the menu “Insert”.• Select “Operators...”.The selection window will be opened:
fig. 99: Selection of an operator which is to insert
• Select the operator group and then mark the operator which you want to insert.
• Insert the operator at cursor position by click on the button “OK”.
4.4.2.3 Insert functionsTo insert functions you have the choice between user defined functions and manufacturer definedfunctions. User defined functions are functions that have been defined by yourself, while manu-facturer functions are functions that are distributed together with OpenPCS.
• Place the cursor to the position at which you want to insert the function.• Either click right into the IL-window to open the context menu or select the menu “Insert”.• Select “Insert�User Functions...” or “ Insert�Manufacturer Functions...”.The following selection dialog will be opened:
4 The POU-Editor
100 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 100: Function “Insert”
Select a function from the list and insert at cursor position with “OK”.
4.5 The instruction part of the programming in LD
4.5.1 OverviewThe graphical programming language Ladder Diagram (LD) has its origin in the domain of elec-tromagnetic relay systems and is suited for the programming of logical connections of binaryvariables with their possible states TRUE “1” or FALSE “0”.
LD describes the possible current flow through a network, starting at the left “power rail” (whichhas the state TRUE) pass through different network elements (the variables) to the right “powerrail”.
The result is determined by the network elements, their placement, and the kind of their connec-tions (serial or parallel).
A POU can consist of single networks according to the program sequence. In the head of the net-work is the current network number, a comment can be entered below the network number.
LD-networks consist of the graphical objects:
- Connections,
- Contacts and coils,
- Jump instructions,
- Calls of function blocks.
The declaration of variables is done in the variable-editor which is the same for all programminglanguages. The detailed description of the declaration of variables can be found in section 4.2.
The programming languages IL, LD, and FBD can be cross-compiled to each other. Therefore,you can create a program in LD-style and represent or edit further this program in IL- or FBD-style afterwards. Some constraints should be noted which are described in section 4.8.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
101
Activate the POU-editor LD (Extras� Programming Language� LD ) in the instruction part tocreate a POU in the programming language LD.
A series of language elements like network-structure of the POU, the representation of functionsor function blocks are the same in the programming languages LD and FBD. There are languagespecific differences between LD and FBD on the programming of logical connections of binaryoperands.
All actions for the entering of the program can be selected by the menu “Insert” in the LD-editor.Actions which are used frequently, are available in the toolbar additionally. You can also use thecontext menu by click with the right mouse button. Only for some actions you have to use thekeyboard when entering the program.
The following descriptions for the program in LD creation are based mainly on the use (themenu-actions) of the context menu.
At first the basic POU-structure is described, i.e. the network ordering and the structure of asingle network will be described. The identification of networks as branch destination, the inputof variable names, and the comments will be explained in the further sections.
The variable identifier and the branch label get the specification “undef_opd” automatically. Thisspecification must be replaced by the desired variable identifiers or branch labels.
Arithmetic functions, logical operations, and compare functions can be used by thedialog field “Operators” from the list field of the POU-editor which you haveopened by the menu item “Insert�Operators...” or by the context menu“Operators...” before.
In one network you can use arbitrarily many graphical elements side by side, butonly one function block call. The graphics will extend over several pages if neces-sary. Make a test print and modify the printer adjustments to determine the biggestpossible printable area.
4 The POU-Editor
102 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.5.2 Create the POU in LD
• In the Project Manager, selectFile�New�POU Program, or File�New�POU FunctionBlock or File�New�Function, depending on which type of POU you want to create.
• A dialog box will be opened prompting you for the name of the POU. Enter the name andpress "OK". The POU Editor will be opened on that new POU
• In addition to the standard tool buttons display also the tool buttons for editing in LD-notation by “View�LD/FBD-toolbar ”.
• Declare the variables, as declared in chapter 4.2, and press the tool-button “Use of the LD-editor”:
fig. 101: Tool-button “Use of the LD-editor”
In the menu “Insert” the following actions are available for the program development:
fig. 102: Accept variable into LD
For an easier program editing, you can also use the buttons of the toolbar:
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
103
fig. 103: Button of the tool panel
4.5.2.1 Display and Accept operatorsOpenPCS allows you to display a toolbox or a list field with all operators in order to give you anoverview of all available operators. The list has the advantage to display operators in groups.From this list or toolbox you can directly insert operators in the instruction part.
Condition: The window of the instruction part is activated.
• Activate the toolbox by the menu item„View�Toolbox“ and click on the correspondingoperator for retrieving.
fig. 104: Toolbox of the operators
or alternatively:
• Select the operator from the list field in the dialog field “Operators”, which you open by themenu item “Insert�Operators...” or by the context menu “Operators...”. On the right of thelist field, all operators are listed which are available in the first marked group “Logic”. If youmark another group, the operators, which belong to this group, will be listed.
• Mark the group and the desired operator and select the button “OK ”. The selected operatorwill be inserted at the cursor position.
If you need information to the single operators, select the button “Help”.
Depending on the cursor position or the marked area in the instruction part, the POU-editoroffers different actions in the menu “Insert” of the toolbar or context menu.
4.5.2.2 Create new network
Conditional Operation
4 The POU-Editor
104 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Select „Insert�Initial LD Network“ . In the instruction part appears the first network with acontact and an output symbol. You can get this action by the toolbar or the context menu, too.
fig. 105: Conditioned operation
Unconditional Operation
Select the operations JMP or RET from the menu„Insert�Operators...“or the toolbox.
The jump symbol appears in the new network, the element for specification of the branch label isgiven and can be edited consequently.
fig. 106: LD – branch label
Accept by the Enter-key. The window „Name element" will be opened, in which you specify thebranch label:
fig. 107: Name element: branch label
4.5.2.3 Insert function blocks• Place the cursor at the desired position in the instruction part of your LD-POU.
• Select the function block from the list of all declared variables which you opened by the menuitem „Insert�Variable�All...“ or the context menu. The option „All...“ cause that in addi-tion to all variables also all declared manufacturer- and user defined function blocks arelisted for transmission in the dialog window “Insert variable”.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
105
fig. 108: Select function block instances
Mark the instance of the desired function block or enter this instance directly into the input-fieldand accept by button “OK”. The graphical symbol of the function block appears with all oper-ands as a new network. Name the elements as desired.
4.5.2.4 Insert functionFunctions can’t be entered into LD-networks.
The OpenPCS POU Editor is capable of mixing languages LD and FBD. If a network contains afunction, the LD-Editor will display this network in FBD and the rest of the POU in LD. To add afunction call, switch to FBD, do so, then switch back to LD.
4.5.2.5 Edit a POU in LDTo modify the POU, you must mark the relevant part of the POU before. You can mark a single,graphical element, several neighbouring elements, a network, or an entire POU.
Mark POU-elementsA single element can be marked by the mouse pointer, the arrow keys, or the tabulator key. Tomark several neighbouring elements in a network, you have different possibilities:
- Press the shift key and use the mouse to mark elements.
- Press the shift key and use the cursor keys to mark elements
- Drag a rubber band around the network region using the mouse
To mark a complete network, select with the mouse pointer the square marker which is directlyvisible at the left screen border below the network. To mark several networks, first click on onenetwork marker, then press shift and select another network marker.
To mark the entire POU, select “Edit� Select All”.
Delete a network• Mark the network that you want to delete.
4 The POU-Editor
106 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
• Use delete key „DEL" or„Edit� Delete“ from the menu„Edit“ or the context menu.
The marked network will be deleted.
4.5.2.6 Mark a network as branch labelA network can be marked as a branch label for a branch operation which is programmed inanother network.
• Place the cursor into the network which you want to mark as branch label.
• Select „Insert� Network-Label“ . Dialog „Network-Label” will be opened:
fig. 109: LD - Network-Label
• Enter the name of the branch label into the cell and accept by the „OK”-button. The name ofthe branch label appears in the network header of the marked network:
fig. 110: LD-network with branch label
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
107
4.5.2.7 Edit logical operationA LD-initial-network consists of a contact and an termination symbol. In this network you caninsert and edit logical operations.
4.5.2.8 Insert of an AND-operationMark the horizontal line where the new contact should be inserted.
fig. 111: Place for insertion is marked
Use the “space key”. A contact will be inserted. The AND-Operator can be picked from the tool-box or from dialog „Insert�Operators...“or from the context menu.
fig. 112: AND-operation inserted
4.5.2.9 Insert of an OR-operationMark the contact or the network region to which a parallel contact should be created.
fig. 113: An Input is marked to which a parallel contact should be created
Select the OR-Operator from the toolbox or the list field „Operators“ which you open by the menuitem “Insert�Operators...“or the context menu.
A new contact will be inserted parallel to the marked region.
4 The POU-Editor
108 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 114: Parallel contact inserted
4.5.2.10 Insert of a conditional termination• Mark the horizontal line directly in front of or after a termination symbol.
fig. 115: Position of inserting a new termination is marked: Termination is inserted under „Output_1”
• Select the desired conditional operation: ST, STN, S, R,JMPC, JMPCN, RETC or RETCNfrom the toolbox or the list field “Operators” which you open before by the menu item “In-sert� Operators...” or the context menu.
The corresponding graphical symbol appears above (marker in front of the output symbol) or be-low (marker after the output symbol) the existing output symbol.
fig. 116: List of branch operators
You can also mark the horizontal line directly in front of the Output_2 and after that insert theconditioned operation.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
109
fig. 117: New output above „Output_2“ inserted
4.5.2.11 Modify an expressionIf you have an expression consisting of a mixture of AND and OR expressions, you can modifythat expression by inserting or removing a vertical connection between parallel rungs.
Add vertical lineTo add a vertical connection, first mark the two ending points of the vertical line:
• Use the mouse or the arrow keys to mark the first ending point.
• Press and hold theCTRL-Key, then mark the second ending point (mouse or keyboard).
• Release theCTRL-Key.
fig. 118: Connecting ending points are marked
Hit the Spacebarto have the vertical connection inserted:
4 The POU-Editor
110 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 119: Vertical connection was inserted
Delete vertical lineMark the vertical line that you want to delete.
fig. 120: Deleting connection is marked
Use the "DEL" key or "Edit�Delete". The marked line will be deleted, the OR-before-AND-op-eration turned into anAND-before-OR-operation:
fig. 121: Connection is deleted
4.5.2.12 Negate a contact or an outputYou can only negate one single element at a time.
• Mark the element to be negated.
fig. 122: The element, which is to negate, is marked
• Hit the spacebar. The marked element will be negated.
You can also carry out this action by the toolbar or the toolbox.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
111
fig. 123: Element was negated
4.5.2.13 Delete elementsYou can delete a single element or a group of neighbouring elements. The Editor will take carethat the elements remaining after the delete are legal LD or FBD networks. If you want to deletemultiple elements in mixedAND/OR-operations, the POU-editor allows only such groupings ofelements that lead to a useful network content that means after the deleting at least one validinitial network must remain.
In networks with conditional branch operations, e.g.,JMPCN or RETC, the entire logicaloperation can be deleted. An unconditioned operation, JMP or RET, remains in the network.
In networks with conditioned assignments, ST, STN, S and R, at least one contact must remainafter the deleting.
When deleting output symbols, at least one output must remain.
4.5.2.14 Name elementsWhen you insert operations, the operand is always given the name “undef_opd”. You have toname the elements properly. When invoking function block instances, you pass values by namingthe inputs and outputs of the function block appropriately.
• Mark the element you want to name.
fig. 124: The element, which is to name, is marked
• Hit the Enter key. The dialog field „Name element” will be opened:
fig. 125: Name LD - Element
4 The POU-Editor
112 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
or
• Select the variable from the list of all declared variables which you open before by the menuitem „Insert�Variable�All...“ or the context menu.
4.5.2.15 Name a labelA jump instruction, like most other operations, has to be completed by entering the label to beused as the jump target.
• Mark the jump instruction for which you want to define a label.
fig. 126: The jump instruction, which is to define, is marked
• Hit the Enter key.
• This action is also available in the menu „Insert� Name Element...“ .
The dialog field „Name Element" will be opened:
fig. 127: Name LD - Element as label
• Enter the name of the branch destination and hit the „OK"-button.
fig. 128: Jump operation is defined
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
113
4.5.2.16 Enter a network-commentEach network can have a comment.
• Have the cursor positioned in the network to be commented.
Select „Insert�Network-comment...“. The dialog field „Network-comment" will be opened:
fig. 129: Enter LD - network-comment
• Enter the comment, then press „OK". The entered comment appears in the network headingbelow the network number.
fig. 130: Network-comment is inserted
4.5.2.17 Create function blocks in LD
• In the Project Manager, selectFile�New�POU Function Block
• A dialog box will be opened prompting you for the name of the POU. Enter the name andpress "OK". The POU Editor will be opened on that new POU
For the creation of function blocks in LD the same rules are valid as on the creation of a program.
4.5.2.18 Create functions in LD• In the Project Manager, selectFile�New�Function
4 The POU-Editor
114 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
• A dialog box will be opened prompting you for the name of the POU. Enter the name andpress "OK". The POU Editor will be opened on that new POU
For the creation of functions in LD the same rules are valid as on the creation of a program.
4.6 The instruction part on programming in FBD
4.6.1 Overview
The programming language Function Block Diagram (FBD) has its origin in the domain ofsignal processing.
The instruction part is subdivided into networks like in LD before. The single programming ele-ments are represented by means of graphical circuit symbols. These graphics give the POU astructure.
Operators, functions, and function blocks are represented as square symbols with connectionpoints for the inputs of the left side and connection points for the outputs on the right side. Theconnection points are parameters (variables/constants) or other inputs or outputs. First, these areset toundef_opd.
Inside a network, several operators and functions can be combined in arbitrary order.
A function block invocation represents a network on its own, no further program components canbe added. The function block can have multiple inputs and outputs. A function has only oneoutput and several inputs.
If you create a user defined function block, the inputs and outputs on the block symbol are dis-played in the order in which they were declared in the variable-editor of this function blocks.
FBD-networks consist of the graphical objects:
- Network label,
- Network comment, and
- Network graphic,
which will be explained in the following.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
115
4.6.1.1 Network labelEach network, which another network should jump to, starts with an alphanumeric identifier thatis used as a jump label.
fig. 131: Network-Label
4.6.1.2 Network commentBetween network label and network graphic, a network comment can be inserted.
fig. 132: Network-comment
4.6.1.3 Network graphicThe network graphic consists of graphical elements (rectangular symbols) with connection pointsfor the input on the left side and for the output on the right side. The signal processing is realisedthrough these connection points.
Outputs of one rectangle and the outputs of different rectangles mustn’t be combined, because thesource of transferred data is not unique.
The data flow can only happen from one output or one variable/constant to one or more inputs ofthe following rectangle.
4 The POU-Editor
116 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 133: Network-graphic
The variable declaration is done by the variable-editor which is used in each programming lan-guage. The complete description of the variable declaration can be found in section 4.2.
The programming languages IL, LD, and FBD can be compiled among each other. Therefore,you can create a program in LD-style and represent or edit further this program in IL- or FBD-style afterwards. In addition, some conditions should be noted which are described in section 4.8.
Activate the POU-editor FBD (Extras� Programming Language� FBD ) in the instructionpart for creation of a POU in the programming language FBD.
A series of language elements like network-structure of the POU, the representation of functionsor function blocks are the same in the programming languages LD and FBD. There are languagespecific differences between LD and FBD on the programming of logical connections of binaryoperands.
All actions for the entering of the program can be select by the menu “Insert” in the FBD-editor.Actions, which are used frequently, are available in the toolbar additionally. For a faster enteringon the programming of your POU you can also use the context menu by click with the rightmouse button. Only for some actions you have to use the keyboard when entering the program.
The following descriptions for the program in FBD creation are based mainly on the use (themenu-actions) of the context menu.
The principle POU-structure is described in the programming hints, i.e. the structure of a singlenetwork will be described. The identification of networks as branch destination, the input of vari-able names, and the comments will be explained in the further sections.
Arithmetic functions, logical operations, and compare functions can be called bythe dialog field “Operators” from the list field of the POU-editor which you haveopened by the menu item “Insert�Operators...” or by the context menu“Operators...” before.
4.6.2 Create a POU in FBD
• In the Project Manager, selectFile�New�POU Program, or File�New�POU FunctionBlock or File�New�Function, depending on which type of POU you want to create.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
117
• A dialog box will be opened prompting you for the name of the POU. Enter the name andpress "OK". The POU Editor will be opened on that new POU
• In addition to the standard tool buttons display also the tool buttons for editing in LD-notation by “View�LD/FBD-toolbar ”.
fig. 134: LD/FBD-toolbar
• Declare the variables, as declared in chapter 4.2, and press the tool-button “Use of the FBD-editor”:
fig. 135: Tool-button “Use of the FBD-editor”
In the menu “Insert” the following actions are available for the program development:
fig. 136: FBD –Accept variable
4 The POU-Editor
118 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.6.2.1 OperatorsOpenPCS allows you to display a toolbox or a list field with all operators in order to give you anoverview of all available operators. The list has the advantage to display the operatorsthematically ordered. From this list or toolbox you can directly Accept a required operator intoyour POU.
Condition: The window of the instruction part is activated.
• Activate the toolbox by the menu item„View�Toolbox“ and click on the correspondingoperator for retrieving.
fig. 137: The toolbox
or alternatively:
• Select the Operator from the list field in the dialog field “Operators”, which you open by themenu item “Insert�Operators...” or by the context menu “Operators...”. On the right of thelist field, all operators are listed which are available in the first marked group “Logic”. If youmark another group, the operators, which belong to this group, will be listed.
fig. 138: Insert operator
• Mark the group and the desired operator and select the button “ OK ”. The selected operatorwill be inserted at the cursor position.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
119
If you need information on any operator, select the button “Help”.
Depending on the cursor position or the marked area in the instruction part, the POU-editoroffers different actions in the menu “Insert” of the tool panel or context menu.
4.6.2.2 Create new network
Conditional Operation
Select „Insert� Initial-F BD-Network“. In the instruction part appears the first network with acontact and an output symbol.
Unconditional Operation
• Select the operations JMP or RET from the menu„Insert�Operators...“or the toolbox.
The jump symbol appears in the new network, the element for specification of the branch label isgiven and can be edited consequently.
fig. 139: FBD – branch label
• Accept by theEnter-key. The window „Name element" appears, in which you enter thebranch label.
4.6.2.3 Insert a function block
A function block represents its own network.
• Place the cursor at the desired position in the instruction part of your FBD-POU.
• Select the function block from the list of all declared variables which you opened by the menuitem „Insert�Variable�All...“ or the context menu. The option „All...“ has the effect thatall variables and all manufacturer- and user defined function blocks will be listed for transferin the dialog box “Insert variable”.
4 The POU-Editor
120 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 140. Accept declared function block
• Mark the instance of the desired function block or enter this instance directly into the input-field and accept by button “OK”. The graphical symbol of the function block appears with alloperands as a new network. Give the parameters the desired variable identifiers.
fig. 141: Function block inserted
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
121
4.6.2.4 Insert function
• Mark the complete connection line after which a function should be inserted.
fig. 142: Position for insertion is marked
• Select the function from a list which you can open by the menu item with„Insert�Manufacturer/User Functions...“or by the context menu.
fig. 143: FBD – insert function
• Mark the desired function or enter this function directly into the input field and hit the button“OK”. The graphical symbol of this function will be inserted after the marked position.
4 The POU-Editor
122 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 144: Function „ispositive“ was inserted
If you try to insert a function at a incorrect position, the following error message will bedisplayed:
fig. 145: FBD – Function inserted incorrectly
4.6.2.5 Delete function block or function• Mark the function block or function and hit the deletion key „DEL" or„Delete“ by the menu
item or the context menu. The marked graphical circuit symbol will be deleted.
4.6.2.6 Edit a POU in FBDTo modify the POU, you must mark the relevant part of the POU first. You can mark a singlegraphical element, several neighbouring elements, a network, or the entire POU.
4.6.2.7 Mark POU-elementsA single element can be marked by the mouse button, arrow keys, or tabulator key, and in combi-nation with the shift key, too.
• To mark several neighbouring elements in a network, you have different possibilities:
Hold pressed theshift keyand select the twoborder elementsby themouse pointer.
Hold pressed theshift keyand select theaffected elementsby thearrow key.
Draw aframearound the network region with themouse pointer.
• To mark a complete network, select the square marker point by the mouse pointer which ismapped at the left screen side directly below the network.
• To mark several networks, first click on a marker. Press the shift key and hold it pressed, andselect the marker of the above or below situated networks.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
123
• To mark the entire POU, select “Edit� Select all”.
4.6.2.8 Insert a network• Mark the network marker after which the new network should be inserted.
• Select from the menu„Insert" the desired network content. For selection are: The header of aFBD/LD-networks, function blocks („variables...“), a unconditional jump, and aunconditional return.
4.6.2.9 Delete networkA network can be deleted completely.• Mark the network to delete, and hit the deletion key „DEL” or select„Edit�Delete“. The
marked network will be deleted.
4.6.2.10 Mark a network as a branch labelA network can be indicated as a branch label for a jump instruction which is programmed in an-other network.
• Place the cursor into the network that you want to indicate as branch label.
• Select „Insert� Network Label...“. The window „Network Label” appears:
fig. 146: FBD - Network-label
• Enter the name of the branch label into the cell and hit the button „OK". The branch labelname appears in the network-header of the marked network:
fig. 147: Network was provided with a label
4 The POU-Editor
124 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.6.2.11 Edit a networkIn an existing network you can insert circuit symbols like operators and functions. It is therebypossible to program several operators and functions in arbitrary order.
With a function, only the first input of the function can be connected to other functions.
Editing a network in FBD arbitrary operators and functions can be encapsulatedeven if the data types don’t match. The check of data types happens only during thesyntax check.
4.6.2.12 Insert a circuit symbolTo insert a circuit symbol, the contact line must be marked behind or in front of an existingcircuit symbol. The new circuit symbol will be inserted on the right side of the marked position.
• Mark the contact line behind which you want to insert a new operator, for example a logicalAND-operation.
fig. 148: Position for insertion is marked
• Select the operator „AND“ from the toolbox
or
• from the list field „Operators” which you have opened by the menu item with „In-sert�Operators...“or by the context menu.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
125
fig. 149: List of logical operators
4 The POU-Editor
126 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
• Hit the button „OK”. The symbol of the operator appears behind the marked position:
fig. 150: Operand „AND“ was inserted
4.6.2.13 Delete circuit symbolMarked circuit symbols can be deleted from a network. Deleting a marked operation symbol, onlythe circuit symbols are retained which are pre-connected on the top input and all following ones.
• Mark the circuit symbol to delete.
fig. 151: Circuit symbol to delete is marked
• Hit the „DEL" key or use „Edit�Delete“. The marked circuit symbol will be deleted.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
127
fig. 152: Circuit symbols and no longer connected circuit symbols were deleted
4 The POU-Editor
128 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.6.2.14 Insert inputThe number of inputs can only be increased for the logical operation symbols (AND, OR, XOR)and the mathematical operations ADD and MUL.
• Mark the input behind which you want to insert a new input.
fig. 153: Input, behind which a new input should be inserted, is marked
• Select „Insert� Additional Input“ . Behind the marked input a new input will be inserted.
fig. 154: New input was inserted
Should an input be inserted below, the lower input or the circuit symbol can be marked in orderto do it.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
129
4.6.2.15 Delete inputThe number of variables of logical or arithmetic operations with more than two operationvariables can be reduced up to two. If the number of inputs is reduced up to one, the completeblock will be deleted automatically.
• Mark the input to delete.
fig. 155: Input to delete is marked
• Hit the „DEL" key or use „Edit�Delete“. The marked input will be deleted.
fig. 156: Input was deleted
You can also mark and delete several neighbouring inputs.
4 The POU-Editor
130 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.6.2.16 Insert outputAn output can be inserted above or below an existing output.
For boolean outputs you can use the operators ST, STN, S, R,JMPC, JMPCN, RETC, andRETCN, for the other data types only ST. On bit-sequences STN can also be used.
Insert the output at first position• Mark the contact line in front of the output symbol.
fig. 157: If the position in front of the output is marked, the new output will be insertedabove theexisting one
• Select the operator from the list field of the dialog field „Operators“, which you have openedby menu item „Insert�Operators...“or by the context menu„Operators...“. In the right sideof the list field all operators are listed which are available in the currently marked group.Behind them the available operations are arranged into groups:
(1) Group „Logic"
- for boolean outputs: S, R
(2) Group „Branching”:
- for boolean outputs:JMPC, JMPCN, RETC and RETCN
(3) Group „Assignment”:
- for boolean outputs: ST
- for the other data types: ST
- for bit sequences: STN
Mark the desired operator. The corresponding graphical symbol appears above the existingoutput.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
131
fig. 158: New output was inserted above the output „fault indicator“
Insert output be hind an existing output• Mark the output behind which a new output should be inserted.
fig. 159: If an existing output is marked, the new output will be inserted below the existing one
• Select the operator as described above.
• Mark the desired operator. The corresponding graphical symbol appears below the existingoutput.
4 The POU-Editor
132 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 160: A new output was inserted under the output „fault indicator“
4.6.2.17 Delete outputSingle and multiple neighbouring outputs can be deleted. On deleting output symbols at least onesymbol must be retained.
• Mark the output region to delete.
fig. 161: The outputs to delete are marked
• Hit the „DEL" key or use „Edit�Delete“. The marked output region will be deleted.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
133
fig. 162: The marked outputs was deleted
4 The POU-Editor
134 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.6.2.18 Negate inputInputs, which are assigned boolean data types or bit sequences, can be negated.
• Mark the input to negate.
fig. 163: The input to negate is marked
• Hit the spacebar. The marked input will be negated.
You can also carry out this action by the tool panel or the toolbox.
fig. 164: The marked input was negated
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
135
4.6.2.19 Negate outputAll output operations (except “S” and “R”) can be negated:
• Mark the output to negate.
fig. 165: The output to negate is marked
• Hit the spacebar. The marked output will be negated.
You can also carry out this action by the toolbar or the toolbox.
fig. 166: The marked output was negated
4 The POU-Editor
136 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.6.2.20 Name elementWhen you insert operators or functions, all operands will be set to “undef_opd”. You shouldnever declare a variable of that name to have the compiler warn you about operands still notproperly set. The contacts and outputs must be completed by entering the variable names. Theparameter assignment is realised by assignment of the variable names to the single contacts of thefunctions and function blocks. You can also assign constants (that means values) to the inputs.
Name input
• Mark the input for which you want to enter a variable name or a constant value.
• Hit "Enter". The dialog field „Name element" will be opened:
fig. 167: Name FBD - element
• Enter the variable name directly or by the clipboard, or enter the value of a constant andpress “OK”,
or
• Select a variable from the list of all declared variables which you have opened before by themenu item with „Insert�Variable�All...“ or by the context menu.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
137
fig. 168: Insert variable
Name output
• Mark the output for which you want to enter a variable name.
• Hit "Enter". The dialog field „Name element" will be opened:
fig. 169: Name FBD - element
• Enter the variable name and press “OK”,
or
• Select a variable from the list of all declared variables which you have opened before by themenu item with „Insert�Variable�All...“ or by the context menu.
4 The POU-Editor
138 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.6.2.21 Enter a label for a jump instructionA jump symbol must be completed by definition of the branch destination.
• Mark the jump symbol for which you want to define a branch destination.
fig. 170: The jump instruction, which is to defined, is marked
• Hit "Enter".
The action is also available in the menu „Insert� Name element...“ .
The dialog field „Name element" will be opened:
fig. 171: Name FBD - element as branch destination
• Enter the name of the branch destination and press „OK".
fig. 172: Branch destination was entered
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
139
4.6.2.22 Enter network-commentEach network can be completed by a multiple line comment.
• Place the cursor into the network.
• Select „Insert� Network Comment...“. The window „Network-comment" will be opened:
fig. 173: FBD - network-comment
Enter a comment (the "ENTER"-key will produce a new line) and press “ OK ”. The enteredcomment appears in the network-header below the network number.
fig. 174: Network-comment was inserted
4 The POU-Editor
140 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.7 The instruction part in STThe language ST (“Structured Text”) is a textual general language similar to the well-known lan-guages like PASCAL and C. Complex expressions and calculation operations can be describedclearly as formula; powerful control structures help you to develop complicated logical evalua-tions.
The variable declaration is done by the variable-editor which is used in the other programminglanguages. The complete description of the variable declaration can be found in section 4.2. Inprinciple it’s up to you to declare the variables at first or to edit the ST-part at first. You canchange between these editors anytime. Note that all variables, which are used in the POU, are de-clared before the syntax check, otherwise error messages will occur caused by the missingvariable declaration.
Activate the POU-editor ST (Options� Programming Llanguage� ST ) in the instruction partfor creation of a POU in the programming language ST. In the window of the ST-editor enter theinstruction part of your POU. The possible instructions in ST are described in chapter 4.7.2:„Instructions in ST“.
4.7.1 Create ST-POU
• In the Project Manager, selectFile�New�POU Program, or File�New�POU FunctionBlock or File�New�Function, depending on which type of POU you want to create.
• A dialog box will be opened prompting you for the name of the POU. Enter the name andpress "OK". The POU Editor will be opened on that new POU
• Declare the variables, as declared in chapter 4.2, and press the tool-button “Use of the ST-editor”, or select„Options�Programming Language�ST“
fig. 175: Button for switching to ST
4.7.2 Instructions in STCode written in ST is a sequence of ST-instructions. ST-instructions are terminated with a semi-colon.Linefeeds are not significant, i.e. more than one instruction can be on one line, and oneinstruction can use one or more line.
The instructions known in ST are:Description Keyword Example
Assignment := a:=5;
Condition IF IF a<b THEN c:=1;
ELSIF a>b THEN c:=2;
ELSE c:=3;
END_IF;
Multiselection CASE CASE n OF
2: p:=4;
3: p:=p+3;
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
141
5..10: p:=100-p*(p-q);
ELSE p:= MAX(a,b);
END_CASE;
Looping WHILE WHILE x > 1 DO
y:= y-2;
END_WHILE;
Looping FOR FOR a:=1 TO 100 BY 2
DO
IF a>c THEN b:=a; END_IF;
END_FOR;
Looping REPEAT REPEAT
a:=a+b;
UNTIL a<100
END_REPEAT;
Terminate Repetition EXIT EXIT;
Return to caller RETURN RETURN;
Function Block instancecall and use of output
FBName(Para-meter_1,
Parameter_2 |Parameter_out);
RTC(IN:=1,
PT:=T#1996-12-31-00:00:00);
A:=RTC.Q;
fig. 176: Instructions in ST
For more description, see the rest of this chapter.
4.7.3 AssignmentsAn Assignment will assign the result of an expression to a variable.Example
VARa: INT;b: ARRAY [0..5] OF INT;c: REAL;e: INT;
END_VARa := 5;(* assign 5 to a *)b[1]:= a*2; e := a; (* two assignments *)e:= REAL_TO_INT( c );(* assignment with function call *)
The assignment instruction will evaluate the expression on the right side and assign the resultingvalue to the variable given on the left.
The type of the variable must match the type of the expression
4.7.4 Conditional instructionsConditional instructions allow the programmer to execute instructions not on every execution of aprogram, but only under some condition. We discuss in this context the instructionIF (single in-struction) andCASE (multiple instruction).
4 The POU-Editor
142 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.7.4.1 IF-instructionThe IF-instruction has following syntax:
IF expressionTHEN Block{ ELSIF expressionTHEN Block}[ ELSE Block ]
END_IF;
If the expression after IF evaluates to “true”, the instructions given after THEN will be executed.If the expression after IF evaluates to “false”, the instructions after ELSE will be executed or theELSEIF-condition will be checked. In any case, execution will then continue with the nextinstruction after END_IF.
IF ExpressionTHENInstruction block;
ELSIF ExpressionTHEN Instruction block;
ELSE Instruction block;
END_IF;
Execution of the instruction block only if the expression is“true”.
Execution only if previous expressions are “false” and thisexpression is “true”. This partial instruction can be omitted orrepeated arbitrary frequently.
Execution only if all previous expressions are “false”. ThisELSE- branch is optional.
Closing bracket of the IF-instruction
An instruction block represents one or more instructions.
Note that every instruction block is finished by a semicolon.
The following IF instruction will compute the maximum of two numbers:
IF a>b THENmaximum := a;ELSEmaximum := b;
END_IF;
IF instructions may be nested, i.e. the THEN-part as well as the ELSE-part may contain other IFinstructions.
Example:The following program will again compute the maximum of two numbers, but if this maximum is“a” and “a” is greater than 10, it will be reduced by 1:
VARa: INT :=12;b: INT :=5;maximum: INT;
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
143
END_VARIF a>b THEN
maximum :=a;IF (a>10) THENa:=a-1;ELSEa:=a+1;END_IF;
ELSEmaximum :=b;
END_IF;
4.7.4.2 CASE-instructionThough IF instructions may be nested, checking for one of many conditions can look quitecomplicated using IF. CASE, instead, can check for more than one value with one instruction.The “expression” of the CASE-instruction is of type INT, and only the instruction will beexecuted that corresponds to this INT-value. After that the first instruction behind END_CASEwill be executed.IF the expression does not match any of the case-values, the first instruction (block) behind theELSE will be executed. This partial instruction is optional.
CASE expressionOFcase_value1: { instructions; }case_value2: { instructions; }...case_valueN: { instructions; }
[ ELSE instructions; ]END_CASE;
Example:
VARnumber : INT:= 10;amount : INT :=2;
END_VARCASE number OF
10: amount := amount +1;11: amount := amount -1;
ELSEamount := number;
END_CASE;
In this example, the value of “number” will be determined, and if it is equal to 10, “amount” willbe incremented, if it is equal to “11”, ”amount” will be decreased. In any other case, ”amount”will be set to equal “number”.
4.7.5 RepetitionsRepetition instructions, or loops, allow to execute a piece of code not only once, but many times.With ST, there are three types of loops:• FOR• WHILE• REPEAT
All repetition instructions have an expression which will control execution and termination of theloop. With WHILE and FOR loops, this condition is checked before execution of the loop,whereas the REPEAT loop does check it after executing the loop instructions. That means theinstructions of the REPEAT-repetition will be executed at least one times (independent if theexpression is true or not) in opposite to the WHILE-repetition.
4 The POU-Editor
144 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.7.5.1 WHILE-loopThe WHILE loop will execute the loop body as long as the given expression evaluates to “true”.Syntax:
WHILE expressionDOinstructions;
END_WHILE ;
The expression given after the keywordWHILE will be evaluated before entering the loop. If itis true, the loop body will be executed. This will terminate only when the expression evaluates to“false”.Example
VARi : INT := 3;
END_VARWHILE i > 0 DO
i:=i-1;END_WHILE;
Initially, “i” equals 3. 3 is greater than 0, so the expression after WHILE is true and the loop bodyexecuted. This will decrement the value of “i” to 2. 2 is still greater than 0, so the loop body willbe executed again. Some time later, the loop body will decrement “i” from 1 to 0. On the nextcheck, the expression after WHILE will be false, hence the loop body will not be executed again.
4.7.5.2 FOR-loopWith the FOR loop, a loop control variable will be set to a specified starting value, then incre-mented (or decreased), and the loop will be terminated when a given end value is reached.
Use only integral variables for control variables.
The syntax is:
FOR assignmentTO EndvalueBY IncrementDOInstructions;
END_FOR;
Example
VARField : ARRAY[1..5] OF INT :=[2,14,8,12,5];Index : INT;MaxIndex : INT :=5;Maximum : INT :=0;
END_VARFOR Index :=1 TO MaxIndex BY 1 DO
IF Field[Index] > Maximum THENMaximum := Field[Index];
END_IF;END_FOR;
The loop control variable “Index” will start with “1”, and will be incremented “BY 1” on eachexecution of the loop. This will be done until the end value “MaxIndex” (=5) will be reached.Note: the BY-term is optional and can be omitted. Default then is to increment by 1.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
145
Execution of the FOR-loop:
1. Initialising of the control variables2. Check of the termination criterion and termination if necessary.3. Execution of the instruction block4. Increase/decrease of the control variable about the step size.5. Go to step 2.
4.7.5.3 REPEAT-loopIn contrast to the other loop types, REPEAT will check the loop expression after execution of theloop. The syntax is:
REPEATinstructions;
UNTIL expressionEND_REPEAT;
So, the REPEAT loop will always be executed at least once. Example:
VARi : INT := -1;
END_VARREPEAT
i:=i-1;UNTIL i < 0END_REPEAT;(* now, i = -2 *)
Although “i” will meet the loop condition from the beginning, the REPEAT loop will be executedonce anyway.
4.7.5.4 EXITAny of the loops can be “left” under program control before the loop condition dictates so. TheEXIT instruction will jump to the first instruction after the innermost loop.Example:
VARstart: INT :=0;summe: INT :=0;ende : INT := 10;
END_VARFOR Start := 1 TO Ende BY 2 DO
Summe := Summe + 1;IF Summe > 4 THEN
EXIT ;END_IF;
END_FOR;(* Will continue here *)
As soon as “Summe” is greater than 4, the FOR loop will be left.
4.7.6 Cyclic Execution and Structured TextApplications in a PLC typically are executed in a cyclic manner, i.e. the operating system of yourPLC will restart your cyclic application quite soon after it finished. “Endless-loops” in your appli-cation are generally not a proper programming technique, but rather considered a programmingerror, and a good PLC operating system will terminate such application programs.
4 The POU-Editor
146 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
“Actively waiting”, like the following pseudo-code demonstrates:
FOR n:=1 TO 10 DOSwitch on light ‘n’Wait one secondSwitch off light ‘n’
END_FOR;
is not a good programming technique, because the simple “wait” would use the entire controller,preventing it from fulfilling more demanding tasks. And, if the PLC uses a process image, likemost do, no light would ever be seen on.The use of loops, which wait for events, is forbidden for automation systems according to the IEC1131-3.
4.7.7 Calling function block instancesFunction Block Instances are called by simply writing the name of the function block instance,with the formal parameters assigned actual parameters in parentheses after the instance name.It is not necessary to provide actual values for all formal parameters, all parameters not assignedwill keep the value from the previous call, or their default value.Example:
Function Block Definition
FUNCTION_BLOCK FB_ABCVAR_INPUT
x: INT:=1; (* one input *)END_VARVAR_OUTPUT
y: INT:=4; (* one output *)END_VARIF (x >2) THEN (* some logic *)
y :=5;END_IF;END_FUNKTION_BLOCK
Declaration of an instance of this FB type:
VARFBName: FB_ABC;
END_VAR
Calling this instance• FBName();
(* FBName.y equals 4 *)• FBName(x :=3);
(* FBName.y equals 5 *)
4.7.8 RETURNThe RETURN instruction will cause the current POU to be left, transferring control back to thecaller of the current POU. Note that on working with functions, the function value (variable withthe name of the function) must be assigned. If output values of function blocks aren’t assigned bylocal values of the function block, they have the predefined values of their data types.
Example:IF a<b THEN
RETURN;END_IF;
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
147
4.7.9 Expressions and operatorsOperands known in ST are:• Literal variables, e.g. 14, ‘abc’, t#3d_5h• Variables, e.g.: Var1, Var[2,3]• Function Call, e.g.: Max(a,b)While operators are parts of ST-language, expressions are constructions which must be con-structed by aid of ST-elements. Operators need operands to build expressions.Operators known in ST are:
Parentheses ( )function callExponentiation **Negation -Complement NOTMultiplication *Division /Modulo MODAddition +Subtraction -Comparison <, >, <=, >=Equality =Inequality <>boolean AND &, ANDboolean exclusive OR XORboolean OR OR
fig. 177: List of operators
4.7.10 Function call as operatorFunctions are invoked with the parameters specified in a comma separated list, enclosed inparentheses. The return value of the function will be used as the value of the function inevaluating it.
A function shall always return the same value when given the same input values.Therefore a function can’t have a memory in opposite to a function block.
Functions are regarded as expressions.
In OpenPCS, predefined functions (“standard functions”) and user-defined functions can be used.
Example:m:= MAXIMUM(x,y);
with the following definition ofMAXIMUMFUNCTION MAXIMUM : INTVAR
x, y, z: INT;END_VARIF x > y THEN
z:= x;ELSE
z:=y;END_IF;
MAXIMUM :=z;END_FUNCTION
4 The POU-Editor
148 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.7.11 CommentsLike all modern programming languages, ST supports comments. A comment is any textincluded between “(*” and “*)”, e.g.
(* Comments are helpful *)The compiler will ignore comments when generating executable code, so your program will notaccelerate in any way if you omit comments. Comments may span multiple lines, e.g.
(* This commentis long andneeds more than oneline
*)
4.7.12 Input helps
4.7.12.1 Calling function block instancesTo get a list of all defined function blocks:• Select “Insert�Variable�All... ”. A window will be opened in which all declared variables
are displayed:
fig. 178: Dialog box manufacturer function block
• Mark the name of a function block instance
• Close the dialog box with “OK”.
4.7.12.2 Calling functionsWe will use two standard functions, namely BYTE_TO_INT and INT_TO_BYTE. You mayenter these by keying in their names as part of the ST program, or use the following procedure:
• Place the cursor where you want to enter the call to the function
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
149
• Select “Insert�Manufacturer functions”. The dialog box “functions” will be shown:
fig. 179: Dialog box manufacturer function
• Select the function, e.g. INT_TO_BYTE and press “OK”. The function call will be inserted atthe current cursor position.
• Enter the opening parenthesis “(“.
4 The POU-Editor
150 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.8 Switching Programming LanguagesLanguages IL, LD, and FBD are mutually compatible and “cross-compileable” into each otherwith OpenPCS as far as technically feasible. You can switch from the ST-language to otherlanguages and back again if the POU isn’t modify in the other languages. A switch to ST ofPOUs, which are created in IL, LD, or FBD, is not supported.
The switchover is done by:
• Select “Extras�Programming Language�AWL/FBD/LD/ST ”
Or
• Select the language of your choice by the tool-button of the standard toolbar.
fig. 180: Tool-button for switchover the programming language
The instruction part of the POU appears in the selected programming languages.
If you start in instruction list, it is quite easy and common to create sequences that will notproperly be understood by the LD/FBD Editor. Such sequences will be represented by a specialcomment “network cannot be displayed graphically”, plus the original instruction list text. Youcannot edit these parts of your POU in LD/FBD, but the contents will be kept, so you may modifyother parts. The corresponding instructions are represented in IL.
fig. 181: POU-part can’t be displayed graphically
To work around restrictions in cross-compiling from IL to LD and FBD, see the following chap-ters.
4.8.1 Conditional function block callLD/FBD cannot display conditional calls.
Example:VAR
Counter_3 : CTU;PutInContainer, sensor, RES_key, full : BOOL;
END_VAR(* Conditional call to Counter-Block
"PutInContainer" runs *)LD PutInContainerCALC Counter_3(CU := sensor,RESET := RES_key,PV := 120
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
151
|full := Q,:= CV)
After switching to language LD or FBD, this will be displayed as:
SolutionReplace the conditional call by a conditional jump over an unconditional call
VARCounter_3 : CTU;PutInContainer, sensor, RES_key, full : BOOL;
END_VARLDN PutInContainerJMPC Label_4CAL Counter_3(CU := sensor,RESET := RES_key,PV := 120|full := Q,:= CV)
Label_4:
After switching to language LD or FBD, this will be displayed as:
4 The POU-Editor
152 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
4.8.2 Intermediate StoresIn IL, you may used Store-Instructions in the middle of an expression to keep intermediateresults:
Example(* AND before OR-operation,
only in IL representable*)LD var1OR ( var2AND var3ST AND_result)
OR var4ST OR_result
After switching to LD or FBD, this will be displayed as
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
153
Solution(* AND before OR-operation,
LD/FBD kompatibel, part1 *)LD var2AND var3ST AND_result(* AND before OR-operation,
LD/FBD kompatibel, part2 *)LD var1OR AND_resultOR var4ST OR_result
After switching to FBD, this will be displayed as:
4.8.3 Line commentsIn Instruction List, comments are possible on each line, while in LD and FBD, comments areonly possible for networks. When switching to LD or FBD, the comments of all instructions of anetwork will be displayed as the comment of the network. When switching back to instructionlist, the comments will no longer be associated with the individual lines.
Example(* Counting the produced items *)CAL Counter_4( (* Instance of the Function
Block CTD *)CD := part, (* Impulse of a sensor *)LOAD := Setkey,PV := 50 (* number of items in one box *)|leer := Q, (* Counter completed,
i.e. box full *):= CV)
4 The POU-Editor
154 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
After switching to FBD, this will be displayed as:
After switching back to instruction list, it will look like:
4.9 Editor for global types
Complex type-declarations, e.g., structures which you want to use for several POUs inside theentire project, can be declared very easy in a separate editor. This one will be opened if you edit aglobal type declaration in the project browser.
Type-declaration can be constructed from derived or elementary data types. They are declaredinside the keywordsTYPE...END_ TYPE.
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
155
fig. 182: Global user-defined data types
Deviating from the derived data types, which you create as variable-section “TYPE” for the POU-types “Program” and “Function block” and which are only valid inside the particular POU, theconstructed data types are global here, and so these data types are valid for the whole project.
4.10 Syntax check and error correction
� Select from the toolbar the button , in the menu „File�Syntaxcheck“, or press the func-tion key combinationAlt+F10.
If the POU can be compiled without error, you receive the message “No syntax error occurred” inthe status line at the lower border of the window after the finished syntax check.
If syntax errors are found, the window “Error messages” will be opened:
4 The POU-Editor
156 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 183: Syntax check with error message
An entry in a line indicates if an error was found in the instruction section or declaration section.The line- and column-number of the error, name and path of the POU, and a short description ofthe error can be found behind this entry. The maximum of 25 errors will be listed, so afterelimination of the first errors, new error messages can eventually be displayed.
Correct the errors in increasing order of the lines. The faulty position in the IL-editor will be dis-played bydouble clickon the error message. The cursor appears in the faulty program line. If youneed help, mark an error message and press the F1-key.
The POU will automatically be saved, when you start a syntax check.
4.11 Create cross-reference list
In order to keep the overview over your variables, a cross-reference list can be displayed.Select„File � Crossreference”:
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
157
fig. 184: Cross-reference list
4.12 Edit POU
In the menu “Edit” the following items are available for program editing:
� Select „Edit� Undo“ if you want to represent the POU in its original manner so you canundo the last modifications.
� Select “Edit� Cut” if you want to cut out a text from the POU and put it into the clipboard.
� Select „Edit�Copy” if you want to put a copy of a text into the clipboard.
� Place the mouse pointer to the position at which you want to insert the content of the clip-board. Then select„ Edit� Paste“ .
� Select“Edit�Delete” to delete marked regions.
� Select“Edit�Select All” to mark the whole contents of the particular editor.
� Select“Edit�Find...” to search for a definite character string.
� Select“Edit�Find Next” to search once more for a definite character string.
� Select“Edit�Replace...”to replace a found character string by another one.
� Select“Edit�Find Variable...” to search for a variable.
� Select“Edit�Goto...” to jump to a definite line.
fig. 185:Take the cursor to a definite line
4.13 Save POU
UseFile�Saveto save the modified contents of a POU.
4.14 Change POU-Type
Use this option if the content of an existing POU is used in a new POU of other type (program,function, or function block), or if you have selected the wrong POU-type on creation of the POU.
On changing the POU-type a part of the variable declaration can be lost. The variable-sections which aren’t available in the new POU-type (e.g., input- or output-variables ofthe POU-type “program”) are deleted. The IL-part will be accepted unchanged.
• Select „File� Convert POU type“. In the opening list field, where the current POU-type ismarked, select one of the two others POU-types, and the change will be executed. In theheader of the POU the new POU-type will be displayed.
4 The POU-Editor
158 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 186: Change POU-Type
• Switchover the variable editor with „Extras�Variable Editor�Free-Mode“ to view theentire declaration part with all variable-sections. Check the declaration and instruction partof your POU.
You can also use this option to change the return-value of a POU of type “function” into anotherreturn-value.
Select „File� Convert POU type“. In the opening list field, where the POU-type “function” ismarked by a hook, select “function type”. The dialog field “Function type” will be opened,where you can enter the new function type and press the „OK"-button for confirmation.
The change of the return-value will be executed and immediately be displayed in the title line ofthe POU-editor.
fig. 187: Change function type
4.15 Printing
4.15.1 Print a POU
• Select „File�Print“ ,
The dialog field „Print" will be opened:
4 The POU-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
159
fig. 188: Dialog field „Print“
� Select the button „OK". Afterward the print will be sent to the printer.
5 ControlX Editor
160 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
5 ControlX Editor
5.1 Survey
5.1.1 The standard IEC-61131-3The norm IEC 61131-3 consists of five parts. It specifies requirements for modern PCS systemsregarding the PCS hardware and the programming system. The norm comprises as wellestablished concepts of traditional PCS programming as improvements and new programmingmethods.The IEC 61131-3 is thought of as a guideline of PCS programming and is accepted by most PCSmanufacturers.The norm was set up by the commission SC65B WG7 (initially SC65A WG6) of the InternationalElectrotechnical Commission (IEC) consisting of representatives of different PCS manufacturers,software companies and users.
5.1.2 General Information
The ControlX Edit Framework consists of two independent windows. The first window isdivided into the variable editor in the upper section and the instruction editor in the lowersection. The instruction editor may me one of several available editors, as the ladderdiagram editor or the SFC editor. The second window is the output window.
Further information:Overview Working with the ControlX Editor FrameworkGeneral Information on Ladder LogicVariable EditorLadder EditorOutput - Window
5.1.3 Components
5.1.3.1 Output WindowThe output window is a part of the ControlX editor framework. It displays the results of thesyntax check.
Further information:General InformationPresentationFunction of the Output Window
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
161
5.1.3.2 Variable EditorThe variable editor is a part of the ControlX editor framework which enables you to insertlanguage elements of the language you are working with. You can work in the "free variableeditor mode".
Further information:General InformationIntroductionAvailable variable typesDeclarations
5.1.3.3 Instruction Editor
5.1.3.3.1 Ladder Editor
The Ladder Editor serves for creating ladder diagrams. The framework consists of twowindows. The first window is split and consists of the variable editor above the separationline and the instruction section below it. The second window is the output window, whereoutput information will be displayed.
Example:
5 ControlX Editor
162 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Further information:General InformationGeneral Information on Ladder LogicVariable EditorOutput - WindowLadder Diagram
5.1.3.3.2 SFC Editor
The framework consists of two windows. Using the SFC Editor you can create SFCdiagrams. The first window is split and consists of the variable editor above theseparation line and the instruction section below it. The second window is the outputwindow, where output information will be displayed
Further informations:General InformationElemente der AblaufspracheVariable EditorOutput - WindowSFC (AS)
5.2 Output Window
5.2.1 PresentationThe framework consists of two windows. The first window is split and consists of the variableeditor above the separation line and the instruction section below it. The output window isplaced in the lower part of the ControlX Editor framework, in the second window which couldbe switched on or off with the commands of the menu view.
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
163
Presentation of the output window in the ControlX Editor framework (Example.: Program forcoordinating the arm of a robot)
Further information:General InformationLadder EditorFunction of the Output Window
5.2.2 Function of the Output WindowThe function of the output window is to display the results of theSyntax check.
This comprises every encountered error with the exact error position within the program code.You can click on any error message to mark the corresponding code fragement within theprogram editor (this may be within the declaration section or the instruction section of theControlX editor framework).The last output line of the output window is always the report of the total of errors.
5 ControlX Editor
164 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Example: Program for controlling a roboter arm with one syntax error within the instructionsection. The error position is the variable identifier of the first contact of the first network. Thisvariable has been declared as "grundstellung" but is referred to as "rundstellung".You can click on the error message in order to mark the contact and easily correct the error.
Further information:General InformationLadder EditorPresentation
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
165
5.3 Variable Editor
5.3.1 IntroductionThe variable editor is a part of the ControlX editor framework, just as the instruction editor andthe output window.
Variable editor in the "free mode".
The "free mode" of the variable editor is suitable for skilled programmers, who arefamiliar with variable declarations. The "free mode" is a fast tool for declaring variables.Note that every declaration must be syntactically correct. Error messages will not bedisplayed before the syntax check.
In the "free mode", the variable editor displays all variable blocks at the same time. Thisgives you a better overview of all declared variables.
Further information:General InformationAvailable variable typesDeclarations
5 ControlX Editor
166 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
5.3.2 Available variable typesThere are certain restrictions on the variable types you may use in the three different POU types.There is only one variable type that may be used more than once.
Further information:General InformationIntroductionDeclarations
5.3.3 Declarations
In the "free mode", variables of each type have to be declared within a separatedeclaration block. It is advisable to separate the different components of a declarationline with tabs. Each declaration block is introduced and closed with a certain key word,e.g. VAR and END_VAR for local variables.
Note that the declaration blocks have to follow in this order:
1.) VAR_INPUT 3.) VAR_OUTPUT 5.) VAR_EXTERNAL 6.) VAR
2.) VAR_IN_OUT 4.) VAR_GLOBAL 6.) TYPE
The key words that introduce and close the variable blocks is displayed in blue color.
You should add comments to each declaration line. A comment begins with an opening
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
167
bracket and an asteriks "(*" and ends with an asteriks and a closing bracket "*)".Comments are displayed in green color.
Note that there is no syntax check during input. Errors wll not be displayed before theSyntax check of the entire program.
Further information:General InformationIntroduction
Available variable types
5.4 Menus
5.4.1 Basic Commands
5.4.1.1 Restore
Use this command to restore size and position of the active window to the size it has been beforeusing the commandsmaximize or minimize.
5.4.1.2 Move
Use this command to produce a fourfold arrow, with whom you can move of the activewindow or by pressing the buttons of direction.
Note: This command is not available if the window is shown full sized.
Shortcut:Keyboard: STRG+F7
5.4.1.3 Change Size
Use this command to produce a fourfold arrow, with whom you can change the size ofthe active window or dialogue-field by pressing the buttons of direction.
After producing the fourfold arrow:Press one of the buttons of direction in order to move the pointer to the border you want tochange.Press one of the buttons of direction for moving the frame.PressEnter when the window has the right size.
Note: This command is not available if the window is shown full sized.
5 ControlX Editor
168 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Shortcut:Mouse: Drag the frames in the corners or borders of the window to the right size.
5.4.1.4 Minimize (Basic Commands)
Use this command to minimize the window of the editor to an icon.
Shortcut:Mouse: Press on the symbol for minimize in the title-bar.Keyboard: ALT+F9
5.4.1.5 Maximize (Basic Commands)
Use this command to enlarge the window to the largest possible extension.
Shortcut:Mouse: Press on the symbol for minimize in the title-bar or double-click on the title-bar.Keyboard: STRG+F10 enlarges one program-window.
5.4.1.6 Close (Basic Commands)
Use this command to close the active window or dialogue-field.
Note: If there is more than one window open, this command will close only a single window. Ifyou want to close all windows you can use the commandCloseout of the menuFile.
Shortcut:Keyboard: STRG+F4 closes one program-window.
5.4.1.7 Next (Basic Commands)
Use this command for switching to the next open program-window. The ContolX Editor willswitch the windows in the sequence you opened them.
Shortcut:Keyboard: STRG+F6
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
169
5.4.2 Menus in the SFC Editor
5.4.2.1 Survey of menus (SFC Editor)
File MenuEdit MenuInsert MenuView MenuWindow MenuOnline MenuHelp Menu
5.4.2.2 Commands "File" Menu
5.4.2.2.1 Commands "File" Menu (SFC)
TheFile menu contains the following commands:
Close Closes an open SFC-program
Save Saves changes of an open SFC-program
Print Prints the current SFC-program
Page Setup Displays the Page Setup dialog, so you can set the margins
Print Preview Allows you to see a preview of your printed file
Exit Closes the SFC-Editor
5.4.2.2.2 Close (File Menu / SFC)
Use this command to close all windows which contains the current SFC-program. The SFC-Editor proposes to save your changes. If you close an program without saving your changes sincethe last saving will be lost.
You can also use the close-symbol in the toolbar to close your SFC-program, like it is shown inthe following picture:
5 ControlX Editor
170 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
5.4.2.2.3 Save (File Menu / SFC)
Use this command to save your current SFC-program. It will be stored with its original name andpath.
Shortcut:
Toolbar:Keyboard: STRG+S
5.4.2.2.4 Print (File Menu)
Use this command to print a document. In case you activate this command a dialog appears inwhich you can make statements about the side area, which should be printed, the number ofcopies, the printer and other options about the printer setup.
Shortcut:
Toolbar:Keyboard: STRG+P
5.4.2.2.5 Page Setup (File Menu)
Use this command to set the margins for your printout.
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
171
In the areaPaper you can arrange the format as well as the source of the used paper.In the areaMargins you can fit the margins of your document. The textfieldTopprovides a space for you to specify the width of the top margin on every printed page.The TextfiledBottom provides a space for you to specify the width of the bottom margin on everyprinted page. The distance between header/footer and the respective margin is fix.In the areaAusrichtung you can choose whether the paper shoulb be printed in the uprightformat or the horizontal format.
5.4.2.2.6 Print Preview (File Menu / SFC)
Use this command to show your current document, how it would look printed. If you choose thiscommand, the main window will be hided by a side-view-window, where you can decide whetherone ot two pages should be shown in this window. Furthermore you can move through the text,you can reduce or enlarge the view or you can start to print.
5.4.2.2.7 Exit (File Menu)
Use this command to finish your session. You can also choose the commandClosefrom yourSystem menu. The Editor asks you to save programs with unsaved changes.
Shortcut:Mouse: Doupleclick on the system menu of the application
5 ControlX Editor
172 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Keyboard: ALT+F4
5.4.2.3 Commands "Edit" Menu
5.4.2.3.1 Commands "Edit" Menu (SFC)
TheEdit Menu contains the following commands:
Undo Allows you to reverse changes
Redo Macht die letzte Rückgängig-Aktion wiederrückgängig
Cut Deletes the selected item and places it on theclipboard
Copy Copies the selected item and places it on theclipboard
Paste / Replace Replaces the selected item with data from theclipboard
Paste / Add Left Adds the data from the clipboard left beside theselected item.
Paste / Add Right Adds the data from the clipboard right beside theselected item.
Delete Deletes the selected item
Move Left Verschiebt den Alternativzweig nach links
Move Right Verschiebt den Alternativzweig nach rechts
Search Suchen von Codefragmenten zur Fehlerbeseitigunganhand von Textstellen
Go to AWL row Suchen von Codefragmenten zur Fehlerbeseitigunganhand der Zeilennummern
Select All Selects all items
Edit Editieren des Codes eines bestimmten SFC-Elementes
Properties Allows you to edit the properties of SFC-elements
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
173
5.4.2.3.2 Undo (Edit Menu)
Use this command to reverse (undo) your last change.
Shortcut:
Toolbar:Keyboard: STRG+Z oder
ALT-RÜCKTASTE
5.4.2.3.3 Redo (Edit Menu)
Use this command to reverse the lastUndocommand.
Shortcut:
Toolbar:Keyboard: STRG+Y
5 ControlX Editor
174 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
5.4.2.3.4 Cut (Edit Menu)
By using this command you delete the selected items and place a copy of them in the clipboard.In the case that no items are marked or the action would have an unauthorized condition as effectyou can not use this command.In the clipboard are allways the items from the last use of cut or copy.
Shortcut:
Toolbar:Keyboard: STRG+X
5.4.2.3.5 Copy (Edit Menu)
By using this command you copy the selected items to the clipboard. In the case no items aremarked you can not use this command. In the clipboard are allways the items from the last use ofcut or copy.
Shortcut:
Toolbar:Keyboard: STRG+C
5.4.2.3.6 Paste / Replace (Edit Menu)
Use this command to replace the selected items with a copy from the data from the clipboard.In the case that the clipboard is empty or the action would have an unauthorized condition aseffect you can not use this command.
Shortcut:
Toolbar:Keyboard: STRG+V
5.4.2.3.7 Paste / Add Left (Edit Menu / SFC)
Use this command to add a copy of the clipboard left beside the selected items.In the case that the clipboard is empty or the action would have an unauthorized condition aseffect you can not use this command.
Shortcut:Keyboard: STRG+L
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
175
5.4.2.3.8 Paste / Add right (Edit Menu / SFC)
Use this command to add a copy of the clipboard right beside the selected items.In the case that the clipboard is empty or the action would have an invalide condition as effectyou can not use this command.
Shortcut:Keyboard: STRG+R
5.4.2.3.9 Delete (Edit Menu)
Use this command to delete the selected items. In case deleting will have an invalide condition ofdata as effect you can not use this command.
Shortcut:Keyboard: ENTF
5.4.2.3.10 Move Left (Edit Menu / SFC)
Verwenden Sie diesen Befehl, um den markierten Alternativzweig nach links zu verschieben.Damit ist es möglich, die Abarbeitungspriorität der einzelnen Alternativzweige zu ändern. Derverschobene Zweig erhöht durch diese Operation seine Abarbeitungspriorität.
Shortcut:Keyboard: ALT+L
5.4.2.3.11 Move Right (Edit Menu / SFC)
Verwenden Sie diesen Befehl, um den markierten Alternativzweig nach rechts zu verschieben.Damit ist es möglich, die Abarbeitungspriorität der einzelnen Alternativzweige zu ändern. Derverschobene Zweig vermindert durch diese Operation seine Abarbeitungspriorität.
Shortcut:Keyboard: ALT+R
5.4.2.3.12 Search (Edit Menu)
Use this command to search for a textposition inside the plan. You will see the result in theoutput window. With an double click on the result, you approach to the editor window of therespective transition. Notice that you have to save your plan before you can search inside it.
Shortcut:
5 ControlX Editor
176 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Keyboard: STRG+Q
5.4.2.3.13 Go To AWL-row (Edit Menu / SFC)
Use this command to
Verwenden Sie diesen Befehl, um anhand einer Nummer einer fehlerhaften Zeile in dererzeugten POE-Datei das entsprechende Codefragment im SFC-Plan zu finden. Die Nummereiner fehlerhaften Zeile wird beim Compilieren im OpenPCS-System protokolliert.Weitere Hinweise sind unterFehlersuchezu finden.
Shortcut:Keyboard: STRG+F
5.4.2.3.14 Select All (Edit Menu)
Use this command to select all items.
Shortcut:Keyboard: STRG+A
5.4.2.3.15 Edit (Edit Menu / SFC)
Use this command to edit all marked elements
Verwenden Sie diesen Befehl, um den Quellcode des markierten Elementes zu editieren.
Shortcut:Keyboard: RETURN
5.4.2.3.16 Properties (Edit Menu / SFC)
Verwenden Sie diesen Befehl, um die Eigenschaften des markierten Elementes zu ändern.
Shortcut:Keyboard: ALT+RETURN
5.4.2.4 Commands "Insert" Menu
5.4.2.4.1 Commands "Insert" Menu (SFC)
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
177
TheInsert Menu contains the following commands:
Insert Step/Transition Ersetzt die Markierung mit einerTransitions-Schrittfolge
Add Step/Transition Left Fügt links zur Markierung einen Schrittoder eine Transition an
Add Step/Transition Right Fügt rechts zur Markierung einen Schrittoder eine Transition an
Jump Ersetzt die Markierung mit einem Sprung
5.4.2.4.2 Insert Step/Transition (Insert Menu / SFC)
Verwenden Sie den Befehl, um die aktuelle Markierung mit einem Transition - Schritt – Paar zuersetzen. Die notwendige Reihenfolge wird dabei automatisch bestimmt.Dieser Befehl steht nicht zur Verfügung, falls das Ersetzen zu einem ungültigen Zustand derDaten führt.Shortcut:
Keyboard: STRG+ALT+S
5.4.2.4.2.1
5.4.2.4.3 Add Step/Transition Left (Insert Menu / SFC)
Verwenden Sie den Befehl, um links an die aktuelle Markierung einen Schritt oder eineTransition anzufügen.Dieser Befehl steht nicht zur Verfügung, falls das Anfügen zu einem ungültigen Zustand derDaten führt.
Shortcut:Keyboard: STRG+ALT+L
5.4.2.4.4 Add Step/Transition Right (Insert Menu / SFC)
Verwenden Sie den Befehl, um rechts an die aktuelle Markierung einen Schritt oder eineTransition anzufügen.Dieser Befehl steht nicht zur Verfügung, falls das Anfügen zu einem ungültigen Zustand derDaten führt.
Shortcut:Keyboard: STRG+ALT+R
5.4.2.4.4.1
5.4.2.4.5 Jump (Insert Menu / SFC)
Verwenden Sie den Befehl, die Markierung mit einem Sprung-Element zu ersetzen.Dieser Befehl steht nur zur Verfügung, wenn die letzte Verbindungslinie in einemAlternativzweig markiert ist.
5 ControlX Editor
178 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Shortcut:Keyboard: STRG+ALT+J
5.4.2.5 Commands "View" Menu
5.4.2.5.1 Commands "View" Menu (SFC)
TheView Menu contains the following commands:
Toolbar Blendet die Symbolleiste ein oder aus
Status Bar Blendet die Statusleiste ein oder aus
Output Window Blendet das Ausgabefenster ein oder aus
Zoom In Vergrößert den Darstellungsmaßstab
Zoom Out Verkleinert den Darstellungsmaßstab
5.4.2.5.2 Toolbar (View Menu / SFC)
Verwenden Sie diesen Befehl zum Ein- oder Ausblenden der Symbolleiste. Die Symbolleisteenthält einige Schaltflächen der gebräuchlichsten Befehle vom SFC-Editor, wie zum BeispielDatei Öffnen. Wenn die Symbolleiste angezeigt wird, erscheint ein Häkchen neben diesemMenüeintrag.
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
179
Hilfe zum Gebrauch der Symbolleiste finden Sie unterSymbolleiste
5 ControlX Editor
180 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
5.4.2.5.3 Descripton of the Toolbar
Die Symbolleiste wird horizontal oben im Anwendungsfenster unterhalb der Menüleisteangezeigt. Sie stellt per Maus schnellen Zugriff auf viele Tools des SFC-Editors bereit.
Um die Symbolleiste ein- oder auszublenden, können Sie aus dem MenüAnsicht den BefehlSymbolleisteauswählen (ALT,A,S).
Schaltfläche Tasten-kürzel
Aktion
Ctrl + S Saves the current SFC-programoder die aktive Vorlage unteraktuellen Namen.
Ctrl + X Entfernt die markierten Daten aus dem SFC-Programm und übsie in die Zwischenablage (siehe BefehlCut)
Ctrl + C Kopiert die markierten Daten in die Zwischenablage (siehe BeCopy)
Ctrl + V Fügt den Inhalt der Zwischenablage an der Einfügestelle ein (sBefehlPaste)
Ctrl + P Druckt das aktuelle Programm aus (siehe BefehlPrint)
Ermöglicht die Vorschau auf die Druckerausgabe (siehe BefehPreview)Vergrößert den Maßstabder Darstellung des SFC-Planes
Verkleinert den Maßstabder Darstellung des SFC-Planes
Ctrl + Z Macht die letzte Bearbeitung rückgängig (siehe BefehlUndo)
Ctrl + Y Macht die letzte Rückgängig-Aktion rückgängig (siehe Befehl
Schaltet die Anwendung in den Hilfemodus, um zu einzelnenElementen des Editors Hilfetext anzugeben (siehe BefehlDirec
.
5.4.2.5.4 Status Bar (View Menu / SFC)
Verwenden Sie diesen Befehl, um die Statusleiste ein- oder auszublenden. Die Statusleistebeschreibt die Aktion, die vom ausgewählten Menüeintrag oder einer gedrückten Schaltfläche derSymbolleiste ausgeführt wird und zeigt den Zustand der feststellbaren Tasten an. Falls dieStatusleiste angezeigt wird, erscheint ein Häkchen neben dem Menüeintrag dieses Befehls.
Hilfe zur Verwendung der Statusleiste finden Sie unterStatusleiste
5.4.2.5.5 Output Window (View Menu / SFC)
Verwenden Sie diesen Befehl zum Ein- oder Ausblenden des Ausgabefensters. DasAusgabefenster dient für Nachrichten des SFC-Editors an den Benutzer, z.B. beim Speichern derdamit verbundenen Codeerzeugung erscheinen dort eventuell Warnungen und Fehlermeldungenzum SFC-Plan.
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
181
Hilfe zum Gebrauch des Ausgabefensters finden Sie unterDescription of the Output Window.
5.4.2.5.6 Description of the Status Bar
Die Statusleiste wird am unteren Rand des Fensters des SFC-Editors angezeigt. Sie können dieStatusleiste im MenüAnsicht mit dem BefehlStatusleisteein- oder ausblenden.
Während Sie sich mit den RICHTUNGSTASTEN durch Menüs bewegen, beschreibt der linkeBereich der Statusleiste die Funktion der Menüeinträge. Entsprechend dazu werden in diesemBereich auch Beschreibungen zur Wirkung der Schaltflächen der Symbolleiste angezeigt, wennSie diese niederdrücken und gedrückt halten. Wenn Sie den zu einer Schaltfläche derSymbolleiste zugehörigen Befehl nicht ausführen wollen, nachdem Sie seine Beschreibunggelesen haben, lassen Sie die Maustaste los, während sich der Mauszeiger nicht mehr auf derSchaltfläche befindet.
Befindet sich der Mauscursor über einem Element des SFC-Planes, werden zugehörigeInformationen wie der Name in der Statusleiste angezeigt.
In den rechten Bereichen der Statusleiste wird angezeigt, welche der folgenden Tasten festgestelltsind:
Anzeige BeschreibungUF Die FESTSTELLTASTE ist aktiviert
NUM Die Taste NUM ist festgestellt
RF Die Taste ROLLEN ist festgestellt
5.4.2.5.7 Description of the Output Window (View Menu / SFC)
Das Ausgabefenster dient der Interaktion des SFC-Editors mit dem Benutzter bei derSyntaxkontrolle und bei der Zwischencodeerzeugung eines Programmes. Die genannte Vorgängewerden automatisch im Hintergrund beim Vorgang des Speicherns ausgeführt. Treten dabeiWarnungen oder Fehler auf, werden diese zeilenweise im Ausgabefenster beschrieben.Der SFC-Editor besitzt genau ein Ausgabefenster, in welche alle Meldungen gesammelt werden.Durch Doppelklick auf eine Zeile des Ausgabefensters wird automatisch der SFC-Plan geöffnet,der die entsprechende Zeile hervorgerufen hat.
Das Ausgabefenster läßt sich verstecken, um Platz für die Anzeige größerer Pläne zugewinnen.(Output Window)
5 ControlX Editor
182 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
5.4.2.5.8 Zoom In (View Menu / SFC)
Verwenden Sie diesen Befehl, um den Maßstab der Darstellung zu vergrößern. Die einzelnenElemente werden dadurch größer dargestellt. Der Anteil des sichtbaren Ausschnittes des SFC-Planes verkleinert sich mit diesem Befehl.
Shortcut:
Toolbar:
5.4.2.5.8.1
5.4.2.5.9 Zoom Out (View Menu / SFC)
Verwenden Sie diesen Befehl, um den Maßstab der Darstellung zu verkleinern. Die einzelnenElemente werden dadurch kleiner dargestellt. Der Anteil des sichtbaren Ausschnittes des SFC-Planes vergrößert sich mit diesem Befehl.
Shortcut:
Toolbar:5.4.2.5.9.1
5.4.2.6 Commands "Online" Menu
5.4.2.6.1 Commands "Online" Menu (SFC)
The Online Menu contains the following commands to change in the Online-modeDas MenüOnline bietet Ihnen Befehle zum Wechseln in den Online-Modus.
State Notice Einschalten der Statusanzeige zu einem laufendenProgramm
Offline Ausschalten der Statusanzeige
5.4.2.6.1.1
5.4.2.6.2 State Notice (Online Menu / SFC)
Wurde das aktuelle Programm über die Test- und Inbetriebnahme von OpenPCS gestartet, stehtder Befehl Zustandsanzeige zur Verfügung. Durch Anwahl dieses Menüpunktes baut der Editoreine Verbindung zur Steuerung auf und fragt den Status des laufenden SFC-Programmes ab.Aktive Schritte des Programmes werden in diesem Modus optisch durch ein rotes Rechteckgekennzeichnet:
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
183
5.4.2.6.2.1
5.4.2.6.3 Offline (Online Menu / SFC)
Schaltet die Statusanzeige des SFC-Editors ab. (siehe dazu den BefehlState Notice).
5.4.2.7 Commands "Window" Menu
5.4.2.7.1 Commands "Window" Menu (SFC)
Das MenüFensterbietet folgende Befehle, die Ihnen erlauben, mehrere Ansichten von mehrerenSFC-Programmen im Anwendungsfenster einzurichten:
Cascade Arranges the windows in cascade style
Tile Arranges the windows side by side
Arrange Icons Arranges the to symbols reduced icons
Window 1, 2, ... Switches to the specified window
5 ControlX Editor
184 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
5.4.2.7.2 Arrange Icons (Window Menu / SFC)
Verwenden Sie diesen Befehl, um die Symbole der minimierten Fenster im unteren Bereich desHauptfensters anzuordnen. Falls sich dort ein geöffnetes SFC-Programmfenster befindet, kann espassieren, daß einige oder alle Symbole verdeckt sind, weil sie sich unterhalb des SFC-Programmfensters befinden.
5.4.2.7.3 Cascade (Window Menu / SFC)
Verwenden Sie diesen Befehl, um die geöffneten Fenster überlappend anzuordnen.
5.4.2.7.4 Tile (Window Menu / SFC)
5.4.2.7.4.1
5.4.2.7.5 Tile Horizontally (Window Menu / SFC)
Verwenden Sie diesen Befehl, um die geöffneten Fenster vertikal nebeneinander anzuordnen
5.4.2.7.6 Tile Vertically (Window Menu / SFC)
Verwenden Sie diesen Befehl, um mehrere geöffnete Fenster Seite an Seite anzuordnen.
5.4.2.7.7 The commands 1,2... (Window Menu / SFC)
Am Ende des MenüsFensterstellt der SFC-Editor eine Liste der aktuell geöffneten SFC-Programmfenster dar. Vor dem SFC-Programmnamen des aktiven Fensters erscheint einHäkchen. Wählen Sie ein SFC-Programm aus der Liste, um sein Fenster zu aktivieren.
5.4.2.8 Commands "Help" Menu
5.4.2.8.1 Commands "Help" Menu (SFC)
Das MenüHilfe enthält folgende Befehle, die Ihnen Unterstützung für diese Anwendungbereitstellen:
Content andIndex
Starts the online-help and shows the first site
Use of the Help Explains the use of help
Info Shows the product information
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
185
5.4.2.8.2 Content and Index (Help Menu / SFC)
Verwenden Sie diesen Befehl, um über das Verzeichnis der Themen eine bestimmtes Hilfethemaauszuwählen.
5.4.2.8.3 Direct Help
Verwenden Sie den BefehlKontexthilfe , um Hilfe zu einem bestimmten Teil des SFC-Editors zuerhalten. Wenn Sie die Schaltfläche "Kontexthilfe" aus der Symbolleiste auswählen, ändert sichder Mauszeiger zu einem Pfeil mit Fragezeichen. Klicken Sie dann mit der Maus irgendwo in dasFenster des SFC-Editors, zum Beispiel auf eine andere Schaltfläche in der Symbolleiste. Das demangeklickten Element entsprechende Hilfethema wird daraufhin angezeigt.
Shortcut:Keyboard: UMSCHALT+F1
.
5.4.2.8.4 Use Help (Help Menu / SFC)
Hier erfahren Sie alles über den genauen Gebrauch und den Umgang mit der Onlinehilfe.
5.4.2.8.5 About SFC Editor (Help Menu / SFC)
Verwenden Sie diesen Befehl zur Anzeige des Copyrighthinweises und der VersionsnummerIhrer Kopie des SFC-Editors.
5.4.3 Menus in the Ladder Editor
5.4.3.1 Survey of Menus (Ladder-Editor)
File MenuEdit MenuInsert MenuView MenuOptions MenuOnline MenuWindow MenuHelp Menu
5.4.3.2 Commands "File" Menu
5.4.3.2.1 Commands "File" Menu (Ladder)
5 ControlX Editor
186 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
TheFile menu contains the following commands:
Close Closes the current Ladder-program
Save Saves the current Ladder-program to its original name
Convert POU-Type Allows you to change between program and function block
Check Syntax Checks the program about syntax errors and opens the inspection-report
Print Prints the current Ladder-program
Page Setup Displays an dialog, so you can set the margins
Print Preview Shows an print preview
Exit Closes the Ladder-Editorr
5.4.3.2.2 Close (File Menu / Ladder)
Use this command to close all windows, which contains the current Ladder-program.The Ladder-Editor proposes you to save your changes. If you close an program without savingyour changes since the last saving will be lost.
You can also use the close-symbol in the toolbar to close your SFC-program, like it is shown inthe following picture:
5.4.3.2.3 Save (File Menu / Ladder)
5.4.3.2.3.1Use this command to save your current SFC-program. It will be stored with its orriginal nameand path.
Shortcut:
Toolbar:Keyboard: STRG+S
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
187
5.4.3.2.4 Convert POU-Type (File Menu / Ladder)
This command allows you to change the type of block between program and function block andthe other way round.
5.4.3.2.5 Check Syntax (File Menu / Ladder)
By using this command you check the program about syntax errors. Notice that you allways checkthe last saved version. In case you have changed your program without saving it appears andialog which asks you to save changes. Confirm this question withOK .After that appears an inspection-report.
Shortcut:Symbol:Keyboard: Alt+F10
5.4.3.2.6 Print (File Menu)
Use this command to print a document. In case you activate this command a dialog appears inwhich you can make statements about the side area, which should be printed, the number ofcopies, the printer and other options about the printer setup.
Shortcut:
Toolbar:Keyboard: STRG+P
5.4.3.2.7 Page Setup (File Menu)
Use this command to set the margins for your printout.
5 ControlX Editor
188 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
In the areaPaper you can arrange the format as well as the source of the used paper.In the areaMargins you can fit the margins of your document. The textfieldTopprovides a space for you to specify the width of the top margin on every printed page.The TextfiledBottom provides a space for you to specify the width of the bottom margin on everyprinted page. The distance between header/footer and the respective margin is fix.In the areaAusrichtung you can choose whether the paper shoulb be printed in the uprightformat or the horizontal format.
5.4.3.2.8 Print Preview (File Menu / SFC)
Use this command to show your current document, how it would look printed. If you choose thiscommand, the main window will be hided by a side-view-window, where you can decide whetherone ot two pages should be shown in this window. Furthermore you can move through the text,you can reduce or enlarge the view or you can start to print.
5.4.3.2.9 Exit (File Menu)
Use this command to finish your session. You can also choose the commandClosefrom yourSystem menu. The Editor asks you to save programs with unsaved changes.
Shortcut:Mouse: Doupleclick on the system menu of the application
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
189
Keyboard: ALT+F4
5.4.3.3 Commands "Edit" Menu
5.4.3.3.1 Commands "Edit" Menu (Ladder)
TheEdit Menu contains the following commands:
Undo Allows you to reverse changes
Redo Reverse the last Undo command
Negate Negates connection results inside a program
Cut Deletes the selected item and places it on the clipboard
Copy Copies the selected item and places it on the clipboard
Paste / Replace Replaces the selected item with data from the clipboard
Delete Deletes the selected items
Select All Selects all items
Search Searchs for a piece of text inside the plan
Replace Searchs for a piece of text inside the plan and replaces it
Search Variable Declarations Searchs for variables inside the declaration part
Replace Variable Declarations Searchs for variables inside the declaration part and replacesit
Go To ... Jumps inside a program to a specified network or jumpingmark respectively
5.4.3.3.2 Undo (Edit Menu)
Use this command to reverse (undo) your last change.
Shortcut:
Toolbar:Keyboard: STRG+Z oder
ALT-RÜCKTASTE
5 ControlX Editor
190 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
5.4.3.3.3 Redo (Edit Menu)
Use this command to reverse the lastUndocommand.
Shortcut:
Toolbar:Keyboard: STRG+Y
5.4.3.3.4 Negate (Edit Menu / Ladder)
By using this command you can put the contact of the binary variables in the instruction sectionin the opposite condition (true or false). Moreover it is is possible to negate the signal, which issend to the exit. Notice that you can not negate the logical symbols set and reset.
Shortcut:Keyboard: Space
5.4.3.3.5 Cut (Edit Menu)
By using this command you delete the selected items and place a copy of them in the clipboard.In the case that no items are marked or the action would have an unauthorized condition as effectyou can not use this command.In the clipboard are allways the items from the last use of cut or copy.
Shortcut:
Toolbar:Keyboard: STRG+X
5.4.3.3.6 Copy (Edit Menu)
By using this command you copy the selected items to the clipboard. In the case no items aremarked you can not use this command. In the clipboard are allways the items from the last use ofcut or copy.
Shortcut:
Toolbar:Keyboard: STRG+C
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
191
5.4.3.3.7 Paste / Replace (Edit Menu)
Use this command to replace the selected items with a copy from the data from the clipboard.In the case that the clipboard is empty or the action would have an unauthorized condition aseffect you can not use this command.
Shortcut:
Toolbar:Keyboard: STRG+V
5.4.3.3.8 Delete (Edit Menu)
Use this command to delete the selected items. In case deleting will have an invalide condition ofdata as effect you can not use this command.
Shortcut:Keyboard: ENTF
5.4.3.3.9 Select All (Edit Menu)
Use this command to select all items.
Shortcut:Keyboard: STRG+A
5.4.3.3.10 Search (Edit Menu)
Use this command to search for a textposition inside the plan. You will see the result in theoutput window. With an double click on the result, you approach to the editor window of therespective transition. Notice that you have to save your plan before you can search inside it.
Shortcut:Keyboard: STRG+Q
5.4.3.3.11 Replace (Edit Menu / Ladder)
Use this command to search in the current program for entered text, formats or comment signsyou want to replace.
5 ControlX Editor
192 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Shorrtcut:Keyboard: Strg+H
5.4.3.3.12 Search Variable Declarations (Edit Menu / Ladder)
Use this command to search for variables inside the declaration part.
5.4.3.3.13 Replace Variable Declaration (Edit Menu / Ladder)
Use this command to search for variables in the declaration part you want to replace.
5.4.3.3.14 Go To (Edit Menu / Ladder)
Use this command to jump inside the program to the specified network or the specified jumpingmark respictively, with the intention to change the insert mark.
5.4.3.4 Commands "Insert" Menu
5.4.3.4.1 Commands "Insert" Menu (Ladder)
TheInsert menu contains the following commands:
Network Inserts a new network into the instruction section
Functionblock Inserts a new function block into the instruction section
Function Inserts a new function into the instruction section
Variable Inserts differnt variables into the instruction section
...AND Contact Create Contact in serial order (Logical AND)
...OR Contact Create Contact in parallel order (Logical OR)
Coil Inserts a coil at the exit
Control Relay Inserts a control relay at the exit
Others Inserts other beginning symbols
5.4.3.4.2 Network (Insert Menu / Network)
This command allows you to insert new branches into the instruction section.
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
193
Shortcut:Toolbar:Keyboard: F12
5.4.3.4.3 Functionblock (Insert Menu / Ladder)
Use this commans to insert function blocks into the instruction section.
Shortcut:Keyboard: Strtg+Alt+B
5.4.3.4.4 Function (Insert Menu / Ladder)
Use this command to insert functions into the instruction section.
Shortcut:Toolbar:Keyboard: Strg+Alt+F
5.4.3.4.5 Variable (Insert Menu / Ladder)
Use this command to insert different variables into the instruction section.
Shortcut ActionAlt + V All...Alt + I Input...Alt + O Output...Alt + N In/Out...Alt + L Local...Alt + G Global...Alt + E External...Alt + F FB-Instanz...
Toolbar:
5.4.3.4.6 ...AND Contact (Insert Menu / Ladder)
Use this command to insert an contact right beside the input mask into the instructionsection.
Shortcut:Toolbar:Keyboard: F9
5 ControlX Editor
194 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
5.4.3.4.7 ...Or Contact (Insert Menu / Ladder)
Use this command to insert a contact below the input mask into the instruction section.
Shortcut:Toolbar:Keyboard: Strg+F9
5.4.3.4.8 Coil (Insert Menu / Ladder)
Use this command to insert a coil at the exit.
Shortcut:Toolbar:Keyboard: F10
5.4.3.4.9 Control Relay (Insert Menu / Ladder)
Use this command to insert a control relay additional to the logical symbol.You can assign each exit maximally one control relay.
Shortcut:Toolbar:Keyboard: F11
5.4.3.4.10 Others (Insert Menu / Ladder)
By using this menu point you can assign other output symbols to the exit in theinstruction section. By clicking the right mouse button you receive a list with possiblelogical symbols.
Button ActionR InsertsResetas beginning symbolS InsertsSetas beginning symbolJMP Inserts Jump as beginning symbolRET InsertsReturn as beginning symbol
5 ControlX Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
195
5.4.3.5 Commands " View" Menu
5.4.3.5.1 Commands "View" Menu (Ladder)
Toolbar By putting a small hook you you can hide or show the Toolbar
Common LadderOperations
By putting a small hook you you can hide or show the Common LadderOperations.
Common LadderFunctions
By putting a small hook you you can hide or show the Common LadderFunctions
Common LadderFunction Blocks
By putting a small hook you you can hide or show the Common LadderFunction Blocks
Output Window By putting a small hook you you can hide or show the Output Window
Statusbar By putting a small hook you you can hide or show the Status Bar below theOutput-Window
Zoom In Enlarges the current file on your screen
Zoom Out Reduces the current file on your screen
5.4.3.6 Commands "Options" Menu
5.4.3.6.1 Settings (Options Menu / Ladder)
This command allows you to edit layout and colors in the ControlX Framework.
5.4.3.7 Commands "Online" Menu
5.4.3.7.1 Commands "Online" Menu (Ladder)
Start Connection to control and statustest of an active programStop Closes the connection to the control
5.4.3.7.2 Start (Online Menu / Ladder)
Have you started the current program in the project file and loaded it in the online-editoryou can use the command Start. If you choose this command, the editor builds up anconnection with the control and interrogates the status of the current Ladder-program.
5 ControlX Editor
196 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
5.4.3.7.3 Stop (Online Menu / Ladder)
This command closes the connection to control.
5.4.3.8 Window (Ladder)
5.4.3.8.1 Survey "Window" Menu (Ladder)
Close All Closes all active windows
Cascade Arranges the windows in cascade style
Tile Arranges the windows side by side
Arrange Icons Arranges the to symbols reduced icons
Split Allows to change the size of the window from variable editor and instructionsection
Next pane Allows to change the window section between variable editor and instructionsection
Document Window Sets the cursor into the ducumentation window
Output Window Sets the cursor into the output-window
Window 1, 2, ... Switches to the specified window
5.4.3.9 Help (Ladder)
5.4.3.9.1 Survey "Help" Menu (Ladder)
Content and Index Starts the online-help and shows the first site
This Windows Starts the online-help
Using Help Explains the use of help
Info Shows the product information
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
197
6 Ladder Diagram Editor
6.1 Introduction
6.1.1 General information on Ladder Logic
The basic principle of Ladder Logic is currency flow through networks. Generally, Ladder Logicis restricted to processing boolean signals (1=True, 0=False).
A Networkis restricted by so called margin connectors to the left and to the right within theLadder Editor. The left margin connector has the logical value 1 (current). There are connectionsthat conduct currency to elements (variables) that conduct currency to the right hand side orisolate depending on their logical state. The result of the procedure depends on the arrangementof elements and the way they are connected (AND = serial; OR = parallel).
Networks consist of the following graphical objects:• Connections (horizontal or vertical lines, and soldered points)• Contacts, Coils, Control Relays• Function blocksandFunctions• Jumps (Graphical elements for control flow)
See also:Ladder Diagram
6.1.2 General Information on Ladder Diagram Editor
The Ladder Diagram Editor included in the ControlX Editor Framework is an editor suitable forthe US market. It neatly fits into anIEC - 61131-3programming environment.
With the Ladder Diagram Editor, you write IL code translatable by the IEC compiler anddisplayable by the IEC IL editor (kispoeed). Thus it is possible to write function blocks in IL thatcan be used as ladder function blocks in the US.
See also:Overview Working with the ControlX Editor FrameworkGeneral Information on Ladder Logic
6.1.3 Informations on handling
6.1.3.1 Menu
The menu provides file edit and management functions, display options lf the editor andhelp functions.
See also:Survey of Menus (Ladder Editor)
6 Ladder Diagram Editor
198 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.1.3.2 ToolbarThe toolbar increases the speed of working by providing the functionality of different menus ordialogs in one place.Choose View→ Toolbar in the menu, in order to display or hide the toolbar.
6.2 Quickstart
6.2.1 Create Ladder DiagrammBefore working with the Ladder Diagram Editor you should have analyzed the control task andstructured the program.Use the Project Browser to create a new project and a new file. The file the Ladder DiagramEditor uses is "LDD".
Double click the file with the left mouse button in the Project Browser. This opens the file intothe Ladder Diagram Editor. If the ControlX Editor Framework has not yet been opened, it will beopened together with the file.Use the menu entries and the toolbar to edit the file.
See also:Ladder DiagramCreate Ladder LogicSaveSyntax - CheckMenuToolbarKeyboard
6.2.2 Create Ladder Logic
In order to create a Ladder Logic, a file of type "LDD" must exist and be opened.
1.) When a new file is being opened, a standard network will be displayed with a contact on theleft hand side and a coil on the right hand side. The label fields of network elementscontain "X" by default.
2.) There is no restriction on whether to declare variables in the variable editor or addinstructions in the instruction editor first. It is possible to freely switch between both editorsduring program creation.
3.) Since the variable editor is available in the "free mode" only, you should stick to the correctsyntax according to the normIEC 61131-3.
4.) On creating networks, you should also stick to basic logical principles in order to avoiderrors. Refer to the norm IEC 61131-3 for further information.
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
199
See also:General Information on Ladder LogicLadder DiagramCreate Ladder DiagramSaveSyntax - CheckOnline
6.2.3 SaveThe Save command is available only if changes were made to an opened LDD file. If this is notthe case, the "Save" toolbar button and the menu entry are grayed.There will be a save before attempting to close an unsaved file to avoid loss of data.
See also:Ladder DiagramCreate Ladder DiagramCreate Ladder LogicSyntax - CheckOnline
6 Ladder Diagram Editor
200 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.2.4 Syntax Check
The syntax check of a program succeeds if all language elements that were used are infact available and if they were used and combined in a permissible manner according tothe programming language.Basic language elements (contacts, key words, literals and identifiers) may always be used.However, data types (bool, integer) and variables may only be used if their declarations areavailable.
1.) Precondition: The program of the current LDD file has been comnpleted.2.) In the menu "File", click "Syntax Check".3.) If there are unsaved changes to the file, a save query will appear. The syntax check always
operates on the latest saved version.
The results of the syntax check will be displayed in the output window.
See also:Ladder DiagramCreate Ladder DiagramCreate Ladder LogicSaveOnlineOutput - Window
6.2.5 OnlineBefore working with the Online Editor, you should have create ressources and tasks within theProject Browser. Ressources and tasks are compiled by the code generator, which yields anexecutable SPS program. Further necessary tools that have to be invoked from the ProjectBrowser are the Test and Commissioning Tool (T&C) and the Control.
1.) In the "Online" menu, click "Start".2.) Note that the load state "LOW" changes to a blue color, while "HIGH" will be highlighted
in red.3.) The states of the control will be initialized and displayed in the online editor.
See also:General Information on Ladder LogicLadder DiagramCreate Ladder DiagramCreate Ladder LogicSaveSyntax - Check
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
201
6.3 Working on Ladder Diagrams
6.3.1 Ladder DiagramA ladder diagram consists of aDiagram Commentand one or manyNetworks.A ladder diagram may be programmed as one of the kinds program, function block or function.The kind of a new ladder diagram is chosen on creation in the Project Browser (File→ New).
Example:
See also:General Information on Ladder LogicOperatorsFunction and Function BlocksLogical Connection
6 Ladder Diagram Editor
202 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.3.2 Comments
You should use comments to describe network elements and their purpose in some detail. Thismay increase their readability for other persons and enables the user as well as the developer toquickly understand the purpose of subprograms.A comment is a language element that enables the inclusion of plain text into programs withoutany implications on program execution. When programming in a graphical language, text framesare provided for comments.
Example:
See also:General Information on Ladder Logic
6.3.3 Network
The instruction section of the Ladder Diagram Editor is subdivided into so called networks,which help structuring the graphic.
A network consists of:
• Network label• Network comment• Network graphic
Network label: Each network that may be a jump target from within another network willautomatically be assigned a preceding alphanumerical identifier or an unsigneddecimal integer. By default, networks will be numbered. This numbering of allnetworks will be automatically updated whenever a new network is inserted.The numbering simplifies finding a certain network an corresponds to linenumbers of textual programming languages.
Network comment: TheNetwork Commentis represented as a square area in the ladderdiagram. To enter a commentary text, double click on this square. Thecomment is always placed below the network label. Note that the first networkadditionally contains a ladder diagram comment above the network label andthe network comment.
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
203
Network graphic:The network graphic consist of graphical objects, which may be graphicalsymbols or connections. Connections transport data between graphical symbols,which process the data at their inputs and transfer the processed data to theiroutputs. Note that the connections may also cross.
See also:General Information on Ladder LogicOperatorsFunctions and Function BlocksLogical Connections
6.3.4 Instructions
6.3.4.1 OperatorsWithin a ladder diagram, the term operator designates the graphical objects contact, coil andjump.
Contacts: A contact associates the value of an incoming connection with the value of anassigned variable. The kind of association depends on the type of contact. Theresult value will be transferred to the connection on the right hand side. Thereare triggers and interruptors.
Coils: Coils serve to assign values to output variables of networks. A coil copies thestate of the connector on its left hand side to its connector on its right hand sidewithout any changes. Furthermore, the coil saves a function of the state or thetransition of the left connector into aboolean variable.
Jump: Jumps manipulate the control flow of programs. They make it possible todirectly invoke certain networks in a defined order. When encountering a jumpoperator, control flow continues at a different network. Thus, jumps are anexception from the basic principle that networks are always processed in a topdown fashion.
6 Ladder Diagram Editor
204 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
See also:General Information on Ladder LogicContactsCoilsFunctions and Functions BlocksLogical Connections
6.3.4.2 Functions and Function BlocksFunctions: If a program block might be useable for different and reoccuring parts
of a control task, you should consider using a function for this subtask.A function may have more than one input parameter, but one outputparameter only. I.e. the calculation may yield one data element asresult only. Functions may not have an internal state, i.e. they may notsave any data. Thus, if a function is invoked twice with the same inputparameters, it will always yield the same return value.
Function Blocks: You may also use function blocks for reoccuring subtasks. Functionblocks may have more than one input parameter and more than oneoutput parameters, too. A function block can save its variable valuesfrom one invocation to the next. These values can be used in the nextinvocation if they are not assigned new values. Thus, function blocksmay have an internal state.
See also:General Information on Ladder LogicFunctions and Functions BlocksUse of FunctionsUse of Function BlocksLogical Connections
6.3.4.3 Logical Connections
A logical connection is represented as parallel or serial combinations of different networks. Thereis no restriction on the number of serially or parallely linked networks. A serial sequence is calledan AND connection, while a parallel sequence is called an OR connection.
See also:General Information on Ladder LogicANDOR
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
205
6.4 Ladder Logic
6.4.1 Operators
6.4.1.1 Contacts
There are two contact symbols for boolean input variables:
1.) Contact symbol for a variable that must have the value "1" to make the correspondingboolean connection true. If the variable is associated with a physical address, the state"1" corresponds to a released interruptor or a pressed trigger.
2.) Contact symbol for a variable that must have the value "0" to make the correspondingboolean connection true. If the variable is associated with a physical address, the state"0" corresponds to a pressed interruptor or a released trigger.
See also:General Information on Ladder LogicOperatorsFunction and Function BlocksLogical Connections
6.4.1.2 Coils
The output variable is always situated to the right hand side of the network and is connected tothe right currency rail.
6 Ladder Diagram Editor
206 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
1.) The result of the logical connection will directly be assigned to the output variable.
2.) The output variable will be assigned the negation of the result of the logical connection.
3.) The result of the logical connection will "permanently set" the output variable: If theresult of the logical connection is "1", the output variable will be set to "1". If, however,the result of the logical connection is "0", this will have no implications.
4.) The result of the logical connection will "permanently reset" the output variable: If theresult of the logical connection is "1", the output variable will be set to "0". If, however,the result of the logical connection is "0", this will have no implications.
5.) Jump operations manipulate control flow. With jumps, networks may be executed only ifcertain conditions hold. Jumps may be conditioned by a binary combination result, orunconditioned, i.e. obligatory. The jump target must always be the beginning of anetwork, designated by its network label.
6.) Return jumps stop program execution within the current POU, and continue at the pointwhere the POU was invoked from. Return jumps may be conditioned by a binaryconnection result, or unconditioned.
See also:General Information on Ladder LogicOperatorsFunction and Function BlocksLogical Connections
6.4.1.3 Control Relays
Control relays are contacts that are inserted in front of coils. Control relays may be used asbreakpoints in manual execution, for example. There can always be one control relay before eachcoil only.
Exmple:
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
207
See also:General Information on Ladder LogicOperatorsFunction and Function BlocksLogical Connections
6.4.2 Blocks
6.4.2.1 Function Blocks
6.4.2.1.1 Function Block
Function blocks may be used for frequently needed functionality. Function blocks may containseveral input parameters and several output parameters. A function block keeps up its variablevalues from one invocation to the next. They may be reused during the next invocation if theyare not assigned new values.
6.4.2.1.2 Use of Function Blocks
A Function Blockis represented as a rectangular graphical symbol. The connectors on the lefthand side represent the input variables, while the connectors to the right represent the outputvariables. Within the rectangle, you see the name of the function block. The names of the inputoperands are situated to the left, while the names of the output operands are to the right. Theinstance name is above the rectangle.
Example of a function block:
A function block constitutes an autonomous network. Input and output operands that are not usedwill not be assigned variable identifiers. The corresponding connectors will then remain withoutlabels. If parameters are passed outside the function block, the function block symbol will bedrawn without any connectors.
6 Ladder Diagram Editor
208 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
The following table presents an overview of all function blocks, ordered according to theirpurpose.
Function Block Purpose .F_TRIG Falling TriggerR_TRIG Raising TriggerRS RS – Flip – FlopSR SR – Flip – FlopTOF Delayed Off TriggerTON Delayed On TriggerTP ImpulsCTD Counter downCTU Counter upCTUD Counter up and down
Choose a function block from the table to see a graphical representation.
See also:General Information on Ladder LogicUse of Functions
6.4.2.1.3 Graphical presentations of prototypes
6.4.2.1.3.1 F_TRIG
The function block F_TRIG processes the state of the input operand "CLK". If there is a changeof state from "1" to "0" in the next processing cycle, this will be recognized and the output "Q"will yield the boolean value "1". The state is "1" at the output only during the one cycle where thechange of state of "CLK" was recognized and thus a falling edge is signaled.
Prototype:
Meaning of operands:CLK: input operand whose falling edge is to be recognizedQ: output operand; signals if "CLK" has a falling edge
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
209
6.4.2.1.3.2 R_TRIG
The function block R_TRIG processes the state of the input operand "CLK". If there is a changeof state from "0" to "1" in the next processing cycle, this will be recognized and the output "Q"will yield the boolean value "1". The state is "1" at the output only during the one cycle where thechange of state of "CLK" was recognized and thus a rising edge is signaled.
Prototype:
Meaning of operands:CLK: input operand whose rising edge is to be recognizedQ: output operand; signals if "CLK" has a rising edge
6 Ladder Diagram Editor
210 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.1.3.3 RS
The function block "RS" statically switches a data element (the output "Q1") to aboolean state"1" or "0"Switching between the two states is due to the values of theboolean input operands "SET" and"RESET1".At the beginning of the procedure. the output "Q1" will be initialized with the value "0". If thefunction block is invoked for the first time with the "1" as the value of the "SET" operand, theoutput "Q1" will yield the value "1" – it will be set. Afterwards, any changes of "SET" will nothave implications on the output value "Q1" any more. "1" as a value of the input operand"RESET1" will always switch the output "Q1" to "0", i.e. it will reset the output.If both input operands have the value "1", the true reset condition will dominate. In other words,"Q1" is preferably reset.
Prototype:
Meaning of operands:SET: Set condition
RESET1: Reset conditionQ1: Output state of bi-stable element
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
211
6.4.2.1.3.4 SR
The function block "RS" statically switches a data element (the output "Q1") to aboolean state"1" or "0"Switching between the two states is due to the values of theboolean input operands "SET1" and"RESET".At the beginning of the procedure. the output "Q1" will be initialized with the value "0". If thefunction block is invoked for the first time with the "1" as the value of the "SET1" operand, theoutput "Q1" will yield the value "1" – it will be set. Afterwards, any changes of "SET1" will nothave implications on the output value "Q1" any more. "1" as a value of the input operand"RESET" will always switch the output "Q1" to "0", i.e. it will reset the output.If both input operands have the value "1", the true set condition will dominate. In other words,"Q1" is preferably set.
Prototype:
Meaning of operands:SET1: Set condition
RESET: Reset conditionQ1: Output state of bi-stable element
6 Ladder Diagram Editor
212 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.1.3.5 TOF
If the state of the input operand "IN" is "1", this will be passed to the output operand "Q" withoutany delay. If there is a falling edge, a timer function will be started lasting as long an interval asspecified by the operand "PT"If the timer is running, a change of state at the input "IN" to "0" will have no implications. It isafter the time is up that the operand "Q" will change to the state "0". If the "PT" value changesafter the start, it will have no implications until there is the next rising edge of the operand "IN".The operand "ET" contains the current timer value. If the time is up, the operand "ET" will keepits value as long as the operand "IN" has the value "1". If the state of the "IN" operand changes to"0", the value of "ET" will switch to "0".If the input "IN" is switched off, this will switch off the output "Q" after an interval specified bythe delay value.
Time Diagram:
Prototype:
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
213
Meaning of operands:IN: Start condition
PT: Initial time valueQ: binary state of the timerET: current time value
6.4.2.1.3.6 TON
The rising edge of the input opernad "IN" will start the timer "TON", and it will run as long atime interval as specified by the operand "PT".While the timer is running, the output operand "Q" will have the value "0". If the time is up, thestate will change to "1" and keep this value until the operand "IN" changes to "0".If the "PT" value changes after the timer has been started, this will have no implications until thenext rising edge of the operand "IN".The output operand "ET" contains the current timer value. If the time is up, the operand "ET"will keep its value as long as the operand "IN" has the value "1". If the state of the "IN" operandchanges to "0", the value of "ET" will switch to "0".If the input "IN" is switched on, this will switch on the output "Q" after an interval specified bythe delay value.
Time diagram:
Prototype:
Meaning of operands:IN: Start condition
PT: Initial time valueQ: binary state of the timerET: current time value
6 Ladder Diagram Editor
214 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.1.3.7 TP
A rising edge of the input operand "IN" will start the timing function of the timer "TP", and itwill run as long an interval as specified by the operand "PT".While the timer is running, the output operand "Q" will have the state "1". Any changes of stateat the input "IN" will have no implications on the procedure.If the "PT" value changes after the start, this will not have any implications before the next risingedge of the "IN" operand.The output operand "ET" contains the current timer value. If the operand "IN" has the state "1"after the time is up, the operand "ET" will keep its value.Every edge occuring while the timer is not running will cause am impuls that lasts as long asspecified.
time diagram:
Prototype:
Meaning of operands:IN: Start condition
PT: Initial time valueQ: binary state of the timerET: current time value
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
215
6.4.2.1.3.8 CTD
The function block "CTD" serves for counting down impulses received from the input operand"CD". On initialization, the counter will be set to "0".If the operand "LOAD" is "1", the value received by the operand "PV" will be taken over as avalue into the counter.Each rising edge at the input "CD" will decrease the counter by "1".The output operand "CV" contains the current value of the counter. If the counter value ispositive, the output operand "Q" will have theboolean value "0". If the counter value reaches zeroor becomes negative, the output "Q" will be set to "1".
Prototype:
Meaning of operands:CD: Counter impulses, rising edge
LOAD : set conditionPV: initial valueQ: signals whether counter value has reached zeroCV : counter value
6 Ladder Diagram Editor
216 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.1.3.9 CTU
The function block "CTD" serves for counting up impulses received from the input operand"CD". On initialization, the counter will be set to "0".The counter value will be reset if the operand "RESET" receives the value "1".Each rising edge at the input "CD" will increase the counter by "1".The output operand "CV" contains the current value of the counter. If the counter value is belowthe margin value "PV", the output operand "Q" will have the boolean value "0". If the countervalue reaches or passes the margin, the output "Q" will be set to "1".
Prototype:
Meaning of operands:RESET: reset condition
PV: counter margin valueQ: signals if counter has reached the margin valueCV : counter value
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
217
6.4.2.1.3.10 CTUD
The function block "CTUD" serves for counting up and down impulses. On initialization, thecounter will be set to the value "0". Every rising edge at the input operand "CD". will increase thecounter by "1", while every falling edge at the input "CD" will decrease it by "1".If the operand "LOAD" is "1", the value received by the operand "PV" will be taken over as avalue into the counter.The counter value will be reset if the operand "RESET" receives the value "1". While the staticstate of the operand "RESET" remains unchanged, the counting conditions or the load conditionwill have no implication, independent of their value.The output operand "CV" contains the current value of the counter. If the counter value is belowthe margin value "PV", the output operand "Q" will have the boolean value "0". If the countervalue reaches or passes the margin, the output "Q" will be set to "1". If the counter value ispositive, the output operand "QD" will have theboolean value "0". If the counter value reacheszero or becomes negative, the output "QD" will be set to "1".
Prototype:
Meaning of operands:CU: counting impulses for counting up, rising edge
CD: counting impulses for counting down, rising edgeRESET: reset conditionLOAD : load conditionPV: load valueQU: signals wheter counter state has reached PVQD : signals whether counter state has reached "0"CV: counter state
6 Ladder Diagram Editor
218 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.2 Functions
6.4.2.2.1 Function
If a certain functionality is needed for reocurring purposes, a function may beappropriate. A function may have several input parameters, but one output parameteronly, i.e. the calculation may have a single data element as a result only. Functionscannot save internal data from invocation to invocation. If repeatedly invoked with thesame parameters, a function will always yield the same return value.
6.4.2.2.2 Use of Functions
A Functionis represented by a rectangular graphical symbol. The connectors on the left hand siderepresent the input variables, while the connectors to the right represent the output variables.Within the rectangle, you see the name of the function and the names of the input operands.There may be more than one function or operation symbols in series in a network. If the datatypes of the connected symbols do not match, a type conversion function must be inserted betweenthem.
The following table presents an overview of all functions, ordered according to theirpurpose.
Function Purpose .
*_TO_** Type conversion of elementary data types
TRUNC round a real down to the closest integer
ABS absolute value
ADD Add numeric data types
MUL Multiply numeric data types
SUB Subtract numeric data types
DIV Divide numeric data types by one another
SHL Binary shift left
SHR Binary shift right
ROL Binary rotation left
ROR Binary rotation right
GT Comparison Greater than
GE Comparison Greater or Equal than
EQ Comparison Equals
LE Comparison Less or Equal than
LT Comparison Less than
NE Comparison Not Equal
LEN Length of a string
LIMIT Limit
MOD Modulo Operation
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
219
MOVE Assignment
Choose a function from the table to see a graphical representation.
Further InformationGeneral Information on Ladder LogicFunctions and Function Blocks
6.4.2.2.3 Graphical presentation of functions
6.4.2.2.3.1 Type Conversion
Operands that are to be combined must always be of the same type. Assume that the inputoperand of a function is required to be of type BYTE, for instance. Now, if the data type of thepassed variable is BOOL, a type conversion will be necessary. In this case, the type conversionfunction BOOL_TO_BYTE will be appropriate.If types are converted, the value from the working register is used as an input operand. Theresult, i.e. the operand with its new data type, will also be written to the working register.
Prototype:
Description of operands:* Data type of the input operand
** Data type of the output operand
If numerical values are converted in their type, care has to be taken that the currentvalue is within the valid range of the target data type. If the value is too large, the resultwill be clipped to the number of bits the target operand possesses, which will be anincorrect value.
6 Ladder Diagram Editor
220 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.2.3.2 Type Conversion Functions
BOOL_TO_BYTE BOOL_TO_DINT BOOL_TO_DWORD BOOL_TO_INTBOOL_TO_SINT BOOL_TO_TIME BOOL_TO_UDINT BOOL_TO_UINTBOOL_TO_USINT BOOL_TO_WORDBYTE_TO_BOOL BYTE_TO_DINT BYTE_TO_DWORD BYTE_TO_INTBYTE_TO_SINT BYTE_TO_ TIME BYTE_TO_UDINT BYTE_TO_UINTBYTE_TO_USINT BYTE_TO_WORDDINT_TO_BOOL DINT_TO_BYTE DINT_TO_DWORD DINT_TO_INTDINT_TO_SINT DINT_TO_TIME DINT_TO_UDINT DINT_TO_UINTDINT_TO_USINT DINT_TO_WORDDWORD_TO_BOOL DWORD_TO_BYTE DWORD_TO_DINT DWORD_TO_INTDWORD_TO_SINT DWORD_TO_TIME DWORD_TO_UDINT DWORD_TO_UINTDWORD_TO_USINT DWORD_TO_WORDINT_TO_BOOL INT_TO_BYTE INT_TO_DINT INT_TO_DWORD INT_TO_SINTINT_TO_TIME INT_TO_UDINT INT_TO_UINT INT_TO_USINT INT_TO_WORDSINT_TO_BOOL SINT_TO_BYTE SINT_TO_DINT SINT_TO_DWORD SINT_TO_INTSINT_TO_TIME SINT_TO_UDINT SINT_TO_UINT SINT_TO_USINTSINT_TO_WORDTIME_TO_BOOL TIME_TO_BYTE TIME_TO_DINT TIME_TO_DWORDTIME_TO_INT TIME_TO_SINT TIME_TO_UDINT TIME_TO_UINT TIME_TO_USINTTIME_TO_WORDUDINT_TO_BOOL UDINT_TO_BYTE UDINT_TO_DINT UDINT_TO_DWORDUDINT_TO_INT UDINT_TO_SINT UDINT_TO_TIME UDINT_TO_UINTUDINT_TO_USINT UDINT_TO_WORDUINT_TO_BOOL UINT_TO_BYTE UINT_TO_DINT UINT_TO_DWORDUINT_TO_INT UINT_TO_SINT UINT_TO_TIME UINT_TO_UDINT UINT_TO_USINTUINT_TO_WORDUSINT_TO_BOOL USINT_TO_BYTE USINT_TO_DINT USINT_TO_DWORDUSINT_TO_INT USINT_TO_SINT USINT_TO_TIME USINT_TO_UDINTUSINT_TO_UINT UINT_TO_WORDWORD_TO_BOOL WORD_TO_BYTE WORD_TO_DINT WORD_TO_DWORDWORD_TO_INT WORD_TO_SINT WORD_TO_TIME WORD_TO_UDINTWORD_TO_UINT WORD_TO_USINT
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
221
6.4.2.2.3.3 TRUNC
The function "ABS" yields the absolute value of a numerical variable. The data type remainsunchanged.The smallest SINT value (–128) and the smallest INT value (–32768) remain unchanged by theABS function, as the binary representation of –128 and +128 (and of –32768 and +32,768,respectively) are identical. Note that in these cases, no error message will be generated, though.
Prototype:
Meaning of operands:IN: Input: Operand of data type ANY_NUM
OUT: Output: Operand of data type ANY_NUMEN: Input controlling the executing of the functionENO: Output controlling the execution of the function
6 Ladder Diagram Editor
222 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.2.3.4 ABS
The function "ABS" yields the absolute value of a numerical variable. The data type remainsunchanged.The smallest SINT value (–128) and the smallest INT value (–32768) remain unchanged by theABS function, as the binary representation of –128 and +128 (and of –32768 and +32,768,respectively) are identical. Note that in these cases, no error message will be generated, though.
Prototype:
Meaning of operands:IN: Input: Operand of data type ANY_NUM
OUT: Output: Operand of data type ANY_NUMEN: Input controlling the executing of the functionENO: Output controlling the execution of the function
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
223
6.4.2.2.3.5 ADD
ADD adds the value of the operand "IN1" and the values of the operands (IN2...Inn). All inputoperands have to be of the same numerical data type. If the result exceeds the range of the targetdata type, an overflow will be generated.The data type of the result corresponds to the data type of the input operands.In the Ladder Diagram, ADDs are available for the data type Integer and UInteger.Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN1: Input: First summand
IN2...n: Input. further summands to addEN: Input controlling the executing of the functionENO: Output controlling the execution of the function
OUT: Output: yields addition result
6 Ladder Diagram Editor
224 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.2.3.6 MUL
MUL multiplies the value of the operand "IN1" and the values of the operands (IN2...Inn) witheach other. All input operands have to be of the same numerical data type. If the result exceedsthe range of the target data type, an overflow will be generated.The data type of the result corresponds to the data type of the input operands.In the Ladder Diagram, MULs are available for the data type Integer and UInteger.Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN1: Input: First operand
IN2...n: Input. further operands to multiplyEN: Input controlling the executing of the functionENO: Output controlling the execution of the function
OUT: Output: yields multiplication result
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
225
6.4.2.2.3.7 SUB
SUB subtracts the value of the operand "IN2" from "IN1". Both input operands have to be of thesame numerical data type. If the result exceeds the range of the target data type (on subtractingnegatives), an overflow will be generated.The data type of the result corresponds to the data type of the input operands.In the Ladder Diagram, SUBs are available for the data type Integer and UInteger.Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN1: Input: Minuend
IN2. Input: SubtrahendEN: Input controlling the executing of the functionENO: Output controlling the execution of the function
OUT: Output: yields subtraction result
6 Ladder Diagram Editor
226 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.2.3.8 DIV
DIV divides the value of the operand "IN1" by the values of the operand IN2. Both inputoperands have to be of the same numerical data type. If there is a remainder, the result will betruncated, i.e. always rounded down (e.g. 7 / 3 = 2 or (–7) / 3 = (-2)).In the Ladder Diagram, DIVs are available for the data type Integer and UInteger.Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN1: Input: Dividend
IN2: Input: DivisorEN: Input controlling the executing of the functionENO: Output controlling the execution of the function
OUT: Output: yields division result
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
227
6.4.2.2.3.9 SHL
The bit pattern in the operand "IN" is shifted to the left by as many bits as specified in theoperand "N". The empty binary digits to the right will be set to zero. The result is of the samedata type as the input operand "IN".Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN: Input: BYTE, WORD or DWORD (as a bit pattern)
N Input: Number of binary digits to shiftEN: Input controlling the executing of the functionENO: Output controlling the execution of the function
OUT: Output. Result
6 Ladder Diagram Editor
228 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.2.3.10 SHR
The bit pattern in the operand "IN" is shifted to the right by as many bits as specified in theoperand "N". The empty binary digits to the left will be set to zero. The result is of the same datatype as the input operand "IN".Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN: Input: BYTE, WORD or DWORD (as a bit pattern)
N Input: Number of binary digits to shiftEN: Input controlling the executing of the functionENO: Output controlling the execution of the function
OUT: Output. Result
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
229
6.4.2.2.3.11 ROL
The bit pattern in the operand "IN" is rotated to the left by as many bits as specified in theoperand "N". Bits that are "shifted off" to the left "re-enter" to the right. The result is of the samedata type as the input operand "IN".Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN: Input: BYTE, WORD or DWORD (as a bit pattern)
N Input: Number of binary digits to shiftEN: Input controlling the executing of the functionENO: Output controlling the execution of the function
OUT: Output. Result
6 Ladder Diagram Editor
230 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.2.3.12 ROR
The bit pattern in the operand "IN" is rotated to the right by as many bits as specified in theoperand "N". Bits that are "shifted off" to the right "re-enter" to the left. The result is of the samedata type as the input operand "IN".Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN: Input: BYTE, WORD or DWORD (as a bit pattern)
N Input: Number of binary digits to shiftEN: Input controlling the executing of the functionENO: Output controlling the execution of the function
OUT: Output. Result
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
231
6.4.2.2.3.13 GT
The comparison function GT checks whether the input operand "IN1" is greater than the inputoperand "IN2". If this is true, the output yields "1", otherwise "0". For more than two arguments,the result is defined by {FUN := 1, iff INi > IN(i+1)}. Input operands may be of type ANY_BIT,ANY_NUM, STRING, ANY_DATE or TIME. There will be a type conversion within thefunction.Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN1...n: Input: Operands to be compared
EN: Input controlling the executing of the functionENO: Output controlling the execution of the function
6 Ladder Diagram Editor
232 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.2.3.14 GE
The comparison function GE checks whether the input operand "IN1" is greater or equal than theinput operand "IN2". If this is true, the output yields "1", otherwise "0". For more than twoarguments, the result is defined by {FUN := 1, iff INi >= IN(i+1)}. Input operands may be of typeANY_BIT, ANY_NUM, STRING, ANY_DATE or TIME. There will be a type conversionwithin the function.Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN1...n: Input: Operands to be compared
EN: Input controlling the executing of the functionENO: Output controlling the execution of the function
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
233
6.4.2.2.3.15 EQ
The comparison function EQ checks whether the input operand "IN1" equals the input operand"IN2". If this is true, the output yields "1", otherwise "0". For more than two arguments, theresult is defined by {FUN := 1, iff INi = IN(i+1)}, i.e. all values must equal. Input operands maybe of type ANY_BIT, ANY_NUM, STRING, ANY_DATE or TIME. There will be a typeconversion within the function.Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN1...n: Input: Operands to be compared
EN: Input controlling the executing of the functionENO: Output controlling the execution of the function
6 Ladder Diagram Editor
234 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.2.3.16 LE
The comparison function LE checks whether the input operand "IN1" is less or equal than theinput operand "IN2". If this is true, the output yields "1", otherwise "0". For more than twoarguments, the result is defined by {FUN := 1, iff INi <= IN(i+1)}. Input operands may be of typeANY_BIT, ANY_NUM, STRING, ANY_DATE or TIME. There will be a type conversionwithin the function.Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN1...n: Input: Operands to be compared
EN: Input controlling the executing of the functionENO: Output controlling the execution of the function
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
235
6.4.2.2.3.17 LT
The comparison function LT checks whether the input operand "IN1" is less than the inputoperand "IN2". If this is true, the output yields "1", otherwise "0". For more than two arguments,the result is defined by {FUN := 1, iff INi < IN(i+1)}. Input operands may be of type ANY_BIT,ANY_NUM, STRING, ANY_DATE or TIME. There will be a type conversion within thefunction.Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN1...n: Input: Operands to be compared
EN: Input controlling the executing of the functionENO: Output controlling the execution of the function
6 Ladder Diagram Editor
236 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.2.3.18 NE
The comparison function NE checks whether the input operand "IN1" does not equals the inputoperand "IN2". If the values differ, the output yields "1", otherwise "0". For more than twoarguments, the result is defined by {FUN := 1, iff INi <> IN(i+1)}, i.e. all values must be inequalequal. Input operands may be of type ANY_BIT, ANY_NUM, STRING, ANY_DATE or TIME.There will be a type conversion within the function.Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN1...n: Input: Operands to be compared
EN: Input controlling the executing of the functionENO: Output controlling the execution of the function
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
237
6.4.2.2.3.19 LEN
The function "LEN" calculates the length of a character string in characters. The data type of theinput operand must be "STRING", while the output opernad has the data type "INT".Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
Meaning of operands:IN1: Input: Operand of data type STRINGOUT: Output: Operand of data type INT
EN: Input controlling the executing of the functionENO: Output controlling the execution of the function
6 Ladder Diagram Editor
238 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.2.3.20 LIMIT
The function "LIMIT" calculates the limit value. Functions must have a EN input and an ENOoutput controlling the execution of the function. If "EN" is FALSE, the function is not executedand "ENO" will be set to FALSE. "ENO" may also be used as the error state of the function.These two parameters must be connected directly or via a sub-network with the currency rails.
Prototype:
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
239
6.4.2.2.3.21 MOD
The function "MOD" is an arithmetic function calculating the remainder of a division.In the Ladder Diagram, DIVs are available for the data type Integer and UInteger.Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
6 Ladder Diagram Editor
240 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.2.2.3.22 MOVE
The function "MOVE" is an arithmetic function that serves for assigning a value.In the Ladder Diagram, DIVs are available for the data type Integer and UInteger.Functions must have a EN input and an ENO output controlling the execution of the function. If"EN" is FALSE, the function is not executed and "ENO" will be set to FALSE. "ENO" may alsobe used as the error state of the function. These two parameters must be connected directly or viaa sub-network with the currency rails.
Prototype:
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
241
6.4.3 Combinations
6.4.3.1 AND
An AND combination corresponds to a serial connection of contacts or other network elements.An AND operation is true if both input variables have the value specified by the kind of contact.
Example:
The AND combination in the example is true if the input variables have the following states:Input_1 1Input_2 0Input_3 1
The output variable AND_Result has the state 1.
See also:NetworkORMixed combinations
6 Ladder Diagram Editor
242 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.4.3.2 OR
An AND combination corresponds to a parallel connection of contacts or other network elements.An AND operation is true if at least one input variables has the value specified by the kind ofcontact.
Example:
The OR combination in the example is true if at least one of the input variables has a value asspecified below:
Input_1 1Input_2 1Input_3 0
The output variable OR_Result has the state 1.
See also:NetworkANDMixed combinations
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
243
6.4.3.3 Mixed combinations
Mixed combinations are a complex wiring made up of AND and OR combinations. Thecombination result is true if there is at least one way where "current" can flow between the leftand the right output symbol.
Example:
The combination in the example yields the value "true" if the input variables have the followingvalues:
Input_1 oder Input_3 1Input_2 0
The output variable OR_AND_Result has the value 1.
See also:NetworkANDOR
6 Ladder Diagram Editor
244 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
6.5 Online
6.5.1 General Information on the Online Editor
The Online Editor simulates the behaviour of an executable program on aSPS. An executableprogram is generated from within the Project Browser, where one ore many ressources and taskscan be compiled.A ressource can generally be thought of as an actually present control. A ressource consists of aname, a hardware description, a communication description and a list of tasks to be executed.A task can be thought of a running program, with some additional information on the kind ofexecution. A task is defined as a name, information on execution (e.g. cyclic), and an executableprogram.
See also:General Information on Ladder Diagramm EditorGeneral Information on Ladder LogicUsing the Online Editor
6.5.2 Using the Online Editor
6 Ladder Diagram Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
245
Precondition: With aid of the Project Browser, at least one ressource and one task must have beendefined and compiled (code generation). The Test and Commissioning Module (TUI) must bestarted, and a control must be active.
From the "Online" menu, choose "Start". This activates the Online Editor. Instead of identifiernames, you will see the current status values, and the load state will be displayed. Blue colourindicates LOW, while red colour indicates HIGH.Changes to the control will be displayed in the Online Editor instantaneously.
See also:General Information on Ladder Diagramm EditorGeneral Information on Ladder LogicGeneral Information on the Online Editor
7 The SFC-Editor
246 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
7 The SFC-Editor
7.1 Elements of Sequential Function ChartSFC-plans are a tool for formulation of control flow of technical process, which are characterisedby change of states. Every state transition is coupled on certain conditions.
The sequential function chart offers the following language elements:
STEP 1
Step:A step contains many actions. Actions contain code frag-ments.A step, which is executing, is called “active”.If a step is active, the contained actions will execute.A step can be activated by:1. switching of a previous transition,2. a jump element,3. setting the initial flag (c.f. initial step).
STEP 1
Initial step:Initial steps are active at the beginning of the program.Positions in the plan could be marked by initial steps, atwhich the execution starts on program start.
T1
Transition:The program flow is controlled temporally andstructurally by switching of transitions. A transition willswitch if the transition condition is true and all previoussteps are active. Once the transition switches, all previoussteps become inactive and all following steps becomeactive.
S1 S2
T1 Simultaneous sequences:One transition may set active multiple steps at the sametime, starting a parallel chain.If all previous steps of transition T1 are active and thetransition condition is TRUE, all following steps (e.g.,S1, S2) of the simultaneous sequence will activate.
S1
T1
S2Convergence of simultaneous sequences:The chains of a simultaneous sequence are convergedinto a single transition.If all previous steps (e.g., S1, S2) are active and the con-dition of the following transition (T1) is TRUE,all previous steps will be deactivated while the steps fol-lowing transition T1 will be activated.
7 The SFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
247
T2
S1
T1
Divergence of sequence selection:Selection of a sequence step chain.If the step before the divergence is active, all transitions ((e.g., T1, T2) are checked from left to right. The firsttransition evaluating to TRUE will switch, deactivatingthe step before and activating the step after.
S1
T1 T2Convergence of sequence selection:The chains of a divergence of sequence selection are con-verged into a step.If one of the transitions switches, the steps before it willbe deactivated, and the Step following it will be activated.
T1
Init
Jump:The program flow is continued at another location.The name of the jump is the name of the activate step ifthe previous transition (T1) switches.
7 The SFC-Editor
248 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
7.2 A program example
Dryer „OFF“ ?
Door locked & „ON“-switch pressed ?
Init
Step 1
Turn drum cyclicduring a definite timeStep 2
Step 4
Unlock door and let water in
Hold waterwarm Step 3
Period of time for warm washing exceed ?
Washing out with clear water
Water amount value exceed?
Time for washing out exceed?
Lower than damp limitvalue ?
Jump to InitInit
Step 5 Let out water
Water level is lower than water amount value?
Turn drum cyclicStep 7 Therm.drying
Step 8
Step 6
Dryer „ON“ ?
Door unlocked and everything switched offff fff h l
fig. 189: a washing process as SFC-plan
As an example, we consider the washing process of a washing machine. At base state, thewashing machine is switched off and the door is unlocked (Init). The machine starts with thewashing process if the door is locked and the “ON”-button is pressed. The washing process is
7 The SFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
249
subdivided in definite phases, for example, the adding of water, the warming up, the cyclicturning of the drum (step 2 and step 3 parallel), the washing out with clear water (step 4), the letout of water (step 5), and finally, the drying (step 7 + step 8) if necessary. For every transition ofa state, different conditions are valid as for example the water amount in the machine, the watertemperature, the washing time, the air damp during the drying process, etc.
The drying of the clothes consists of two parallel states which take place together, namely the me-chanical crease protection (realised by a additional short time turning of the drum), and thethermal drying process. In the IEC-1131 these parallel states are described as simultaneoussequence. These are surrounded by a pair of horizontal double lines. Every simultaneous sequencestarts and ends with a step. The transition following a simultaneous sequence will switch only ifall simultaneous branches are executed completely.
The drying of the clothes starts only if the corresponding switch at the machine is in position“ON”. This behaviour can be realised by use of a divergence of sequence selection (simple hori-zontal line). Divergences of sequence selection consist of several parallel branches with atransition as first element. If a divergence of sequence selection should be executed (previous stepis active), beginning with the left branch, it is looking for a true boolean expression in the firsttransition of a branch, and only this branch is executed.
In general, the IEC-1131 dictates us which sequential elements a SFC-plan must have, whichpredecessors and successors a SFC-element can have:
Element Predecessor
Successor
step transition transitiontransition step step, jumpjump Transition
fig. 190: valid predecessors and successors of SFC-elements
Detailed explanations about the programming with the sequential function chart could be foundedin [IEC1131] or [John & Tiegelkamp, 1995], for example.
7.3 Use of the SFC-Editor
7.3.1 Start of the editor from the browser
From the browser, the SFC-editor can be started by the- button of the toolbar or by selectionof the menu item„SFC“ of the“Tools” menu. A file of the directory “project files” with theappendix „.sfc“ can be loaded by double click with the left mouse button, and the SFC-editor willbe started automatically.
7 The SFC-Editor
250 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
7.3.2 SFC-Editor User Interface
fig. 191 : the layout of the SFC-editor
The SFC-editor is a MDI-application, i.e. several SFC-plans could be opened and worked onsimultaneously. Every SFC-plan consists of a text window for the declaration and the editing oflocal variable respectively. All variables, which should be used by the code of the transitions orsteps, must be declared in this window. If the declaration of variables is forgotten, a compilationof the plan is impossible and corresponding error messages in the output window of the editorwill be generated.In general, all errors, corresponding with the program translation, are printed in an outputwindow as textual message. All SFC-plans share the same output window. By double click on anerror line, the corresponding SFC-plan will be opened and additional sequential actions will beinitiated in dependence of the cause of error (in the SFC editor V4.1, only the corresponding planwould be opened; useEdit�Goto to find the erroneous line).
7.3.3 Creation of a new document• In the Project Manager, selectFile�New�SFC Program
• A dialog box will be opened prompting you for the name of the POU. Enter the name andpress "OK". The SFC-Editor will be opened on that new POU
Every new document consists of a minimal SFC-program that means it consists of an initial step,a transition, and a finishing jump back to the initial step.
fig. 192: the SFC-plan of a new created document
Declaration of localprogram variables
Display of the SFC-plan
Output of user messages
7 The SFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
251
7.3.4 Opening a chartTo open an SFC chart, double click the name in the Project Manager's treeview.
7.3.5 SavingUseFile�Saveto save the current result of your work.
7.3.6 Printing• Use File�Print to print your SFC chart.
A dialog box will be shown asking for printer details. Click OK to start printing.
7.3.7 FormThe current version of the SFC-editor does not support the printing of OpenPCS-forms yet.
7.3.8 Page viewThe page view makes it possible to show the printed form of a plan in the WYSIWYG-format onthe screen. In this mode, one is informed about the necessary pages for printing out the entireprogram and the page numbers of definite program subsection.
7.3.9 Setting of marksTo edit the SFC chart, it is necessary to mark part of it. This selection can comprise only oneelement of the chart, a region of the chart, or the entire chart. Many operations offered by theSFC editor are related to the currently selected area. As the SFC Editor uses context sentitivemenus, some menu items might be greyed depending on the current selection.
7.3.9.1 Single marks
• Click the left mouse button to mark an element with the mouse.
fig. 193 : Marking a single element by aid of the mouse
The mark of a single element can be transformed into a neighbour element by aid of the cursorkeys (←,→,↑,↓) of the keyboard.
7 The SFC-Editor
252 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
7.3.9.2 Region marksIn order to execute a function on several elements of the SFC-plan, all corresponding elementsmust be marked.
fig. 194 : Marking of several elements – region marks
• Mark one element first, using mouse or keyboard.• Hold the Shift-key pressed, and click another element with the mouse to select an entire
region of the chart• or hold the Ctrl-key pressed and click other elements to add them to the selection
In this version are no region marks possible by keyboard.
7.3.10 Editing of the graph-layoutTo maintain the consistency of the graph, some operations are disabled depending on the currentselection. Whether an operation is executable, depends on the mark (it’s impossible to shiftleft/right a branch of a divergence of a sequence selection if no branch of a divergence of a se-quence selection was marked before). In addition, an operation is not allowed if it transforms theplan in an inconsistent state. An example of this is the deleting of a step in a transi-tion�step�transition-sequence that would produce a transition�transition-sequence which isnot allowed. Operations, which are not executable, are not displayed in the menu or toolbarautomatically.In principle, there is always the possibility to cancel every structural change of the plan byEdit� Undo or to restore byEdit� Redo.
7.3.10.1 Cut to the clipboardBy selection of the menu itemEdit� Cut, the marked elements are copied into the clipboard andare deleted from the plan afterwards. Previous elements, situated in the clipboard, areoverwritten. In combination with the menu itemEdit� Paste, elements can be moved in theSFC-plan.
7.3.10.2 Copy into the clipboardBy selection of the menu itemEdit� Copy, all marked elements can be copied into theclipboard. Similar to cutting, all previous elements of the clipboard are overwritten. By
7 The SFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
253
intermediate inserting and replacing respectively ( menu items underEdit� Paste), parts of theSFC-plan can be duplicated.Note that the copying creates new elements with the same name. You might want to modify thesenames after pasting from the clipboard to avoid the problems of having multiple objects withidentical names.
7.3.10.3 Insert of elements from the clipboardWhen inserting elements from the clipboard into the chart, you can select to replace the currentselection, or to add it left or right to the current selection, if applicable.The content of the clipboard remains unchanged by the previous operations, and therefore, isavailable for further operations.
7.3.10.4 Deleting of the marked regionBy selection of the menu itemEdit� Delete, the actual marked elements can be deleted. Theconnecting lines cannot be deleted from the plan.
7.3.10.5 Divergence of sequence selection branches shift left/rightThe selection of the branch of a divergence of sequence selection, which has to execute, startsfrom left to right. Because of this fact, the order of the single branches is important. UseEdit�Move�Left and...�Right to arrange the branches in proper ordering.
7.3.10.6 Replacing of the mark by a step–transition–pairBy selection of the menu itemInsert� Step/Transition, the current selection can be replaced bya step-transition-sequence.
7 The SFC-Editor
254 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
7.3.10.7 Insert a jump
fig. 195 : Insert position of a jump
With Insert� Jump, a jump can be inserted at the place of the current selection. The handle withjumps obeys strong restrictions in order to guarantee sure and executable networks by the editingfunctions of the SFC-editor. The SFC-editor restricts the occurrence of a jump at the last elementof a divergence of sequence selection chain.
7.3.11 Declaration of variablesAll variables used by SFC-elements must be declared before compilation.
Example:
VARImyVar:INT;BMyFlag: BOOL;
END_VAR
The OpenPCS-compiler expects the variable declaration in following order:
- VAR_EXTERNAL
- VAR_GLOBAL
- VAR
There is no possibility to declare variables which are only valid inside one plan element (step,transition).
7 The SFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
255
7.3.12 Exception handlingDuring an execution of a SFC-program, situations could happen which require a specific changeto execution logic in the program. The modelling of this “exception handling” is possible withadditional standard plan elements (transitions, jumps, steps), but reduce the clarity of theprogram.The SFC-editor offers macros for the solution of this problem on the IL-level to activate or inacti-vate steps purposefully.The following commands are available:
@ACTIVATE_STEP(StepName) /* Activating of a step */
@DEACTIVATE_STEP( StepName) /* Inactivating of a step */
@DEACTIVATE_ALL_STEPS() /* Inactivating of all steps */
These macros manipulate the internal execution control so that the given steps will be (in-)acti-vated in the next cycle additionally.
Attention: If the above commands are used in the IL-code, unsure or not executable networkscould arise!
7.3.13 Editing of the program blocksSteps and transitions need the IL-code fragments for their functionality. To edit the code, a texteditor can be opened byEdit� Edit when the corresponding element was marked. In this editorversion, the code of transitions and steps can be given as IL-code only.
fig. 196 : Editing of the IL-code of a step
The names and the comment lines of an element can be adjusted by the appearing dialog underEdit� Properties. Both named functions can be called by the context menu of an SFC-elementequivalently. The context menu can be opened by a click with the right mouse button on theappropriate element.
7 The SFC-Editor
256 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
In the next sections, some specific remarks are given to the separate elements.
7.3.13.1 TransitionsTransition are responsible for the change of the active state of previous step(s) to the followingstep(s). Transitions show the possible change in form of a true,boolean statement (transition con-dition).The code of the transition has to be written so that the current result at the end of the code is oftype BOOL. The transition switches if and only if the value of the accumulator is TRUE.
7.3.13.2 Steps and initial stepsThe code of a step is executed cyclic if and only if this is an active state. In principle, one can saythat the code is surrounded by a loop which is entered if a previous transition switches, and is leftif a following transition switches. If a step was activated, its code is executed at least one time.Initial steps are always active at program start that means that no preceding transition isnecessary. In standard, the entry-point into the IL-program is the first IL-element. Every step canbe converted into an initial step by activating the control box “initial step” in the propertieswindow. De-activating this switch will turn the initial step back into a normal step.
The name of a step must meet following syntax:
The first character of the step name is a letter (‚a‘-‚z‘, ‚A‘-‚Z‘); every further character is a letteror a number (,0‘ – ‚9‘) or a underline (‚_‘).
Valid step names: „Step1“ „S_1“ „S1_“Invalid step names: „_Step1“ „1Step“ „Heater off“
Step names have a maximum length of 31 characters.
7.3.13.3 JumpsJumps are elements of a SFC-plan for controlling the flow of execution. With the up to now intro-duced elements, the activation of the steps happens always from top to button. For programmingof cycles and similar things, a further possibility is necessary to activate previous steps. Jumpsexist to provide this functionality.The predecessor of a jump element is always a transition. The target of a jump is always a step.The target of the jump is fixed by giving the jump the same name as the selected target-step. If astep is given as a target of a jump, its name must be unique. If a jump-target is not or more thanonce available, corresponding error messages are created during the syntax control.To guarantee the consistency of an SFC-plan, the insertion of a jump is possible only as the lastelement of a divergence of sequence selection.
7.3.14 Syntax controlThe syntax control, integrated in the SFC-editor, tests the entire plan for logical consistency.Therefore, for example, jump-targets are tested for uniqueness or names of plan elements for va-lidity.The syntax check is invoked during saving of the chart. If errors are detected during the control,no IL-code can be created! In order to avoid an inconsistency between the generated IL-program(extension *.poe) and the SFC-program (extension *.sfc), the content of the IL-file is deleted. Ifsuch a POU would be compiled anyway, the following error message would result:
<Progname>.POE is not a program. Convert POU-Type or remove taskfrom the resource.It occurred 1 error during the generation !
7 The SFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
257
Objects, which creates errors during the syntax control, are marked by a small red lightning opti-cally.
By double click on the error lines, which appear in the output window, elements of the plan thatcause this error or are in connection can be marked.For example, the following errors are recognised during the syntax control:
1. The jump has no valid jump-target
fig. 197: SFC jump with no valid target
2. The jump has no unique jump-target
7 The SFC-Editor
258 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 198: SFC jump with no unique target
After the output of the error message, all objects that come into consideration as a possible jump-target are listed.
3. The target of a jump is situated in a simultaneous sequence.
fig. 199: SFC jump into a simultaneous sequence
7 The SFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
259
Jumps into simultaneous sequences are seen as a error because the “token” in a simultaneous se-quence could leave the sequence only if every parallel branch has a “token”. But the jump into asimultaneous sequence gives a “token” only to one of the branches.
The program has no initial
step.
fig. 200: SFC chart with no initial step
If a program has no initial step, no step can ever be activated. Therefore, the entire network is notexecutable.
No IL-syntax errors are recognised during the syntax check. If mistakes are made in the variabledeclaration, in the code of the single steps or in the formulation of the transition conditions, thesecould be recognised only during the compilation in OpenPCS. Then, the compiler lists the corre-sponding line numbers of the POU-file which caused an error. In order to assign a line number ofthe POU-file to an element of the SFC-plan,Edit� Goto IL-Line can be used to find thislocation in the SFC chart
fig. 201: SFC dialog "GoTo IL-Line"
If an element is found that fits to the line number, the text editor is opened automatically, toeliminate the error in the code. If an error in the variable declaration is found, it’s indicated bythe following message box:
7 The SFC-Editor
260 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 202: SFC Error messages on error in declarations
Then, the error must be removed in the variable declaration window.
7.3.15 The SFC-editor in online-modeIf a SFC-program is created and compiled successfully, it can be tested with the TUI.• In the Project Manager, selectOnline�Go Onlineon the proper resource• Open the resource tree and select the task icon corresponding to the SFC program• In the Project Manager, selectOnline�Online-Editor to start the SFC-Editor in Online
mode• In the SFC-Editor, selectonline� status display
The online-modus helps to observe the control flow of a SFC-program which is situated in a con-trol unit. Therefore, all active steps are marked by a red rectangle.
fig. 203 : Display of the active steps in the online-modus
7.4 The buttons of the toolbar
Icon Menu entry Short keys Description
File� Save Ctrl + S Saving of the active document
Edit� Cut Ctrl + X Cut the marked elements into the clipboard
7 The SFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
261
Edit� Copy Ctrl + C Copy the marked elements in the clipboard
Edit� Paste Ctrl + V Replace of the marks by the elements of theclipboard
File� Print Ctrl + P Output of the program on the printer
File� Print preview Preview of the printer output
View� Zoom in Zoom in
View�Zoom Out Zoom out
Edit� Undo Ctrl + Z Cancel the last alteration
Edit� Redo Ctrl + Y Cancel the command “cancel” again
Help to the menu items
7 The SFC-Editor
262 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
263
8 The CFC-EditorThe OpenCFC-Editor (Continuous Function Chart Editor) is an engineering tool used to createautomation programs graphically. The individual modules of a program are represented byfunction charts, which in their total form are projects. Predefined function blocks are transformed
into block objects with the help of the OpenCFC-Editor, and then connected graphically into afunction chart. A completed project composed of several function charts can be transferred to thecontroller and tested online.
The OpenCFC-Editor allows for the documentation of a project: the function charts can beprinted.The context menu is always available. Users can directly access the required menu commands byclicking the right mouse key. The online help system informs the user how to proceed with the
creation of a CFC project. The OpenCFC-Editor has no limitations concerning the project size.The program will run on Windows 95 and Windows NT.
8.1 Styles and Symbols
An important advice. This should help to avoid mistakes, or remind you of an importantrequirement for the further development of the program.
A tip which will make work easier or a further advice.
A reference to the toolbar. It is beside an instruction which refers to a menu commandalso available in the toolbar. The corresponding symbol is displayed on the button.
8.2 Structure of the OpenCFC-EditorThe main window of the OpenCFC-Editor consists of a title bar, a menu bar, a toolbar and astatus line. Within the main window one or more function charts can be optionally displayed intheir own windows.
8 The CFC-Editor
264 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 204: CFC Editor
The menu bar contains all necessary commands for creating and handling a program. For fre-quently repeated actions extra toolbar symbols can be chosen:
fig. 205 : CFC-Editor toolbar
The individual symbols have the following meaning:
Create a new program
Open an existing program
Save program
Preview a function chart
Print an active function chart
Search for a named connector or a block type
Cut selected blocks to clipboard
Copy selected blocks to clipboard
Paste from clipboard to function chart
Undo last action
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
265
Go to the upper level
Enlarge section of active window; size of objects will decrease
Reduce section of active window; size of objects will increase
Insert a block from the library to the function chart
Create connection between the selected connectors
Create several connections with the connection tool
Show/hide grid
Information about OpenCFC-Editor
The status information of the editor are displayed in the status line, e.g. details of the propertiesof a selected block connector or the functionality of a selected menu command.By selecting the appropriate commands in the “view” menu, the toolbar and the status line can behidden or shown. Located on both vertical boundaries of the “Function Chart” window aremargin bars. They consist of a set of margin connectors which can be used to create connectionsbetween different function charts or connections to the hardware.According to the selected format the width of a “Function Chart“ window will be limited bythree, five or seven blocks. Its length is free expandable; the single sheets of the function chartarea are marked off on the screen by a horizontal line.
8 The CFC-Editor
266 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
8.2.1 Creating a Program
8.2.1.1 Creating a new CFC program
• In the Project Manager, selectFile�New�CFC Programor File�New�CFC FunctionBlock.
• A dialog box will be opened prompting you for the name of the POU. Enter the name andpress "OK". The CFC-Editor will be opened on that new POU
fig. 206 : CFC-Editor with no chart opened
� Select the desired format of the function chart and click the “OK” button. All menus of theOpenCFC-Editor will be displayed in the menu bar.
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
267
fig. 207: empty chart in CFC Editor
8.2.1.2 Show/Hide GridFor better orientation during the creation of a function chart a grid, which divides the work areainto single block fields, can be shown.� Choose“View →→→→ Grid”. The grid will appear in the currently active function charts.
fig. 208: CFC Editor with grid shown
8 The CFC-Editor
268 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
8.2.1.3 Adding Blocks to a Function ChartA function chart is structured in rows and columns. The intersections of the rows and columnsare the block fields. In each block field a single block can be placed; the size of the field will beadjusted automatically to fit the size of the block. Between the block fields there are narrowcolumns and rows which serve as connection channels. No blocks can be placed in these areas.
The block library contains one block prototype of each available block type. When selecting ablock from the library a copy of its prototype, a so-called instance, will be inserted into the func-tion chart.When a block is placed into the function chart it receives an instance number, which appears inthe left hand side of the block symbol below the block name. The allocation of numbers isautomatic. Each block type will be numbered separately: beginning with 1 and incrementing forany further inserted block of the same type.
Choose“Insert � Function Block” to open the dialog “Block Selection”.
fig. 209: CFC-Editor: Insert Function Block dialog
� Select the desired block from the function block list.
According to its location in the work area, the pointer will change its form after a block has beenselected. This simplifies the insertion of the block into the function chart.
The pointer is in a free block field, in which a block can be placed.
The pointer is in a connection channel, i.e. a block cannot be placed here.
The pointer is in an occupied block field; if a new block is placed here, a columnwill be added and the block which has occupied the field will be shifted one gridspace to the right.
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
269
� Move the pointer to a block field.
� Click the left mouse button. The selected block will be placed in the field. The pointerreturns to its original form.
fig. 210: block inserted into CFC chart
� Insert further blocks into the function chart in the same way.
Note the sequence of the program execution. The position of the blocks can be changed subse-quently.
8.2.1.4 Connecting Blocks in a Function ChartA connection can be created between a block output connector and one or more block input con-nectors. Loops, i.e. connections between an output and one or more inputs of the same block are
also possible. The OpenCFC-Editor checks the data type of the connectors to be connected andonly allows connections between connectors of the same data type.The connections are placed automatically in the provided connection channels. If it’s not possibleto draw a continuous connection line in a connection channel, the connection will be replacedautomatically by reference points.
fig. 211: connected blocks in CFC-Editor
8 The CFC-Editor
270 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
In order to create a connection between blocks of the same function charts, you must select theconnectors to be connected. A connector is selected with a mouse click or by moving the cursor tothe connector with the help of the arrow keys and pressing the space key.
8.2.1.4.1 Creating a Connection between an Output Connector and an InputConnectorFirst select the two connectors to be conntected. The sequence of selection is not relevant..
fig. 212: Output and Input connector marked
Select“Insert � Single Connection”.The two connectors will be connected with a connectionline.
fig. 213: Output and Input connector connected
8.2.1.4.2 Creating a Connection between one Output Connector and SeveralInput Connectors� Each output connector can be connected to several input connectors. A
connection between several output connectors and one input connectoris not possible
� Select the output connector and the first input connector to be connected.
� Select the other input connectors while pressing the CTRL key.
fig. 214: Ouput and multiple Inputs marked
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
271
�Choose“Insert →→→→ Single Connection”. The selected connectors will be connected. Theconnection line coming from the output connector branches to the various inputs. The branchingpoints will be represented as knots:
fig. 215: Output and multiple Inputs connected
8.2.1.4.3 Adding an Input Connector to an Already Existing Connection
� Select the output connector of the existing connection which you wantto extend with a further destination input connector. All connectors ofthe connection will be marked
� Select the input connector to be added while pressing the CTRL key
fig. 216: Connection line and Input marked
Choose“Insert →→→→ Single Connection”. The existing connection will be ex-tended with an additional input. In the example above it is represented byreference points.
8 The CFC-Editor
272 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 217: Input added to connection line
8.2.1.5 The Connection ToolIf you wish to create a series of connections in one operation, the CFC editor supports you with
the connection tool .Choose“Insert →→→→ Connection Tool”. The pointer will change
Select the output and the inputs to be connected. With this tool it isn’t necessaryto press the CTRL-key. When you have all connectors marked, choose“Insert→→→→ Single Connection”to create the connection.If a connection is to be made between a further output connector and an inputconnector, the output connector must be selected first.In this manner several connections can be created quickly and efficiently Choose“ Insert→ Connection Tool” to switch off the connection Tool. The pointer willreturn to its original form:
8.2.1.6 The Margin BarThe working area of OpenCFC is terminated on the left and right side with amarginbar. Eachmarginbar provides room formargin connectors. Initially, all margin connectors are empty andunused. To use a margin connector, give it a name. You can use margin connectors for differentpurposes:� Connection to physical addresses (in IEC1131 notation: AT %I or AT %Q is
possible only via margin connectors� If you want to wire an output from the far right side of a chart to the far left,
you can draw a direct connection or use margin connectors. Typically, usingmargin connectors will increase readability.
� In IEC1131 each margin connector will be mapped to the declaration
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
273
of a global variable.
8.2.1.6.1 Assigning a name to a margin connector
� Choose“Properties...” in the context menu. The dialogbox “Propertiesmargin connector” will open.
� Select option “Identifier” and enter a name in the field provided
fig. 218:Properties margin connector dialog
� Hit “OK”. The name will be displayed in the margin connector
8 The CFC-Editor
274 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 219: Margin connector named
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
275
8.2.1.6.2 Connecting to a physical addressTo connect a block to a physical address, the block has to be connected to the margin bar first,inputs to the left margin bar, and outputs to the right margin bar, respectively. You should assignnames to the margin connectors used.
8.2.1.6.3 Connecting a block to the margin bar� Select the block connector you want to create the connection with� Select a margin connector in the margin bar
fig. 220: Margin connector marked
� Choose “Insert→ Single Connection”. The selected block connector and themargin connector will be connected
fig. 221: Input connected to margin connector
8 The CFC-Editor
276 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
8.2.1.6.4 Creating a connection
� Choose“Properties...” in the context menu of the margin connector to bemapped to a hardware address, e.g. a named input connector. The dialog box“Properties margin connector” will open.
� Select the option “Identifier” and click the check box “use IO”.� Enter the hardware address in the edit field „memory location (at ...)“. Please
note that the address you enter is not checked by the OpenCFC editor, but onlyby the compiler during compilation later. This is because legal hardwareaddresses are dependent on target system properties unknown to the OpenCFCeditor.
fig. 222: Margin connector properties dialog
� Choose the “OK” button. The memory location appears in the correspondingsymbol of the margin connector
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
277
fig. 223: Input connected to margin bar with address
8.2.1.7 Assigning a Constant to an Input ConnectorWhen a block connector is selected, the corresponding connector description and the data typeappear in the status line. If you have assigned further properties to a connector, these will also bedisplayed in the status line..� Select the block input a constant is to be assigned to� Choose“Edit →→→→ Properties...”. The “Properties” window will open� Choose theInput Valuesheet, enter the required value and click the“OK” but-
ton
fig. 224: constant value input
The input value appears in the status line of the main window when the connector is selected .
8 The CFC-Editor
278 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
8.2.1.8 Zooming in and outThe “View” menu offers two commands in order to change the zoom factor of the function chartin the active window by steps. In the following example the function chart is shown in thestandard size:
fig. 225: sample chart window
� Choose“View →→→→ Zoom Out”. A larger section of the function chartin the “Function Chart” window will be displayed without having toenlarge the window
fig. 226: sample chart window zoomed out
� Choose“View →→→→ Zoom In” if you want to enlarge the blocks of thefunction chart.
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
279
8.2.2 Editing a ProgramThe positioning on the work area, i.e. the shifting and adding of blocks is supported by thealtering form of the mouse pointer. The pointer can adopt the following forms
The mouse pointer is in an empty block field. The dragged blocks can be dropped here.
The mouse pointer is in an occupied block field. A column will be inserted for thedragged block. If you have selected several blocks with a rubber band, the suitablequantity of columns and rows will be inserted.
The mouse pointer is in an empty block field. The block copied to the clipboard can beplaced. The arrangement of the other blocks will not be modified. If you have copied agroup of blocks to the clipboard, the suitable quantity of columns will be inserted.
The mouse pointer is in a connection channel which is restricted for blocks.
8.2.2.1 Opening a programTo open a CFC chart, double click the CFC chart in the Project Managers treeview.
8.2.2.2 Moving a block to an empty block field
fig. 227: CFC chart
� Click the block to be shifted and drag it to the empty block field where it is tobe placed while pressing the mouse button
8 The CFC-Editor
280 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 228: Moving block to empty field
� Release the mouse button. The block will be placed in the empty block field.The existing connections will be preserved; the connection layout will be ad-justed automatically to the new arrangement
fig. 229: block moved to empty field
8.2.2.3 Dragging a block to an empty field� Click the block to be moved, drag it to the destination block field while
keeping the mouse button pressed down
fig. 230: sample chart with block dragged
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
281
� Release the mouse button, dropping the block into the block field. Space willbe provided as necessary, connections will be rearranged.
fig. 231: block dragged to empty field
8.2.2.4 Shifting a Group of blocksIt is possible to shift several selected blocks within a function chart.� Drag a rubber band around the blocks to be shifted.
� Using the mouse, the blocks can be marked separately while pressing the CTRL key. Agroup of blocks selected in this manner can only be shifted, if the totality of the blocks iswithin an rectangular area like the marking with a rubber band
fig. 232: multiple blocks marked
� Click one block within the selected area and drag it to the requested spot whilepressing the mouse button. All selected blocks will be shifted; their arrange-ment among themselves will not be modified
� Release the mouse button if the destination position is reached. If there are notenough coherent and unoccupied block fields, the lacking amount of columnswill be added. The connections within the selected area and to the other blockswill be preserved
8 The CFC-Editor
282 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 233: multiple blocks dragged
8.2.2.5 Copying or Shifting Blocks Using the ClipboardA group of blocks can be put to the clipboard by copying or cutting. They can be inserted fromthe clipboard to any function chart. The connections within the inserted group will be preserved.� Drag a rubber band around the blocks.� Using the mouse, the blocks can be marked separately while pressing the
CTRL key. A group of blocks selected in this manner can only be copied orcut, if the totality of the blocks is within an rectangular area likewise themarking with a rubber band
fig. 234: sample chart
� Choose“Edit →→→→ Copy” if you want to put a copy of the group ofblocks to the clipboard
� Choose“Edit →→→→ Cut” if you want to cut the group of blocks fromthe function chart to the clipboard
� Choose“Edit →→→→ Paste”.
� Locate the mouse pointer in the destination block area. If the group of blocksis to be inserted to another function chart activate the concerning functionchart at first.
� Click the block field where the upper left block of the group is to be inserted.The remaining blocks will be arranged to the right and below this spot.
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
283
fig. 235: blocks pasted
� Connect the blocks among themselves and create connections to otherfunction charts of the project if required. The connections within the insertedarea will be preserved
8.2.2.6 Deleting a Block� Select the block to be deleted� Press the DEL key. The selected block will be deleted and the existing connec-
tions within function chart will be cut. If there are connections to the marginbar the connection information will be deleted
8.2.2.7 Changing ConnectionsIt is possible to delete existing connections or to add new onesTo delete a connection within one chart or between charts:� Select a connected connector.� Press the DEL key. The connection(s) of the selected connector to the function
chart will be deletedTo delete a connection to a margin connector� Choose“Properties...” in the context menu of the margin connector with a
connection to another function chart that should be deleted. The “PropertiesMargin Connector” window will open
8 The CFC-Editor
284 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 236: margin bar properties dialog
� uncheck “use I/O” and press “OK”. The connection to the physical addresswill be deleted
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
285
8.2.2.8 Saving a program
� Choose“File →→→→ Save” if a program is to be stored .
If the program exists already, it will be stored with its originalname.
If a new program is to be stored, the dialog box “Save As” willopen..
� Browse in the directory box and choose where the program is to be stored, editthe file name and click the “OK” button
The extension.CFC will be added automatically
8.2.2.9 Documenting a ProgramTo print a program, each function chart has to be printed independently.
� Select„File � Print“ and press „OK“.
� In case no printer or the wrong printer is installed, configure your printerusing“File � Printer Setup”.
In the dialog box“ Printer Configuration” a new printer driver can be installed or an installedprinter can be chosen. Dependent on the type of printer, the sheet size and the print direction(vertical or horizontal) can be selected.
8.2.2.10 Using the help function
The help function of the OpenCFC-Editor is following the standard MS-Windows help system.The usage of the help system is the same as in any MS-Windows application. Hints can be foundselecting the command “Use Help” in the menu “Help”.
The help system of the OpenCFC-Editor offers all information that are required when you are
working with the OpenCFC-Editor. In the summary there is a short list of the topics that allowsto jump directly to a searched topic.Along with the help topics covering the particular procedures there are buttons which allow tojump to superior, related or more detailed topics. Additionally the user can always branch to “Ba-
sics of the OpenCFC-Editor” and “Summary”.All menu commands and dialog boxes are explained through the context-sensitive help.Select the menu item to which help is required and press the “F1” key in order to fade in thecorresponding help topic.In order to get information on a dialog box, open it and press the “F1” key. All elements of thedialog box will be explained (Display fields, Edit fields, List boxes and buttons).
8.3 Advanced Topics
8.3.1 Online – Debugging ProgramsTo debug a program written with OpenCFC online, perform the following steps:� Write your program, compile it and download it to your controller� Use the Test and Commissioning tool TUI to start your controller. Note the
resource tree shown in the project browser.
8 The CFC-Editor
286 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 237: TUI window
� Locate entry in the resource tree representing your CFC program, mark it andchoose“Online � Online Editor” in the project browser.
� The OpenCFC Editor will be started, opening this very program. Select “On-line� Online”
Current values will now be displayed for all visible connections, and periodically updated. Tomodify the program, select off“Online � Online” first.
8.3.2 Execution SequenceThe arrangement of the blocks on a chart is directly related to the sequence of execution: Blocksare executed first column first from top to bottom, then second column top to bottom, and so on.To modify execution sequence, rearrange the blocks as required.
8.3.3 Modifying a block interfaceOpenCFC stores, with each block, the interface of that block as it was when the block has beeninserted into a chart. If you are using blocks you created yourself, using IEC1131 languages (in-struction list, structured test, function block diagram, ladder diagram, or CFC), you might modifythis block interface later.If you then re-load a block referencing such a block, CFC will notice the modification of theblock interface and warn you showing the following message
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
287
fig. 238: block interface modified warning message
All instances of blocks with modified interfaces will be shown with question marks. To correctthe chart, find all such instances and replace the blocks with correct blocks.
� Choose“Edit →→→→ Find...” . The dialog box “Find” appears.� Select the option “Invalid Block”. “.“.
fig. 239: Find-dialog
� If the item is positioned outside of the currently visible section of a functionchart, the section will be shifted so that the block or margin connector will bevisible. If the discovered item is located in an invisible or closed functionchart, the function chart will appear immediately
8 The CFC-Editor
288 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
8.3.4 Using forms for printingPrint forms are not supported with the current version of CFC.
•
8.3.5 Compound Blocks
Compound Blocks are a way to structure your application
8.3.5.1 Compound Blocks: Introduction
The work area of the CFC-Editor is limited to one page width. By selecting the paper size, youdetermine the number of blocks that can be placed horizontally. Vertically, a function chart cangrow unlimited.
Although in fact you are not limited in the length of your CFC chart, it is easy to loose overviewon a too lengthy chart. Compound Blocks are a means to finer structure your application, hidinggroups of logically related blocks inside one „Compound Block“.
Signals between the blocks inside a Compound Block are not visible to the outside. Outside aCompound Block, only those signals are visible that enter or leave the Compound Block.
On screen, double-click the Compound Block to see it’s contents. Use“View�Level up” orin the toolbar to get back to the location where the Compound Block is being invoked.
Compound Blocks can be nested, i.e. inside a Compound Block you can define, or use, other com-pound blocks. The contents of a Compound Block can be edited, you can add or delete blocks,rewire connections, add, modify or delete connections leaving or entering the Compound Block.
On screen, the last input and output connector of a Compound Block is shorter than any otherconnector, so you can easily distinguish a Compound Block from other Blocks.
8 The CFC-Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
289
8.3.5.2 Insert a new empty Compound Block
To create a new, empty Compound Block,
1. Select“Insert � Compound block...”2.
The mouse cursor changes to3. Click the mouse where you want to insert the new Compound Block
You can now fill the Compound Block first, by double-clicking and editing it just like any otherfunction chart. Or, add inputs and outputs to the Compound Block first, editing it’s contents laterusing the already provided inputs and outputs then.
8.3.5.3 Converting Blocks to a Compound Block
Whenever you run out of space on a chart, or think readability would be increased by morehierarchically grouping, you can collapse some of your already wired blocks into a CompoundBlock:
1. Have the Block(s) selected2. Select “Insert� Compound block...”3. CFC-Editor will prompt you to verify you want to convert the blocks to a Compound
Block4. The selected Blocks will be removed from the chart and replaced by a Compound Block.
All signals between these blocks will be moved with the Blocks, all signals to otherblocks will be kept and changed to interface signals of the Compound Block.
8.3.5.4 Adding an input or output to a Compound Block
You can edit the contents of a Compound Block just like any other function chart. When youneed to provide additional inputs, or need to provide additional outputs, you need to change theinterface of the Compound Block accordingly. You can do this from the surrounding (top-down)or from within the Compound Block (bottom-up).
top-down:
1. Any Compound Block has one very last connector which is shorter than the others.This is always the last connector, one on the left side as an input, one on the right sideas an output.
2. Wire this last input or output3. As soon as you use this last connector, it will be shown in full length, and another
shorter connector will be added to the end.
Bottom-Up:(currently not supported yet)
9 Introduction into IE C1131
290 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9 Introduction into IEC1131
9.1 Program Structure
The Programming Languages of OpenPCS are compliant to IEC1131-3. This manual describesthe elements of these languages. Continuous Function Chart (CFC) is an extension to IEC1131and is not covered in this manual.
Your application will be structured into small, independent units of code and data, calledProgram Organisation Units, which we abbreviate as POU. The German abbreviation is POE,which you will see in the software in some instances. There are three types of POUs:
Program
Function
Function block
IEC1131 defines a set of commonly used standard functions and function blocks, and OpenPCSprovides most of these.
If a program is structured into multiple POUs, on each call to another POU execution of thecalling POU will be suspended, and resumed after return from the called POU. A call can beunconditional or conditional.
Each POU is subdivided into a declaration part and an instruction part. All variables used in theinstruction part have to be declared in the declaration part.
Instructions as well as declarations may have comments, arbitrary character strings enclosed in“(*” and “*)”.
The entire POU is enclosed in keywords
PROGRAM...END_PROGRAM orFUNCTION...END_FUNCTION orFUNCTION_BLOCK...END_FUNCTION_BLOCK.
Example „Typical Elements of a POU“PROGRAM smpl_pou
(* Declaration part*)VAR
Memory_1 : SR; (* Declare an instance of an FB of type SR *)ON_key AT %I0.0 : BOOL; (* Declare variables *)OFF_key AT %I0.1 : BOOL;Release : BOOL;Start : BOOL;. (* Declare more variables *).
END_VAR(* instruction part*)
CAL Memory_1( Set1 := ON_key, (* Call FB with parameters *)ReSet := OFF_key)
LD Memory_1.Q1ST Release. (* and more instructions *).
END_PROGRAM (*End of Program*)
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
291
Important Note
�OpenPCS is a portable, configurable programmingsystem. Not all functions, datatypes, and otherfeatures described here are available with all con-trollers. If in doubt, see the vendor of your con-troller
9.2 Declarations
9.2.1 DatatypesIEC1131 defines a set of elementary datatypes, plus means to define derived datatypes. The key-words for datatypes may be written in lower or upper case.
Elementary Datatypes
The following table lists all elementary datatypes of IEC1131 with their keyword and defaultinitial value. Any variable defined to be of a given type will have this default initial value unlessit is declared as being different for this individual variable:
Keyword Datatype Bits DefaultBOOL Boolean value, can be 1 or 0, which is the same as
“TRUE” and “FALSE”.1 0
SINT Short Integer; values range from –128 to +127 8 0INT Integer; values range from –32768 to +32767 16 0DINT Double Integer; values range from –2147483648 to
+214748364732 0
USINT Unsigned Short Integer; values range from 0 to 255 8 0UINT Unsigned Integer; values range from 0 to 65 535 16 0UDINT Unsigned Double Integer; values range from 0 to
429496729532 0
REAL Real number 32 0.0TIME Time duration value – T#0sDATE Calendar date – D#1900-01-01TIME_OF_DAY Time of day – TOD#00:00:00DATE_AND_TIME Calendar date and time of day – DT 1900-01-01-
00:00:00STRING Character string of variable length (for maximum length
of strings, see §12.7.1)' ' (Empty String)
BYTE Bitstring of 8 bits 8 0WORD Bitstring of 16 bits 16 0DWORD Bitstring of 32 bits 32 0
Data types DATE, TIME_OF_DAY and DATE_AND_TIME are not supported by the currentversion of OpenPCS.
Some standard functions and operations (called “overloaded”) can be used with only onedatatype, but a variety of datatypes. The permitted datatypes for these is given as a genericdatatype (starting withANY...) according to the following hierarchy:
9 Introduction into IE C1131
292 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
SINTINTDINTUSINTUINTUDINT
BOOLBYTEWORDDWORD
DATETIME_OF_DAYDATE_AND_TIME
REAL
ANY_BIT ANY_DATE
ANY_INT
ANY_NUM
ANY
STRING TIME AbgeleiteteDatentypen
fig. 241: Hierarchy of datatypes
Please note that you cannot use these generic datatypes (those starting withANY...) to declarevariables, not can you use it in a definition of your own functions or function blocks.
BOOL R_EDGE and BOOL F_EDGEDatatypes BOOL R_EDGE (rising edge) and BOOL F_EDGE (falling edge) are offered as ele-mentary datatypes in OpenPCS. These may be used only in the declaration of INPUT variablesfor Function blocks.
Derived datatypes
Derived datatypes are defined by the manufacturer of your controller, or by yourself. These newdatatypes are defined using keywords TYPE...END_TYPE, based on the elementary datatypes.After definition, they may be used just like predefined or elementary datatypes.
Example: Derived datatypesIn the following sample code, a new datatype is defined to represent a “Pressure” value
TYPEPressure : INT;
END_TYPE
VARPreValvePressure: Pressure;
END_VAR
Declaration of a datatype with sub-rangeUsing a derived sub-range datatype, you can restrict values for variables declared to be of thisdatatype.
�The behaviour if, due to the result of a calculation,a variable value should exceed the sub-range, iscontroller-dependent and not defined by IEC1131nor by OpenPCS.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
293
�This feature is not implemented in Version 4.1 ofOpenPCS
Example: sub-range datatypeWe define a datatype to represent voltage, which is assumed to be below 150 Volts.
TYPEVoltage: INT (0..150);
END_TYPEVAR
Inlet: Voltage;END_VAR
�The upper and lower limit is written separated bytwo dots with no blank in between.
Declaration of an enumeration datatypeA variable of an enumerated datatype can take any one of a fixed list of values. The list of legalvalues is listed in the declaration of the enumeration datatype, separated by commas. An initialvalue may be given after the closing “)”; if no initial value is given, the first value will be the de-fault.
Example: Enumeration datatypeDatatype TrafficLight can be “red”, “yellow” or “green”. “Yellow” shall be the default.
TYPE TrafficLight:(red,yellow,green):= yellow;
END_TYPEVAR
MainRoad : TrafficLight;CrossRoad : TrafficLight;StopCar: BOOL;
END_VAR
In the instruction part of that POU, the defined enumerated values can be used:
Example: ILLD MainRoadEQ redST StopCar
Declaration of an array datatypeArrays contain multiple elements of the same datatype. The keyword ARRAY is used to define anarray. Each element of an array can be an elementary variable.
Example: Array datatypeType Arr1 will hold five elements of type INT
PROGRAM feldTYPEArr_5_INT:ARRAY [1..5] OF INT;END_TYPEVARArr1 : Arr_5_INT;END_VAR.END_PROGRAM
9 Introduction into IE C1131
294 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Declaration of a structured datatypeA structure holds multiple elements of same or different datatypes, elementary. KeywordSTRUCT is used to define a structure. The individual elements of a structure are called membersof that structure, and are accessed by writing the structure, followed by a dot and the name of themember.
Example: Structured datatypePROGRAM strukturTYPERobotArm :STRUCT
Angle_1 : REAL;Angle_2 : REAL;Grip: BOOL;Length: INT;
END_STRUCT;END_TYPEVARRobot1 : RobotArm;Robot2: RobotArm;END_VARLD Robot1.Grip
..
END_PROGRAM
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
295
9.2.2 VariablesVariables are names to represent memory locations which can hold different data values. Thereare two groups of variables:
Variables mapped to physical (or logical) inputs, outputs or markers of a PLC, and
Variables used only internally within the program to hold intermediate results
Each variable has a name, starting with a letter (a-z) or an underscore. The variable name maycontain digits, upper and lowercase letters and underscores, but not space, TAB or umlaut charac-ters. The length of a variable name should not exceed 64 characters.
Directly represented variables
Directly represented variables are those variables, that under the control of the programmer aremapped to a specific input, output or memory address. Keyword AT is used to declare this, andthe address is specified in a string starting with a percent sign (%).
Example: directly represented variablesDeclaration of a directly represented variable with and without a symbolic name
PROGRAM POU4VARAT %I0.0 : BOOL;In_1 AT %I0.1 : BOOL;Results : BOOL;
END_VARLD In_1AND %I0.0ST Results
END_PROGRAM
It is strongly recommended to use symbolic names for directly represented variables, as this easesrewiring to different addresses. The declaration cannot be saved either.
�Directly represented variables are only allowed ina POU of type PROGRAM!
9 Introduction into IE C1131
296 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Syntax of the %...
The syntax of the string starting with the percent sign is:% Location-Mnemonic Size-Mnemonic Number Dot Number
whereLocation-Mnemonic is one ofI: Digital-InputQ: Digital-OutputM: Marker
And Size-Mnemonicis one of
Mnemonic Meaning Size Example<none> Bit 1 Bit %I0.0X Bit 1 Bit %IX0.0B: Byte 8 Bit %IB0.0W: Word 16 Bit %QW0.0D: Doubleword 32 Bit %ID4.0
Multiple Declaration
Directly represented variables can be mapped to physical addresses so that more than one variableis mapped to the same, or partly the same address. A variable of a smaller size can be locatedcompletely within a variable of a larger datatype. This is helpful if done intentionally anddisastrous if done unintentionally.
Example: Multiple DeclarationVariable Bit_Var will be mapped to the fifth bit of variable Word_Var. Variable Byte_Var ismapped to the higher byte of Word_Var.
VARBit_Var AT %I0.4:BOOL;Byte_Var AT %I1.0:BYTE;Word_Var AT %I0.0:WORD;
END_VAR
Variable types
All variables that you want to use in the instruction part of your POU have to be declared in thedeclaration part of this POU. There are different types of variables, depending on the keywordused to introduce the declaration section. The following list gives an overview:
Keywords UsageVAR “Local Variable”, only accessible in the defining POU.VAR_GLOBAL Global Variable, accessible from all parts of a program. Any other POU wishing to
access this variable has to declare this as external.VAR_EXTERNAL Declaration for a variable defined as global elsewhere.VAR_INPUT Input variable, only to be read from within the defining POU, and to be written by other
POUs (typically the calling POU).VAR_OUTPUT Output variable, to be written by the defining POU and read by others (typically the
calling POU)VAR_IN_OUT IN_OUT variable; in contrast to input and output variables, IN_OUT variables are
passed “by reference”, not “by value”, i.e. the defining POU is handed a reference to theoriginal variable by it’s calling POU. It may be read and written by the defining POU.
TYPE Definition of local datatypes.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
297
Each declaration section starts with the respective keyword and ends with END_VAR orEND_TYPE.
Local and global variable declarations can be attributed with the following attributes:
Keyword UsageRETAIN Use RETAIN to identify variables which should not be initialised at power-up (warm-
start and hot-start). These variables retain there value over a power-failure (if properlysupported by the controller).
CONSTANT Use CONSTANT to flag variables that should not be written by the program. Using thiskeyword makes your program more self-documenting and helps you spot programmingerrors, if unintentionally you tried to write this variable
AT Use AT to map variables to physical addresses
RETAIN typically is supported only for global variables, not for variables of a Function block.
Example: Using RETAIN and CONSTANTDeclaration of a remnant variable, a remnant function block instance, and a constant variable:
VAR RETAINCounterValue : UINT;
END_VARVAR RETAIN
Counter : CTU;END_VARVAR_GLOBAL CONSTANT
NullKelvin : INT := -273;END_VAR
9 Introduction into IE C1131
298 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
The following table lists which section of declarations is allowed in which type of POU:
Section FUNCTION FUNCTIONBLOCK
PROGRAM
VAR_INPUT (2) (2)
VAR_OUTPUT (2)
VAR_IN_OUT (2)
VAR_GLOBAL (2)
VAR_EXTERNAL (2)
VAR (2) (2) (2)
TYPE (1) (1) (1)
(1) Allowed, but only once
(2) Allowed
9.2.3 Instantiating Function blocksWith IEC1131, Function blocks cannot be called; only instances of function blocks can be called.Before, the instance has to be declared like any other variable. To declare an instance, declare itlike any other variable by using the function block name as the datatype.
Counter1 : CTU;
This declares an instance “Counter1” of function block CTU. Inputs and Outputs areparameterised with the call to an instance.
9.3 Instruction part of a POU
9.3.1 Instructions
Operator Operand MeaningLD ANY Load Operand into current resultLDN ANY_BIT Load negated Operand into current resultST ANY Store current result to operandSTN ANY_BIT Store negated current result to operandS BOOL If current result is non-zero, set operand to TRUE.R BOOL If current result is TRUE, set operand to FALSE.AND ANY_BIT Boolean AND& ANY_BIT Boolean ANDANDN ANY_BIT Negated Boolean AND&N ANY_BIT Negated Boolean ANDOR ANY_BIT Boolean ORORN ANY_BIT Negated Boolean ORXOR ANY_BIT Boolean exclusive ORXORN ANY_BIT Negated Boolean exclusive ORADD ANY_NUM Addition
SUB ANY_NUM SubtractMUL ANY_NUM MultiplyDIV ANY_NUM DivideGT ANY Compare for greater-thanGE ANY Compare for greater-equalEQ ANY Compare for equalNE ANY Compare for non-equal
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
299
LE ANY Compare for less-equalLT ANY Compare for less-thanJMP Label Unconditional jumpJMPC Label Jump if current result is TRUE,JMPCN Label Jump if current result is FALSECAL Instance name Unconditional call of function block instanceCALC Instance name If current result is TRUE, call function block instanceCALCN Instance name If current result is FALSE, call function block instanceRET – Unconditional return to calling functionRETC – If current result is TRUE, return to calling functionRETCN – If current result is FALSE, return to calling function
Syntax of an instruction
Label Operator Operand CommentL1: LD %I0.1 (* Load input bit *)
Label Mark the instruction to later jump here (optional)
Operator One of the available instruction, see table above
Operand typically a variable name, or instance name, or label
Comment Description of instruction (optional)
9 Introduction into IE C1131
300 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Instruction List Syntax
An instruction list sequence starts with a load-instruction (LD or LDN), or consists of a (uncondi-tional) CAL, JMP or RET.
IL sequencesThe following syntax graph shows the syntax for instruction list sequences.
fig. 242: definition of an IL sequence
Label-DefinitionLabels are used to mark instructions as a target for a jump.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
301
9.3.1.1 Load Instructions
LDLoad
Applicable Datatypes: all
DescriptionThe value of the operand is evaluated and loaded into the current result. The operand is not modi-fied.
ExampleOperation Operand NoteLD %I0.5 1 Assuming that %I0.5 is 1, this
1 is loaded into the currentresult
LD %IB0.0 11010100 Assuming that on Byte 0 apattern of 11010100 ispresent, this 11010100 isloaded into the current result
LDNLoad negated
Applicable Datatype:ANY_BIT
DescriptionThe operand is evaluated, and the current result is loaded with the negated value. The operand isnot modified.
ExampleOperation Operand NoteLDN %I0.3 1 Assuming that a 1 is present at
input it 0.3, a 0 is loaded intothe current result
LDN %IB0.0 11010100 Assuming that on Byte 0 apattern of 11010100 ispresent, 00101011 is loadedinto the current result
9 Introduction into IE C1131
302 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9.3.1.2 AssignmentsSTAssignment
Applicable Datatypes: all
DescriptionThe value contained in the current result is stored to the operand. The datatype of the operandmust match the datatype contained in the current result.
ExampleOperation Current Result NoteST %Q0.0 1 Output bit 0.0 will be set to 1ST Result1 1001100100001111 The bit pattern contained in
the current result will bestored into Result1
LD 17ST Val1ST Val2
Variables Val1 and Val2 willbe set to 17
STNNegated Assignment
Applicable Datatype:ANY_BIT
DescriptionThe negated value of the current result will be stored into the operand. The current result will notbe modified.
ExampleOperation Current Result NoteSTN %Q0.1 1 Output 0.1 will be set to 0
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
303
SSet
Applicable Datatype: BOOL
DescriptionIf the current result is TRUE, the operand will be set to TRUE. If the current result is FALSE, theoperand will not be modified. The current result will not be modified in either case.
ExampleOperation Current
ResultNote
LD %I0.0
S %Q0.0
1
1
Assuming that input 0.0 is set,output 0.0 will be set
RReset
Applicable Datatype: BOOL
DescriptionIf the current result is TRUE, the operand will be set to FALSE. If the current result is FALSE,the operand will not be modified. The current result will not be modified in either case.
ExampleOperation Operand
valuesNote
LD %I0.1
R %Q0.0
1
0
Assuming that input 0.1 isTRUE, output 0.0 will be reset
9 Introduction into IE C1131
304 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9.3.1.3 Logical Operations
AND, &AND
Applicable Datatypes:ANY_BIT
DescriptionReplace the current result with the result of a binary boolean AND of the current result and theoperand given. The previous value of the current result is lost, the operand is not modified.
ExampleOperation Operand
statusNote
LD %I0.0AND Start
ST Band
10
0
Assuming that input 0.0 isTRUE and variable Start isFALSE, variable Band will beset to FALSE.
LD %IB0.0
AND %IB1.0
ST Result
11001100
10101010
10001000
The two bitstrings will beANDed bitwise.
ANDN, &Nnegated AND
Applicable Datatypes:ANY_BIT
DescriptionReplace the current result with the result of a binary boolean AND of the current result and the
negation of the operand given. The previous value of the current result is lost, the operand is notmodified.
ExampleOperation Current Result NoteLD %I0.1ANDN StartST Band
101
Assuming that input 0.1 is TRUE and variable Start isFALSE, variable Band will be set to TRUE.
LD %IB0.0&N %IB0.1ST Result
110011001010101001000100
The first bitstring and the negation of the second bitstringwill be ANDed bitwise
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
305
OROR
Applicable Datatypes:ANY_BIT
DescriptionReplace the current result with the result of a binary boolean OR of the current result and the op-
erand given. The previous value of the current result is lost, the operand is not modified.
ExampleOperation Current
ResultNote
LD Input1OR Input2
ST OR_Bit
10
1
Assuming that Input 1 isTRUE and input2 is FALSE,variable OR_Bit will be set toTRUE
LD Byte_1
OR Byte_2
ST OR_Byte
11001100
10101010
11101110
The two bit-strings will beORed bitwise
ORNnegated OR
Applicable Datatypes:ANY_BIT
DescriptionReplace the current result with the result of a binary boolean OR of the current result and thenegation of the operand given. The previous value of the current result is lost, the operand is notmodified.
ExampleOperation Current
ResultNote
LD Input1
ORN Input2
ST ORN_Bit
0
0
1
Assuming that Input1 isFALSE and Input2 is FALSE,variable ORN_Bit will be setto TRUE
LD Byte_1
ORN Byte_2
ST ORN_Byte
11001100
10101010
11011101
The two bit-strings will beORN’ed bitwise
9 Introduction into IE C1131
306 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
XORExclusive OR
Applicable Datatypes:ANY_BIT
DescriptionReplace the current result with the result of a binary boolean exclusive OR of the current resultand the operand given. The previous value of the current result is lost, the operand is notmodified.
ExampleOperation Current
ResultNote
LD Input1
XOR Input2
ST XOR_Bit
1
1
0
Assuming that Input1 is TRUEand Input2 is TRUE, variableXOR_Bit will be set to FALSE
LD Byte_1
XOR Byte_2
ST XOR_Byte
11101111
10111110
01010001
The two bitstrings will beXOR’ed bitwise
XORNnegated exclusive OR
Applicable Datatypes:ANY_BIT
DescriptionReplace the current result with the result of a binary boolean exclusive OR of the current resultand the negation of the operand given. The previous value of the current result is lost, theoperand is not modified.
ExampleOperation Current Result NoteLD Input1XORN Input2ST XOR_Bit
111
Assuming that Input1 is TRUE and input2 is TRUE, variableXOR_Bit will be set to TRUE.
LD Byte_1XORN Byte_2ST XORN_Byte
111011111011111010101110
The two bitstrings will be XORN’ed bitwise
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
307
9.3.1.4 Arithmetic Operations
ADDAddition
Applicable Datatypes:ANY_NUM
DescriptionReplace the current result with the sum of the current result and the given operand. The previous
value of the current result is lost, the operand is not modified.
�See also function ADD in chapter 9.5.
ExampleOperation NoteLD 23ADD VariableST Sum
Set Sum to the sum of variable and 23
SUBSubtraction
Applicable Datatypes:ANY_NUM
DescriptionReplace the current result with the result of the given operand subtracted from the current result.
The previous value of the current result is lost, the operand is not modified.
�See also function SUB in chapter 9.5
ExampleOperation NoteLD MinuendSUB SubtrahendST Difference
Set Difference to the difference between Minuendand Subtrahend
9 Introduction into IE C1131
308 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
MULMultiplication
Applicable Datatypes:ANY_NUM
DescriptionReplace the current result with the product of the current result and the given operand. The previ-ous value of the current result is lost, the operand is not modified.
�See also function MUL in chapter 9.5
ExampleOperation NoteLD MultiplikandMUL MultiplikatorST Produkt
Set Produkt to the product of Multiplikand andMultiplikator
DIVDivision
Applicable Datatypes:ANY_NUM
DescriptionReplace the current result with the quotient of the current result and the given operand. Theprevious value of the current result is lost, the operand is not modified.
�See also function DIV in chapter 9.5
ExampleOperation NoteLD DividendDIV DivisorST Quotient
Set Quotient to the quotient of Dividend andDivisor
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
309
9.3.1.5 Comparisons
Applicable Datatypes: ANY
DescriptionThe following comparisons are available:
GT greaterGE greater or equalEQ equalLE less or equalLT lessNE not equal
The operand will be compared to the current result, and the current result will be set to TRUE ifthe comparison is correct, to FALSE else. The previous contents of the current result is lost.
ExampleLabel Operation Note
M1:
LD Num1EQ Num2JMPC M1LD 1ADD Num1ST Num1
The variable Num1 is compared to Num2. If both are equal, a jump to label M1will be executed, else variable Num1 will be incremented
Instructions without parentheses:
9 Introduction into IE C1131
310 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Instructions with parentheses:
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
311
9.3.1.6 Conditional and unconditional Jump
JMPUnconditional Jump
Applicable Datatype: the operand has to be a label
DescriptionThe program will be continued at the label given as the operand. The label has to be set at thestart of a sequence. The label and the Jump have to be within the same POU.
ExampleLabel Operation NoteM1: LD Num1
EQ Num2JMPC M2..
The following sequence will be skipped ifNum1 and Num2 are equal
M2:
LD 1ADD Num1ST Num1JMP M1..
Increment Num1 and go back to labelM1.
JMPC/JMPCNConditional Jumps
Applicable Datatype: the operand has to be a label
DescriptionIf the current result is TRUE (with JMPC) or FALSE (with JMPCN), execute a Jump to the labelgiven, else continue with the next instruction after the Jump. The label has to be set at the start ofa sequence. The label and the Jump have to be within the same POU.
ExampleLabel Operation NoteM1:
M2:
LD Num1EQ Num2JMPC M2LD 1ADD Num1ST Num1JMP M1
Skip the following increment sequence, if Num1 equals Num2.
Increment Num1 and go back to label M1
9 Introduction into IE C1131
312 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9.3.1.7 Conditional and unconditional Return
RETUnconditional Return (RET)
Applicable Datatype: the Return instruction has no operand
DescriptionThe execution of the current POU will be terminated. If programmed in a Function block orFunction, execution will be transferred back to the calling POU. If programmed in a Program,execution will be transferred back to the PLC operating system.
ExampleLabel Operation Note
M1:
LD ErrorJMPCN M1RET..
If Error is TRUE, the Jump will not beexecuted and the RET will end thecurrent POU
RETC/RETCNConditional Return
Applicable Datatype: the RETC and RETC instructions have no operands
DescriptionIf the current result is TRUE (with RETC) or FALSE (with RETCN), a Return will be executed,else execution will be continued with the next instruction after the RETC/RETCN.
ExampleOperation NoteLD ErrorRETC..
If Error is TRUE, the current POU will beterminated
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
313
9.3.1.8 Function block invocation
CALUnconditional function block call
DescriptionExecution will be transferred to the instance given as the argument.
A CAL is not allowed in the mid of a sequence or nested in parentheses.
ExampleOperation Note..ST Output2CAL Block_2_Hz (Set:=Start,
Period:=TimeVal)
After the Store, instanceBlock_2_Hz is called
CALC/CALCNConditional function block call
DescriptionIf the current result is TRUE(with CALC) or FALSE (with CALCN), the function block instancewill be called.
ExampleOperation Note..ST Output2LD Result3CALC Block_2_Hz(Set:=Start,Period:=TimeVal)..
If Result3 is TRUE, instanceBlock_2_Hz will be called
9 Introduction into IE C1131
314 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9.3.1.9 Calling Functions
A function is called by using the function name as an operator, without any keyword. See chapter“functions” for more details.
9.3.2 ConstantsWith OpenPCS, there are two ways to use constant values:
a) declare a variable with attribute CONSTANT, and assign the constant value to this value asan initial value in the declaration,
b) write the constant as a literal constant directly in the instruction list.
ExampleVariable Val1 shall be incremented by a constant value of 115, and stored into variable val2:
LD val1ADD 115ST val2
Within a literal constant, underscores are allowed to increase readability. Such underscores haveno meaning regarding the value of a constant.
Literal constants for some datatypes require a special prefix:
Constant Datatype Example MeaningINT -13
45165 or 45_165+125
Integer -13Integer 45165 (both)Integer 125
REAL -13.12123.450.123-1.23E-3
Real –13,12Real 123,45Real 0,123Real -0,00123
Dual number 2#0111_1110 or 126 126Octal number 8#123 or 83 83Hexadecimal number 16#123 or 291 291BOOL 0 and 1
TRUE and FALSEBoolean TRUE and FALSE values
STRING 'ABC' Character string ABCTIME T#12.3ms or
TIME#12.3msTime duration of 12,3 milliseconds
T#12h34m orT#12h_34m
Time duration of 12 hours and 34 minutes
T#-4m Negative time duration of 4 minutesDATE DATE#1995-12-24 or
D#1995-12-24Date 24.12.1995
TIME_OF_DAY TOD#12:05:14.56 orTIME_OF_DAY#12:05:14.56
12 hours05 minutes and 14,56 seconds PM
DATE_AND_TIME DT#1995-12-24-12:05:14.56 orDATE_AND_TIME#1995-12-24-12:05:14.56
Date and time: 12 hours05 minutes and 14,56 seconds PMon 24.12.1995
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
315
Note: DATE, TIME_OF_DAY and DATE_AND_TIME are currently not supported byOpenPCS.
Please see the important note in §2.1!
Literal constants of datatypes TIME, DATE and DATE_AND_TIME uses keywords plus a hashsign “#”. The keywords can be written in long (e.g. DATE_AND_TIME) or short form (e.g. DT).
A string constant is sequence of characters enclosed in “’”. Special characters can be embeddedwithin a character string literal by using escape sequences starting with the $ sign, as listed in thefollowing table:
Predefined characterconstants
Meaning
'$''’ The Apostrophe “’”'$$' The $ sign itself'$L' or '$l' Line Feed'$N' or '$n' New Line'$P' or '$p' Form Feed'$R' or '$r' Carriage Return'$T' or '$t' Tabulator
ExampleCharacter Constant Meaning and Length'A' Single character A, length=1' ' Blank character, length=1'' No character, length=1'$R$L' Carriage Return, Line Feed, length=2'$0D$0A' Carriage Return, Line Feed, length=2
9.3.3 ProgramA program is the top-level structure of OpenPCS. A Program does contain declarations and in-structions itself, but it does call other POUs to execute their code.
Example „Program POU1“Program „POU1“ with a call to function SHL (shift left) and function block CTU (count up)
PROGRAM POU1(* Declarations *)
VARCounter1 : CTU; (* Declaration of Counter1 as CTU *)ShiftNum AT %IW2.0: WORD;ShiftDigits : UINT := 2;ShiftResult : WORD;Start AT %I0.0 : BOOL;AT %I0.1 : BOOL;Pulse AT %I0.2 : BOOL;AT %I0.3 : BOOL;Band AT %Q0.1 : BOOL;Stand : INT;
END_VAR(* Instructions *)
LD %I0.1AND StartST BandLD ShiftNum (*call function and parameterise *)SHL ShiftDigitsST ShiftResultCAL Counter1(CU := Pulse, (* Call FB and parameterise *)
ReSet := %I0.3)LD Counter1.CVST Stand
END_PROGRAM (* Program end *)
9 Introduction into IE C1131
316 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9.3.4 FunctionsA function provides one means of re-usability. A function may have more than one input, but italways has exactly one output value (which may be an array or structure).
A function is always accessible to all POUs of a project, there is no declaration needed to be ableto call a function. There are no instances of functions. To call a function, the function’s name isused as an operator, the current result is always used for the first parameter, more parameters arepassed to the function as operands after the function name, separated by commas.
The function returns it’s value by storing it into a variable having the name of the function (asPASCAL does). After the function call, the value returned by the function will be the currentresult.
Function cannot store values over a call, give the same input parameters, a function shall alwaysreturn the same output value.
Example Function “Sum”Sample function “Sum” will compute the sum of three arguments:
FUNCTION SUM : INTVAR_INPUT
A : INT;B : INT; (* Declarations *)C : INT;
END_VARLD AADD B (* instructions*)ADD CST SUM
END_FUNCTION
SUM
INT —— A —— INT
INT —— B
INT —— C
Example „Program POU2“Calling Function SUM of above
PROGRAM POU2VAR
SUMMAND1 : INT:= 1;SUMMAND2 : INT:= 2;SUMMAND3 : INT:= 3;RESULT : INT;
END_VARLD SUMMAND1 (* Load First parameter into current result *)SUM SUMMAND2, SUMMAND3 (* call function and pass more arguments *)ST RESULT (* store function result *)
END_PROGRAM
A function may call other functions, but it may not instantiated nor call instances of functionblocks, and function blocks are not allowed as parameters to functions. Besides defining your ownuserdefined functions, you can use many standard functions that come already with OpenPCS.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
317
9.3.5 Function blocksBesides Functions, function blocks are the second way of re-usability in IEC1131 and OpenPCS.Other than functions, a function block may have more than one output, it may store values fromone call to the next.
A function block may call other functions, it may instantiate other function blocks and invoke in-stances of function blocks.
Usage Example from withinFB
Example from outsideFB
Read input LD IN1AND IN2ST Q1
LD FBx.IN1ST %QW3.0
Write input Not allowed LD StartST FBx.IN1CAL FBx
Read Output LD OUT1AND IN1ST OUT1
CAL FBx(IN1 := Ein,...)LD FBx.OUT1ST %QW3.0
Write Output LD 1000ST OUT1
Not allowed
A function block input may be declared as being edge detective
Example Edge Detection
Rising Edge Falling Edge
VAR_INPUTStart : BOOL R_EDGE;
END_VAR
VAR_INPUTPause : BOOL F_EDGE;
END_VAR
IEC1131 defines different ways to pass parameters to function blocks. The following examplewill demonstrate these:
Example function block “average”A simple function block to compute the average of two numbers, and it’s invocation from a pro-gram POU3
FUNCTION_BLOCK averageVAR_INPUT
Val1 : USINT;Val2 : USINT;
END_VARVAR_OUTPUT
AvgVal : USINT;END_VAR
9 Introduction into IE C1131
318 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
LD Val1ADD Val2DIV 2ST AvgVal
END_FUNCTION_BLOCK
average
USINT —— Val1 AvgVal —— USINT
USINT —— val2
Example „Program POU3“Instantiate function block “Average”, and two different invocations
PROGRAM POU3VAR
Instance1_Name : Average;Instance2_Name : Average;MessVal1 AT %IB0.0 : USINT;MessVal2 AT %IB1.0 : USINT;Result1 AT %QB0.0 : USINT;Result2 AT %QB1.0 : USINT;
END_VAR(* 1. Method of FB call *)
CAL Instance1_Name (Val1:= MessVal1,Val2:= MessVal2)
LD Instance1_Name.AvgValST Result1
(* 2. Method of FB Call *)LD MessVal1ST Instance2_Name.Val1LD MessVal2ST Instance2_Name.Val2CAL Instance2_NameLD Instance2_Name.AvgValST Result2
END_PROGRAM
Function block Average exists only once, but multiple instances of it may be declared withdifferent names (here: „Instance1_Name“ and „Instance2_Name“). Although not shown in thisexample, it is definitely possible to call one instance more than once.
Each instance will receive it’s own copy of all data associated with function block Average. Pa-rameters are passed to the function block
a) as arguments to the CAL instruction, enclosed in parentheses
b) before the call by storing some value into the proper member variable (e.g. ST In-stance2_Name.Val1).
c) not at all, in which case the input will be left to the value it was assigned last, or the initialvalue.
To access output variables, IEC1131 defines only one way, and that is to access outputs like struc-ture members (similar to “b” above). But OpenPCS provides an extension to IEC1131 to accessoutput variables directly as an argument to the CAL operation, similar to “a” above:
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
319
ExampleCAL Instance3_name (Val1:=MessVal1,
Val2 := MessVal2|Result3 := AvgVal)
9.4 Other Programming Languages
9.4.1 Other Programming LanguagesBesides Instruction List, OpenPCS offers other languages. On the one hand, these are thelanguages as defined by IEC1131:
- Ladder Diagram (LD)
- Function Block Diagram (FBD)
- Structured Text (ST)
- Sequential Function Chart (SFC)
On the other hand, in extension to IEC1131, OpenPCS features additional the language
- Continuous Function Chart (CFC)
The languages Ladder Diagram and Function Block Diagram will be explained in the followingchapters. For more information on the other languages and their respective editors see the othermanuals.
Not all these languages are supported in all versions of OpenPCS. If in doubt, check with the ven-dor of your controller.
9.4.2 LD and FBD: IntroductionOpenPCS supports the two graphical languages defined by IEC1131, Ladder Diagram (LD) andFunction Block Diagram (FBD).
A POU created in Ladder Diagram or Function Block Diagram consists of a declaration part andan instruction part, just like a POU in instruction list. The declaration part is edited with thesame declaration editors as in the instruction list editor. The instruction part will be showngraphically.
The instruction part is divided into networks, each network has a network number on it’s top.Close to the network number an optional network comment can be displayed.
9 Introduction into IE C1131
320 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9.4.3 Programming in Ladder DiagramProgramming language Ladder Diagram is suited for logical expressions of binary variables.
Programs in Ladder Diagram are shown with the following graphical elements:
Contact: Check variable for value TRUE
Negated contact: check variable for value FALSE
Coil: store result to variable
Negated coil: store negated result to variable
Set: set variable to TRUE if expression evaluates to TRUE
Reset: set variable to FALSE if expression evaluates to TRUE
Unconditional jump to label “Label”
Conditional jump: if result is TRUE, jump to label “Label”
Negated conditional jump: if result is FALSE, jump to label “Label”
Unconditional return: terminate current POU and return to caller
Conditional jump: if result is TRUE, terminate current POU and returnto caller
Negated conditional jump: if result is FALSE, terminate current POUand return to caller
Each ladder network is divided into two parts. The left part is reading input variables (contacts),the right part is using the evaluated expression and storing the result into other variables (coils),or executing conditional instructions based on the result of the expression.
The terminating right part of a ladder network can be
An assignment
A conditional jump to a label
A conditional return to the caller
The result of an expression can be stored to a variable:
Store result to variable
Store negated result to variable:
The number of output variables is unlimited. For each variable in an assignment, use at most 64characters. The number of characters that can be displayed on screen depends on the resolution ofyour screen, at most three lines are being used.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
321
AND operation
An AND operation in Ladder Diagram is done by putting multiple contacts in sequence. All con-tacts must evaluate to TRUE to have power flow through the rung:
The logic shown will be TRUE and hence set variable AND_Result to TRUE if and only if theinput contacts have the following values:
Variable Value
Input_1 1
Input_2 0
Input_3 1
OR-Operation
An OR-operation is done in Ladder Diagram by putting contacts in parallel. At least one of theparallel rungs must evaluate to TRUE for the logic to evaluate to TRUE.
The logic shown will be TRUE, and hence output variable OR_Result will be set to TRUE, if anyof the variables has the value shown in the following table:
Variable Value
Input_1 1
Input_2 1
Input_3 0
9 Introduction into IE C1131
322 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Mixed Logic
Complex expressions represented by parallel and sequential expressions in Ladder Diagram willevaluate to TRUE if any one rung has power flow from the left rail to the right rail:
The logic shown will evaluate to TRUE, and hence set variable OR_before_AND_Result toTRUE, if and only if the input variables have the values as shown in the following table:
Variable Value
Input_1 orInput_3 1
Input_2 0
Negated Assignment
An output variable can be assigned the negation of the current result. This will be shown by aslash in the assignment symbol.
Storing Assignment
An output variable can be assigned storing, either set or reset.
SetIf the current result is TRUE, the output variable will be set. If the current result is not TRUE, theoutput variable will not be modified. This operation is shown with the letter “S” in theassignment symbol.
ResetIf the current result is TRUE, the output variable will be reset. If the current result is not TRUE,the output variable will not be modified. This operation is shown with the letter “R” in theassignment symbol.
Jumps
Jumps and Labels are a means of structuring your code within one POU. Jumps can be pro-grammed to be unconditional or conditional, like in any other language of IEC1131.
Unconditional JumpAn unconditional jump will be done regardless of the value of the current result. In Ladder Dia-gram, an unconditional jump is always a network on it’s own.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
323
Conditional JumpA conditional jump (JMPC) is executed if the current result is TRUE; a negated conditional jump(JMPCN) is executed if the current result is FALSE. Otherwise, execution will be continued withthe first instruction after the conditional jump.
Return
A Return will terminate the execution of the current POU and transfer it back to the calling POU,or the operating system of the PLC. A Return, like a jump, can be conditional or unconditional.
Unconditional ReturnAn unconditional return will terminate the execution of the current POU. In Ladder Diagram, anunconditional return is always a network on it’s own.
Conditional ReturnA conditional Return (RETC) will terminate execution of the current POU only if the currentresult is TRUE; a negated conditional return (RETCN) will terminate execution of the currentPOU only if the current result is FALSE. Otherwise, execution will continue with the nextinstruction after the conditional return.
Calling Functions
A network containing a function call will be displayed in language Function Block Diagram,even if edited in the Ladder Diagram editor. Functions are displayed as rectangular boxes, andmore than one function can be used in one network, like in Function Block Diagram.
Calling Function blocks
An invocation of a function block instances is shown as a network of it’s own, identically inLadder Diagram and in Function Block Diagram. Inputs are visualised on the left side of the box,outputs on the right. On the top of the box is the name of the instance (outside the box) and thename of the function block type (inside the box).
It is not required by IEC1131, and neither by OpenPCS, that any or all inputs and/or outputs of afunction block be connected to symbols. Any input of a function block instance can be given avalue by using it as an operand of an assignment, close or not to the function block invocation.
�With OpenPCS, only unconditional calls (CAL) tofunction block instances are possible in graphicallanguages Ladder Diagram and Function BlockDiagram, but no conditional calls (CALC,CALCN). Use a conditional Jump (JMPC,JMPCN) over an unconditional call if you need aconditional call to be representable in Ladder Dia-gram and Function Block Diagram.
9 Introduction into IE C1131
324 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9.4.4 Programming in Function Block DiagramProgramming Language Function Block Diagram displays most language elements as rectangularboxes. Multiple operations and function calls can be used in one single network, but functionblock calls are each displayed as networks of their own.
The following elements are used in language Function Block Diagram:
Operation with two input variables, used for logical, arithmetical andcomparison operations. With logical operations, inputs can be negated(visualised by a small circle).
Assignment of current result to a variable
Assignment of negated current result to a variable
Set variable to TRUE if current result is TRUE
Reset variable to FALSE if current result is TRUE
Unconditional jump to label “Label”
Conditional jump to label “Label” if current result is TRUE
Conditional jump to label “Label” if current result is FALSE
Unconditional return to caller
Conditional return to caller if current result is TRUE
Conditional return to caller if current result is FALSE
Function Call (manufacturer defined or user defined)
Function block invocation
Variable names are limited to a maximum of 64. At most three lines of variable names are dis-played, the exact number of characters depending on your font selection, screen resolution, etc.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
325
Logical operations
Logical operationsAND, OR and XOR are displayed as a box with two or more inputs and oneoutput. Individual inputs can be negated, in which case the input will be negated first, then thelogical expression be evaluated. Negation is visualised by a small circle beneath the input. Like inlanguage Ladder Diagram, the result of an expression can be used for an output operation termi-nating an Function Block Diagram network:
Assignment
Conditional jump
Conditional return
AND operationThe AND-operation will do a logical AND on it’s inputs. If used on bitstrings (BYTE, WORD,etc.), the operation is done bitwise.
In the example shown, “AND_Result” will be TRUE if Input_1 is TRUE and Input_2 is FALSE
OR operationThe OR-operation will do a logical OR on it’s inputs. If used on bitstrings (BYTE, WORD, etc.),the operation is done bitwise.
In the example shown, variable OR_Result will be set to TRUE, if either (or both) of Input_1 andInput_2 is TRUE.
Exclusive OR operationThe XOR-operation will do a logical XOR on it’s inputs. If used on bitstrings (BYTE, WORD,etc.), the operation is done bitwise.
Mixed operations
A network may contain any sequence of logical operations. A logical operation that shouldinclude more than two inputs can be programmed in two different ways:
a) by “extending” the number of inputs of one operation
b) by adding another box of the same operation at one of the inputs
Negating intermediate valuesTo negate the intermediate result of a computation, insert a NOT function call.
9 Introduction into IE C1131
326 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Assignment
The current result, or the negated current result, can be assigned to any variable:
Symbol for assignment:
Symbol for negated assignment:
A negated assignment of bitstrings will do the negation bitwise. The negation will not modify thecurrent result. Only datatypesANY_BIT can be assigned using the negated assignment.
Storing Assignment
The current result can be assigned storing
SetIf the current result is TRUE, the output variable will be set to TRUE. If the current result isFALSE, the output variable will be left unchanged. The Set-Assignment is visualised by a boxwith letter “S”.
ResetIf the current result is TRUE, the output variable will be set to FALSE. If the current result isFALSE, the output variable will be left unchanged. The Reset-Assignment is visualised by a boxwith letter “R”.
Arithmetic Operations
Operations Addition, Subtraction, Multiplication and Division are available to be used with nu-meric datatypes.
Comparison OperationsThe comparison operations will compare the value of the first operand (the upper one) with thevalue of the second operand (the lower one). The current result will be set to reflect the result ofthis comparison. The comparison operations are visualised by a box with the name of thecomparison written in it:
GT greater than
GE greater or equal
EQ equal
NE not equal
LE less or equal
LT less than
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
327
Example: Comparison for greater-than:
The conditional jump to label “mark_1” will be executed, if the value of “number_1” is greaterthan the value of “number_2”.
Jumps
Jumps are a means to structure the code of your application within one POU. Jumps can be pro-grammed to be conditional or unconditional:
Unconditional jumpAn unconditional jump will transfer execution to the label given as an argument, regardless ofthe value of current result. An unconditional jump is shown as a network of it’s own.
Conditional JumpA conditional jump will, depending on the value of the current result, transfer execution to thelabel given as an operand. The jump will be made if the current result is TRUE for a normalconditional jump (JMPC), and it will be made if the current result is FALSE for a negatedconditional jump (JMPCN).
Return
A RETURN will terminate the execution of the current POU and transfer it back to the callingPOU, or the operating system of the PLC. A Return, like a jump, can be conditional or uncondi-tional.
Unconditional ReturnAn unconditional return will terminate the execution of the current POU. An unconditionalreturn is shown as a network of it’s own.
Conditional ReturnA conditional Return (RETC) will terminate execution of the current POU only if the currentresult is TRUE; a negated conditional return (RETCN) will terminate execution of the currentPOU only if the current result is FALSE. Otherwise, execution will continue with the nextinstruction after the conditional return.
Calling Functions
Functions are displayed as rectangular boxes, and more than one function can be used in one net-work.
Calling Function blocks
An invocation of a function block instances is shown as a network of it’s own, identically inLadder Diagram and in Function Block Diagram. Inputs are visualised on the left side of the box,
9 Introduction into IE C1131
328 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
outputs on the right. On the top of the box is the name of the instance (outside the box) and thename of the function block type (inside the box).
It is not required by IEC1131, and neither by OpenPCS, that any or all inputs and/or outputs of afunction block be connected to symbols. Any input of a function block instance can be given avalue by using it as an operand of an assignment, close or not to the function block invocation.
�With OpenPCS, only unconditional calls (CAL) tofunction block instances are possible in graphicallanguages Ladder Diagram and Function BlockDiagram, but no conditional calls (CALC,CALCN). Use a conditional Jump (JMPC,JMPCN) over an unconditional call if you need aconditional call to be representable in Ladder Dia-gram and Function Block Diagram.
9.5 Functions (IEC1131)OpenPCS comes with a variety of standard functions and standard function blocks according toIEC1131. The following table provides an overview:
Function Purpose*_TO_** Type ConversionTRUNC Integer part of real numberABS Absolute valueSQRT Square root of a real numberLN Natural Logarithm of a real numberLOG Logarithm of a real number to the base 10EXP Exponential function of a real number to the base
eSIN Sinus of a real numberCOS Cosinus of a real numberTAN Tangens of a real numberASIN Arcus sinus of a real numberACOS Arcus cosinus of a real numberATAN Arcus tangens of a real numberADD AdditionMUL MultiplicationSUB SubtractionDIV DivisionMOD ModuloSHL Shift leftSHR Shift rightROL Rotate leftROR Rotate rightAND, & Logical ANDOR Logical ORXOR Logical exclusive ORNOT Bitwise negationNEG NegationGT Compare for greater-thanGE Compare for greater or equalEQ Compare for equalLE Compare for less-or-equalLT Compare for less-thanNE Compare for not-equalLEN Length of character stringLEFT First part of character string
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
329
RIGHT Last part of character stringCONCAT Conclusion of character stringsFIND Position of a part of a character string
For some functions, operators exist to be used in language instruction list.
The following description of all standard functions shows the prototype of each function ingraphical format, with datatypes and symbolic names of inputs and outputs as appropriate.
Example „Prototype“The following textual prototype definition for standard function SHR...
FUNCTION SHR : ANY_BITVAR_INPUT
IN : ANY_BIT;N : UINT;
END_VAREND_FUNCTION
...corresponds to this graphical prototype:
SHR
ANY_BIT —— IN —— ANY_BIT
UINT —— N
Overloaded FunctionsSome functions, like SHR shown above, can be applied not only to one datatype of operands, butto a variety of datatypes. For function “SHR”, this is shown by giving the generic datatypeANY_BIT as the datatype for input argument “IN”.
�Only manufacturer defined functions may be over-loaded, this is not possible for userdefined func-tions.
Seefig. 241: Hierarchy of datatypeson page 292 for a list of generic datatypes and theirmeaning.
The syntax for calling a function is language specific, see the respective sections in this manual.
Type conversion functions
*_TO_**
* —— —— **
*_TO_** Function name
* Datatype of input
** Datatype of output
9 Introduction into IE C1131
330 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
IEC1131, and so OpenPCS, is very strict with datatypes. Unlike in traditional PLC programminglanguages, the input values of an operation must have exactly the required datatypes, else thecompiler will throw an error message and not compile the program. Therefore, type conversionfunctions are provided to implement all reasonable conversions between the individual datatypes.
All type conversion functions have only one input, and this always will be the current result.
�Type conversion function will in general, for per-formance reasons, not implement any rangechecking. So if converting to a datatype with arestricted range, be aware of this.
The following type conversion functions are available with OpenPCS:
BOOL_TO_BYTEBOOL_TO_DINTBOOL_TO_DWORDBOOL_TO_INTBOOL_TO_REALBOOL_TO_SINTBOOL_TO_STRINGBOOL_TO_UDINTBOOL_TO_UINTBOOL_TO_USINTBOOL_TO_WORDBYTE_TO_BOOLBYTE_TO_DINTBYTE_TO_DWORDBYTE_TO_INTBYTE_TO_REALBYTE_TO_SINTBYTE_TO_STRINGBYTE_TO_UDINTBYTE_TO_UINTBYTE_TO_USINTBYTE_TO_WORDDINT_TO_BOOLDINT_TO_BYTEDINT_TO_DWORDDINT_TO_INTDINT_TO_REALDINT_TO_SINTDINT_TO_STRINGDINT_TO_TIMEDINT_TO_UDINTDINT_TO_UINTDINT_TO_USINTDINT_TO_WORDDWORD_TO_BOOLDWORD_TO_BYTEDWORD_TO_DINTDWORD_TO_INTDWORD_TO_REALDWORD_TO_SINTDWORD_TO_STRINGDWORD_TO_UDINTDWORD_TO_UINTDWORD_TO_USINTDWORD_TO_WORDINT_TO_BOOLINT_TO_BYTEINT_TO_DINTINT_TO_DWORDINT_TO_REALINT_TO_SINTINT_TO_STRINGINT_TO_UDINTINT_TO_UINTINT_TO_USINTINT_TO_WORD
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
331
REAL_TO_BOOLREAL_TO_BYTEREAL_TO_DINTREAL_TO_DWORDREAL_TO_INTREAL_TO_SINTREAL_TO_STRINGREAL_TO_UDINTREAL_TO_UINTREAL_TO_USINTREAL_TO_WORDSINT_TO_BOOLSINT_TO_BYTESINT_TO_DINTSINT_TO_DWORDSINT_TO_INTSINT_TO_REALSINT_TO_STRINGSINT_TO_UDINTSINT_TO_UINTSINT_TO_USINTSINT_TO_WORDSTRING_TO_BOOLSTRING_TO_BYTESTRING_TO_DINTSTRING_TO_DWORDSTRING_TO_INTSTRING_TO_REALSTRING_TO_SINTSTRING_TO_UDINTSTRING_TO_UINTSTRING_TO_USINTSTRING_TO_WORDTIME_TO_DINTTIME_TO_UINTTIME_TO_USINTUDINT_TO_BOOLUDINT_TO_BYTEUDINT_TO_DINTUDINT_TO_DWORDUDINT_TO_INTUDINT_TO_REALUDINT_TO_SINTUDINT_TO_STRINGUDINT_TO_UINTUDINT_TO_USINTUDINT_TO_WORDUINT_TO_BOOLUINT_TO_BYTEUINT_TO_DINTUINT_TO_DWORDUINT_TO_INTUINT_TO_REALUINT_TO_SINTUINT_TO_STRINGUINT_TO_UDINTUINT_TO_USINTUINT_TO_WORDUSINT_TO_BOOLUSINT_TO_BYTEUSINT_TO_DINTUSINT_TO_DWORDUSINT_TO_INTUSINT_TO_REALUSINT_TO_SINTUSINT_TO_STRINGUSINT_TO_UDINTUSINT_TO_UINTUSINT_TO_WORDWORD_TO_BOOLWORD_TO_BYTEWORD_TO_DINTWORD_TO_DWORDWORD_TO_INT
9 Introduction into IE C1131
332 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
WORD_TO_REALWORD_TO_SINTWORD_TO_STRINGWORD_TO_UDINTWORD_TO_UINT
WORD_TO_USINT
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
333
ABSAbsolute Value
ABS
ANY_NUM —— —— ANY_NUM
DescriptionABS will compute the absolute value of the input.
9 Introduction into IE C1131
334 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
335
ACOSArcus cosinus
ACOS
REAL —— —— REAL
DescriptionACOS will compute the arcus cosinus of the input
9 Introduction into IE C1131
336 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
ADDAddition
ADD
ANY_NUM —— IN1 —— ANY_NUM
ANY_NUM —— IN2
.
.
.
ANY_NUM —— INn
InputsIN1 First input, provided by current resultIN2 more values to add
.
.INn
DescriptionAll inputs applied will be summed. All inputs have to be of the same datatype. The output willhave the same datatype as all inputs.
Example „Addition of num eric values“PROGRAM add3VARA : INT := 7;B : INT := 2;Sum : INT;
END_VARLD 3ADD AADD BST Sum (* Sum: 12 *)
END_PROGRAM
Example „Functioncall ADD”In instruction list, ADD is an instruction and not a function, so it cannot be extended. The firstADD sequence will compile, the latter one will cause a compiler error:
LD Var1ADD Var2 (* ok *)ADD Var3 (* ok *)ST ResultLD Var1ADD Var2, Var3 (* error *)ST Result
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
337
9 Introduction into IE C1131
338 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
ASINArcus sinus
ASIN
REAL —— —— REAL
DescribtionASIN will compute the arcus sinus of the input
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
339
9 Introduction into IE C1131
340 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
ATANArcus tangens
ATAN
REAL —— —— REAL
DescribtionATAN will compute the arcus tangens of the input
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
341
9 Introduction into IE C1131
342 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
CONCATConclusion of character strings
CONCAT
STRING —— IN1 —— STRING
STRING —— IN2
.
.
.
STRING —— INm
InputsIN1 First string, provided by current resultIN2 Further strings to append
.
.INn
DescribtionCONCAT will append IN2,...,INn to IN1 and deliver the conclusion to the current result.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
343
9 Introduction into IE C1131
344 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
COSCosinus
COS
REAL —— —— REAL
DescribtionCOS will compute the cosinus of the input
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
345
DIVDivision of numeric values
DIV
ANY_NUM —— IN1
ANY_NUM —— IN2 —— ANY_NUM
InputsIN1 Dividend, provided by current resultIN2 DivisorAll inputs have to have the same datatype, and the output will have the same datatype as allinputs.
DescriptionThe first input will be divided by the second input.
Example „Division“PROGRAM divideVARA : INT := 15;B : INT := 3;Quotient : INT;
END_VARLD ADIV BST Quotient (* Quotient: 5 *)
END_PROGRAM
9 Introduction into IE C1131
346 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
347
EXPExponential function to the base e
EXP
REAL —— —— REAL
DescribtionEXP will compute the exponential function of the input to the base e.
9 Introduction into IE C1131
348 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
FINDPosition of a part of a character string
FIND
STRING —— IN1
STRING —— IN2 —— INT
InputsIN1 Character string, provided by current resultIN2 Part of the character string
DescribtionFIND will return the position of the substring IN2 within the string IN1. If IN2 isn’t part of IN1FIND will return ‘0’.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
349
LEFTFirst part of character string
LEFT
STRING —— IN
ANY_INT —— L —— STRING
InputsIN Character string, provided by current resultL Length of the part
DescribtionLEFT will deliver the first L characters of IN to current result.
9 Introduction into IE C1131
350 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
LENdetermine length of character string
LEN
STRING —— —— INT
DescriptionLEN computes the length of a character string
Example „Get length of string“PROGRAM how_longVARText : STRING := ’hello world’;Textlen : INT;
END_VARLD TextLENST Textlen (* Textlen: 11 *)
END_PROGRAM
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
351
9 Introduction into IE C1131
352 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
LNNatural Logarithm
LN
REAL —— —— REAL
DescribtionLN will compute the logarithm of the input to the base e.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
353
9 Introduction into IE C1131
354 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
LOG
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
355
Logarithm to the base 10
LOG
REAL —— —— REAL
DescribtionLOG will compute the logarithm of the input to the base 10.
9 Introduction into IE C1131
356 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
357
MAXMaximum
MAX
ANY —— IN1 —— ANY
ANY —— IN2
.
.
.
ANY —— INm
InputsIN1 First input, provided by current resultIN2 Further inputs
.
.INnAll inputs have to have the same datatype, and the output will have the same datatype as allinputs.
DescribtionMAX will deliver the greatest input-value to current result.
9 Introduction into IE C1131
358 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
359
MINMinimum
MIN
ANY —— IN1 —— ANY
ANY —— IN2
.
.
.
ANY —— INm
InputsIN1 First input, provided by current resultIN2 Further inputs
.
.INnAll inputs have to have the same datatype, and the output will have the same datatype as allinputs.
DescribtionMIN will deliver the smallest input-value to current result.
9 Introduction into IE C1131
360 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
MOD
Modulo
MOD
ANY_INT —— IN1
ANY_INT —— IN2 —— ANY_INT
InputsIN1 Dividend, provided by current resultIN2 DivisorAll inputs have to have the same datatype, and the output will have the same datatype as allinputs.
DescriptionThe first input will be divided by the second input. MOD delivers the residue to current result.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
361
MULMultiplication of numeric values
MUL
ANY_NUM —— IN1 —— ANY_NUM
ANY_NUM —— IN2
.
.
.
ANY_NUM —— INn
InputsIN1 First input, provided by current resultIN2 more values to be multiplied
.
.INnAll inputs have to have the same datatype, and the output will have the same datatype as allinputs.
Description1)The first input will be multiplied by the second, then by the third input etc.
Example „Multiplication“PROGRAM mul3VARA : SINT := 5;B : SINT := 2;C : SINT := 3;Product_3 : SINT;
END_VARLD AMUL BMUL CST Product_3 (* Product_3: 30 *)
END_PROGRAM
Example „Function Call MUL in Function Block Diagram“In the graphical languages Ladder Diagram and Function Block Diagram, function MUL isextensible, i.e. additional inputs can be created at will. To multiply with more than one value at atime, insert a MUL and extend it.
Example „Function Call MUL in IL“In instruction list, MUL is an instruction and not a function, so it cannot be extended. The firstMUL sequence will compile, the latter one will cause a compiler error:
LD Var1MUL Var2 (* ok * )MUL Var3 ( * ok *)ST ResultLD Var1MUL Var2, Var3 (* error *)ST Result
9 Introduction into IE C1131
362 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
NEG
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
363
Negation
NEG
ANY_NUM —— —— ANY_NUM
DescriptionNEG changes the sign of the input. The input must be a signed variable of the type INT, SINT,DINT or REAL.
9 Introduction into IE C1131
364 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
NOTBitwise Negation
NOT
ANY_BIT —— —— ANY_BIT
DescriptionThe input is negated. If the input is a bitstring, this negation is done bitwise.
Example „Function NOT“LD BitpatternNOT
Example „Binary Complement“PROGRAM negationVARBitfolge : BYTE := 2#00110101;Negations_Result : BYTE;
END_VARLD BitfolgeNOTST Negations_Result (* Negations_Result 2#11001010 *)
END_PROGRAM
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
365
RIGHTLast part of character string
RIGHT
STRING —— IN
ANY_INT —— L —— STRING
InputsIN Character string, provided by current resultL Length of the part
DescribtionRIGHT will deliver the last L characters of IN to current result.
9 Introduction into IE C1131
366 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
ROLRotate left
ROL
ANY_BIT —— IN —— ANY_BIT
UINT —— N
InputsIN the bitstring to be rotated, should be of datatype „BYTE“, „WORD“ or „DWORD“.N number of digits to rotate
DescriptionThe first input (the current result) will be rotated left as many digits as given by the second input.The output will be of the same datatype as the input. Bits shifted out to the left (most significant)will be shifted in into the rightmost (least significant) bit.
Example „Rotate pattern left“PROGRAM rot_leVARBitPattern: BYTE := 2#01110001;Numb : UINT := 3;NewPattern: BYTE;
END_VARLD BitPatternROL NumbST NewPattern (*NewPattern:
2#10001011 *)END_PROGRAM
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
367
RORRotate right
ROR
ANY_BIT —— IN —— ANY_BIT
UINT —— N
InputsIN the bitstring to be rotated, should be of datatype „BYTE“, „WORD“ or „DWORD“.N number of digits to rotate
DescriptionThe first input (the current result) will be rotated right as many digits as given by the secondinput. The output will be of the same datatype as the input. Bits shifted out to the right (leastsignificant) bit will be shifted in into the left (most significant) bit.
Example „Rotate pattern right“PROGRAM rot_reVARBitPattern: BYTE := 2#01110001;Numb : UINT := 3;NewPattern: BYTE;
END_VARLD BitPatternROR NumbST NewPattern (*NewPattern:
2#01011100 *)END_PROGRAM
9 Introduction into IE C1131
368 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
SHLShift left
SHL
ANY_BIT —— IN —— ANY_BIT
UINT —— N
InputsIN The bitstring ( „BYTE“, „WORD“ or „DWORD“) to be shifted.N number of digits to shift
DescriptionThe first input will be shifted to the left as many digits as given by the second input. Zeros will beused to fill the rightmost (least significant) bit. The datatype of the output is the same as that ofthe first input.
Example „Shift pattern left“PROGRAM shft_lVARBitpattern : BYTE := 2#00111011;Digits : UINT := 3;NewPattern : BYTE;
END_VARLD BitpatternSHL DigitsST NewPattern (* NewPattern
2#11011000 *)END_PROGRAM
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
369
SHRShift Right
SHR
ANY_BIT —— IN —— ANY_BIT
UINT —— N
InputsIN The bitstring ( „BYTE“, „WORD“ or „DWORD“) to be shifted.N number of digits to shift
DescriptionThe first input will be shifted to the right as many digits as given by the second input. Zeros willbe used to fill the leftmost (most significant) bit. The datatype of the output is the same as that ofthe first input.
Example „Shift pattern right“PROGRAM shft_rVARBitpattern : BYTE := 2#00111011;Digits: UINT:= 2;NewPattern : BYTE;
END_VARLD BitpatternSHR DigitsST NewPattern (* NewPattern: 2#00001110 *)
END_PROGRAM
9 Introduction into IE C1131
370 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
371
SINSinus
SIN
REAL —— —— REAL
DescribtionSIN will compute the sinus of the input
9 Introduction into IE C1131
372 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
373
SQRTSquare root
SQRT
REAL —— —— REAL
DescribtionSQRT will compute the square root of the input
9 Introduction into IE C1131
374 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
SUBSubtract numeric values
SUB
ANY_NUM —— IN1
ANY_NUM —— IN2 —— ANY_NUM
InputsIN1 Minuend, the value to subtract fromIN2 Subtrahend, the value to subtract
DescriptionThe second input will be subtracted from the first. All inputs have to be of the same datatype, andthe output will be of the same datatype as all inputs are.
Example „Subtract numeric values“PROGRAM aminusbVARA : INT:= 123;B : INT:= 12;Difference : INT;
END_VARLD ASUB BST Difference (* Difference: 111 *)
END_PROGRAM
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
375
9 Introduction into IE C1131
376 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
TANTangens
TAN
REAL —— —— REAL
DescribtionTAN will compute the tangens of the input
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
377
TRUNCInteger part of real number
TRUNC
REAL —— —— ANY_INT
DescriptionTRUNC truncates a real number to it’s integer part.
ExamplePROGRAM IntNumVARCommaNum : REAL := 123.5;IntPart : INT;
END_VARLD CommaNumTRUNCST IntPart (* IntPart: 123 *)
END_PROGRAM
9.6 Function blocks (IEC1131)OpenPCS comes with a variety of predefined standard function blocks. Most of these are definedby IEC1131. Function blocks defined by IEC1131 are vendor-independent, and chances areexcellent that you will find these on other controllers that are IEC1131 compliant. The followingtable gives an overview, with more description to follow:
Function block PurposeF_TRIGR_TRIG
Edge-Detection (falling)Edge-Detection (rising)
RSSR
RS-Flip-FlopSR-Flip-Flop
TOFTON
Time Delayed OffTime Delayed On
TP Timed PulseCTDCTUCTUD
Count DownCount UpCount up and/or down
The function blocks will be described giving their interface prototype, as we did for the standardfunctions. A graphical prototype will be shown, with inputs shown on the left side, and outputson the right side of the function block box.
Example „Prototype“The following textual prototype of function block R_TRIG...
FUNCTION_BLOCK R_TRIGVAR_INPUTCLK : BOOL;
END_VARVAR_OUTPUTQ : BOOL;
END_VAREND_FUNCTION_BLOCK
...corresponds to the following graphical prototype:
9 Introduction into IE C1131
378 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
R_TRIG
BOOL —— CLK Q —— BOOL
Other than functions, function blocks cannot be called, onlyinstancesof function blocks can becalled (orinvoked). For more information, see chapter 9.3.1.8 on page 313.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
379
CTDCount Down
CTD
BOOL —— CD Q —— BOOL
BOOL —— LOAD CV —— INT
INT —— PV
InputsCD Count Pulse (rising edge)LOAD Set Initial ValuePV Preset Counter ValueQ Status (Counter ==0)CV Counter Value
DescriptionCTD counts down on each rising edge on input CD. With a 1 on input “LOAD”, the value of“PV” is used to initialise the counter value, which defaults to 0. “CV” delivers the current countervalue, output “Q” is set TRUE if the current counter value reaches 0.
9 Introduction into IE C1131
380 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
CTUCount Up
CTU
BOOL —— CU Q —— BOOL
BOOL —— RESET CV —— INT
INT —— PV
InputsCU Count Pulse (rising edge)RESET ResetPV Preset Counter LimitQ Status: Counter == LimitCV Counter Value
DescriptionCTU counts up on each rising edge of input “CU”. The counter starts off with a value of 0. A “1”on input “Reset” will reset the counter value to 0. Output “CV” delivers the current counter value.Output “Q” is set to 1 once the current counter value has reached the counter limit.
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
381
CTUDCount up and down
CTU
BOOL —— CU QU —— BOOL
BOOL —— CD QD —— BOOL
BOOL —— RESET CV —— INT
BOOL —— LOAD
INT —— PV
InputsCU Count up on rising edgeCD Count down on rising edgeRESET Reset counterLOAD Load preset valuePV Preset counter valueQU Status: Counter Value >= PVQD Status: Counter Value <= 0CV Current Counter Value
DescriptionCTUD counts up and down. The counter is initialised to 0, and counted up on each rising edge ofinput “CU”, and counted down on each rising edge on input “CD”. A Value of 1 on input“LOAD” will set the current counter value to the value of “PV”. A value of 1 on input “RESET”will set the current counter value to 0.
Output “CV” delivers the current counter value. Output “QU” is set to TRUE once the counterhas reached "PV”. “QD” is set to TRUE once the counter has reached 0.
Example „Count Up and DownPROGRAM VisitorsVARPersonCounter : CTUD;Sensor1 AT %I0.2 : BOOL;Sensor 2 AT %I0.3 : BOOL;Reset AT %I0.1 : BOOL;PersonNum AT %QW0.0 : INT;
END_VARCAL PersonCounter(CU := Sensor 1,
CD := Sensor 2,ReSet:= Reset)
LD PersonCounter.CVST PersonNum
END_PROGRAM
9 Introduction into IE C1131
382 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
F_TRIGDetect falling edge
F_TRIG
BOOL —— CLK Q —— BOOL
InputsCLK Signal to detect falling edge fromQ Status: TRUE on a falling edge of CLK
DescriptionF_TRIG monitors it’s input CLK and delivers a TRUE on output Q anytime that a transition from1 to 0 is detected on input CLK.
Example „Edge Detect“PROGRAM EdgesVARSignal1_raising : R_TRIG;Signal1_falling : F_TRIG;Signal1 AT %I0.2 : BOOL;Impuls_0_1 : BOOL;Impuls_1_0 : BOOL;
END_VARCAL Signal1_raising(CLK := Signal1)LD Signal1_raising.QST Impuls_0_1CAL Signal1_falling(CLK := Signal1)LD Signal1_falling.QST Impuls_1_0
END_PROGRAM
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
383
RSFlip-Flop reset dominant
RS
BOOL —— SET
BOOL —— RESET1 Q1 —— BOOL
InputsSET SetRESET1 ResetQ1 Status
DescriptionRS implements a Flip-Flop. Output Q1 delivers the current state of that Flip-Flop. The initialvalue of the Flip-Flop is FALSE. TRUE on input SET will set the Flip-Flop, TRUE on inputRESET1 will reset the Flip-Flop to FALSE. If both SET and RESET1 are TRUE in one call, RSis reset dominant, which means the RESET will override the SET and the Flip-Flop will hence bereset.
Example „Valve Control“
PROGRAM FillVARVent1 : RS;Position AT %I0.0 : BOOL;VesselFull AT %I0.1 : BOOL;Halt AT %I0.2 : BOOL;Vent1_shut : BOOL;Vent1_open_shut AT %Q0.3 : BOOL;
END_VARLD VesselFullOR HaltST Vent1_shutCAL Vent1(SET := Position,
RESET1 := Vent1_shut)LD Vent1.Q1ST Vent1_open_shut
END_PROGRAM
9 Introduction into IE C1131
384 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
SRFlip-Flop set dominant
SR
BOOL —— SET1
BOOL —— RESET Q1 —— BOOL
InputsSET SetRESET1 ResetQ1 Status
DescriptionSR implements a Flip-Flop. Output Q1 delivers the current state of that Flip-Flop. The initialvalue of the Flip-Flop is FALSE. TRUE on input SET will set the Flip-Flop, TRUE on inputRESET1 will reset the Flip-Flop to FALSE. If both SET and RESET1 are TRUE in one call, SRis set dominant, which means the SET will override the RESET and the Flip-Flop will hence beset.
Example „ Alarm Notification“PROGRAM Alarm
VARFault1_indicate : SR;Fault1 AT %I0.0 : BOOL;Verify_Alert AT %I0.1 : BOOL;Display_Alert AT %Q0.6 : BOOL;
END_VAR
CAL Fault1_indicate(SET1 := Fault1,RESET := Verify_Alert)
LD Fault1_indicate.Q1ST Display_Alert
END_PROGRAM
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
385
TOFTimed Off Delay
TOF
BOOL —— IN Q —— BOOL
TIME —— PT ET —— TIME
InputsIN Start ConditionPT Preset TimeQ StatusET Elapsed Time
Description
Time Diagram (TOF)
If Input IN is TRUE, output Q will immediately be set to TRUE as well. With the falling edge ofinput IN, the timer will start and output Q will be kept to TRUE for the time given by input PT.Input PT will be sampled only on the rising edge of input IN, later changes have no effect. OutputET gives the time elapsed since the falling edge of input IN, but it will not go negative.
Example „Delay for 125 milliseconds“PROGRAM time2VARTimer3 : TOF;Start AT %I0.0 : BOOL;Duration : TIME := T#125ms;Output AT %Q0.0 : BOOL;ActTime : TIME;
END_VARCAL Timer3(IN := Start,
PT := Duration)LD Timer3.QST OutputLD Timer3.ETST ActTime
END_PROGRAM
9 Introduction into IE C1131
386 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
TONTimed On Delay
TON
BOOL —— IN Q —— BOOL
TIME —— PT ET —— TIME
InputsIN Start ConditionPT Preset TimeQ StatusET Elapsed Time
Description
Time diagram (TON)
The rising edge of input IN will start the timer. Output Q will go to TRUE after the time given byPT has elapsed after the rising edge of input IN. If IN is FALSE, Q will always be set to FALSE.PT is sampled only on the rising edge of input IN, later changes will have no effect. Output ETdelivers the time elapsed since the rising edge of IN, but will not go higher than PT. If IN isFALSE, ET will be 0.
Example „Off-Delay by 12 milliseconds“PROGRAM time1VARTimer2 : TON;Start AT %I0.0 : BOOL;Duration : TIME := T#12ms;Output AT %Q0.0 : BOOL;ActTime : TIME;
END_VARCAL Timer2(IN := Start,
PT := Duration)LD Timer2.QST OutputLD Timer2.ETST ActTime
END_PROGRAM
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
387
TPTimed Pulse
TP
BOOL —— IN Q —— BOOL
TIME —— PT ET —— TIME
InputsIN Start ConditionPT Preset TimeQ StatusET Elapsed Time
Description
Time Diagram (TP)
The rising edge of input IN will start the timer, but only if it is idle. Output Q will be set to TRUEfor the time given by input PT. A falling edge on IN will not stop the timer nor change the outputQ while the timer is running, neither will another rising edge during this time restart the timer.Input PT is samples only on the rising edge of IN starting the timer, later changes will have noeffect.
Example „125 ms pulse“PROGRAM pulseVARTimer1 : TP;Start AT %I0.0 : BOOL;PulseDuration: TIME := T#125ms;OutputPulse: BOOL;ActTime : TIME;
END_VARCAL Timer1(IN := Start,
PT := PulseDuration)LD Timer1.QST OutputPulseLD Timer1.ETST ActTime
END_PROGRAM
9 Introduction into IE C1131
388 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9.7 Functions (OpenPCS)
GETTIMEGet current system time
GETTIME
TIME —— IN1 —— TIME
InputsIN1 Previous time
DescriptionGETTIME will retrieve the time elapsed since the controller has last been switched on, less thetime value supplied as an input. This can be used to easily measure time spans.
Example „Stop Watch“PROGRAM StopWVAR
begin, result : TIME;END_VARstart:
LD t#0msGETTIMEST begin...
stop:LD beginGETTIMEST result
END_PROGRAM
9 Introduction into IE C1131
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
389
GETTIMECSGet current system time
GETTIME
TIME —— IN1 —— TIME
InputsIN1 Previous time
DescriptionGETTIME will retrieve the time elapsed at the last system control point since the controller haslast been switched on, less the time value supplied as an input. This can be used to easily measuretime spans. Compared to GETTIME, GETTIMECS will return the same value when called multi-ple times within the same cycle.
Example „Stop Watch“PROGRAM StopWVAR
begin, result : TIME;END_VAR...start:
LD t#0msGETTIMECSST begin...
stop:LD beginGETTIMECSST result
END_PROGRAM
9 Introduction into IE C1131
390 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
9.8 Language Extensions
Single-Bit Access
With OpenPCS, each individual bit of BYTE or WORD variable can be accessed by writing thebitnumber, separated by a dot, after the variable name
ExamplePROGRAM Only_1_BitVAR
Bitpattern1 : BYTE := 2#10101010;Bitpattern2 AT %IW0.0 : WORD;
END_VARLD Bitpattern2.15 (* Copy bit 15 *)ST Bitpattern1.0 (* into bit 0 *)..
END_PROGRAM
Passing Output Parameters
IEC1131 defines two ways of passing parameters. OpenPCS provides, as a legal extension toIEC1131, a means to directly pass output parameters. You can pass output parameters within theline of the CAL instruction by using a vertical slash “|” instead of a comma, and giving the actualparameter on the left side of the assignment:
ExampleCAL SR_Instance_1(SET1 := On,
RESET := Off|Result := Q1)
Declaration of derived datatypes
Local type definitions cannot be used for passing parameters to functions or function blocks.Though the names and definitions of the types might be identical, to the compiler these aredistinct types.
With OpenPCS, you can add global type definitions by adding them in file USERTYPE.TYP, tobe located in the root directory of your project. Use the standard windows editor (notepad) to editthis file.
Comments
Comments may be nested, which eases out-commenting of entire program sections which shouldcontain comments on their own.
10 Forms Editor
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
391
10 Forms Editor
10.1 OverviewUse the forms editor to create your own forms to be used with printing in OpenPCS.
fig. 243: Forms Editor
Draw your form using lines to structure the page, insert logos and other graphical entities, usingthe forms editor. Store these forms with file extension “.wmf”.
The forms editor features a tool-bar, allowing you to easily insert date, page numbers, file namesetc. within your forms, and to determine the region to be used for program output.
With OpenPCS, several standard forms are delivered to be used right from the start.
10.2 Design a formTo create a new form, you either take an existing one an modify it to your taste, or you start fromscratch.
Precondition: The forms editor is running and showing a form, either a new one created withFile→→→→Newor an existing one created withFile→→→→Open....
• SelectFile→→→→Page Setup...and choose proper page format and orientation.
• Select the region to be used for program output later by clicking the respective symbols. Youcan modify this region by moving these symbols with the mouse button pressed after youhave selectedInsert→→→→Edit Elements. The name and size of the font used for printing in thisregion is as by the time of the definition of the printing region
• Add other elements. If, e.g. you want to draw a rectangle, click on the rectangle icon andplace it onto the form or selectInsert→→→→Rectangle
• To add fixed text, selectExtras→→→→Font..., choose the proper font and then click the symbol forinsert text or selectInsert→→→→Text
10 Forms Editor
392 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
• To modify the type or name of the font used for program output, choose the “Edit Elements”-mode, double-click into the printing region and select the proper font in the dialog box. Fontsof fixed text will not be modified by that.
• Store the new form usingFile→→→→Save As...
10.3 Using fixed text in a formPrecondition: The forms editor is running, with a form opened.
• SelectExtras→→→→Font... and select the proper font.
• Click the symbol “Insert Text” or selectInsert→→→→Text, then click on the very spot of the form,where you want to insert the fixed text.
• Insert your text. Use Backspace to correct typing mistakes.
�While you enter your text, it will be displayed in astandard font. This does not affect later print-out
• End the text by hitting the Enter key. Your text will now be displayed in the font you selected.
• To move text, click the symbol“edit element”, then click your text and move it with themouse button pressed.
• To edit your text, click the symbol“edit element”, then double-click your text.
10.4 Form previewPrecondition: The forms editor is running with a form opened.
• SelectFile→→→→Print Preview.
For variable elements, like date, filename, only placeholders will be displayed.
10.5 Editing elementsPrecondition: The forms editor is running with a form opened.
• SelectElements→→→→Edit Elementsor click the“arrow” symbol
• Select the element you want to edit or move the element to the desired new position.
�Be careful to store all Bitmaps that you embeddedinto a form in the same directory as the form.
11 FXF Import/Export
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
393
11 FXF Import/Export
FXF is the abbreviation ofFile Exchange Format. The File Exchange Format is a file format toallow for the exchange of code units (functions and function blocks) between IEC1131 program-ming systems from different vendors. Use the FXF Import/Export Utility to transfer code betweenOpenPCS and other programming systems supportingFXF, in both directions.
The File Exchange Format has been defined by PLCopen:
PLCopenP.O. Box 2015NL 5300 CA ZaltbommelThe NetherlandsTel. +31-418-541139http://www.plcopen.org/
OpenPCS supports version 1 of the File Exchange Format for language instruction list. Withcross-compilation, ladder diagram and function block diagram can be imported and exported aswell.
11.1 Export to FXFTo export POUs to FXF, proceed as follows:
• Launch the FXF Import/Export utility (fxf.exe):
fig. 244: FXF main window
11 FXF Import/Export
394 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
• Press Button „Add...“ and locate all POUs you want to export. See the list „Project Files“updated accordingly.
fig. 245: FXF with files added to export
11 FXF Import/Export
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
395
• Fill in the fields provided in the upper half of the screen to describe the archive you are goingto create:
fig. 246: FXF export
11 FXF Import/Export
396 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
• Press Button „Export...“, and enter the filename of your new FXF archive:
fig. 247: FXF specify export archive name
• Successful export will be reported by a message box, close this with „OK“.
fig. 248: FXF reporting success
• Exit the program by clicking the cross in the very right of the title bar, or press „Reset“ tocreate another FXF archive.
�You cannot use the FXF import/export utility pro-vided with OpenPCS to create FXF archives forother programming systems. Instead, use the toolssupplied with the other IEC1131 programmingsystem.
11 FXF Import/Export
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
397
11.2 Import from FXFTo import POUs from an FXF archive, created with OpenPCS or any other IEC1131programming system, proceed as follows:
• Start the FXF Import/Export Utility (fxf.exe), or press button „Reset“ if it is already running
fig. 249: FXF main window
• Press button „Import“. Enter the name of the FXF archive first, then the path of the directorywhere you want the FXF import/export utility to store the extracted POUs.
fig. 250: FXF import archive dialog
11 FXF Import/Export
398 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
• After the successful import, the screen will be updated to show the project information fromthe FXF archive in the upper half, and the list of extracted files in the list “Project Files”.
�The directory that you specify as the target direc-tory to hold the extracted files must exist, and foryour convenience it should be empty.
fig. 251: FXF import successful
The FXF import/export utility does not register the POUs with an OpenPCS project. So, to usethe extracted POUs within an OpenPCS project, proceed as follows:
• Copy the POUs in the directory of the project, where you want to use them
• Start OpenPCS, and use the Browser to open this project
• SelectProject→→→→Add File or the corresponding symbol in the toolbar and choose the file youwant to add to the project. The file appears now in the project tree.
• Double click on the new file to open it in the POU editor
• SelectFile�Syntaxcheck, to create a prototype and ensure correctness
• Repeat this for all POUs you want to use within this project.
12 IEC1131-3 Compliance Stat ement
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
399
12 IEC1131-3 Compliance Statement
The following tables have the same numbering as those in the IEC 1131-3/EN61131-3 standard. Tables showing features not yet supported by this version ofOpenPCS are not listed. Some tables in IEC1131-3 do not contain features, somissing table numbers do not necessarily imply missing features. To understandthis document, you will want to consult IEC1131-3.
OpenPCS 4.1 complies with the requirements of IEC1131-3, for the following language features:
12 IEC1131-3 Compliance Stat ement
400 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
12.1 Common Elements
12.1.1 Table 1: Character set features
No. Description Yes No
1 Required character set x
2 Lower case x
3a
3b
Number sign (#)orPound sign (£)
x
x
4a
4b
Dollar sign ($)orCurrency sign
x
x
5a
5b
Vertical bar (|)orExclamation mark (!) x
x
6a
6b
Subscript delimiters:brackets [ ]orparentheses ( )
x
x
12.1.2 Table 2: Identifier features
No. Description Yes No
1 Upper case and numbers x
2 Upper and lower case, numbers, embedded underlines x
3 Upper and lower case, numbers, leading or embeddedunderlines
x
12.1.3 Table 3: Comment features
No. Description Yes No
1 Comments x
12.1.4 Table 4: Numeric Literals
No. Description Yes No
1 Integer literals x
2 Real literals x
3 Real literals with exponents x
4 Base 2 literals x
5 Base 8 literals x
6 Base 16 literals x
7 Boolean zero and one x
8 Boolean FALSE and TRUE x
12 IEC1131-3 Compliance Stat ement
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
401
12.1.5 Table 5: Character string literal features
No. Description Yes No
1 Empty string (length zero)
String of length one containing the single character A
String of length one containing the “space” character
String of length one containing the “single quote” character
String of length two containing CR und LF
String of length five which would print as “$1.00”
x
x
x
x
x
x
12.1.6 Table 6: Two character combinations in character strings
No. Description Yes No
2 Dollar sign ($$) x
3 Single quote ($´) x
4 Line feed ($L or $l) x
5 New line ($N or $n) x
6 New page ($P or $p) x
7 Carriage return ($R or $r) x
8 Tab ($T or $t) x
12.1.7 Table 7: Duration literal features
No. Description Yes No
1a1b
Duration literals without underlines:
Short prefixLong prefix
xx
2a2b
Duration literal with underlines
Short prefixLong prefix
xx
12 IEC1131-3 Compliance Stat ement
402 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
12.1.8 Table 8: Date and time of day literals
No. Description Yes No
1 Date literals (long prefix: DATE#) x
2 Date literals (short prefix: D#) x
3 Time of day literals (long prefix: TIME_OF_DAY#) x
4 Time of day literals (short prefix: TOD#) x
5 Date and time literals(long prefix: DATE_AND_TIME#)
x
6 Date and time literals (short prefix: DT#) x
12.1.9 Table 10: Elementary data types
No. Keyword Data type Yes No
1 BOOL Boolean x
2 SINT Short integer x
3 INT Integer x
4 DINT Double integer x
5 LINT Long integer x
6 USINT Unsigned short integer x
7 UINT Unsigned integer x
8 UDINT Unsigned double integer x
9 ULINT Unsgined long integer x
10 REAL Real numbers x
11 LREAL Long reals x
12 TIME Duration x
13 DATE Date (only) x
14 TIME_OF_DAYorTOD
Time of day (only) x
15 DATE_AND_TIME or TD
Date and time x
16 STRING Variable-length character string x
17 BYTE Bit string of length 8 x
18 WORD Bit string of length 16 x
19 DWORD Bit string of length 32 x
20 LWORD Bit string of length 64 x
12 IEC1131-3 Compliance Stat ement
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
403
12.1.10 Table 12: Data type declaration feature
No. Description Yes No
1 Direct derivation from elementary types x
2 Enumerated data types x
3 Subrange data types x
4 Array data types x
5 Structured data types x
12.1.11 Table 13: Default initial values
Description Initial value Yes No
BOOL, SINT, INT DINT, LINT, 0 x
USINT, UINT, UDINT, ULINT 0 x
BYTE, WORD, DWORD, LWORD 0 x
REAL, LREAL 0.0 x
TIME T#0s x
DATE D#0001-01-01 x
TIME_OF_DAY TOD#00:00:00 x
DATE_AND_TIME DT#0001-01-01-00:00:00 x
STRING "(the empty string) x
12.1.12 Table 14: Data type initial value declaration features
No. Description Yes No
1 Initialization of directly derived types x
2 Initialization of enumerated data types x
3 Initialization of subrange data types x
4 Initialization of array data types x
5 Initialization of structured data types x
6 Initialization of derived structured data types x
12 IEC1131-3 Compliance Stat ement
404 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
12.1.13 Table 15: Location and size prefix features for directly repre-sented variables
No. Description Yes No
1 I: Input location x
2 Q: Output location x
3 M: Marker location x
4 X: (Single) bit size x
5 None: (Single) bit size x
6 B: Byte (8 bits) size x
7 W: Word (16 bits) size x
8 D: Double word (32 bits) size x
9 L: Long word (64 bits) size x
12.1.14 Table 16: Variable keywords for variable declaration
Keyword Yes No
VAR x
VAR_INPUT x
VAR_OUTPUT x
VAR_IN_OUT x
VAR_EXTERNAL x
VAR_GLOBAL x
VAR_ACCESS x
RETAIN x
CONSTANT x
AT x
12.1.15 Table 17: Variable type assignment features
No. Description Yes No
1 Declaration of directly represented, non-retentive variables x
2 Declaration of directly represented, retentive variables x
3 Declaration of locations of symbolic variables x
4 Array location assignment x
5 Automatic memory allocation of symbolic variables x
6 Array declaration x
7 Retentive array declaration x
8 Declaration of structured variables x
12 IEC1131-3 Compliance Stat ement
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
405
12.1.16 Table 18: Variable initial value assignment features
No. Description Yes No
1 Initialization of directly represented, non-retentive variables x
2 Initialization of directly represented, retentive variables x
3 Location and initial value assignment to symbolic variables x
4 Array location assignment and initialization x
5 Initialization of symbolic variables x
6 Array initialization x
7 Retentive array declaration and initialization x
8 Initialization of structured variables x
9 Initialization of constants x
12.1.17 Table 19: Graphical negation of Boolean signals
No. Description Yes No
1 Negated input x
2 Negated output x
12.1.18 Table 20: Use of EN input and ENO output
No. Description Yes No
1 Use of EN and ENO x
2 Use of EN and ENO x
3 FBD without EN andENO
x
12.1.19 Table 21: Typed and overloaded functions
No. Description Yes No
1 Overloaded functions (non type-dependent) x
2 Typed functions x
12.1.20 Table 22: Type conversion function features
No. Description Yes No
1 *_TO_** x
2 TRUNC x
3 BCD_TO_** x
4 *_TO_BCD x
12 IEC1131-3 Compliance Stat ement
406 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
12.1.21 Table 23: Standard functions of one numeric variable
No. Description Yes No
1 ABS x
2 SQRT x
3 LN x
4 LOG x
5 EXP x
6 SIN x
7 COS x
8 TAN x
9 ASIN x
10 ACOS x
11 ATAN x
12.1.22 Table 24: Arithmetic standard functions
No. Name Symbol Yes No
12 ADD + x
13 MUL * x
14 SUB - x
15 DIV / x
16 MOD x
17 EXPT ** x
18n18s
MOVE:= x
x
12.1.23 Table 25: Standard bit shift functions
No. Name Yes No
1 SHL x
2 SHR x
3 ROR x
4 ROL x
12.1.24 Table 26: Standard bitwise Boolean functions
No. Name Yes No
5 AND x
6 OR x
7 XOR x
8 NOT x
12 IEC1131-3 Compliance Stat ement
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
407
12.1.25 Table 27: Standard selection functions
No. Name Yes No
1 SEL x
2a MAX x
2b MIN x
3 LIMIT x
4 MUX x
12.1.26 Table 28: Standard comparison functions
No. Name Yes No
5 GT x
6 GE x
7 EQ x
8 LE x
9 LT x
10 NE x
12.1.27 Table 29: Standard character string functions
No. Name Yes No
1 LEN x
2 LEFT x
3 RIGHT x
4 MID x
5 CONCAT x
6 INSERT x
7 DELETE x
8 REPLACE x
9 FIND x
12 IEC1131-3 Compliance Stat ement
408 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
12.1.28 Table 30: Functions of time data types
No. Name Operation Yes No
1
2
3
ADD TIME + TIME = TIME
TOD + TIME = TOD
DAT + TIME = DAT
x
x
x
4
5
6
7
8
9
SUB TIME - TIME = TIME
DATE - DATE = TIME
TOD - TIME = TOD
TOD - TOD = TIME
DAT - TIME = DAT
DAT - DAT = TIME
x
x
x
x
x
x
10
11
MUL
DIV
TIME * ANY_NUM = TIME
TIME / ANY_NUM = TIME
x
x
12 CONCAT DATE TOD = DAT x
13
14
Type conversion functions
DATE_AND_TIME_TO_TIME_OF_DAY
DATE_AND_TIME_TO_DATE
x
x
12.1.29 Table 31: Functions of enumerated data types
No. Name Yes No
1 SEL x
2 MUX x
3 EQ x
4 NE x
12 IEC1131-3 Compliance Stat ement
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
409
12.1.30 Table 33: Function block declaration features
No. Description Yes No
1 RETAIN qualifier on internal variables x
2 RETAIN qualifier on output variables x
3 RETAIN qualifier on internal function blocks x
4a Input/output declaration (textual) x
4b Input/output declaration (graphical) x
5a Function block instance name as input (textual) x
5b Function block instance name as input (graphical) x
6a Function block instance name as input/output (textual) x
6b Function block instance name as input/output (graphical) x
7a Function block instance name as external variable (textual) x
7b Function block instance name as external variable(graphical)
x
8a
8b
Textual declaration of
- rising edge inputs
- falling edge inputs
x
x
9a
9b
Graphical declaration of
- rising edge inputs
- falling edge inputs
x
x
12.1.31 Table 34: Standard bistable function blocks
No. Name Yes No
1 SR x
2 RS x
3 SEMA x
12.1.32 Table 35: Standard edge detection function blocks
No. Name Yes No
1 R_TRIG x
2 F_TRIG x
12.1.33 Table 36: Standard counter function blocks
No. Name Yes No
1 CTU x
2 CTD x
3 CTUD x
12 IEC1131-3 Compliance Stat ement
410 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
12.1.34 Table 37: Standard timer function blocks
No. Name Yes No
1 TP (Pulse) x
2a TON (on-delay) x
2b T---0 (on-delay) x
3a TOF (off-delay) x
3b 0---T (off-delay) x
4 RTC (real-time clock) x
12.1.35 Table 39: Program declaration features
No. Description Yes No
1 RETAIN qualifier on internal variable x
2 RETAIN qualifier on output variable x
3 RETAIN qualifier on internal function blocks x
4a Input/output declaration (textual) x
4b Input/output declaration (graphical) x
5a Function block instance name as input (textual) x
5b Function block instance name as input (graphical) x
6a Function block instance name as input/output (textual) x
6b Function block instance name as input/output (graphical) x
7a Function block instance name as external variable(textual) x
7b Function block instance name as external variable(graphical) x
8a8b
Textual declaration of:- rising edge inputs- falling edge inputs
xx
9a9b
Graphical declaration of:- rising edge inputs- falling edge inputs
xx
10 Formal input and output parameters x
11 Declaration of directly represented, non-retentivevariables
x
12 Declaration of directly represented, retentive variables x
13 Declaration of locations of symbolic variables x
14 Array location assignment x
15 Initialization of directly represented, non-retentivevariables
x
16 Initialization of directly represented, retentive variables x
17 Location and initial value assignment to symbolic variables x
18 Array location assignment and initialization x
12 IEC1131-3 Compliance Stat ement
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
411
19 Use of directly represented variables x
20 VAR_GLOBAL .. END_VARDeclaration within a PROGRAM x
21 VAR_ACCESS .. END_VARDeclaration within a PROGRAM x
12.1.36 Table 40: Step features
No. Description Yes No
1 Step graphical
Initial step graphical
x
x
2 Step textual
Initial Step textual
x
x
3a Step flag general form x
3b Step flag - direct connection of boolean variable x
4 Step elapsed time x
12.1.37 Table 41: Transitions and Transition conditions
No. Description Yes No
1 Transition condition using ST language x
2 Transition condition using LD language x
3 Transition condition using FBD language x
4 Use of connector x
4a Transition condition using LD language x
4b Transition condition using FBD language x
5 Textual transition in ST x
6 Textual transition in IL x
7 Transition name x
7a Transition condition using LD language x
7b Transition condition using FBD language x
7c Transition condition using IL language x
7d Transition condition using ST language x
12.1.38 Table 42: Declaration of actions
No. Description Yes No
1 boolean variable as action x
2l graphical declaration in LD language x
2s inclusion of SFC elements in action x
2f graphical declaration in FBD language x
3s textual declaration in ST language x
3i graphical declaration in IL language x
12 IEC1131-3 Compliance Stat ement
412 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
12.1.39 Table 43: Step/action association
No. Description Yes No
1 action block x
2 concatenated action blocks x
3 textual step body x
4 action block "d" field x
12.1.40 Table 44: Action block features
No. Description Yes No
1 qualifier as per 2.6.4.4 x
2 action name x
3 boolean indicator variables x
4 IL language x
5 ST language x
6 LD language x
7 FBD language x
8 action blocks in ladder diagrams x
9 action block in function block diagrams x
12.1.41 Table 45: Action qualifiers
No. Description Yes No
1 none x
2 N (non-stored) x
3 R (overriding reset) x
4 S (set stored) x
5 L (time limited) x
6 D (time delayed) x
7 P (pulse) x
8 SD (stored and time delayed) x
9 DS (delayed and stored) x
10 SL (stored and time limited) x
12.1.42 Table 46: Sequence evolution
No. Description Yes No
1 single sequence x
2a divergence of sequence selection (left-to-right) x
2b divergence of sequence selection (with priorities) x
2c divergence of sequence selection (with mutual exclusion) x
3 convergence of sequence evolution x
4 simultanouse sequences divergence x
5 simultanouse sequences convergence x
12 IEC1131-3 Compliance Stat ement
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
413
5a sequence skip (left-to-right) x
5b sequence skip (with priorities) x
5c sequence skip (with mutual exclusion) x
6a sequence loop (left-to-right) x
6b sequence loop (with priorities) x
6c sequence loop (with mutual exclusion) x
7 directional arrows x
12.2 IL Language Elements
12.2.1 Table 52: Instruction list (IL) operators
No. Operator Modifiers Yes No1 LD N x
2 ST N x
3 SR
xx
4 AND N,( x
5 & N,( x
6 OR N,( x
7 XOR N,( x
8 ADD ( x
9 SUB ( x
10 MUL ( x
11 DIV ( x
12 GT ( x
13 GE ( x
14 EQ ( x
15 NE ( x
16 LE ( x
17 LT ( x
18 JMP C, N x
19 CAL C, N x
20 RET C, N x
21 ) x
12 IEC1131-3 Compliance Stat ement
414 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
12.2.2 Table 53: Function block invocation feature for IL language
No. Description Yes No
1 CAL with input list x
2 CAL with load/store of inputs x
3 Use of input operators x
12.3 ST Language Elements
12.3.1 Table 55: Operators of the ST language
No. Description Yes No
1 Parenthisization x
2 Function evaluation x
3 Exponentiation x
4 Negation x
5 Complement x
6 Multiply x
7 Divide x
8 Modulo x
9 Add x
10 Subtract x
11 Comparision x
12 Equality x
13 Inequality x
14 Boolean AND x
15 Boolean AND x
16 Boolean Exclusive XOR x
17 Boolean OR x
12.3.2 Table 56: ST language statements
No. Description Yes No
1 Assignment x
2 Function block invocation and FB output usage x
3 RETURN x
4 IF x
5 CASE x
6 FOR x
7 WHILE x
12 IEC1131-3 Compliance Stat ement
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
415
No. Description Yes No
8 REPEAT x
9 EXIT x
10 Empty Statement x
12.4 Common graphical Elements
12.4.1 Table 57: Representation of lines and block
No. Description Yes No
1
2
Horizontal lines:
ISO/IEC 646 „minus“ character
graphic or semigraphic x
x
3
4
Vertical lines:
ISO/IEC 646 „vertical line“ character
graphic or semigraphic x
x
5
6
Horizontal/vertical connection:
ISO/IEC 646 „plus“ character
graphic or semigraphic x
x
7
8
Line crossing without connection:
ISO/IEC 646 characters
graphic or semigraphic x
x
9
10
Connected and non-connecte corners:
ISO/IEC 646 characters
graphic or semigraphic x
x
11
12
Blocks with connecting lines
ISO/IEC 646 characters
graphic or semigraphic x
x
13
14
Connectors using ISO/IEC 646 chararcters:
Connector, Continuation of a connected line
graphic or semigraphic x
x
12 IEC1131-3 Compliance Stat ement
416 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
12.4.2 Table 58: Graphic execution control elements
No. Description Yes No
1
2
Unconditional Jump
FBD language
LD language
x
x
3 Conditional Jump (FBD language) x
4 Conditional Jump (LD language) x
5
6
Conditional Return
LD language
FBD language
x
x
7
8
Unconditional Return
from Function
from Function Block
Alternative Representation in LD language
x
x
x
12.5 LD language Elements
12.5.1 Table 59: Power rails
No. Description Yes No
1 Left power rail x
2 Right power rail x
12.5.2 Table 60: Link Elements
No. Description Yes No
1 Horizontal link x
2 vertical link with attached horizontal links x
12.5.3 Table 61: Contacts
No. Description Yes No
1
2
Normally open contact
x
x
3
4
Normally closed contact
x
x
5
6
Positive tranisition-sensing contact
x
x
12 IEC1131-3 Compliance Stat ement
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
417
No. Description Yes No
7
8
Negative transition-sensing contact
x
x
12.5.4 Table 62: Coils
No. Description Yes No
1 Coil x
2 Negated Coil x
3 SET (latch) coil x
4 RESET (unlatch) coil x
5 Retentive (Memory) coil x
6 SET retentive (Memory) coil x
7 RESET retentive (Memory) coil x
8 Positive transition-sensing coil x
9 Negative transition-sensing coil x
12.6 FBD language elements[Note: this chapter is empty because the corresponding chapter in IEC1131-3 does not list anyfeatures to be referenced here].
12.7 Annex D Implementation-dependent parameters
12.7.1 Table D.1: Implementation-dependent parameters
Clause Parameter Values
1.5.1 Error handling procedures see next chapter
2.1.1 National characters used see table 1 above
2.1.2 Maximum length identifiers 256
2.1.5 Maximum comment length >512
2.2.3.1 Range of values of duration +/- 24,85 days
2.3.1 Range of values for variables of typeTIME
Precision of representation of secondsin type
TIME_OF_DAY andDATE_AND_TIME
+/- 24,85 days
-
2.3.3 Maximum- number of array subscripts- array size- number of structure elements- structure size
6< 4KB per POU< 8KB per POU
12 IEC1131-3 Compliance Stat ement
418 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
- number of variables per declaration
2.3.3.1 Maximum number of enumerated values < 64 KB per POU
2.3.3.2 Default maximum length of STRINGvariablesMaximum permissible length of STRINGvariables
32
253 [see note 1]
2.4.1.1 Maximum number of hierarchical levels
Logical or physical mapping
5
2.4.1.2 Maximum number of subscripts
Maximum number of subscript values
Maximum number of levels of structures
-
-
>512
2.4.2 Initialization of system inputs The value of the systeminputs correponds to theirphysical values
2.4.3 Maximum number of variables perdeclaration < 8 KB per POU
2.5 Information to determine execution timesof program organisation units No
2.5.1.1 Method of function representation Textual
2.5.1.3 Maximum number of functionspecifications
limited only by availablememory
2.5.1.5 Maximum number of inputs of extensiblefunctions
IL: 2, LD/FBD: unlimited
2.5.1.5.1 Effects of type conversions on accuracy truncated
2.5.1.5.2 Accuracy of functions of one variable
Implementation of arithmetic functions
Currently not supported
2.5.2 Maximum number of function blocks andinstantiations
ca. 8000
2.5.2.3.3 PVmin, PVmax of counters minimum/maximum valueof respective data type
2.5.3 Program size limitations limited only by availablememory
2.6 Timing and postability effects ofexecution control elements
-
2.6.2 Precision of step elapsed time
Maximum number of steps per SFC
-
2.6.3 Maximum number of transitions per SFCand per step
-
2.6.4 Action control mechanism -
2.6.4.2 Maximum number of action blocks perstep
-
2.6.5 Graphic indication of step stateTransition clearing time
-
12 IEC1131-3 Compliance Stat ement
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
419
Maximum width of diverge/convergeconstructs
2.7.1 Content of RESOURCE libraries -
2.7.2 Maximum number of tasks
Task interval resolution
Pre-emptive or non-pre-emptivescheduling
-
3.3.1 Maximum length of expressionsPartial evaluation ofBoolean expressions
unlimitedno
3.3.2 Maximum length of statements unlimited
3.3.2.3 Maximum number of CASE selections unlimited
4.1.1 Graphic/semigraphic representation
Restrictions on network topology
graphic
4.1.3 Evaluation order of feedback loops -
note 1: OpenPCS is highly configurable, so this parameter may vary depending on yourhardware. If in doubt, consult the documentation of your hardware.
12.8 Appendix E (normative): Error conditions
12.8.1 Table E.1: Error conditions
Clause Error conditions system response
2.3.3.1 Value of a variable exceeds thespecified subrange
Syntax error; overflow canbe scanned during run time
2.4.2 Length of initialisation list doesn’t matchthe number of array entries
Syntax error
2.5.1.5.1 Type conversion errors Syntax error
2.5.1.5.2 Numerical result exceeds range for datatypeDivision by zero
Can be monitored
Can be monitored
2.5.1.5.4 Mixed input data types to a selectionfunction
Selector (K) out of range for MUXfunction
Syntax
-
2.5.1.5.5 Invalid character position specified
Result exceeds maximum string length
-
2.5.1.5.6 Result exceeds range for data type Restriction to maximumvalue (see 2.2.3.1)
2.6.2 Zero or more than one initial step in theSFC network
User program attempts to modify step
-
12 IEC1131-3 Compliance Stat ement
420 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
state or time
2.6.2.5 Simultaneously true, non-prioritizedtransitions in a selection divergence
-
2.6.3 Side effects in evaluation of transitioncondition
-
2.6.4.5 Action control contention error -
2.6.5 “Unsafe“ or „Unreachable“ SFC -
2.7.1 Data type conflict in VAR_ACCESS -
2.7.2 Tasks require too many processorresources
Execution deadline not met
Other task scheduling conflicts
-
3.2.2 Numerical result exceeds range for datatype
Scan via functions
3.3.1 Division by zeroInvalid data type for operation
Syntax errorcan be monitored
3.3.2.1 Return from function without valueassigned
-
3.3.2.4 Iteration fails to terminate -
4.1.1 Same identifier as connector label andelement name
-
4.1.4 Uninitialised feedback variable -
4.1.5 Numerical result exceeds range for datatype
Division by 0
-
13 Index
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
421
13 Index
13.1 Table of figuresfig. 1:Project management (demo-project pre-selected)..................................................................... 17fig. 2:Dialogbox „New Project“ ............................................................................................................ 18fig. 3: Minimum Project Structure....................................................................................................... 19fig. 4: Creating a new POU .................................................................................................................. 20fig. 5: Project structure after insert of a POU ..................................................................................... 21fig. 6: POU-editor with syntax driven declaration editor, and IL-editor............................................ 22fig. 7: Buttons to select declaration types (from function blocks) ....................................................... 23fig. 8: Declaration Edit Fields .............................................................................................................. 23fig. 9: Declaration list ........................................................................................................................... 24fig. 10 The completed sample program................................................................................................25fig. 11:Dialog box „Error Messages“ ................................................................................................... 25fig. 12: Definition of a resource ............................................................................................................ 28fig. 13: Project Tree with a resource.................................................................................................... 29fig. 14: Task Properties ........................................................................................................................ 30fig. 15: Compiler-Messages .................................................................................................................. 31fig. 16: The SmartSIM32...................................................................................................................... 32fig. 17: Test and Commissioning .......................................................................................................... 33Fig 18: Messages of the PLC ................................................................................................................ 33fig. 20: TUI window with watch variables ........................................................................................... 34fig. 21: Set variable.............................................................................................................................. 35fig. 22: „POSITION“ marked .............................................................................................................. 35fig. 23: Online editor ............................................................................................................................ 36fig. 24: Programming Language LD .................................................................................................... 37fig. 25: Programming Language FBD..................................................................................................38fig. 26: Programming Language CFC..................................................................................................39fig. 27: Free Declaration Editor ........................................................................................................... 41fig. 28: The project manager............................................................................................................... 44fig. 29: Dialog box „Create new project“............................................................................................ 46fig. 30: Open project............................................................................................................................. 47fig. 31: Display of entire paths ............................................................................................................ 47fig. 32: Copying a project .................................................................................................................... 48fig. 33: Create backup copy................................................................................................................. 48fig. 34: Selection of the safe copy of a project which must be restored.............................................. 49fig. 35: Selection of the project directory............................................................................................ 49fig. 36: Additional accepting for deleting the project......................................................................... 50fig. 37: Rename project ....................................................................................................................... 50fig. 38: Project tree of the project „Bsp“ ............................................................................................. 51fig. 39: Subdirectory of a project (in this case „Bsp“)......................................................................... 51fig. 40: The branch „Configuration“ consists the resources of the project ......................................... 51fig. 41: The branch „Project files“ ...................................................................................................... 52fig. 42: Create new module................................................................................................................... 52fig. 43: POU-and CFC- Modules in the branch „Project files“.......................................................... 53fig. 44: Creation of a new declaration of global variables .................................................................. 54fig. 45: Declaration of variables in the branch „Project files“ ........................................................... 54fig. 46: Standard-type definition „Usertype.typ“ ............................................................................... 55fig. 47: Create new type definition...................................................................................................... 55fig. 48: Type definitions in the branch „Project files“....................................................................... 55fig. 49: Create new resource................................................................................................................ 56fig. 50: Editing resource ...................................................................................................................... 57fig. 51: Define a network protocol of a resource................................................................................. 58fig. 52: Task properties ....................................................................................................................... 58
13 Index
422 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 53: Selection of the files which will be added ............................................................................... 59fig. 54: Selection of the type definition file.......................................................................................... 60fig. 55: Compiler messages during the compilation of the resource „Bsp_res“ ................................. 61fig. 56: Error messages during compilation........................................................................................ 61fig. 57: Install Library.......................................................................................................................... 68fig. 58: The SmartSIM32..................................................................................................................... 71fig. 59: Test and commissioning .......................................................................................................... 72fig. 61: Variable listing of the task „POSITION“.............................................................................. 74fig. 62: „Test and commissioning“-window with watched variables.................................................. 74fig. 63: Set variable.............................................................................................................................. 75fig. 64: Resource „Bsp_res“ with the task „POSITION“ was compiled and transmitted to
the PLC ................................................................................................................................... 75fig. 65: Online-editor with state display.............................................................................................. 76fig. 66: Information about the used hardware .................................................................................... 76fig. 67: Information about the resource............................................................................................... 77fig. 68: Settings ..................................................................................................................................... 78fig. 69: Directory structure.................................................................................................................. 79fig. 70: Logical structure ..................................................................................................................... 79fig. 71: With variable knots.................................................................................................................. 79fig. 72: Without variable knots............................................................................................................. 79fig. 73: Printer settings ........................................................................................................................ 80fig. 74: POU-Editor with declarations part (at the top), and instruction part (at the bottom) .......... 82fig. 75: Create new POU....................................................................................................................... 83fig. 76: Elements of a declaration......................................................................................................... 88fig. 77: Tool buttons free-mode and syntax-mode ................................................................................ 88fig. 78: Editor options to adjust free/syntax-mode ............................................................................... 88fig. 79: Possible variable sections for the POU-type „Program“......................................................... 89fig. 80: Message after incorrectly edited line....................................................................................... 89fig. 81:Declaration part in syntax-mode: Selection of the data type................................................... 90fig. 82: Context menu in the declaration part ...................................................................................... 90fig. 83: Menu „Insert“ .......................................................................................................................... 90fig. 84: Example: Insert of elementary data types............................................................................... 91fig. 85: Example: Insert of manufacturer-function-block.................................................................... 91fig. 86: Free variable-editor ................................................................................................................. 93fig. 87: Declaration line in the free mode............................................................................................. 93fig. 88: Exception: Address without variable name ............................................................................. 93fig. 89: Example for the variable declaration in the „Free-mode“...................................................... 94fig. 90: Example: Elementary data types............................................................................................ 95fig. 91: Standard-toolbar ...................................................................................................................... 96fig. 92: „Use of the IL-editor“ .............................................................................................................. 96fig. 93: Syntax of an IL-line with operator...........................................................................................96fig. 94: Syntax of a call of a function block instance........................................................................... 97fig. 95: Calls can be spread out over several lines ............................................................................... 97fig. 96: Insert of a variable or function block instance ........................................................................ 98fig. 97: FB-Instance with call-template................................................................................................ 98fig. 98: The toolbox ............................................................................................................................... 99fig. 99: Selection of an operator which is to insert............................................................................... 99fig. 100: Function “Insert” ................................................................................................................. 100fig. 101: Tool-button “Use of the LD-editor” ..................................................................................... 102fig. 102: Accept variable into LD....................................................................................................... 102fig. 103: Button of the tool panel....................................................................................................... 103fig. 104: Toolbox of the operators....................................................................................................... 103fig. 105: Conditioned operation.......................................................................................................... 104fig. 106: LD – branch label................................................................................................................. 104fig. 107: Name element: branch label................................................................................................ 104fig. 108: Select function block instances............................................................................................. 105
13 Index
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
423
fig. 109: LD - Network-Label ............................................................................................................. 106fig. 110: LD-network with branch label ............................................................................................. 106fig. 111: Place for insertion is marked............................................................................................... 107fig. 112: AND-operation inserted....................................................................................................... 107fig. 113: An Input is marked to which a parallel contact should be created..................................... 107fig. 114: Parallel contact inserted....................................................................................................... 108fig. 115: Position of inserting a new termination is marked: Termination is inserted under
„Output_1” ............................................................................................................................ 108fig. 116: List of branch operators....................................................................................................... 108fig. 117: New output above „Output_2“ inserted.............................................................................. 109fig. 118: Connecting ending points are marked................................................................................ 109fig. 119: Vertical connection was inserted......................................................................................... 110fig. 120: Deleting connection is marked............................................................................................. 110fig. 121: Connection is deleted............................................................................................................ 110fig. 122: The element, which is to negate, is marked......................................................................... 110fig. 123: Element was negated............................................................................................................ 111fig. 124: The element, which is to name, is marked........................................................................... 111fig. 125: Name LD - Element.............................................................................................................. 111fig. 126: The jump instruction, which is to define, is marked........................................................... 112fig. 127: Name LD - Element as label................................................................................................. 112fig. 128: Jump operation is defined.................................................................................................... 112fig. 129: Enter LD - network-comment.............................................................................................. 113fig. 130: Network-comment is inserted.............................................................................................. 113fig. 131: Network-Label...................................................................................................................... 115fig. 132: Network-comment................................................................................................................ 115fig. 133: Network-graphic .................................................................................................................. 116fig. 134: LD/FBD-toolbar ................................................................................................................... 117fig. 135: Tool-button “Use of the FBD-editor” ................................................................................... 117fig. 136: FBD –Accept variable.......................................................................................................... 117fig. 137: The toolbox........................................................................................................................... 118fig. 138: Insert operator...................................................................................................................... 118fig. 139: FBD – branch label.............................................................................................................. 119fig. 140. Accept declared function block............................................................................................ 120fig. 141: Function block inserted........................................................................................................ 120fig. 142: Position for insertion is marked........................................................................................... 121fig. 143: FBD – insert function........................................................................................................... 121fig. 144: Function „ispositive“ was inserted....................................................................................... 122fig. 145: FBD – Function inserted incorrectly................................................................................... 122fig. 146: FBD - Network-label............................................................................................................ 123fig. 147: Network was provided with a label...................................................................................... 123fig. 148: Position for insertion is marked........................................................................................... 124fig. 149: List of logical operators........................................................................................................ 125fig. 150: Operand „AND“ was inserted ............................................................................................. 126fig. 151: Circuit symbol to delete is marked...................................................................................... 126fig. 152: Circuit symbols and no longer connected circuit symbols were deleted............................. 127fig. 153: Input, behind which a new input should be inserted, is marked......................................... 128fig. 154: New input was inserted........................................................................................................ 128fig. 155: Input to delete is marked ..................................................................................................... 129fig. 156: Input was deleted.................................................................................................................. 129fig. 157: If the position in front of the output is marked, the new output will be inserted
above the existing one ........................................................................................................... 130fig. 158: New output was inserted above the output „fault indicator“ .............................................. 131fig. 159: If an existing output is marked, the new output will be inserted below the existing
one ......................................................................................................................................... 131fig. 160: A new output was inserted under the output „fault indicator“ .......................................... 132fig. 161: The outputs to delete are marked........................................................................................ 132
13 Index
424 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
fig. 162: The marked outputs was deleted.......................................................................................... 133fig. 163: The input to negate is marked............................................................................................. 134fig. 164: The marked input was negated............................................................................................ 134fig. 165: The output to negate is marked............................................................................................ 135fig. 166: The marked output was negated.......................................................................................... 135fig. 167: Name FBD - element............................................................................................................ 136fig. 168: Insert variable ...................................................................................................................... 137fig. 169: Name FBD - element............................................................................................................ 137fig. 170: The jump instruction, which is to defined, is marked......................................................... 138fig. 171: Name FBD - element as branch destination........................................................................ 138fig. 172: Branch destination was entered........................................................................................... 138fig. 173: FBD - network-comment...................................................................................................... 139fig. 174: Network-comment was inserted........................................................................................... 139fig. 175: Button for switching to ST ................................................................................................... 140fig. 176: Instructions in ST................................................................................................................. 141fig. 177: List of operators ................................................................................................................... 147fig. 178: Dialog box manufacturer function block ............................................................................. 148fig. 179: Dialog box manufacturer function....................................................................................... 149fig. 180: Tool-button for switchover the programming language...................................................... 150fig. 181: POU-part can’t be displayed graphically............................................................................ 150fig. 182: Global user-defined data types............................................................................................ 155fig. 183: Syntax check with error message......................................................................................... 156fig. 184: Cross-reference list............................................................................................................... 157fig. 185:Take the cursor to a definite line.......................................................................................... 157fig. 186: Change POU-Type............................................................................................................... 158fig. 187: Change function type............................................................................................................ 158fig. 188: Dialog field „Print“ .............................................................................................................. 159fig. 189: a washing process as SFC-plan ............................................................................................ 248fig. 190: valid predecessors and successors of SFC-elements............................................................ 249fig. 191 : the layout of the SFC-editor ................................................................................................ 250fig. 192: the SFC-plan of a new created document............................................................................ 250fig. 193 : Marking a single element by aid of the mouse ................................................................... 251fig. 194 : Marking of several elements – region marks ..................................................................... 252fig. 195 : Insert position of a jump ..................................................................................................... 254fig. 196 : Editing of the IL-code of a step........................................................................................... 255fig. 197: SFC jump with no valid target ............................................................................................. 257fig. 198: SFC jump with no unique target.......................................................................................... 258fig. 199: SFC jump into a simultaneous sequence.............................................................................. 258fig. 200: SFC chart with no initial step .............................................................................................. 259fig. 201: SFC dialog "GoTo IL-Line" ................................................................................................ 259fig. 202: SFC Error messages on error in declarations..................................................................... 260fig. 203 : Display of the active steps in the online-modus .................................................................. 260fig. 204: CFC Editor ........................................................................................................................... 264fig. 205 : CFC-Editor toolbar ............................................................................................................. 264fig. 206 : CFC-Editor with no chart opened ...................................................................................... 266fig. 207: empty chart in CFC Editor .................................................................................................. 267fig. 208: CFC Editor with grid shown ................................................................................................ 267fig. 209: CFC-Editor: Insert Function Block dialog .......................................................................... 268fig. 210: block inserted into CFC chart.............................................................................................. 269fig. 211: connected blocks in CFC-Editor.......................................................................................... 269fig. 212: Output and Input connector marked................................................................................... 270fig. 213: Output and Input connector connected............................................................................... 270fig. 214: Ouput and multiple Inputs marked ..................................................................................... 270fig. 215: Output and multiple Inputs connected................................................................................. 271fig. 216: Connection line and Input marked...................................................................................... 271fig. 217: Input added to connection line............................................................................................. 272
13 Index
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
425
fig. 218:Properties margin connector dialog...................................................................................... 273fig. 219: Margin connector named..................................................................................................... 274fig. 220: Margin connector marked................................................................................................... 275fig. 221: Input connected to margin connector.................................................................................. 275fig. 222: Margin connector properties dialog.................................................................................... 276fig. 223: Input connected to margin bar with address....................................................................... 277fig. 224: constant value input.............................................................................................................. 277fig. 225: sample chart window............................................................................................................ 278fig. 226: sample chart window zoomed out........................................................................................ 278fig. 227: CFC chart............................................................................................................................. 279fig. 228: Moving block to empty field................................................................................................. 280fig. 229: block moved to empty field.................................................................................................. 280fig. 230: sample chart with block dragged......................................................................................... 280fig. 231: block dragged to empty field................................................................................................ 281fig. 232: multiple blocks marked........................................................................................................ 281fig. 233: multiple blocks dragged....................................................................................................... 282fig. 234: sample chart......................................................................................................................... 282fig. 235: blocks pasted........................................................................................................................ 283fig. 236: margin bar properties dialog............................................................................................... 284fig. 237: TUI window .......................................................................................................................... 286fig. 238: block interface modified warning message.......................................................................... 287fig. 239: Find-dialog............................................................................................................................ 287fig. 241: Hierarchy of datatypes......................................................................................................... 292fig. 242: definition of an IL sequence................................................................................................. 300fig. 243: Forms Editor ........................................................................................................................ 391fig. 244: FXF main window ................................................................................................................ 393fig. 245: FXF with files added to export............................................................................................. 394fig. 246: FXF export............................................................................................................................ 395fig. 247: FXF specify export archive name........................................................................................ 396fig. 248: FXF reporting success.......................................................................................................... 396fig. 249: FXF main window ................................................................................................................ 397fig. 250: FXF import archive dialog ................................................................................................... 397fig. 251: FXF import successful.......................................................................................................... 398
13 Index
426 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
13.2 Keywords
$
$ 309$$ 395$´ 395$L 395$N 395$P 395$R 395$T 395
%
% 289I 290M 290Q 290
&
& 292, 298&N 292, 298
*
** 400*_TO_** 323*_TO_BCD 399
0
0---T 404
8
80386 15
A
About SFC Editor (Help Menu / SFC) 180ABS 217, 327, 329, 332, 334, 336, 351, 353Absolute Value 327ACTIVATE_STEP 250ADD 218, 292, 330, 402
numeric 301Add Step/Transition Left (Insert Menu /
SFC) 173
Add Step/Transition Right (Insert Menu /SFC) 173
addition 144, 301, 330Address 23Adresse 85Alt+F10 152AND 144, 236, 292, 298, 315, 319AND Contact (Insert Menu / Ladder) 188ANDN 292, 298ANY_BIT 320, 323Anzeigen�
Toolbox 101, 116Apostrophe 309arithmetic operators 301Arrange Icons (Window Menu / SFC) 179ARRAY 287Assigning a Constant 271assignment 138, 296AT 289, 291
%I 266%Q 266
Attribut 85Attribute 23Aufrufe von Funktionsbausteinen 98Available variable types 163
B
B 85BCD_TO_** 399Bearbeiten�
Alles markieren 154Ausschneiden154Ersetzen 154Gehe zu...154Kopieren 154Löschen 154Rückgängig 154Suchen 154
Betragsbildung 329, 332, 334, 336, 351, 353block 262, 263
adding 262Copying 275Copying a Group of 275delete 277drag 274drop 275fields 262invalid 281move 273, 274Placing 262Positioning 262Selecting 262Shifting a Group of 275
blocks
13 Index
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
427
Connecting 263BOOL 308
F_EDGE 286R_EDGE 286
booleanAND 144OR 144XOR 144
bsp 18BY 141
C
CAL 293, 307, 317, 322CALC 293, 317, 322CALCN 293, 317, 322Carriage Return 309Cascade (Window Menu / SFC) 179CASE 140CFC 37, 39, 284, 313CFC-Editor
Overview of 257Change POE-Type (File Menu / Ladder) 182Change Size 164clipboard 276Close (Basic Commands) 165Close (File Menu / Ladder) 181Close (File Menu / SFC) 166Coil 314Coil (Insert Menu / Ladder) 189Coils 200Cold Start 33columns 262Commands "Edit" Menu (Ladder) 184Commands "Edit" Menu (SFC) 168Commands "File" Menu (Ladder) 181Commands "File" Menu (SFC) 166Commands "Help" Menu (SFC) 179Commands "Insert" Menu (Ladder) 187Commands "Insert" Menu (SFC) 172Commands "Online" Menu (Ladder) 190Commands "Online" Menu (SFC) 177Commands "View" Menu (Ladder) 190Commands "View" Menu (SFC) 174Commands "Window" Menu (SFC) 178comment 16, 23, 293
nested 384Comments 197comparison 144, 303Compile 30complement 144Compound Block
add input 283add output 283convert blocks 283insert new 283nesting 282
CONCAT 402Connection
Add another Input 265Connecting Blocks 263
Connection Tool 266delete 277Deleting 277Input to Constant 271Output to Input 264Output to more than one input 264
connection channels 262Connection Properties 63Connection Setup 61Connection Tool 266constant 271
Assigning to an Input Connector 271character constants 309literal 308predefined character constants 309Strings 309
CONSTANT 291, 308Contact 314Contacts 200Content and Index (Help Menu / SFC) 180Continuous Function Chart 37, 284, 313Control Relay (Insert Menu / Ladder) 189Control Relays 201Copy (Edit Menu) 170, 185Create Ladder Diagramm 193Create Ladder Logic 193CTD 210, 373Ctrl + C 255Ctrl + S 255Ctrl + V 255Ctrl + X 255Ctrl + Y 255Ctrl + Z 255CTRL Key 107, 264, 265CTRL+SHIFT 32CTU 211, 309, 374CTUD 212, 375Cursor keys 246Cut (Edit Menu) 170, 185cyclic 142
D
D 308D# 396datatypes 285
derived 286elementary 285generic 323
Datatypes�User defined function blocks... 68
DATE 308, 396, 397DATE# 396DATE_AND_ TIME 396DATE_AND_TIME 308, 397DATE_AND_TIME# 396DATE_AND_TIME_TO_DATE 402DATE_AND_TIME_TO_TIME_OF_DAY
402Datei�
Drucken... 155
13 Index
428 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
POE-Typ wandeln 154, 155Syntaxprüfung 152
Datentyp 85Ddeclaration
Attributes 291DEACTIVATE_ALL_STEPS 250DEACTIVATE_STEP 250Debug�
Add watch variable33Debugging 279declaration part 284declaration sections
overview 290declaration sections 292Declarations 163DEL Key 30, 277DELETE 401Delete (Edit Menu) 171, 186Deleting
Connection 277DEMO 15derived datatypes
array 287enumeration 287structure 288sub-range 286
Description of the Output Window (ViewMenu / SFC) 176
Description of the Status Bar 176Descripton of the Toolbar 175Digital-Ausgang 85Digital-Eingang 85Direct Help 180directly represented variable 289
declaration 289symbolic name 289syntax of %... 290
DIV 221, 292, 339, 402numeric 302
division 144, 302, 339DO 141drag 274Drag-and-Drop 29driver 61drop 275DT 308DT# 396Dual number 308DW 85
E
Edit (Edit Menu / SFC) 172Edit Resource 64Edit�
Copy 247, 255cut 255Edit 250Insert�Replace 255Redo 255Replace 247
Undo 255Einfügen�
Anfangs-KOP-Netzwerk 101, 117Eingang einfügen 125Element benennen... 110, 135Funktionen...�Anwender 119Funktionen...�Hersteller 119Netzwerkabschluß 102, 117Netzwerk-Kommentar...111Netzwerk-Kommentar.... 136Netzwerk-Label 104, 121Operatoren... 105, 122, 127Variable 102, 110, 117, 133, 134
Eingabetaste 110Eingabetaste 102, 109, 117, 133, 134elementary datatypes 285ELSE 140EN 399END_CASE 140END_FOR 141END_REPEAT 142END_TYPE 286, 291END_VAR 291END_WHILE 141ENO 399Enter 102, 109, 117, 133, 134ENTF 104, 120, 123, 126, 129EQ 228, 292, 303, 320, 402equality 144escape sequences 309EXAMPLES
add3 330Addition 330Alarm 378aminusb 368Arrays 287Bit Addressing 384CTUD 375directly represented variables 289divide 339Edge Detection 376Edges 376F_TRIG 376feld 287Fill 377Flip-Flop 377, 378Function Call 310Functionblock Call 312how_long 344IntNum 371LEN 344mul3 355Multiplication 355negation 358Only_1_Bit 384poe1 309poe2 310poe3 312poe4 289PROGRAM 309pulse 381rot_le 360
13 Index
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
429
rot_re 361Rotate 360, 361RS 377shft_l 362shft_r 363Shift 362, 363smpl_pou 284SR 378structures 288struktur 288Subtract 368time1 380time2 379TOF 379TON 380TP 381TRUNC 371typical elements of a POU 284Visitors 375
Exchange Format 387Exclusive OR 300execution sequence 280EXIT 142Exit (File Menu) 168, 183exponentiation 144Exponentiation 408EXPT 400Extern 84
F
F_TRIG 203, 376FALSE 285FALSE 394FBD 37, 313File Exchange Format 387File�
New 245New Resource28New Task 29Save 255Syntaxcheck25, 66, 392
Flip-Flopreset dominant 377set dominant 378
FOR 141Form Feed 309Forms Editor
Editing elements 386Fixed Text 386Overview 385Printing a form 386
Free Declaration Editor 40Function 213, 310
Calling 308Calling in Function Block Diagram 321Calling in Ladder Diagram 317Example 310overloaded 323Overview 322Standard Functions 322
FUNCTION 26, 39, 145, 292Call 144Invocation 144
Function (Insert Menu / Ladder) 188Function Block 202Function Block (Insert Menu / Ladder) 188Function Block Diagram 37, 313
AND 319Assignment 320Calling Functionblocks 321Calling Functions 321Conditional Jump 321JMPC 321JMPCN 321negate intermediate result 319OR 319programming 318R 320RET 321RETC 321RETCN 321Return 321S 320Unconditional jump 321XOR 319
Programming Language 318Function Blocks 202Function of the Output Window 160FUNCTION_BLOCK 26, 39Functionblock 311
Call 143Calling in Function Block Diagram 321Calling in Ladder Diagram 317conditional call 147example 311Instance 312instantiating 292Overview 371parameter passing 312passing output parameters 384Standard Functionblocks 322unconditional call 307
functionblock list 262Functions and Function Blocks 199FXF 387
G
GE 227, 292, 303, 320General Information 157General Information on Ladder Diagram
Editor 192General information on Ladder Logic 192General Information on the Online Editor
239generic datatype 323GETTIME 382GETTIMECS 383Global 83Go To (Edit Menu / Ladder) 187Go To AWL-row (Edit Menu / SFC) 172
13 Index
430 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Grid Show/Hide 261GT 226, 292, 303, 320
H
hard disk drive 15Help 3Hexadecimal number 308Hide Grid 261Hot Start 33
I
IEC1131 266AT %I 266AT %Q 266Declaration 266
IF 139IL 37inequality 144Initial step 241Initial value 23Initialwert 85input operators 408Insert
Compound Block 283INSERT 401Insert Step/Transition (Insert Menu / SFC)
173instance 292, 312, 372instruction
arithmetic operators 301assignment 296comparisons 303conditional jump 305Function call 308functionblock call 307Load 295logical operations 298syntax 293unconditional jump 305
instruction list 37instruction part 284Introduction 162invalid block 281invoked 372ISO/IEC 646 409
J
JMP 293, 305JMPC 293, 317, 322JMPCN 293, 317, 322Jump 242, 314
Conditional 305in Ladder Diagram 316instruction 305unconditional 305
Jump (Insert Menu / SFC) 173
K
Kaltstart 72keywords_ declaration 290Kommentar 85Kontakte 98
L
Label 293, 294Ladder Diagram 196, 313
AND operation 315Calling Functionblocks 317Calling Functions 317JMPC 317JMPCN 317Jump 316negated assignment 316negated assignment symbol 316OR-operation 315reset 316RETC 317RETCN 317Return 317set 316unconditional jump 316
Ladder Editor 158LD 292, 295, 313LDN 292, 295LE 229, 293, 303, 320Leertaste 105, 108, 131, 132LEN 232, 344libraries 65Library �
Add 68Install 67Install 67Uninstall 68
licence 15licence code 15LIMIT 233, 401Line Feed 309Line number 25LINT 396literal constant 308Literals 144Load Instructions 295Location-Mnemonic 290Logical Connections 199logical operations 298Lokal 84LREAL 396LT 230, 293, 303, 320LWORD 396
13 Index
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
431
M
margin bars 259margin connectors 266marginbar 266Marker 290Maximize (Basic Commands) 165member 288Menu 192Merker 85microprocessor 15Microsoft Windows 15MID 401Minimize (Basic Commands) 165Mixed combinations 238Mixed Logic 316MOD 144, 234modulo 144mouse 15move 273, 274Move 164MOVE 235, 400Move Left (Edit Menu / SFC) 171Move Right (Edit Menu / SFC) 171MUL 219, 292, 355, 402
numeric 302multiplication 144, 302, 355MUX 401, 402
N
Name 23NE 231, 292, 303, 320, 402Negate (Edit Menu / Ladder) 185negation 144, 358Network 197Network (Insert Menu / Network) 187Network Settings 64Netzwerkgrafik 112, 113Netzwerkkommentar 113Netzwerkkommentar 112Netzwerkmarke 112, 113New Line 309Next (Basic Commands) 165NOT 144, 358
function 319NT 15
O
Octal number 308OF 140Offline (Online Menu / SFC) 178Online 195, 279Operand 144, 293Operations
assignment 296conditional jump 305Function call 308
unconditional jump 305Operator 293
arithmetic operators 301CAL 307comparisons 303Load 295logical 298
operatorsinput operators 408
Operators 198Operators 144Optionen�
Programmiersprache�ST 137Variableneditor�Freier Modus 86Variableneditor�Freier-Modus 155Variableneditor�Syntax Modus 86
Options (Extra Menu / Ladder) 190Options�
Free Mode 40Programming Language147Syntaxcontrolled Mode40
OR 144, 237, 292, 299, 319Or Contact (Insert Menu / Ladder) 189ORN 292, 299OR-operation 315Others (Insert Menu / Ladder) 189Output 83Output Window 157Output Window (View Menu / SFC) 175overloaded 285Overloaded Functions 323
P
Page Setup (File Menu) 167, 182PASCAL 310Paste / Add Left (Edit Menu) 170Paste / Add right (Edit Menu / SFC) 171Paste / Substitute (Edit Menu) 170, 186Pentium 15PLC�
ColdStart 33Hot Start 33Stop 33Warm Start 33
plcOpen 4PLCopen 387POE
bearbeiten 154position 16Position.poe 29POU
declaration part 284instruction part 284Program Organisation Units 284
POU Editor ILswitch to LD/FBD 147
POU Editor LD/FBDSwitch to IL 147
Presentation 160Print 279
13 Index
432 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
Print (File Menu) 167, 182Print Preview (File Menu / SFC) 168, 183Printer
configuration 279Program 309
Storing 279PROGRAM 16, 26, 40, 292Program Organisation Units 284Programm
Test 279Programming Language
graphical languages 313Ladder Diagram 314switching 147
Project Browser 17Project�
New 18New... 65, 67
Properties (Edit Menu / SFC) 172Property Sheet 271
Q
question marks 281
R
R 292, 297, 320R_TRIG 204RAM 15Redo (Edit Menu) 169, 185reference points 263REPLACE 401Replace (Edit Menu / Ladder) 186Replace Declaration of variables 187Reset 297, 314, 320resource 26, 28Restore 164RET 293, 306RETAIN 291RETC 293RETCN 293return 306, 314RETURN 143rewiring 289robot arm 16ROL 224, 360ROR 225, 361rows 262RS 205, 377RTC 404
S
S 292, 297, 320Save 194Save (File Menu / Ladder) 181Save (File Menu / SFC) 167
Search (Edit Menu) 171, 186Search for Declaration of variables (Edit
Menu / Ladder) 187SEL 401, 402Select All (Edit Menu) 172, 186SEMA 403sequence of execution 280sequences 294serial number 15Set 297, 314, 320SETUP.EXE 15SFC Editor 159SFC-editor 244SHL 222, 309, 362Show Grid 261SHR 223, 363Simultaneous sequences 241Single-Bit Access 384Size-Mnemonic 290Spacebar 107Springer Verlag 3Sprunganweisungen 98Spulen 98SR 206, 378ST 37, 292, 296, 313Standard Functionblocks 322, 371Standard Functions 145, 322
Shift 362type conversion 323
Start (Online Menu / Ladder) 190State Notice (Online Menu / SFC) 177Status Bar (View Menu / SFC) 175status line 259Step 241STN 292, 296STOP 33Stop (Online Menu / Ladder) 191STRING 308STRUCT 288structure 288
member 288Structured Text 37, 313Strukturierter Text 37SUB 220, 292, 368, 402
numeric 301subtraction 144, 301Survey "Help" Menu (Ladder) 191Survey "Window" Menu (Ladder) 191Survey of Menus (Ladder-Editor) 180Survey of menus (SFC Editor) 166syntax check 25Syntax Check 195Syntax Check (File Menu / Ladder) 182
T
T 308T---0 404Tabulator 309task 26, 29TD 396
13 Index
© 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
433
Test and Commissioning 279The commands 1 2... (Window Menu / SFC)
179The standard IEC-61131-3 157Tile (Window Menu / SFC) 179Tile Horizontally (Window Menu / SFC) 179Tile Vertically (Window Menu / SFC) 179TIME 308TIME_OF_DAY 308, 397TIME_OF_DAY 396TIME_OF_DAY# 396TO 141TOD 308, 396TOD# 396TOF 207, 379TON 208, 380toolbar 258Toolbar 193Toolbar (View Menu / SFC) 174Toolbox 101, 116TP 209, 381Training 3Transition 241Transitionsbedingung 405TRUE 285, 394TRUNC 216, 371, 399TUI 279Type 23, 84TYPE 84, 286, 290, 292Type Convention 214Type Conversion Functions 215
U
ULINT 396undef_opd 109underscore 308Undo (Edit Menu) 169, 184UNTIL 142Use Help (Help Menu / SFC) 180Use of Functions 213Using the Online Editor 239
V
VAR 84, 290, 292VAR_ACCESS 398VAR_EXTERNAL 83, 84, 290, 292VAR_GLOBAL 83, 290, 292VAR_IN_OUT 83, 290, 292
VAR_INPUT 83, 290, 292VAR_OUTPUT 83, 290, 292variable 144, 289
AT 291Attributes 291CONSTANT 291directly represented 289global 290IN_OUT 290input 290local 290output 290RETAIN 291status display 33
Variable (Insert Menu / Ladder) 188Variable Editor 157Variablennamen 85Verbindungen 98VGA 15View
Level Up 282View�
Zoom In 255Zoom Out 255
W
W 85Warmstart 33washing machine 243WHILE 141Windows 95 15Windows NT 15
X
X 85XOR 144, 292, 300, 319XORN 292, 300
Z
Zoom FactorZoom In 272Zoom Out 272
Zoom In (View Menu / SFC) 177Zoom Out (View Menu / SFC) 177
13 Index
434 © 1996-2001 infoteam Software GmbH, D-91088 Bubenreuthhttp://www.infoteam.de
For internal use only:Document D:\Produkte\v4.1\User Manuals\OpenPCS 41E1.docVersion 4.1Status DraftDatum 12.3.2001