Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
TABLE OF CONTENTS Chapter 1 Course Information..................................................................................1-i Chapter 1 Course Information.................................................................................1-1 1.1 Name .............................................................................................................1-1 1.2 Duration ........................................................................................................1-1 1.3 Description....................................................................................................1-1 1.4 Objectives......................................................................................................1-2 1.5 Student Profile...............................................................................................1-2 1.6 Prerequisites..................................................................................................1-3 1.7 Exercises .......................................................................................................1-3 1.8 Course schedule ............................................................................................1-4 1.9 Reference Material........................................................................................1-5 1.9.1 Introduction.....................................................................................1-5 1.9.2 Product Manuals .............................................................................1-5 1.9.2.1 Control Builder Manuals ...............................................1-5 1.9.2.2 Control Builder Related Manuals Software................1-5 1.9.2.3 Control Builder Related Manuals Hardware ..............1-6 1.10 Legend.........................................................................................................1-7 1.11 Feedback Information to ABB ....................................................................1-9 1.12 Course Evaluation .....................................................................................1-11
1-i
Course T530
1-ii
Course T530
1.1 Name
Course: T530 Control Builder M Professional, Configuration
1.2 Duration
5 days.
1.3 Description
Control Builder M Professional is a programming tool on MS-Windows 2000 for three different Control Products, AC 800M, AC 800C, SoftControl and AC 250. Control Builder M Professional is implemented according to the standard of IEC 61131-3, which is an international standard for PLC-programming. Control Builder M Professional can be programmed in five languages by using Function Blocks, Control Modules and declaration of variables. A variable consists of a name and a Data Type, and does not have a specific address in the system. Data can be exchanged with other systems using MMS, SattBus and COMLI communication. The course goal is to teach students the conceptions, functions and structure in Control Builder M Professional and how to navigate in the system. Topics included:
3BSE 022 838/D
The integrated system An introduction IEC 61131-3 ABB Extensions and simplifications of IEC 61131-3 Getting Started Variables and data types ST Language IL Language FBD Language LD Language SFC Language Using Functions and Function Blocks Creating Function Blocks
1-1
Hardware Configuration Connecting variables to I/O Tasks in the templates Downloading /Online Using Control Modules Creating Control Modules in the application and in libraries Creating interaction windows associated to function blocks or modules? Code sorting Some Function Blocks and Control Modules in Standard libraries Communication Projects with several applications / controllers Analyze Privilege handling Hidden/Protected code Licensing Backup/Restore Code optimization
1.4 Objectives
The course goal is to teach students the conceptions, functions and structure in Control Builder M Professional and how to navigate in the system. Upon completion of this course the participant will be able to: Configure the systems AC 800M/C and AC250 using Control Builder M Professional.
1-2
Course T530
1.6 Prerequisites
Basic knowledge of Windows NT/2000
1.7 Exercises
In this section you will find information how the exercises are built up during the course in order to get a flow in the learning. The idea is to build up a complete control of a course process model. However, when doing the basic exercises for the languages FBD and ST, it is more suitable to do them without involving the model. When Function Blocks are introduced, one exercise is suitable for the process model. The process model can then be tested in simulate mode. After this, the sequence language SFC is introduced. This means that an exercise will be to make a sequence, involving inlet and outlet valves filling/emptying a tank, that is a part of the model. That sequence will be tested in simulate mode. Later in the course I/O connection is treated, which means that the variables from the previous exercises can be connected to I/O. The same sequence structure is used with the Control Modules later in the course Finally, a backup of the project is made.
1-3
Day 2
Review
Day 3
Sequence function chart Tasks Download Simple hardware config and I/O connection Extended hardware config
Day 4
Review Control modules Code sorting Standard libraries Several applications and controllers Review
Day 5
Several applications and controllers (contd.) Communication Analyze Accessibility Back-up and restore Optimize Evaluation
1-4
Course T530
Order code
3BSE 021 350 R201 3BSE 021 358 R101
Order code
3BSE 021 359 R301 3BSE 021 351 R101 3BSE 021 352 R101 3BUR 002 087 R101
1-5
Order code
3BSE 019 193 R201 3BSE 021 353 R101 3BSE 021 355 R101 3BSE 021 354 R201 3BSE 020 923 R201 3BSE 020 924 R101 3BSE 020 927 R101 3BSE 020 926 R101 3BSE 011 778 R101 3BSE 021 356 R101 3BSE 021 357 R101 3BSE 021 940 R101 3BUR 002 088 R101 3BSE 024 894R101
1-6
Course T530
1.10 Legend
<> > |
Bold Code
Indicates a key name. Indicates a menu selection path. Indicates when you go from one pop-up menu to a sub-pop-up menu. Indicates a pop-up menu name or an option in a pop-up menu. Indicates text that should be entered from the keyboard.
1-7
1-8
Course T530
ABB has the right to use submitted suggestions without obligations, with all ideas becoming property of ABB.
Please send this page to your local ABB Training Center or to: ABB Service AB ABB Automation University Training Center - Malm SE-205 22 MALM SWEDEN Fax: +46 40 55 03 14 Please fill in the data bellow in case we need to contact you (optional). Name: Address: Telephone: e-mail:
1-9
1-10
Course T530
We are interested in your honest opinion and ideas to help us improve our courses so you get the satisfaction you deserve. Please complete this form and add additional comments (particularly in areas where improvement is needed). Include explanations for any negative comments. Thank you.
Satisfactory Very Good Excellent
Poor
Fair
10. Were our staff friendly and courteous? 11. Did the course meet your expectations? 12. How do you rate the course overall? 13. What topics would you like to see added to the course and why?
14.
What topics would you like to see deleted from the course and why?
1-12
Course T530
TABLE OF CONTENTS Chapter 2 The Integrated System An Introduction ............................................2-1 2.1 General Information......................................................................................2-1 2.1.1 Description......................................................................................2-1 2.1.2 Objectives .......................................................................................2-1 2.2 Lesson 1 - The Integrated System.................................................................2-1 2.2.1 Description......................................................................................2-1 2.2.2 Objectives .......................................................................................2-1 Enterprise Automation.............................................................................2-2 OperateIT Human System Interface.......................................................2-2 OperateIT SCADA Portal........................................................................2-3 2.2.6 ControlIT Scalable Controllers .....................................................2-3 InformIT Enterprise Historian................................................................2-4 2.2.8 EngineerIT Covers All Engineering Tasks ...................................2-4 OptimizeIT Process Optimization Suite....................................................2-5 ProduceIT ..................................................................................................2-5 2.2.11 ControlIT Control Builder M Professional .................................2-6 2.2.12 ControlIT Control Builder M Languages....................................2-6 ControlIT for AC 800M with................................................................2-7 ControlIT Control Modules....................................................................2-7 2.2.15 ControlIT Control Builder Versions ...........................................2-7 2.2.16 ControlIT Libraries .....................................................................2-8 2.2.17 ControlIT Additional Libraries ...................................................2-8
2-i
Course T530
2-ii
Course T530
2.1.2 Objectives
On completion of this lesson you will be able to: Describe the integrated system Describe the differences between Control Builder Professional, Standard and Basic
2.2.2 Objectives
On completion of this lesson you will be able to: Describe the integrated system Describe the differences between Control Builder Professional, Standard and Basic
2-1
Asset Optimization
2-2
Course T530
2-3
Data
Information
Knowledge
2-4
Course T530
2.2.10 ProduceIT
ProduceIT is a comprehensive Production Management Suite for the Batch Processing Industries Schedule Optimization Procedure Management Recipe Management Material Management Batch Management Batch Records Enterprise Resource Planning Interface
2-5
2-6
Course T530
Control
Control
2-7
Function
Make/change libraries Make/change/use Control Modules No. of controllers No. of applications No.of applications per controller No. of programs per application No.of tasks per controller Distribute code to several controllers Share code between several programming stations Source code control
a
Builder Basic
No No 1 1 1 3 3 No No Official only
IT
Builder Standard
Yes No 8 8 1 64 16 Yes Yes Official/ Unofficial No No
Builder Professional
Yes Yes 32 256 8 64 16 Yes Yes Official/ Unofficial Yes Yes
No No
a. A function for a safe source code handling when the code is shared between several programming stations.
Binary Control
*
Basic Control
* * *
2-8
Course T530
Libraries/Functions
Binary Control
Basic Control
Function
Batch Functionality with BatchLib User Defined Serial Protocols with SerialLib *
2-9
2-10
Course T530
TABLE OF CONTENTS Chapter 3 Training Equipment Overview ..............................................................3-1 3.1 General Information......................................................................................3-1 3.1.1 Description......................................................................................3-1 3.1.2 Objectives .......................................................................................3-1 Configuration of Training Equipment.................................................................3-2 3.2.1 The Controller AC 800M................................................................3-2 3.2.2 The Control Panel ...........................................................................3-3 3.2.3 Connection Between I/O Panel and AC 800M ...............................3-4 3.3 The OSLO Process Model ............................................................................3-7 Overview of the Model and the Variables ...............................................3-7 3.3.2 Connection Between OSLO Process Hardware Model and AC 800M .........................................................................................3-8 3.3.3 Connection Between Process Model Simulation and AC 800M .......................................................................................3-11 3.4 The OSLO Software-Process Model...........................................................3-12 3.4.1 Operation of the Simulated OSLO Process Model .......................3-12
3-i
Course T530
3-ii
Course T530
3.1.2 Objectives
Upon completion of this chapter, you will be able to:
Describe how the training equipment is configured Describe how the operators panel and the process model can be used Describe the name standard of variables in this course
3-1
I/O Panel
Process Model
3-2
Course T530
1 DO
10
11
12
13
14
DI
ON OFF
AO1
AO2
AO3 1 AI 2 3 4
AO4 5 6 7 8
3-3
Variable name
NxxPOT1 NxxPOT2 NxxPOT3 NxxPOT4 NxxPOT5 NxxPOT6 NxxPOT7 NxxPOT8
Object
Potentiometer 1 Potentiometer 2 Potentiometer 3 Potentiometer 4 Potentiometer 5 Potentiometer 6 Potentiometer 7 Potentiometer 8
Miscellaneous
0-100% = 0-10 V 0-100% = 0-10 V 0-100% = 0-10 V 0-100% = 0-10 V 0-100% = 0-10 V 0-100% = 0-10 V 0-100% = 0-10 V 0-100% = 0-10 V
Variable name
NxxINST1 NxxINST2 NxxINST3 NxxINST4
Object
Instrument 1 Instrument 2 Instrument 3 Instrument 4
Miscellaneous
0-100% = 0-20 mA 0-100% = 0-20 mA 0-100% = 0-20 mA 0-100% = 0-20 mA
Nxx = Node number of the AC800M (xx = the last two numbers in the IP address).
3-4
Course T530
Variable name
NxxSW1 NxxSW2 NxxSW3 NxxSW4 NxxSW5 NxxSW6 NxxSW7 NxxSW8 NxxSW9 NxxSW10 NxxSW11 NxxSW12 NxxSW13 NxxSW14 Switch 1 Switch 2 Switch 3 Switch 4 Switch 5 Switch 6 Switch 7 Switch 8 Switch 9 Switch 10 Switch 11 Switch 12 Switch 13 Switch 14 Spare Spare
Object
Miscellaneous
3-5
Variable name
NxxLAMP1 NxxLAMP2 NxxLAMP3 NxxLAMP4 NxxLAMP5 NxxLAMP6 NxxLAMP7 NxxLAMP8 NxxLAMP9 NxxLAMP10 NxxLAMP11 NxxLAMP12 NxxLAMP13 NxxLAMP14 Lamp 1 Lamp 2 Lamp 3 Lamp 4 Lamp 5 Lamp 6 Lamp 7 Lamp 8 Lamp 9 Lamp 10 Lamp 11 Lamp 12 Lamp 13 Lamp 14 Spare Spare
Object
Miscellaneous
Nxx = Node number of the AC800M (xx = the last two numbers in the IP address).
3-6
Course T530
3.3 The OSLO Process Model 3.3.1 Overview of the Model and the Variables
DO801_2.7 NxxMixerOrd DI801_2.7 NxxMixerInd AI810_2.1 NxxInflow
10 100% 50 100%
COUNTER
DO801_2.8 NxxCounterOrd DO801_2.10 NxxCounterDir DO8012.11 NxxCounterRes
current
10 50 100%
AO810_1.5 NxxV3Ref
10 50
V3
FT
AO810_1.7 NxxMixerRef
M1
10
speedref
50
100%
DO801_2.3 NxxV1Ord
LG
ST NxxMixerPulse
100 MAX 90 80 70 60 50 LEVEL 40
H2
DI801_2.15 NxxOverflow
DI801_2.8
V1
100%
V5
40%
LG
H1
DI801_2.1 NxxLevelMax
AI810_2.3 NxxLevel
COOLER
FT
DI801_2.6 NxxCoolerInd
LT
30 20
10
HEATER
50
10 100C 0 MIN
DI801_2.2 NxxLevelMin
DO801_2.6 NxxCoolerOrd
+24V
LG L1
AI810_2.4 NxxTemp
TT
+24V
10
50
100%
FT
DO801_2.5 HEATER.ORD DI801_2.5 NxxHeaterInd AI810_2.2 NxxOutflow
V4
AO810_1.6 NxxV4Ref
10 50 100%
ALARM BUZZER
DO801_2.2 NxxV6Ord DI801_2.9 NxxV6Open DI801_2.11 NxxV6Closed
V6
V2
DO801_2.4 NxxV2Ord
DO801_2.9 NxxAlarmOrd
AO810_1.8 NxxHornRef
3-7
Variable name
NxxINFLOW NxxOUTFLOW NxxLEVEL NxxTEMP NxxMIXERCURR Tank inflow
Object
Miscellaneous
0-100% = 0-10 V 0-100% = 0-10 V 0-100% = 0-10 V 0-100% = 0-10 V 0-100% = 0-10 V
Tank outflow Tank level Tank temperature Mixer motor current Spare Spare Spare
Variable name
NxxV3REF NxxV4REF NxxMIXERREF NxxHORNREF
Object
Control valve V3 for inflow Control valve V4 for outflow Mixer speed reference Variable volume alarm
Miscellaneous
0-100% = 0-20 mA 0-100% = 0-20 mA 0-100% = 0-20 mA 0-100% = 0-20 mA
Nxx = Node number of the AC800M (xx = the last two numbers in the IP address)
3-8
Course T530
Variable name
NxxLEVELMAX NxxLEVELMIN NxxV1CLOSED NxxV2CLOSED NxxHEATERIND NxxCOOLERIND NxxMIXERIND NxxMIXERPULSE NxxV6OPEN NxxV5OPEN NxxV6CLOSED NxxV5CLOSED NxxV1OPEN NxxV2OPEN NxxOVERFLOW
Object
Tank level limit, max. level Tank level limit, min. level Feedback for on/off valve V1 Feedback for on/off valve V2 Feedback main contactor heater Feedback main contactor cooler Feedback main contactor mixer One pulse per revolution Feedback for on/off valve V6 Feedback for on/off valve V5 Feedback for on/off valve V6 Feedback for on/off valve V5 Feedback for on/off valve V1 Feedback for on/off valve V2 Tank overflow Spare
Miscellaneous
1=MAX 1=MIN 1=CLOSED 1=CLOSED 1=ON 1=ON 1=ON 1=OPEN 1=OPEN 1=CLOSED 1=CLOSED 1=OPEN 1=OPEN
3-9
Variable name
NxxV5ORD NxxV6ORD NxxV1ORD NxxV2ORD NxxHEATERORD NxxCOOLERORD NxxMIXERORD NxxCOUNTERORD NxxALARMORD NxxCOUNTERDIR NxxCOUNTERRES
Object
On/off valve V5, inflow On/off valve V6, outflow On/off valve V1, inflow On/off valve V2, outflow Main contactor heater Main contactor cooler Main contactor mixer motor Pulse to counter display Alarm indication LEDs Counting direction Counter reset Spare Spare Spare Spare Spare
Miscellaneous
1=OPEN 1=OPEN 1=OPEN 1=OPEN 1=ON 1=ON 1=ON 1=ON 0=UP; 1=DOWN 1=RESET
For the mixer motor to run it must have a non-zero speed reference (AO1.7), and the mixer main contactor must be active.
3-10
Course T530
Variable name
NxxINFLOW_SIM NxxOUTFLOW_SIM NxxLEVEL_SIM NxxTEMP_SIM NxxMIXERCURR_SIM
Object
Tank inflow simulation Tank outflow simulation Tank level simulation Tank temperature simulation Mixer motor current simulation
Miscellaneous
0-100% = 0-20 mA 0-100% = 0-20 mA 0-100% = 0-20 mA 0-100% = 0-20 mA 0-100% = 0-20 mA
Variable name
NxxLEVELMAX_SIM NxxLEVELMIN_SIM NxxV1CLOSED_SIM NxxV2CLOSED_SIM NxxHEATERIND_SIM NxxCOOLERIND_SIM NxxMIXERIND_SIM NxxMIXERPULSE_SIM NxxV6OPEN_SIM NxxV5OPEN_SIM NxxV6CLOSED_SIM NxxV5CLOSED_SIM NxxV1OPEN_SIM NxxV2OPEN_SIM NxxOVERFLOW_SIM
Object
Tank level limit, max. level simulation Tank level limit, min. level simulation Feedback for on/off valve V1 simulation Feedback for on/off valve V2 simulation Feedback main contactor heater simulation Feedback main contactor cooler simulation Feedback main contactor mixer simulation One pulse per revolution simulation Feedback for on/off valve V6 simulation Feedback for on/off valve V5 simulation Feedback for on/off valve V6 simulation Feedback for on/off valve V5 simulation Feedback for on/off valve V1 simulation Feedback for on/off valve V2 simulation Tank overflow simulation Spare
Miscellaneous
Nxx = Node number of the AC800M (xx = the last two numbers in the IP address)
3-11
3.4 The OSLO Software-Process Model 3.4.1 Operation of the Simulated OSLO Process Model
The software simulated OSLO model means that the process can be simulated by using a special cable which connects I/O outputs and inputs. The following procedure should be followed if the software OSLO model is to be used. 1. Connect the special cable on the backside of the training system. 2. Connect the controller to the network. 3. Start Control Builder Professional and open the project OSLO_CM_Sim. 4. Change system identity and IP address in the hardware configuration. 5. Make an instance of the Control Module Type CMProgramOSLO (from OsloLib) in the Application. Name the instance CMProgramOSLO_1. 6. Download the project to the controller. 7. Open the interaction window for the Control Module CMProgramOSLO_1. 8. Click beneath the valve symbols and put them in Auto mode to start the the sequence. 9. Start the process by clicking the Start button. 10. By clicking on a valve and activating the check box, an error can be simulated. 11. If a valve error occurs, a red circle is shown, and the analog valve is opened. By clicking on this valve, the position can be changed. Use the minus and plus buttons. 12. By clicking on the tank, an information is window. 13. Press <Ctrl+M>, select a module by clicking on the green border, right click and choose Online editor. The code for this object will be shown. 14. The ResetSFC button is used to reset the sequence to the initial step. The tank temperature and level are not affected.
3-12
Course T530
TABLE OF CONTENTS Chapter 4 The IEC 61131-3 Concept and ABB Extensions ..................................4-1 4.1 General Information......................................................................................4-1 4.1.1 Description......................................................................................4-1 4.1.2 Objectives .......................................................................................4-1 4.1.3 Reference Documentation...............................................................4-1 4.2 Lesson 1 - IEC 61131-3, the Concept and Common Elements.....................4-2 4.2.1 Description......................................................................................4-2 4.2.2 Objectives .......................................................................................4-2 4.2.3 IEC 61131-3 Overview................................................................4-2 4.2.3.1 The IEC 61131-3 Standard............................................4-3 4.2.3.2 The 5 Languages of IEC 61131-3 .................................4-3 4.2.3.3 Instruction List (IL) .......................................................4-4 4.2.3.4 Structured Text (ST)......................................................4-4 4.2.3.5 Ladder Diagram (LD)....................................................4-5 4.2.3.6 Function Block Diagram (FBD)....................................4-5 4.2.3.7 Sequential Function Chart, SFC....................................4-5 4.2.3.8 The IEC 61131-3 Standard............................................4-6 4.2.3.9 IEC 61131-3: Common Elements .................................4-6 4.2.3.10 IEC 61131-3: Common Elements (2)..........................4-6 4.2.3.11 IEC 61131-3 Standard Datatypes ................................4-7 4.3 Lesson 2 IEC 61131-3, the Software Model and Compliance...................4-8 4.3.1 Description......................................................................................4-8 4.3.2 Objectives .......................................................................................4-8 4.3.2.1 IEC 61131-3 Software Model .......................................4-8 4.3.2.2 Control Builder Pro Software Model .........................4-9 4.3.2.3 IEC 61131-3: Common Elements (5)............................4-9 4.3.2.4 IEC 61131-3 Standard Functions ................................4-10 4.3.2.5 IEC 61131-3 Standard Functions Blocks ....................4-10 4.3.2.6 POU = Program Organization Unit .............................4-10 4.3.2.7 The Essence of Compliancy ........................................4-11 4.3.2.8 Compliancy: Portability Level ....................................4-11 4.3.2.9 TC3: PLCopen Compliancy Levels.............................4-11
4-i
Course T530
4.4 Lesson 3 ABB Extensions and Simplifications of IEC 61131-3............. 4-12 4.4.1 Description................................................................................... 4-12 4.4.2 Objectives..................................................................................... 4-12 4.4.3 Configuration ............................................................................... 4-12 4.4.4 Program Organization Units (POU)............................................. 4-12 4.4.4.1 Applications................................................................ 4-12 4.4.4.2 Control Modules ......................................................... 4-12 4.4.5 Task Connections......................................................................... 4-13 4.4.5.1 Task Connections to Function Blocks ........................ 4-13 4.4.5.2 Task Connections to Control Modules ....................... 4-13 4.4.6 Project Constants.......................................................................... 4-13
4-ii
Course T530
4.1.2 Objectives
On completion of this chapter you will be able to: Describe the five programming languages of IEC 61131-3. Describe common elements, function blocks and the software model and compliance of IEC 61131-3. Describe the ABB extensions and simplifications of IEC 61131-3 (Configuration, POU, task connection and project constants).
4-1
Course T530 Chapter 4 The IEC 61131-3 Concept and ABB Extensions
4.2 Lesson 1 - IEC 61131-3, the Concept and Common Elements 4.2.1 Description
These lessons contain the basic concept and Common Elements of the IEC 61131-3 standard.
4.2.2 Objectives
On completion of these lessons you will be able to: Describe the five programming languages of IEC 61131-3. Describe common elements, function blocks of IEC 61131-3.
4-2
Course T530
Programming Languages
Common Elements
A B
AND
-| |--|/|----------------( )
4-3
Course T530 Chapter 4 The IEC 61131-3 Concept and ABB Extensions
4-4
Course T530
| |---|/|--------------( )
A B
AND
chemistry
4-5
Course T530 Chapter 4 The IEC 61131-3 Concept and ABB Extensions
Programming Languages
Common Elements
Symbolic representation via labels Restricted area for I/O mapping Hardware independent of code What is this?
01010101 10101010
4-6
Course T530
4-7
Course T530 Chapter 4 The IEC 61131-3 Concept and ABB Extensions
4.3 Lesson 2 IEC 61131-3, the Software Model and Compliance 4.3.1 Description
These lessons contain details about the Software Model and Compliance of the IEC 61131-3 standard.
4.3.2 Objectives
On completion of these lessons you will be able to: Describe the Software Model of the IEC 61131-3 standard. Describe the Compliance of Control Builder to IEC 61131-3.
4-8
Course T530
Global variables
4-9
Course T530 Chapter 4 The IEC 61131-3 Concept and ABB Extensions
Selection functions (SEL, MIN, MAX, LIMIT, MUX) Comparison functions (GT, GE, EQ, LT, LE, NE) String functions (LEN, LEFT, RIGHT, MID, CONCAT, INSERT, DELETE, REPLACE, FIND)
Replicated as:
Program instance FB instance
Comments
Main program Subroutine with own memory, several in- and outputs possible Subroutine without memory only one output possible
Function
Function
4-10
Course T530
FB
FB
Code Body
4-11
Course T530 Chapter 4 The IEC 61131-3 Concept and ABB Extensions
4.4 Lesson 3 ABB Extensions and Simplifications of IEC 61131-3 4.4.1 Description
This lesson contains the extensions and simplifications of the IEC 61131-3 standard implemented by ABB in the Control Builder.
4.4.2 Objectives
On completion of this lesson you will be able to: Describe the ABB extensions and simplifications of IEC 61131-3 (Configuration, POU, task connection and project constants).
4.4.3 Configuration
The term Configuration is not used in the software model of the Control Builder Professional. The Resource has also been excluded. Instead the Application replaces both Configuration and Resource. The Application is discussed below.
4-12
Course T530
4-13
Course T530 Chapter 4 The IEC 61131-3 Concept and ABB Extensions
4-14
Course T530
TABLE OF CONTENTS Chapter 5 Getting Started ........................................................................................5-1 5.1 General Information......................................................................................5-1 5.1.1 Description......................................................................................5-1 5.1.2 Objectives .......................................................................................5-1 5.1.3 Reference Documentation...............................................................5-1 5.2 Lesson 1 Starting a Project.........................................................................5-2 5.2.1 Description......................................................................................5-2 5.2.2 Objectives .......................................................................................5-2 5.2.3 Installation ......................................................................................5-2 5.2.3.1 Release Notes ................................................................5-2 5.2.3.2 Control Builder Software ..............................................5-2 5.2.3.3 Languages and License..................................................5-2 5.2.4 Start of the Control Builder ............................................................5-3 5.2.4.1 Open a Project ...............................................................5-3 5.2.4.2 Creating a New Project and Selecting the Template .....5-3 5.2.5 Overview the Project Explorer ....................................................5-3 5.2.5.1 The Structure .................................................................5-4 5.2.5.2 Toolbar Buttons.............................................................5-5 5.2.5.3 Project Tree ...................................................................5-6 5.2.5.4 Lower Pane....................................................................5-8 5.3 Exercise 5.1 Project Explorer.....................................................................5-8 5.4 Lesson 2 The POU Editor ..........................................................................5-9 5.4.1 Description......................................................................................5-9 5.4.2 Objectives .......................................................................................5-9 5.4.3 The POU Editor ..............................................................................5-9 5.4.4 Opening the POU Editor...............................................................5-10 5.4.4.1 Toolbar Icons...............................................................5-11 5.4.5 Variable Declaration Pane ............................................................5-11 5.4.5.1 Variables......................................................................5-11 5.4.5.2 Function Blocks...........................................................5-12 5.4.6 Message Pane................................................................................5-12 5.4.6.1 Description ..................................................................5-12 5.4.6.2 Check...........................................................................5-12 5.4.6.3 Find in Editor...............................................................5-12
5-i
Course T530
5.4.7 Code Pane .................................................................................... 5-13 5.4.7.1 Changing the Language .............................................. 5-13 5.4.7.2 Inserting Code Blocks................................................. 5-13 5.4.7.3 Arranging Code Blocks .............................................. 5-13 5.4.7.4 Deleting Code Blocks ................................................. 5-13 5.4.7.5 Selecting Code Blocks................................................ 5-13 5.4.7.6 Renaming Code Blocks .............................................. 5-14 5.5 Checking, Applying and Saving the Program ............................................ 5-14 5.5.1 Error Messages............................................................................. 5-14 5.6 Exercise 5.2 Inserting and Arranging Code Blocks ................................ 5-14 5.7 Lesson 3 Simulation and On-line Help ................................................... 5-15 5.7.1 Description................................................................................... 5-15 5.7.2 Objectives..................................................................................... 5-15 5.7.3 Simulation .................................................................................... 5-15 5.7.3.1 Error Messages ........................................................... 5-15 5.7.4 On-line Help................................................................................. 5-15 5.7.4.1 Help Topics................................................................. 5-15 5.7.4.2 Help About the Project Explorer ................................ 5-16 5.7.4.3 Manuals ...................................................................... 5-16 5.7.4.4 About Control Builder M Professional....................... 5-16 5.8 Exercise 5.3 The Online Help System..................................................... 5-16 5.9 Exercise 5.4 Simulation of a Project ....................................................... 5-16
5-ii
Course T530
5.1.2 Objectives
On completion of this chapter you will be able to: Read the Release Notes. Describe the installation procedure. Describe the project explorer. Create a new project. Use the basics of the POU Editor. Check, apply and save the program. Simulate and test a project. Use On-line Help. Run a tutorial.
5-1
5.2.2 Objectives
On completion of this lesson you will be able to: Read the Release Notes. Describe the installation procedure. Describe how to start a project. Describe the project explorer.
5.2.3 Installation
Place the CD in the CD-ROM drive. Select Install Software > Control Builder Professional. Follow the instructions on the screen.
Acrobat Reader will be automatically installed if it is not already installed on the computer. The Acrobat reader must be installed otherwise is it not possible to read the online help or the online manuals.
Course T530
5-3
5-4
Course T530
Hot-key
Ctrl + N Ctrl + O Ctrl + S
Description
Use this button to create a new project. Use this button to open an existing project. Use this button to save the project to file. Use this button for offline testing of the user programs, with no controller required. It compiles and simulates the project. All tasks are executed locally in the PC.
F5
Use this button to connect to the controller, e.g., if you want to debug the program code in running mode. Use this button to return to offline mode. In offline mode, all program modification functions are enabled. Program updating stops, but the controller program continues to execute.
Ctrl + D
The program code in the application is compiled and downloaded for execution in the controller. The application automatically enters Online mode (see above). If you want to enter offline mode, select the Offline (see above) entry. Use this button to enter the online help.
Help Topics
5-5
5.2.5.3.1 Libraries
The Libraries folder contains all libraries used in a project. By connecting a library to a project, its types become available to the application. The library SystemLib is always available in the Project Explorer. There are a number of additional libraries that can be inserted. The libraries contain type definitions such as Data Types, Functions and Function Block Types and Control Module Types that can be used in the project.
5.2.5.3.2 Applications
In the root of the Applications folder of each project, several Applications can be created (a maximum of 256). In the application you create the Program(s) or Control Modules containing the program code to be compiled and downloaded for execution in the Controller(s). Each application to be used must be connected to a Controller, by adding the Application to the Applications folder of the Controllers folder. An application may contain up to 64 Programs. Each Program must be connected to its own Task. This means that you can split the control software into different parts, depending on required interval times and priorities. For each controller, you can create new Tasks (a maximum of 16). You can create and define own Data Types, Function Blocks and Control Module Types in the Application.
5-6
Course T530
5.2.5.3.3 Controllers
The hardware definition and the I/O connection are done in the Controllers folder. In the root of the Controllers folder of each project, several controllers can be created (a maximum of 32). When you create a new project or insert a new controller, is it suitable to select the controller you intend to use in the project (AC 800C, AC800M or Soft Controller). The access variables are used for communication with other systems or Controllers. Hardware units are added to the tree structure representing physical hardware units. The Applications containing the code, are not executed unless a "work scheduler" - a Task - is connected and serves as an "engine" running the code in the controller. In the root of the Tasks folder of each Controller, several tasks can be created (a maximum of 16). Each Controller have three default Tasks labeled Fast, Normal and Slow with the Interval time set to 50ms, 250ms and 1000ms. Each application to be used must be connected to a controller, by adding the application to the Applications folder of the Controllers folder.
5-7
5-8
Course T530
5.4.2 Objectives
On completion of this lesson you will be able to: Use the basics of the POU Editor. Checking, applying and saving the program.
5-9
5-10
Course T530
Description
Apply changes since the last Apply or Apply and close. Note that the editor is closed at the same time. Also note that the changes are not saved to disk, only to the project. Same as Apply and close except it does not close the editor. Checks the editor contents for errors. The result is displayed in the "Check" tab in the output pane. Double-click on the lines with error messages to jump directly to the place where an error occurred. Toggles the visibility of the message pane
Ctrl + W Ctrl + B
Ctrl+J
5.4.5.1 Variables
The variables in the program are the holders of values. They are declared by giving each a name (also called identifier) and by assigning a data type. A single program may contain many variables and they must be declared when they are used.
5-11
5.4.6.1 Description
In the description tab, you can write notes in plain ASCII text. The notes are common to all code blocks and grids. It does not change depending on which tab is activated. The description is displayed in the lower pane of the tree view control by marking the edited object (for which a description has been written), e.g. a program in the tree view control and after that selecting the Description tab.
5.4.6.2 Check
When you are validating code error messages are displayed in this pane. Double-click an error message to go quickly to the place where the error occurred.
5-12
Course T530
The order of execution is determined by the order of the tabs for Function Blocks and Programs. The execution order for Control Modules is set up by the system for the most effective order as possible. In the figure above the CodeBlock1, CodeBlock2 and CodeBlock3 code blocks are executed in that sequence. The sequence can be changed using Edit > CodeBlock or right clicking on a code block tab.
5-13
5-14
Course T530
5.7.2 Objectives
On completion of this lesson you will be able to: Simulate and test a project. Use On-line Help.
5.7.3 Simulation
It is possible to simulate a project without using any physical hardware. Save the project and use this button or select Tools> Simulate Project from the menu in the Project Explorer to simulate the project.
5-15
5.7.4.3 Manuals
To display a list of the manuals for the actual product, use Acrobat Reader. You can open any manual by clicking it in the overview.
5-16
Course T530
5.1.2 Objectives
After this exercise you will be able to: Navigate in the Project Explorer. Open existing projects.
5-1
Expand the Libraries icon in the project tree. Which Function Block types are defined in the library OsloLib ? . .
Expand: Applications > ApplicationOslo in the Project tree. Which Function Block types are defined in the ApplicationOslo? .
5-2
Course T530
What type of Controller is used and what is the name of it? . How many Tasks are defined in the Controller? . What Application is running in the Controller? .
5-3
2. Expand the Data Types. The following Data Types are defined: TankType
CourseDataType
3BSE 022 843/B
Course T530
5-5
5.2.2 Objectives
After this exercise you will be able to: Open the POU Editor. Arranging Code Blocks. Rename Code Blocks.
Arrange the Code Blocks C, A and B in Program2 of the ApplicationOslo. 1. The new order should be A, B and C instead. . 2. Save the project. . 3. What is the purpose of arranging the Code Blocks? .
5-6
Course T530
Rename the code blocks according to the information in the Description Tab in Program2 and save the project. . .
5-7
3. The execution order is changed when the Code Blocks are reorganized.
Click on the description tab in the Message Pane. Right click on a Code Tab and select Rename Change the names accordingly to the information in the message pain. Save the project by use of the save icon in the Project window
5-8
Course T530
5.3.2 Objectives
After this exercise you will be able to: Find information in the Online Help system.
5.3.4 Missions
Find information in the Online Help about:
Read in the Online help about Icons in the Help. Select Help topics from the Help menu in the Project Explorer. Select Contents tab System Introduction > Online Help > Icons in the Help. .
Read in the Online help about Simulation. Select Index tab, type Simulation in the key word field. Select Simulation Process Objects. .
5-9
5.3.4.3 About Code and Code Block Using the Glossary Function
Read in the Online Help about Code blocks. Contents tab, select Glossary then Choose letter C. Select code and code block. .
5-10
Course T530
5.3.5 Solutions Exercise 5.3 5.3.5.1 Solution: About Icons in the Help
Select Help topics from the Help menu in the Project Explorer. Select Contents tab System Introduction > Onlne Help > Icons in the Help.
5.3.5.3 Solution: About Code and Code Block Using the Glossary Function
Contents tab, select Glossary then Choose letter C. Select code and code block.
5-11
5.4.2 Objectives
After this exercise you will be able to: Simulate a project. Run a tutorial.
Simulate the project OSLO_FB. 1. Open Program2 and look for the variable Start. (You must be in simulation mode). 2. Start the process sequence by changing the value of the variable Start from False to True. 3. Reset the Start variable when the process has started.
5-12
Course T530
Check the sequence. . . . Check the variable Level during the filling. At what level does the Heating begin? . The Heating continue until what temperature? . How long time do the Mixing continue? . At what temperature does the Cooling stop? .
5-13
Heating starts when Level > 80 The Heating continue until Temperature > 30 The Mixing continues for 5 sec The Cooling stops when Temperature < 10 The Drain stops at Level < 20
5-14
Course T530
TABLE OF CONTENTS Chapter 6 Variables and Data Types ......................................................................6-1 6.1 General Information......................................................................................6-1 6.1.1 Description......................................................................................6-1 6.1.2 Objectives .......................................................................................6-1 6.1.3 Reference Documentation...............................................................6-1 6.2 Lesson 1 Declaration of Variables .............................................................6-2 6.2.1 Description......................................................................................6-2 6.2.2 Objectives .......................................................................................6-2 6.2.3 General............................................................................................6-2 6.2.3.1 Why Variables and Data Types? ...................................6-2 6.2.3.2 Simple Data Types ........................................................6-3 6.2.3.3 Key Words.....................................................................6-3 6.2.4 Declaring Variables in POU ...........................................................6-3 6.2.4.1 Name .............................................................................6-3 6.2.4.2 Data Type ......................................................................6-4 6.2.4.3 Attributes.......................................................................6-4 6.2.4.4 Initial Value...................................................................6-4 6.2.4.5 I/O-address ....................................................................6-4 6.2.4.6 Access Variables ...........................................................6-5 6.2.4.7 Description ....................................................................6-5 6.2.5 Data Exchange Between Programs Using Global Variables ..........6-5 6.2.5.1 The ABB Implementation of External Variables ..........6-5 6.2.6 Data Exchange Between Controllers Using Access Variables .......6-5 6.3 Exercise 6.1 Declaration of Variables........................................................6-5 6.4 Lesson 2 Data Types ..................................................................................6-6 6.4.1 Description......................................................................................6-6 6.4.2 Objectives .......................................................................................6-6 6.4.3 Structured Data Types ....................................................................6-6 6.4.4 Defining User Defined Structured Data Types...............................6-7 6.4.4.1 Components...................................................................6-7 6.4.4.2 Dot Notation ..................................................................6-8 6.4.4.3 Project Constants...........................................................6-8 6.5 Exercise 6.2 User Defined Structured Data Types.....................................6-8
6-i
Course T530
6-ii
Course T530
6.1.2 Objectives
On completion of this chapter you will be able to: Describe the scope of local variables, global variables and access variables. Describe the influence of attributes on variables. Declare variables with different attributes and of different data types. Access a component in a variable of a certain structured data type. Declare project constants. Declare user-defined structured data types.
6-1
6.2.2 Objectives
On completion of this lesson you will be able to: Describe the scope of local variables, global variables and access variables. Describe the influence of attributes on variables. Declare variables with different attributes and of different data types.
6.2.3 General
A data type is a description of the structure of a variable or a parameter. The system supports simple data types such as Boolean (bool), integer (int), and real. You can combine these simple data types into new data types called structured data types. A structured data type can contain other structured data types. The library SystemLib contains all of the systems predefined data types (for example, BoolIO, date_and_time etc). In most libraries, additional data types are declared.
6-2
Course T530
Description
Boolean double integer Integer Unsigned integer Character string * Bit string Bit string Duration Date and time of day Real number 1
Bits
32 16 16 16 32 0 0 0 0 0 T#0s
Initial value
False, 0
1979-12-31-00:00:00 32 0.0
*) String length is 40 characters by default, but this can be changed by entering string[xx] as the data type, where xx is the string length. Maximum value is 140.
6.2.4.1 Name
It is best to give the variables simple and explanatory names. It is advisable to begin a variable name with a capital letter, and names consisting of more than one word should have capital letters at the beginning of each new word. Examples of recommended variable names are DoorsOpen or PhotoCell. Certain identifiers (names) are reserved by the system and cannot be used for other purposes. If a reserved word is used an error message is given in the message pane: Invalid
variable identifier, Reserved word or Name xxx not valid.
6-3
6.2.4.3 Attributes
The following attribute can be given to a variable: Name
No attribute
Description
The value of the variable is not maintained after a restart. Instead it is set to the initial value of the variable. If the variable has no initial value assigned to it, it will get the default value of the data type (see table in page 6.3) The value of the variable is maintained after a warm restart. The system sets retain on all variables by default. To override this the attribute must be left empty. The value of the variable is maintained after a warm or cold restart. This attribute overrides the retain attributes in a structured data type. You cannot change the value of the variable once given. This attribute overrides the coldretain and retain attributes in a structured data type. The variable will not be visible to the OPC server, and therefore not available in the HMI system.
retain
coldretain
constant
hidden
Note! Variables declared in a Contol Module can also have the attributes State or Nosort. These are described in detail in chapter 17.
6.2.4.5 I/O-address
It is suitable to make the I/O connection from the I/O module editor. This is described in chapter 15 Basic Hardware Configuration.
6-4 3BSE 022 844/D
Course T530
6.2.4.7 Description
Description describes and/or provides information about the variable. A short descriptive text, for example, would include an explanation of the cause of a condition or a simple event; 'Pump 1 is running'.
6-5
6.4.2 Objectives
On completion of this lesson you will be able to: Declare a structured data type. Access a component in a variable of a particular structured data type. Declare project constants.
You can collect all these characteristics into one signal using a structured data type. Given the specifications above you create a structured data type called Tank_Type, with a main identifier Tank and subordinate identifiers Full (Boolean), Volume (real), Temp (real), MaxTemp (real) and MinTemp (real).
6-6
Course T530
6.4.4.1 Components
The variables in the structured Data Type are called Components.
6.4.4.1.1 Name
It is best to give the components simple and explanatory names.
6.4.4.1.3 Attributes
Press < Ctrl+J > in the Attribute column, to find a suitable attribute to be assigned.
6-7
6.4.4.1.5 Description
In the description fields a short description can be written at declaration of the Data Type component.
If you want to set the Full component of the Tank variable to 1 (i.e. "True"), write:
tank.full := true ;
The rest of the subordinate variables are accessed in a similar way. A structured data type is a data type that contains several components and can thus have several values, one for each component.
6-8
Course T530
6.1.2 Objectives
After this exercise you will be able to: Declare local Variables in a Program. Describe the influence of attributes on variables. Declare variables with different attributes and of different data types.
Create a New project. Select AC 800M as template. Accept the suggested location. Name the project: CourseProject
6-1
Data Type
dint dint dint
Attributes
constant coldretain
Initial value
4
Save the project by using the save icon in the Project Explorer Window.
6-2
Course T530
6-3
6.2.2 Objectives
After this exercise you will be able to: Define user-defined Structured Data Types.
Create a new Data Type named Motor_Type in the Application_1 of your CourseProject Declare the components Start, Stop and Run of the data type bool. This data type will be used later on in a student activity.
6-4
Course T530
Click OK. 2. Double click on the new data type (Motor_Type) and the Data Type Editor is opened. Declare the components of the structured data type and specify their Data Type.
6-5
6-6
Course T530
TABLE OF CONTENTS Chapter 7 Function Block Diagram (FBD) Language ...........................................7-1 7.1 General Information......................................................................................7-1 7.1.1 Description......................................................................................7-1 7.1.2 Objectives .......................................................................................7-1 7.1.3 Reference Documentation...............................................................7-1 7.2 Lesson 1 - FBD Language.............................................................................7-2 7.2.1 Description......................................................................................7-2 7.2.2 Objectives .......................................................................................7-2 7.2.3 General............................................................................................7-2 7.2.3.1 FBD Pane ......................................................................7-3 7.2.3.2 Toolbar buttons..............................................................7-4 7.2.4 Insert Function/Function Block ......................................................7-4 7.2.4.1 The EN input parameter ................................................7-5 7.2.4.2 Functions in FBD ..........................................................7-5 7.2.4.3 Edit Parameter Properties..............................................7-6 7.2.5 Connections ....................................................................................7-7 7.2.5.1 Connection of Variables and Constants ........................7-8 7.2.5.2 Connection to Previous Selection..................................7-9 7.2.5.3 Quick connection from one function block to another ...................................................................7-10 7.2.6 Comments .....................................................................................7-10 7.2.6.1 Edit Comments of Function Blocks and Functions .....7-10 7.2.6.2 Edit Page Comments ...................................................7-10 7.2.7 Structure Pane...............................................................................7-10 7.2.8 Execution Rules ............................................................................7-11 7.3 Exercise 7.1 Use the FBD Language .......................................................7-11 7.4 Lesson 2 The Use of Multiple Pages in FBD Language ..........................7-12 7.4.1 Description....................................................................................7-12 7.4.2 Objectives .....................................................................................7-12 7.4.3 Pages .............................................................................................7-12 7.4.3.1 Page Setup ...................................................................7-12 7.4.3.2 Insert Page Break.........................................................7-13 7.4.3.3 Page References ..........................................................7-13 7.5 Exercise 7.2 Using Multiple Pages in the FBD Language.......................7-13
7-i
Course T530
7-ii
Course T530
7.1.2 Objectives
On completion of this chapter you will be able to: Configure a small program using the FBD language Use pages in the FBD Language.
7-1
7.2.2 Objectives
On completion of this lesson you will be able to: Use the FBD language.
7.2.3 General
Function Block Diagram (FBD) is a high-level graphical programming language. It describes the POUs in terms of processing elements and displays the signal flow between them, similarly to electronic circuit diagrams. It represents the function block and functions by graphical symbols (boxes), their input and output parameters by pins of the boxes and the assignment of parameters by lines between the pins. A comprehensive basic range of function blocks and functions are available. The FBD editor consists of the following major parts:
7-2
Course T530
*) In order to use a function block in a program, an instance of a function block type has to be created. The type declaration is usually made in library, and acts as a general template for all instances based on this type. A CTU (Count up) is an example of a Function block type. Instances of this type, Counter_1, CTU_22, MyUpCounter etc. can then be created in the POU editor.
Inspect the Function Block Diagram of the POU you are programming Select, copy and paste functions and function blocks Create, modify and delete function blocks and functions Edit instance name of function blocks, edit comments Assign values to the parameters of function blocks and functions (connect them by lines) Check pagination and repaginate Check texts of the footer
7-3
Key
Ins
Description
Insert new function or function block Use this command to assign variables and constants to the selected parameter of a function block or function.
Ctrl + D
Use this command to de-assign a variable or constant from the selected parameter of a function block or function. Use this command to invert a Boolean input parameter of a function block or function.
In the dialog window a list of available functions and function block types is presented in the drop-down list. Just type the first letters of the function name to jump to that entry. to get an explorer-like overview of all It is also possible to use the Browse button libraries and Applications and their functions and function blocks.
7-4 3BSE 022 846/C
Course T530
If you want to choose from a list of previously used function block types, use the Local FB Declarations button. If it is a function/function block that supports configurable input parameters (number of parameters and data type for these), these inputs can be specified in the dialog window. The EN checkbox makes the optional Enable parameter available (this is explained in the next section). To go straight to the Connection dialog window, check the box Connect Parameters.
7.2.4.2.1 Assignments
Function
Move, :=
Description
Assigns the value (number, logical or string) of the input parameter to the output parameter.
7-5
Description
Negates the Boolean value (1/0, on/off or True/False).
Description
Exponential, i.e. raising to the power.
Description
7-6
Course T530
The checkbox activates the Enable parameter which is optional. This is shown in the figure.
7.2.4.3.3 Invert
By clicking with the right mouse button select the parameter (pin). Select the Invert command to invert the assignment to this parameter (pin). The parameter can also be inverted in the Connect dialog window. This is shown in the section Connect each parameter separately.
7.2.5 Connections
In the Function Block Diagram editor, parameters of functions and function blocks are shown as pins of the (boxes). The assignment of values (variables and constants) to parameters is indicated by lines connecting to the pins. If a parameter is to be connected to another parameter, one of them must be an output parameter and the other one an input parameter. (An output parameter can be assigned to any number of input parameters but never to another output parameter.)
7-7
Start1,Start2
Note! Literal values cannot be assigned to parameters of data type Time or String. After the variable name has been entered, press OK to close the dialog window or Apply/Next to apply the connection and go the next parameter. The Direction setting together with the value in the Next: drop-down list determine what will happen when the Next button is pressed. In the example in the figure pressing Apply/next will move the selection forward to the next unconnected parameter. If the user enters a name that is not recognized by the system (i.e. not declared in the editors declaration pane) and presses OK or Apply/Next, the system will ask the user if the unknown name should be declared by the system, as shown in the figure.
7-8
Course T530
Fill in the name of the variable in the Actual Parameter field. Use the button get a tree-like overview of the POU and its variables.
to
one input parameter and one output parameter. Select the Connect to Previous Selection command from the context menu to accomplish the connection.
7.2.6 Comments
It is possible to write comments to functions/function blocks and pages.
7-10
Course T530
The structure pane consists of the following sizable and movable columns: Item shows the name of the function block or function with their properties in parentheses Comment shows the comment attached to the function block or function Page Comment shows the comment on the top of the corresponding Function Block Diagram page Page Number is given at the first function block or function of every page of the Function Block Diagram Instance shows the name of function blocks
7-11
7.4 Lesson 2 The Use of Multiple Pages in FBD Language 7.4.1 Description
This lesson describes the use of the FBD language when using more than one page of code.
7.4.2 Objectives
On completion of this lesson you will be able to: Use pages in the FBD Language.
7-12
Course T530
If you want to change the default layout when inserting new FBD code blocks, go to Tools > Setup and select the FBD/LD tab.
7-13
Course T530
7.1.2 Objectives
After this exercise you will be able to: Configure a small program using the FBD language Use pages in the FBD Language.
7-1
Use your CourseProject 1. Open Program2 and change language of the code block to FBD language. Write the mathematical expression below, by using the function Add. Sum = Constant1 + Integer1 2. Save and simulate the project
There is something wrong about the attributes of the variables used in the previous exercise. Can you find out what?
7-2
Course T530
Change the attributes on the variables in exercise 7.1.4.1. 1. The variable Integer1 should retain the value after a Cold Restart. 2. Is it necessary to have the attribute coldretain on the variable Sum to maintain its value after cold restart?
7.1.4.4 Motor_Type
Configure a program with the functionality described below. Insert a new code block with FBD language after the existing code block in Program2 and name it Motor. Declare a variable Motor1 of the structured data type Motor_Type Save and simulate the project
7-3
7.1.5 Solutions Exercise 7.1 7.1.5.1 Solution: Using the FBD Language
1. Open the editor of Program2. 2. Change the language of the code block Code from Structured Text to Function Block Diagram. 3. Right click in the FBD pane and select Insert function/Functionblock. 4. Expand the SystemLib and select an ADD function and click OK 5. Right click on one of the input pins of the ADD box and select Connect. 6. A new window appears. Press Ctrl +J, click on Constant1, press Enter. 7. Press Apply/Next, Press Ctrl +J, click on Integer1, press Enter. 8. Press Apply/Next, Press Ctrl +J, click on Sum, press Enter. 9. Click on the OK button. 10. The FBD pane will now look like this.
and
12. Select (Tools > Simulate Project) in the project explorer menu. 13. Double click on the Program2 icon. 14. Change values on the variable Integer1 by right clicking on it and select Set Value. 15. Stop the simulation by selecting (Tools > Stop Simulate) in the project explorer menu.
7-4
Course T530
2. Insert a new code block and name it Motor with the FBD language. 3. Right click in the FBD pane and select Insert function/Functionblock. 4. Expand the SystemLib and select an OR function and click OK 5. Right click on the inserted OR box and select Insert function/Functionblock. 6. Insert an AND function, answer no to the question about were to place the element. 7. The FBD pane will now look like this:
8. Connect the output pin from the OR box with one of the input pins of the AND box by clicking on the output pin with the left mouse button, press the Ctrl key and click on one of the input pins of the AND box. 9. Right click on the unconnected input pin of the AND box and select Invert. 10. Right click on the unconnected input pin of the AND box and select Connect.
7-5
11. A new window appears. Press Ctrl +J, click on Motor1 then press . ( dot), Click on Stop, then press Enter. Click on the OK button. 12. Connect Motor1.Start to one of the inputs of the OR box. 13. Connect the output of the AND box to the variable Motor1.Run. 14. Connect the output of the AND box to the unconnected input of the OR box: Right click on the output pin the AND box, press Ctrl and click on the unconnected input of the OR box. 15. Click on the output pin of the AND box and press Ctrl and the click on the unconnected input pin of the OR box. 16. The FBD pane will now look like this
17. Check the code with the Check button. 18. Close the window with the Apply and Close button. 19. Select (Tools > Simulate Project) in the project explorer menu. 20. Double click on the Program2 icon. 21. Change values on the variables by right clicking on them and select On/Off. 22. Stop the simulation by selecting (Tools > Stop Simulate) in the project explorer menu.
7-6
Course T530
7.2 Use Pages in the FBD language Exercise 7.2 7.2.1 Description
This exercise describes the use of the FBD language when using more than one page of code.
7.2.2 Objectives
After this exercise you will be able to: Use pages in the FBD Language.
7.2.4 Missions
7-7
7.2.4.1 Copy/Paste
Declare a variable named Motor2 of the data type Motor_Type. Use the copy and paste function on the functions (from exercise 7.1.4.3. Motor_Type) Replace 1 with 2 and remove the Paste Page Breaks Option, when you paste the copied functions. Write comments as shown below. Save and simulate the project
7-8
Course T530
5. Right click on AND, select copy. (The OR and AND must be marked blue). Right click on AND, select Paste. 6. A new window appears. Click on the Options tab and remove the Paste Page Breaks check from the checkbox. Write like below in the Replace Variables tab. Click on Replace and then on OK.
7-9
8. Right click on OR on the first row of the structure pane, select Edit Page Comment 9. Write the comment in the window and click OK. 10. Right click on OR on the first row of the structure pane, select Edit Comment 11. Write the comment in the window and click OK. 12. The structure pane will now look like this.
7-10
Course T530
7-11
7-12
Course T530
TABLE OF CONTENTS Chapter 8 Ladder Diagram (LD) Language...........................................................8-1 8.1 General Information......................................................................................8-1 8.1.1 Description......................................................................................8-1 8.1.2 Objectives .......................................................................................8-1 8.1.3 Reference Documentation...............................................................8-1 8.2 Lesson 1 - LD Language...............................................................................8-2 8.2.1 Description......................................................................................8-2 8.2.2 Objectives .......................................................................................8-2 8.2.3 General............................................................................................8-2 8.2.3.1 LD Pane.........................................................................8-3 8.2.3.2 Toolbar Buttons.............................................................8-4 8.2.4 Insert Rung......................................................................................8-5 8.2.5 Insert Contact..................................................................................8-5 8.2.5.1 Edit Contact Type..........................................................8-5 8.2.5.2 Edit Coil Type ...............................................................8-5 8.2.6 Insert Function/Function Block ......................................................8-5 8.2.6.1 Functions in LD.............................................................8-5 8.2.6.2 Edit Parameter Properties..............................................8-6 8.2.7 Connections ....................................................................................8-7 8.2.7.1 Variables and Constants to Parameter...........................8-7 8.2.7.2 Quick Connection..........................................................8-7 8.2.7.3 Disconnect .....................................................................8-7 8.2.8 Comments .......................................................................................8-8 8.2.8.1 Rung Comments ............................................................8-8 8.2.8.2 Item Comments .............................................................8-8 8.2.8.3 Page Comments.............................................................8-8 8.2.9 Structure Pane.................................................................................8-8 8.2.10 Execution Rules ..........................................................................8-10 8.2.11 Pages ...........................................................................................8-10 8.2.11.1 Page Setup .................................................................8-10 8.2.11.2 Insert Page Break.......................................................8-11 8.2.11.3 Page References ........................................................8-11 8.2.12 Inspect and Navigate...................................................................8-11
8-i
Course T530
8-ii
Course T530
8.1.2 Objectives
On completion of this chapter you will be able to: Describe and identify ladder diagram constructs.
8-1
8.2.2 Objectives
On completion of this lesson you will be able to: Describe and identify ladder diagram constructs.
8.2.3 General
Ladder Diagram (LD) is a graphical language. LD describes the POUs similarly to relay logic. In LD, you can implement complex AND/OR logic based on the idea of power flow from a power rail through relay contacts and coil to the other power rail. You can also add function block and functions to the power rails and LD presents them similarly to Function Block Diagram (FBD). In the following, we call function block and functions in LD simply function blocks and functions. The LD editors usage is especially advantageous in case of small systems and if you are familiar with electrical wiring diagrams and relay control.
8-2
Course T530
8.2.3.1 LD Pane
The LD panes are the right upper and lower sub panes within the code pane if you are working with the LD editor. The LD panes contain: Graphic symbols of rungs (contacts and coils), function blocks and functions (boxes with pins). Instance names of the function blocks. Comments attached to rungs, function blocks and functions, Assignment of parameters in form of connection lines between the pins of the boxes and in form of parameter names and values at the contacts and coils Footer and comment of the page
Use the LD panes to: Inspect the Ladder Diagram of the POU you are programming. Create, delete, select, copy or paste rungs. Edit rung comments Create, modify and delete function blocks and functions Assign value and parameters of rungs, function blocks and functions Check pagination and repaginate Edit texts of the footer
8-3
Hot key
Description
Use this command to assign variables and constants to the selected parameter of a function block, function, coil or contact. Use this command to de-assign a variable or constant from the selected parameter of a function block or function. Use this command to invert a Boolean input parameter of a function block or function. Use this command to create a rung below the selected rung. Use this command to create a new contact parallel with the selected coil, contact, function block or function. Use this command to create a new contact on the right of the selected coil, contact, function block or function. Use this command to create a new contact on the left of the selected coil, contact, function block or function. Use this command to create a new function block or function parallel with the selected coil, contact, function block or function. Use this command to create a new function or function block on the left of the selected coil, contact, function block or function. Use this command to create a new function or function block on the right of the selected coil, contact, function block or function.
8-4
Course T530
When you have one or several Rungs in the code block: Right click on a Rung and select Insert Rung.
8.2.6.1 Functions in LD
The following basic functions corresponding to operators of textual programming languages are available in the LD language:
8.2.6.1.1 Assignments
Function
Move, :=
Description
Assigns the value (number, logical or string) of the input parameter to the output parameter.
8-5
Description
Negates the Boolean value (1/0, on/off or True/False).
Description
Exponential, i.e. raising to the power.
Description
Course T530
8.2.6.2.3 Invert
By clicking with the right mouse button select the parameter (pin). Select the Invert command to invert the assignment to this parameter (pin). Connect
8.2.7 Connections
You can assign variables to coils of rungs and output parameters of function block and functions. The variables carry the values of the corresponding coils and output parameters. You can assign values to contacts of rungs and input parameters of function blocks and functions. The value can be either a variable, such as one carrying the value of an output parameter, or a constant. The assignment of parameters is shown by variable names, constant names and lines between the pins of boxes symbolizing the function blocks and functions.
8.2.7.3 Disconnect
By clicking with the right mouse button select the parameter assignment. Select the Disconnect command to remove the assignment.
8-7
8.2.8 Comments
It is possible to write comments to functions/function blocks, Rungs and pages.
8-8
Course T530
Use the structure pane to Overview the POU you are programming Create, delete, select, copy and paste rungs Edit rung comments Change the pagination and page comments Check the pagination and repaginate Navigate within the program
8-9
8-10
Course T530
If you want to change the layout of the current code block, go to Tools > Page Layout >Page Setup.
8-11
8-12
Course T530
TABLE OF CONTENTS Chapter 9 Structured Text (ST) Language.............................................................9-1 9.1 General Information......................................................................................9-1 9.1.1 Description......................................................................................9-1 9.1.2 Objectives .......................................................................................9-1 9.1.3 Reference Documentation...............................................................9-1 9.2 Lesson 1 ST Language ...............................................................................9-2 9.2.1 Description......................................................................................9-2 9.2.2 Objectives .......................................................................................9-2 9.2.3 General............................................................................................9-2 9.2.3.1 Functions Simplifying While Editing............................9-2 9.2.3.2 Using Microsoft Word...................................................9-3 9.2.4 Comments and the ABB Extension ................................................9-3 9.2.5 Instructions .....................................................................................9-3 9.2.5.1 Assignment Operators ...................................................9-3 9.2.5.2 Expressions....................................................................9-4 9.2.5.2.1 Boolean Expressions and Operators .........9-4 9.2.5.2.2 Arithmetic Expressions and Operators .....9-4 9.2.5.2.3 Relational Expressions and Operators ......9-5 9.2.5.3 Statements .....................................................................9-5 9.2.5.3.1 Conditional Statements .............................9-5 9.2.5.3.2 Iteration Statements ..................................9-6 9.2.5.3.3 Return Statements .....................................9-7 9.2.5.4 Execution Order ............................................................9-7 9.2.5.5 Simulate.........................................................................9-7 9.3 Exercise 9.1 Use the ST language..............................................................9-7
9-i
Course T530
9-ii
Course T530
9.1.2 Objectives
On completion of this chapter you will be able to: Use the ST Language.
9-1
9.2.2 Objectives
On completion of this lesson you will be able to: Use the ST Language.
9.2.3 General
Structured Text (ST) is a high-level programming language. It is compact, highly structured and contains a comprehensive range of constructs for assignments, function/function block calls, expressions, conditional statements, iterations and more. The code is simple to write and easy to read, because of its logical and structured layout. The compactness of the language gives an excellent overview of the code and less scrolling in the editor. Tabs and spaces are used to structure the code for easy reading. Below is an example of code written in Structured.
9-2
Course T530
Description
Comment according to IEC 1131-3. Comment that can be nested (ABB extension).
9.2.5 Instructions
The following basic instructions are available in the ST language.
Description
Assigns a value (number, logical or string) to a variable Parentheses. Commonly used to change the priority of an expression.
A variable is assigned a certain value with an assignment statement. If we wish the variable to take the value of Start we write:
Run := Start;
A statement is always concluded with a semicolon, ;. As in mathematics, the parentheses are used to change the priority in which execution is performed. Expressions within parentheses have the highest order of precedence.
9-3
9.2.5.2 Expressions
There are different kinds of expressions. They are expression containing: boolean operators (and, or, not, xor), arithmetic operators (+, -, *, **, mod), and expression containing relational operators (=, >=, >, <=, <, <>). An expression always results in a single value. An expression contains operators, functions and operands. Operators may be +, -, /. Functions may be for instance sin(x) or cos(x). The operand can be a value, a variable, a function or another expression.
Description
Negates the Boolean value (1/0, on/off or True/False). Boolean AND. Boolean AND. See AND. Boolean XOR. Boolean OR.
Description
Exponential, i.e. raising to the power.
9-4
Course T530
Description
Under the headline Conditional Statements, an example is given with Relational Expressions.
Description
These statements conditionally execute a group of statements, depending on the value of one or several Boolean expressions. A conditional statement is always concluded with end_if; These statements conditionally execute a group of statements, depending on the value of one or several Boolean expressions. A conditional statement is always concluded with end_if; These statements conditionally execute a group of statements, depending on the value of one or several Boolean expressions. A conditional statement is always concluded with end_if; A statement is executed depending on the value of an integer variable or an integer expression. The <integer literal> is one or several integer values or one or several ranges of values. If the value of the selector does not occur in any label, the statements following the else word (if it occurs in the case statement) shall be executed. Otherwise, if no else exists, none of the statements shall be executed.
If..then.. else.. end_if; If..then.. elsif.. else.. end_if; case <integer> of <integer literal> : <statements> end_case; case <integer> of <integer literal> : <statements> <integer literal> : <statements> <integer literal> : <statements> else <statements>
end_case;
9-5
Here is an example of a conditional statement using Case: case Seconds of 1..4, 8..10 : RedLight := true; GreenLight := false; 5..7 : RedLight := false; GreenLight := true; else RedLight := false; GreenLight := false; end_case; where Seconds is a variable of type dint.
Description
The for statement is used to allow a statement (or statements) to be executed repeatedly for a given number of times. The counter used in the repetition process can be used in the statements. The while statement is used in order to allow a statement (or statements) to be executed repeatedly while a certain condition is True. This separates it from the for statement. It has some similarities with the repeat statement. The Repeat statement is used in order to allow a statement (or statements) to be executed repeatedly until a certain condition is True. This separates it from the for statement. It has some similarities with the while statement. Use the exit statement whenever you want to terminate a loop immediately and continue execution from the first line after the iteration statement.
While
Repeat
Exit
9-6
Course T530
Description
Exit and terminate the execution of the current code. The instruction is usually found in function blocks and functions. It is not advisable to use the statement unless you are an advanced user as it can cause problems when executing together with other function blocks.
Description
Parenthesized expression. Parameter list of a function, function evaluation. Negation, Boolean complement, i.e. value with "opposite" value (0 becomes 1, 1 becomes 0) and arithmetical negation (-). Exponentiation, i.e. raising to a power. Multiplication, division and modulus. Addition and subtraction. Comparison operators Equality and inequality. Boolean AND. Boolean exclusive OR Boolean OR
Priority
Highest
Lowest
9.2.5.5 Simulate
When you simulate code written in the language Structured Text, is it possible to view the code in Ladder or Function Block Diagram (This works only for code written in Structured Text). Select (Tools> Setup) in the menu of the code block where the code is written (You must be in online mode when you do this).
9-7
9-8
Course T530
9.1.2 Objectives
After this exercise you will be able to: Use the ST Language.
Use your CourseProject and insert a new code block in Program2. Name the code block ST1 and select ST language. Convert from degree Fahrenheit to degree Celsius using the following formula. Celsius = 5.0 / 9.0 * (Fahrenheit - 32.0) Check the conversion with the following values of Farenheit. Fahrenheit
0 32 100
Celsius
3BSE 022 851/A 9-1
Simulate the project. Change the online presentation from Text to Function Diagram
9.1.4.3 If Statement
The variable Temperature should be assigned the Celsius value if the variable Metric (bool) is True. Otherwise the variable Temperature should be assigned the Fahrenheit value.
Write some comments (in the code pane) to the code in the previous exercise (Exercise 9.1.4.1 - 9.1.4.3).
Comment out the code and comments in the previous exercise (the If statement). Use nested comments!
9-2
Course T530
Celsius
- 17.778 0.0 37.778
9-3
In simulate mode:
9-4
Course T530
9-5
9-6
Course T530
TABLE OF CONTENTS Chapter 10 Instruction List (IL) Language ..........................................................10-1 10.1 General Information..................................................................................10-1 10.1.1 Description..................................................................................10-1 10.1.2 Objectives ...................................................................................10-1 10.1.3 Reference Documentation...........................................................10-1 10.2 Lesson 1 IL Language............................................................................10-2 10.2.1 Description..................................................................................10-2 10.2.2 Objectives ...................................................................................10-2 10.2.3 General........................................................................................10-2 10.2.3.2 The Result Register RR..........................................10-3 10.2.4 Comments ...................................................................................10-3 10.2.5 Standard instructions...................................................................10-4 10.2.5.1 Load and Store Instructions.......................................10-4 10.2.5.2 Boolean Operators.....................................................10-4 10.2.5.3 Arithmetic Instructions..............................................10-5 10.2.5.4 Relational and Equality Instructions .........................10-5 10.2.5.5 Return Instructions ....................................................10-5 10.2.5.6 Jump Instructions ......................................................10-6 10.2.5.7 Function Block Call Instructions...............................10-6 10.2.6 Execution Rules ..........................................................................10-6
10-i
Course T530
10-ii
Course T530
10.1.2 Objectives
On completion of this chapter you will be able to: Describe and identify instruction list constructs.
10-1
10.2.2 Objectives
On completion of this lesson you will be able to: Describe and identify instruction list constructs.
10.2.3 General
Instruction List (IL) is a low-level language where the instructions are listed in a column, one instruction on each line. It has a structure similar to simple machine assembler code. Instructions consist of an operator, followed by an operand (or operands). The instruction operates on the operand (like LD loads the D variable below). Some instructions require more than one operand as input argument. In these cases are the operands separated by a comma (,). The result register is of central importance in IL. Current data and the results from calculations, comparison, loading of variables etc. are stored in this register. To support jumps, IL has a separate column (Label) in which tags are placed. IL then navigates in the list using these tags as "targets" for jumps. The rightmost column labeled "Description" can be used for shorter comments corresponding to each line of instruction. For lengthy comments there is the possibility of writing the entire row as a comment. A typical instruction list can look like:
10-2
Course T530
The remaining instructions change the result register after each instruction.
10.2.4 Comments
There are two ways of writing comments in the IL editor, see picture below. 1. Right click on a row in the code pane and choose Insert > Comment Row. 2. To comment out code, write (# #) in the Label column of the code pane.
10-3
Description
Description
Change the value to its negated value. Boolean AND. If the arguments are multi bit then bit wise AND is used. Same as AND. Boolean inverted AND. If the arguments are multi bit then bit wise ANDN is used. Note: the expression is equal to (result register AND NOT operator). Boolean OR. If the arguments are multi bit then bit wise OR is used. Boolean inverted OR. If the arguments are multi bit then bit wise ORN is used. Note: the expression is equal to (result register OR NOT operator). Boolean exclusive OR. If the arguments are multi bit then bit wise XOR is used. Boolean inverted exclusive OR. If the arguments are multi bit then bit wise XORN is used. Note: the expression is equal to (result register XOR NOT operator).
OR ORN
XOR XORN
10-4
Course T530
Description
Description
Greater than. The result is of type bool Greater or equal than. The result is of type bool Equal to. The result is of type bool. Less than. The result is of type bool. Less or equal than. The result is of type bool. Not equal to. The result is of type bool.
Description
Unconditional exit of a list and termination of the current POU Conditional exit of a list and termination of current POU if the value of the result register is True (1). Conditional exit of a list and termination of current POU if the value of the result register is False (0).
10-5
Description
Jumps to a label independently of the value in result register. Warning! Do not use JMP to jump backwards. This may result in execution that exceeds the task interval time for the execution.
JMPC
Jumps to a label if the value in the result register is True (1). Warning! Do not use JMPC to jump backwards. This may result in execution that exceeds the task interval time for the execution.
JMPCN
Jumps to a label if the value in the result register is False (0). Warning! Do not use JMPCN to jump backwards. This may result in execution that exceeds the task interval time for the execution.
Description
10-6
Course T530
TABLE OF CONTENTS Chapter 11 Functions and Function Blocks..........................................................11-1 11.1 General Information..................................................................................11-1 11.1.1 Description..................................................................................11-1 11.1.2 Objectives ...................................................................................11-1 11.1.3 Reference Documentation...........................................................11-1 11.2 Lesson 1 - Using Functions and Function Blocks.....................................11-2 11.2.1 Description..................................................................................11-2 11.2.2 Objectives ...................................................................................11-2 11.2.3 The difference between Functions and Function Blocks............11-2 11.2.3.1 Functions ...................................................................11-2 11.2.3.2 Function blocks .........................................................11-2 11.2.4 Inserting libraries ........................................................................11-2 11.2.5 Some standard functions and function blocks ............................11-3 11.2.5.1 Data type conversion .................................................11-3 11.2.5.2 Mathematical functions .............................................11-3 11.2.5.3 Counters and timers...................................................11-3 11.2.6 Using Functions in different languages ......................................11-3 11.2.6.1 ST and SFC ...............................................................11-3 11.2.6.2 FBD ...........................................................................11-3 11.2.6.3 IL ...............................................................................11-4 11.2.6.4 LD..............................................................................11-4 11.2.7 Instantiation / Using FB Instances in different languages ..........11-4 11.2.7.1 ST and SFC ...............................................................11-4 11.2.7.2 FBD ...........................................................................11-5 11.2.7.3 IL ...............................................................................11-5 11.2.7.4 LD..............................................................................11-6 11.3 Exercise 11.1 Using Function Blocks ....................................................11-7 11.4 Lesson 2 - Creating Function Blocks ........................................................11-8 11.4.1 Description..................................................................................11-8 11.4.2 Objectives ...................................................................................11-8 11.4.3 Creating a user library.................................................................11-8 11.4.3.1 Why using libraries?..................................................11-8 11.4.4 Creating a Function Block Type.................................................11-8 11.4.4.1 Why create Function Block Types? ..........................11-8 11.4.4.2 Function Block Type Editor ......................................11-9 11.5 Exercise 11.2 Creating a simple Function Block Type..........................11-9 11.6 Exercise 11.3 Creating a more complex Function Block Type..............11-9
11-i
Course T530
11-ii
Course T530
11.1.2 Objectives
On completion of this chapter you will be able to: Describe the differences between Functions and Function Blocks. Insert libraries into the project. Use Functions and Function Blocks in the different programming languages. Describe the use of libraries. Create a user library. Describe different parameter directions. Declare a user Function Block. Move FB between libraries.
11-1
11.2.2 Objectives
On completion of this lesson you will be able to: Describe the differences between Functions and Function Blocks. Insert libraries into the project. Use Functions and Function Blocks in the different languages.
11.2.3 The difference between Functions and Function Blocks 11.2.3.1 Functions
Always return a (single) value at the time they are executed. Can be used in expressions. Do not retain their old values from one scan to the next. Always give the same value when the input parameters have the same value.
11-2
Course T530
11.2.6.2 FBD
Use the toolbar button , or select (Insert>Function/Function block...) or press <Ctrl + K> to display the dialog box containing the available functions and function blocks. If the function or function block is extensible, i.e. can be called with a varying number of inputs, you can enter the number in the Properties Size field. An example with the function Add in FBD:
11-3
11.2.6.3 IL
A function call in IL is done by writing the name of the function in the instruction field or using the button, press <Ctrl J >or select (Insert >Function). An example with the function Add in IL:
11.2.6.4 LD
Use one of the toolbar buttons , or select (Insert>Left, Right, Parallel Function/Function block...) to display the dialog box containing
the available functions and function blocks. If the function or function block is extensible, i.e. can be called with a varying number of inputs, you can enter the number in the Properties Size field. An example with the function Add in LD:
11-4
Course T530
Call the function block by writing like this in the code block were you intend to use it: TimerCloseDoor( A new window like the one below will be visible. Write suitable variables in the Actual Parameter field.
11.2.7.2 FBD
In FBD, function blocks are used in the same way as functions. It is not necessary to declare an instance of a function block before using it in the FBD editor, since the declaration of the instance will be made automatically when the function block is inserted in the code area.
11.2.7.3 IL
You must create an instance of the function block before it is used in the IL editor. The instance is created like this: Click on the Function blocks tab of the Program, Control Module Type or Function block type. Write the name of the function block you intend to use in the Function Block Type field or press <Ctrl J>. Give the function block a suitable name in the Name field. Write a description in the Description field.
11-5
Call for the function block by using the CAL instruction in the code block:
A new window like the one below will be visible. Write suitable variables in the Actual Parameter field.
11.2.7.4 LD
It is not necessary to declare a function or function block before using it in the FBD editor. Use the toolbar buttons , or select (Insert>Left, Right, Parallel Function/Function block...), to display the dialog box
containing the available functions and function blocks. The Insert Function / Function Block command displays a dialog box showing functions and function blocks available for insertion. The dialog box is the same as the one in the FBD editor (above). Declare suitable variables with correct data types to the parameters of the function block. Connect the pins of the function block with the variables.
11-6
Course T530
11-7
11.4.2 Objectives
On completion of this lesson you will be able to: Describe the use of libraries. Create a user library. Describe different parameter directions. Define a user Function Block Type. Move FB between libraries.
Course T530
Parameters Variables that passes values in or out from the program. The parameters have Directions, indication if the parameter is read or written by the Function Block. The options are: in, out and in_out. N.B.It is not allowed to assign an initial value to a parameter Local Variables used in the function block. External variables Globally defined variables in the application editor must be specified as external variables to be accessible by the function block. Function blocks. You must explicitly declare function blocks to use them inside the Function Block Type editor. Remember: when using the FBD or LD languages, the declaration of the function block instance will be made automatically when the function block is inserted. Move FB between libraries. It is possible to move functions or function blocks between libraries or applications, by using the copy/paste function.
11-9
11-10
Course T530
11.1.2 Objectives
After this exercise you will be able to: Use Function Blocks in the different languages.
Continue to work in Program2 in the project CourseProject. A Pump should be started when the StartPump command is given. The pump should run for 10s Use the function block type TP with the instance name PumpTimer. The initial value for the Preset Time variable should be declared with the following syntax: T#10s. Give the variables suitable names. This exercise should be done in the ST-language.
11-1
Insert a new code block named Counter in Program2. Use the FBD language. Keep track of the number of boxes between Photocell1 and Photocell2 on the conveyer by using the function block type CTUD.
Photocell 1
Photocell 2
11-2
Course T530
11-3
11-4
Course T530
11.2 Create a simple function block type Exercise 11.2 11.2.1 Description
This exercise describes how to make a simple function block type in a user defined library. The function block type will be called Motor and contain a few parameters and only one line of code. The exercise can be done using FBD or ST language.
11.2.2 Objectives
After this exercise you will be able to Create your own libraries. Create a new function block type. Instantiate a function block in a program.
The Motor Function Block should provide the same functionality as the motor start you created in Exercise 7.1, i.e. it should have 3 parameters for Start, Stop and Run, and one line of code. ........................................................................................................................................... ........................................................................................................................................... ...........................................................................................................................................
11-6
Course T530
11.2.5 Solutions Exercise 11.2 11.2.5.1 Create a Function Block Type Motor
In this solution, the code within the FB type is written in ST, while the code in the program is written in FBD. 1. Right click on the Libraries icon. Select New Library. 2. Enter MotorLib as the name of the library.
3. Right click on the Function Block Types icon in the MotorLib. Select New Function Block Type. Enter Motor as the name of the new type.
11-7
5. Declare three parameters according to the figure below. Make sure that the directions are correct.
6. Enter the code as shown in the figure above. 7. Open Program2. Delete the existing code for the motors. 8. Right-click in the code area. Select Insert function/function block. 9. Select MotorLib and Motor. Name the instance Motor_1. Make sure that there is no variable in Program2 with this name.
10. Right click on the Start pin. Choose Connect. Enter Motor1.Start. Click OK.
11-8
Course T530
11. Repeat the former step for the parameters Stop and Run.
12. Test the program in Simulate mode. Right click on the Motor1.Start and Motor1.Stop and force them. Watch the results. ........................................................................................................................................... ...........................................................................................................................................
11-9
FB Heater
FB Cooler
Additional code
11.3.2 Objectives
After this exercise you will be able to: Create a user library. Declare a user Function Block. Move FB between libraries.
11-10
Course T530
Open the project OSLOPrep. Create a new Function Block Type named Tank in the library OsloLib.
11.3.4.2 Mixer
This exercise should be done using the ST language. Declare an instance of the Function Block Type Mixer in the Function Block Type Tank. Declare parameters to the Function Block in the Tank type with the same names and of the same Data Types and directions as in the Mixer type, because these should be parameters of the Function Block Type Tank. Connect the parameters to the instance of the Mixer.
11-11
11.3.4.3 Heater
This exercise should be done using the ST language. Declare an instance of the Function Block Type Heater in the Function Block Type Tank. Declare parameters to the function block in the Tank type with the same names and of the same Data Types and directions as in the Heater type, because these should be parameters of the Function Block Type Tank. Connect the parameters to the instance of the Heater.
11.3.4.4 Cooler
This exercise should be done using the ST language. Declare an instance of the function block type Cooler in the Function Block Type Tank. Declare parameters to the function block in the Tank type with the same names and of the same data types and directions as in the Cooler type, because these should be parameters of the Function Block Type Tank. Connect the parameters to the instance of the Cooler.
11-12
Course T530
Declare the following parameters in the function block type Tank. Name
Level LevelHigh LevelLow
Data type
Real Bool Bool
Initial value
In
Direction
Out Out
Write some code in the function block type Tank, to achieve the following: LevelHigh should be set to true when Level exceeds 80.0. LevelLow should be set to true when Level falls below 20.0. Use the ST language.
11-13
This exercise can be done in ST or FBD language. It is now time for test and simulation of the Function Block Type Tank. Insert a new Code Block in Program2 named Order and make an instance named OsloTank1 of the Function Block Type Tank. Make the following connections to the Tank: (Note: the variables are already declared.) Parameter
OrderMixer AnswerMixer ErrorMixer OrderCooler AnswerCooler ErrorCooler OrderHeater AnswerHeater ErrorHeater Level LevelHigh LevelLow
Connects to
OsloTank.OrderMixer OsloTank.AnswerMixer OsloTank.ErrorMixer OsloTank.OrderCooler OsloTank.AnswerCooler OsloTank.ErrorCooler OsloTank.OrderHeater OsloTank.AnswerHeater OsloTank.ErrorHeater OsloTank.Level OsloTank.LevelHigh OsloTank.LevelLow
Test the functionality of the Tank by setting the order variables to true.
11-14
Course T530
This exercise prepares for the chapter (SFC). In order to make a sequence, that Fills, Heats, Mixes, Cools and Drains the Tank, we need to control the inlet an outlet of the Tank. By instantiating two function blocks of the type ValveGroup is it possible to simulate the whole process, by giving orders to the UpperValveGroup, Heater, Cooler, Mixer and LowerValveGroup. The only thing missing is the sequence that will run the process. Make an instance UpperValveGroup of the function block type ValveGroup. Make an instance LowerValveGroup of the function block type ValveGroup. Make the following Function Block calls and connections. Note: the variables are already declared.
3. Click OK.
11-16
Course T530
11-17
11.3.5.6 Solution: Make an Instance of the Tank 11.3.5.6.1 Using the ST Language
1. Insert a new Code Block in Program2 named Order. Choose ST for language. 2. Declare an instance named OsloTank1 of the Function Block Type Tank in the Function blocks tab of the declaration pane. 3. Enter OsloTank1(in the code block Order and fill in the connection list as shown in the figure:
11-18
Course T530
11-19
11.3.5.7 Solution: Make Two Instances of the ValveGroup 11.3.5.7.1 Using the ST Language
Use the code block Order. In the Function blocks tab: Declare an instance called UpperValveGroup1 of the function block type ValveGroup. Declare an instance LowerValveGroup1 of the function block type ValveGroup. Make the following Function Block calls and connections:
11-20
Course T530
11-21
11-22