Top Banner
Course T530 3BSE 022 838/D 1-i Chapter 1 Course Information 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
203
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 530

Course T530

3BSE 022 838/D 1-i

Chapter 1 Course Information

TABLE OF CONTENTS

Chapter 1 Course Information..................................................................................1-i

Chapter 1 Course Information.................................................................................1-11.1 Name .............................................................................................................1-11.2 Duration ........................................................................................................1-11.3 Description....................................................................................................1-11.4 Objectives......................................................................................................1-21.5 Student Profile...............................................................................................1-21.6 Prerequisites ..................................................................................................1-31.7 Exercises .......................................................................................................1-31.8 Course schedule ............................................................................................1-41.9 Reference Material ........................................................................................1-5

1.9.1 Introduction.....................................................................................1-51.9.2 Product Manuals .............................................................................1-5

1.9.2.1 Control Builder Manuals ...............................................1-51.9.2.2 Control Builder Related Manuals – Software................1-51.9.2.3 Control Builder Related Manuals – Hardware ..............1-6

1.10 Legend.........................................................................................................1-71.11 Feedback Information to ABB....................................................................1-91.12 Course Evaluation .....................................................................................1-11

Page 2: 530

Course T530

1-ii 3BSE 022 838/D

Page 3: 530

Course T530

3BSE 022 838/D 1-1

Chapter 1 Course Information

1.1 Name

Course: T530Control 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 ofIEC 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:

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

Page 4: 530

Course T530Chapter 1 Course Information

1-2 3BSE 022 838/D

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.5 Student Profile

System, process, and application engineers. Instrumentation, electrical, and service engineers.

The course is meant for programmers who are going to write programs for AC 800M/C or AC 250.

Page 5: 530

Course T530

3BSE 022 838/D 1-3

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.

Page 6: 530

Course T530Chapter 1 Course Information

1-4 3BSE 022 838/D

1.8 Course schedule

Day 1 Day 2 Day 3 Course information

System presentation

The IEC 61131-3 concept and ABB extentions

Getting started

Review

Variables and data types

Function block diagram

Ladder diagram

Strucuted text

Instruction list

Functions and function blocks

Review

Sequence function chart

Tasks

Download

Simple hardware config and I/O connection

Extended hardware config

Day 4 Day 5

Review

Control modules

Code sorting

Standard libraries

Several applications and controllers

Review

Several applications and controllers (contd.)

Communication

Analyze

Accessibility

Back-up and restore

Optimize

Evaluation

Page 7: 530

Course T530

3BSE 022 838/D 1-5

1.9 Reference Material

1.9.1 Introduction

The student gets this course binder. Control Builder M Professional has built in manuals in the help menu.

Each classroom has reference documentation sets available to provide you with additional information if necessary.

To order the product documentation NOT found in your course binder, contact your local sales office or ABB headquarters.

1.9.2 Product Manuals

Product Manuals are product-documents developed by the documentation department within ABB Automation Products. They are all included on the Control Builder installation CD. The manuals are a part of the built in help.

1.9.2.1 Control Builder Manuals

Document Order code

Control Builder Beginner’s HandbookStarting up and Installation

3BSE 021 350 R201

IEC 61131-3 Control LanguagesIntroduction

3BSE 021 358 R101

1.9.2.2 Control Builder Related Manuals – Software

Document Order code

AC 800M/C Control Software and Tools 3BSE 021 359 R301

AC 800M/C Control FunctionsAlarms, Analog Control and Controllers

3BSE 021 351 R101

AC 800M/C CommunicationProtocols and Design

3BSE 021 352 R101

AC 800M/C Foundation FieldbusFunctional Description

3BUR 002 087 R101

Page 8: 530

Course T530Chapter 1 Course Information

1-6 3BSE 022 838/D

1.9.2.3 Control Builder Related Manuals – Hardware

Document Order code

AC 800MController Hardware

3BSE 019 193 R201

AC 800CInstallation and Maintenance

3BSE 021 353 R101

SoftControllerHardware and Operation

3BSE 021 355 R101

AC 250Hardware and Operation

3BSE 021 354 R201

S800 I/OGeneral Information and Installation

3BSE 020 923 R201

S800 I/O,Modules and Termination Units

3BSE 020 924 R101

S800 I/O,Modules and Termination Units with Intrinsic Safety

3BSE 020 927 R101

S800 I/O,Fieldbus Communication Interface for PROFIBUS-DP

3BSE 020 926 R101

S800 I/O,Terminal Diagram Forms

3BSE 011 778 R101

S200 I/OInstallation and Maintenance

3BSE 021 356 R101

S200L I/OInstallation and Maintenance

3BSE 021 357 R101

Control NetworkWiring and Installation

3BSE 021 940 R101

Foundation FieldbusWiring and Installation

3BUR 002 088 R101

ControlNet;Planning and Installation

3BSE 024 894R101

Page 9: 530

Course T530

3BSE 022 838/D 1-7

1.10 Legend

< > Indicates a key name.

> Indicates a menu selection path.

| Indicates when you go from one pop-up menu to a sub-pop-up menu.

Bold Indicates a pop-up menu name or an option in a pop-up menu.

Code Indicates text that should be entered from the keyboard.

Indicates a student activity.

Question to be answered by the student.

Page 10: 530

Course T530Chapter 1 Course Information

1-8 3BSE 022 838/D

Page 11: 530

Course T530

3BSE 022 838/D 1-9

1.11 Feedback Information to ABB

Please evaluate this course binder and use this page to notify us of problems or suggest improvements.

Course binder for: Course T530, Control Builder M Professional, Configuration

Problems are found on the following on page/pages:(If possible attach a copy of page and correction.)

Recommended improvements:(Attach additional information if needed.)

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 ABABB Automation UniversityTraining 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:

Page 12: 530

Course T530Chapter 1 Course Information

1-10 3BSE 022 838/D

Page 13: 530

Course T530

3BSE 022 838/D 1-11

1.12 Course Evaluation

Course T530 Date Control Builder M Professional, Configuration

Training Engineer Location

Your Job Title Your Name [optional]

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.

Ex

ce

llen

t

Ve

ry G

oo

d

Sa

tis

fac

tory

Fa

ir

Po

or

Check your opinion.

1. Quality of training engineer’s presentation

2. Adequacy of course contents

3. Quality of training documentation

4. Adequacy and quality of training equipment

5. Was the training engineer adequately prepared to teach this course?

6. Were course and lesson objectives communicated to you?

7. Was the training engineer helpful and receptive to questions or difficulties?

8. Were the lab exercises effective in helping you learn?

9. Were the facilities in and around the lecture room to your satisfaction

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?

Comments and Recommendations: (Use the reverse side or additional paper if necessary)

Page 14: 530

Course T530Chapter 1 Course Information

1-12 3BSE 022 838/D

Page 15: 530

Course T530

3BSE 022 839/D 2-i

Chapter 2 The Integrated System – An Introduction

TABLE OF CONTENTS

Chapter 2 The Integrated System – An Introduction ............................................2-12.1 General Information......................................................................................2-1

2.1.1 Description......................................................................................2-12.1.2 Objectives .......................................................................................2-1

2.2 Lesson 1 - The Integrated System.................................................................2-12.2.1 Description......................................................................................2-12.2.2 Objectives .......................................................................................2-1Enterprise Automation.............................................................................2-2OperateIT – Human System Interface.......................................................2-2OperateIT SCADA Portal........................................................................2-32.2.6 ControlIT – Scalable Controllers .....................................................2-3InformIT – Enterprise Historian................................................................2-42.2.8 EngineerIT – Covers All Engineering Tasks ...................................2-4OptimizeIT Process Optimization Suite....................................................2-5ProduceIT..................................................................................................2-52.2.11 ControlIT – Control Builder M Professional .................................2-62.2.12 ControlIT – Control Builder M Languages....................................2-6ControlIT for AC 800M with…................................................................2-7ControlIT – Control Modules ....................................................................2-72.2.15 ControlIT – Control Builder Versions ...........................................2-72.2.16 ControlIT – Libraries .....................................................................2-82.2.17 ControlIT – Additional Libraries ...................................................2-8

Page 16: 530

Course T530

2-ii 3BSE 022 839/D

Page 17: 530

Course T530

3BSE 022 839/D 2-1

Chapter 2 The Integrated System – An Introduction

2.1 General Information

2.1.1 Description

In this chapter you will find an overview of products related to the Control Builder

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 Lesson 1 - The Integrated System

2.2.1 Description

In this chapter you will find an overview of products related to the Control Builder.

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

Page 18: 530

Course T530Chapter 2 The Integrated System – An Introduction

2-2 3BSE 022 839/D

2.2.3 Enterprise Automation

2.2.4 OperateIT –Human System Interface

Window Management

Process Graphics

Alarm Manager

Trends

Historian

Report

Controller Integration

Planning and scheduling

Plant Engineering

Maintenance

Operation

Boardroom

Design

Shopfloor

Asset Optimization

Page 19: 530

Course T530

3BSE 022 839/D 2-3

2.2.5 OperateIT SCADA Portal

2.2.6 ControlIT – Scalable Controllers

Control Functionality

From binary logic to superior closed loop control

Pre-defined advanced process objects

User defined function blocks

Very fast execution cycle

Pick your choice of fieldbuses

Open communication standards

Redundancy

Object-oriented SCADA server, with alarm detection, data processing and scaling functionsReal-time database and a wide range of communication protocolsSCADA tools as Aspect SystemsSimple integration with 3rd party control productsReports using industry standard reporting packagesSimple to up-grade to integrated SCADA/DCS solution

Page 20: 530

Course T530Chapter 2 The Integrated System – An Introduction

2-4 3BSE 022 839/D

2.2.7 InformIT – Enterprise Historian

ABB Provides the “Information Backbone”

Pavilion alliance for advanced data modeling and analysis

Available for ABB or Non-ABB Systems

2.2.8 EngineerIT – Covers All Engineering Tasks

Navigation, search & find

Iterative design

Data sharing

Bulk data handling

Library management

Reuse support

Functional planning

Control configuration

Function - resource allocation

Location & layout planning

Fieldbus configuration

Document management

HSI configuration

Data Information Knowledge

Plant and Enterprise Optimization

Page 21: 530

Course T530

3BSE 022 839/D 2-5

2.2.9 OptimizeIT Process Optimization Suite

Solution Technologies

Pavilion Technology Suite

3dMPC

SimconX

Applications and Delivery Expertise

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

Page 22: 530

Course T530Chapter 2 The Integrated System – An Introduction

2-6 3BSE 022 839/D

2.2.11 ControlIT – Control Builder M Professional

IEC 61131-3 standard

Five program editors

Program simulation and online facilities

Online help

Create own libraries

More than one controller/application per project

Source code distribution

Control Modules

Application program distribution

User privileges

2.2.12 ControlIT – Control Builder M Languages

Standard Easy to use IEC 61131-3

All five languages supported

Instruction List

Ladder Diagram

Function Block Diagram

Structured Text

Sequential Function Chart

Control Modules Add Object Orientation to IEC 61131-3 (CB Pro only!).

Implements the control aspect of ABB Objects.

Page 23: 530

Course T530

3BSE 022 839/D 2-7

2.2.13 ControlIT for AC 800M with…

Advanced closed loop control

Adaptive PID

Fuzzy control

PID Autotuning

Bumpless transfer

Predefined advanced process objects

Flexible application distribution and task connection

Time critical task with interval time down to 1ms

2.2.14 ControlIT – Control Modules

Control Modules Add Object Orientationto IEC 61131-3

Implements the control aspect of ABB Objects

Higher level of function oriented programming

No need to see detail in program

Data flow analyse for efficient program execution

Easy to insert new object in application, the system takes care of optimal execution order

More convenient to use

Configuration rather than programming

More efficient reuse of library solutions

Effectively hides complexity

Possibility to make panels for commissioning and maintenance purpose

2.2.15 ControlIT – Control Builder Versions

Control Control Control

Page 24: 530

Course T530Chapter 2 The Integrated System – An Introduction

2-8 3BSE 022 839/D

Function Builder Basic

Builder Standard

Builder Professional

Make/change libraries No Yes Yes

Make/change/use Control Modules No No Yes

No. of controllers 1 8 32

No. of applications 1 8 256

No.of applications per controller 1 1 8

No. of programs per application 3 64 64

No.of tasks per controller 3 16 16

Distribute code to several controllers No Yes Yes

Share code between several programming stations

No Yes Yes

Source code controla Official only Official/

Unofficial

Official/

Unofficial

Integration with the OperateIT

WorkplaceNo No Yes

Logging in and user privilegies No No Yes

a. A function for a safe source code handling when the code is shared between several programming stations.

2.2.16 ControlIT – Libraries

Libraries/

Functions

License level

I/O module (unit) levels

Binary Control

Basic Control

Advanced Process Control

Systemlib * * * 0, 4, 8, 12, 16, 20, 24, 36, 48, 60, 72, 84, 96, 108, 120 or an unlimited number of I/O modules.

One license key includes one of the license levels and one of the I/O module levels.

CommunicationLib * *

ProcessObjectLib * *

ProcessObjectExtLib *

AlarmEventLib *

ControlBasicLib * *

ControlStandardLib * (CB Pro only)

ControlExtendedLib *(CB Pro only)

ControlAdvancedLib *(CB Pro only)

Redundant Control Network (function)

*

2.2.17 ControlIT – Additional Libraries

License level

Page 25: 530

Course T530

3BSE 022 839/D 2-9

Libraries/Functions

Binary Control

Basic Control

Advanced Process Control Function

Control Builder Basic, Standard and Professional

Redundant Control Network (function)

* * Admits the use of redundant network. Included in the Advanced Process Control license.

Batch Functionality with BatchLib

* * (CB Pro only) Admits the use of a library for batch handling.

User Defined Serial Protocols with SerialLib

* * * Admits the use of libraries for communication with external devices via seral channels.

Fuzzy Control with Fuzzylib

* (CB Pro only) Admits the use of a library for creating fuzzy control functions.

Page 26: 530

Course T530Chapter 2 The Integrated System – An Introduction

2-10 3BSE 022 839/D

Page 27: 530

Course T530

3BSE 022 840/C 3-i

Chapter 3 Training Equipment Overview

TABLE OF CONTENTS

Chapter 3 Training Equipment Overview ..............................................................3-13.1 General Information......................................................................................3-1

3.1.1 Description......................................................................................3-13.1.2 Objectives .......................................................................................3-1

Configuration of Training Equipment.................................................................3-23.2.1 The Controller AC 800M................................................................3-23.2.2 The Control Panel ...........................................................................3-33.2.3 Connection Between I/O Panel and AC 800M...............................3-4

3.3 The OSLO Process Model ............................................................................3-7Overview of the Model and the Variables ...............................................3-73.3.2 Connection Between OSLO Process Hardware Model and AC

800M .........................................................................................3-83.3.3 Connection Between Process Model Simulation and AC

800M .......................................................................................3-113.4 The OSLO Software-Process Model...........................................................3-12

3.4.1 Operation of the Simulated OSLO Process Model .......................3-12

Page 28: 530

Course T530

3-ii 3BSE 022 840/C

Page 29: 530

Course T530

3BSE 022 840/C 3-1

Chapter 3 Training Equipment Overview

3.1 General Information

3.1.1 Description

This chapter gives an overview of the training equipment to be used in the course.

3.1.2 Objectives

Upon completion of this chapter, you will be able to:

Describe how the training equipment is configured

Describe how the operator’s panel and the process model can be used

Describe the name standard of variables in this course

Page 30: 530

Course T530Chapter 3 Training Equipment Overview

3-2 3BSE 022 840/C

3.2 Configuration of Training Equipment

Equipment for one workgroup

3.2.1 The Controller AC 800M

PC with:Windows 2000 ProfessionalControl Builder ProfessionalOn-line manualsExcel

AC 800M with Profibus-DP

I/O Panel Process Model

TCP/IP

PPP

Page 31: 530

Course T530

3BSE 022 840/C 3-3

3.2.2 The Control Panel

DO

DI

AO1

AO3

AO2

AO4

AI

1 2 3 4 5 6 7 8 9 10 11 12 13 14

ON

OFF

1 2 3 4 5 6 7 8

Page 32: 530

Course T530Chapter 3 Training Equipment Overview

3-4 3BSE 022 840/C

3.2.3 Connection Between I/O Panel and AC 800MTable 3.1 Analog input signals

I/O module & channel number

Variable name Object Miscellaneous

AI810_1.1 NxxPOT1 Potentiometer 1 0-100% = 0-10 V

AI810_1.2 NxxPOT2 Potentiometer 2 0-100% = 0-10 V

AI810_1.3 NxxPOT3 Potentiometer 3 0-100% = 0-10 V

AI810_1.4 NxxPOT4 Potentiometer 4 0-100% = 0-10 V

AI810_1.5 NxxPOT5 Potentiometer 5 0-100% = 0-10 V

AI810_1.6 NxxPOT6 Potentiometer 6 0-100% = 0-10 V

AI810_1.7 NxxPOT7 Potentiometer 7 0-100% = 0-10 V

AI810_1.8 NxxPOT8 Potentiometer 8 0-100% = 0-10 V

Table 3.2 Analog output signals

I/O module & channel number

Variable name Object Miscellaneous

AO810_1.1 NxxINST1 Instrument 1 0-100% = 0-20 mA

AO810_1.2 NxxINST2 Instrument 2 0-100% = 0-20 mA

AO810_1.3 NxxINST3 Instrument 3 0-100% = 0-20 mA

AO810_1.4 NxxINST4 Instrument 4 0-100% = 0-20 mA

Nxx = Node number of the AC800M (xx = the last two numbers in the IP address).

Page 33: 530

Course T530

3BSE 022 840/C 3-5

Table 3.3 Digital input signals

I/O module & channel number

Variable name Object Miscellaneous

DI810_1.1 NxxSW1 Switch 1

DI810_1.2 NxxSW2 Switch 2

DI810_1.3 NxxSW3 Switch 3

DI810_1.4 NxxSW4 Switch 4

DI810_1.5 NxxSW5 Switch 5

DI810_1.6 NxxSW6 Switch 6

DI810_1.7 NxxSW7 Switch 7

DI810_1.8 NxxSW8 Switch 8

DI810_1.9 NxxSW9 Switch 9

DI810_1.10 NxxSW10 Switch 10

DI810_1.11 NxxSW11 Switch 11

DI810_1.12 NxxSW12 Switch 12

DI810_1.13 NxxSW13 Switch 13

DI810_1.14 NxxSW14 Switch 14

DI810_1.15 Spare

DI810_1.16 Spare

Page 34: 530

Course T530Chapter 3 Training Equipment Overview

3-6 3BSE 022 840/C

Table 3.4 Digital output signals

I/O module & channel number

Variable name Object Miscellaneous

DO810_1.1 NxxLAMP1 Lamp 1

DO810_1.2 NxxLAMP2 Lamp 2

DO810_1.3 NxxLAMP3 Lamp 3

DO810_1.4 NxxLAMP4 Lamp 4

DO810_1.5 NxxLAMP5 Lamp 5

DO810_1.6 NxxLAMP6 Lamp 6

DO810_1.7 NxxLAMP7 Lamp 7

DO810_1.8 NxxLAMP8 Lamp 8

DO810_1.9 NxxLAMP9 Lamp 9

DO810_1.10 NxxLAMP10 Lamp 10

DO810_1.11 NxxLAMP11 Lamp 11

DO810_1.12 NxxLAMP12 Lamp 12

DO810_1.13 NxxLAMP13 Lamp 13

DO810_1.14 NxxLAMP14 Lamp 14

DO810_1.15 Spare

DO810_1.16 Spare

Nxx = Node number of the AC800M (xx = the last two numbers in the IP address).

Page 35: 530

Course T530

3BSE 022 840/C 3-7

3.3 The OSLO Process Model

3.3.1 Overview of the Model and the Variables

M1

ST

FTLG

DO801_2.7NxxMixerOrdDI801_2.7NxxMixerInd

AI810_2.1NxxInflow

AO810_1.5NxxV3Ref

AI810_2.5NxxMixerCurr

AO810_1.7NxxMixerRef

DO801_2.8NxxCounterOrdDO801_2.10NxxCounterDirDO8012.11NxxCounterRes

DI801_2.1NxxLevelMax

DI801_2.2NxxLevelMin

AI810_2.3NxxLevel

AI810_2.4NxxTemp

DO801_2.4NxxV2Ord

AI810_2.2NxxOutflow

DO801_2.9NxxAlarmOrd

AO810_1.8NxxHornRef

DO801_2.6NxxCoolerOrd

DI801_2.6NxxCoolerInd

DI801_2.3NxxV1ClosedDI801_2.13NxxV1Open

DO801_2.1NxxV5OrdDI801_2.10NxxV5OpenDI801_2.12NxxV5Closed

DO801_2.3NxxV1Ord

DO801_2.2NxxV6OrdDI801_2.9NxxV6OpenDI801_2.11NxxV6Closed

100

90

80

70

60

50

40

30

20

10

0

MAX

LEVEL

MIN10 50 100°C

HEATER

COOLER

ALARM

BUZZER

COUNTER

DI801_2.8NxxMixerPulse

AO810_1.6NxxV4Ref

DO801_2.5HEATER.ORDDI801_2.5NxxHeaterInd

current+24V

speedref10 50 100%

10 50 100%

10 50 100%

V1 V5

100% 40%

V3

H2

LG H1

LT

LG L1

FT

TT

10 50 100%FT10 50 100%

+24V

+24V

M

V4

V6 V2

10 50 100%

DI801_2.4NxxV2ClosedDI801_2.14NxxV2Open

DI801_2.15NxxOverflow

Page 36: 530

Course T530Chapter 3 Training Equipment Overview

3-8 3BSE 022 840/C

3.3.2 Connection Between OSLO Process Hardware Model and AC 800M

Table 3.5 Analog input signals

I/O module & channel number

Variable name Object Miscellaneous

AI810_2.1 NxxINFLOW Tank inflow 0-100% = 0-10 V

AI810_2.2 NxxOUTFLOW Tank outflow 0-100% = 0-10 V

AI810_2.3 NxxLEVEL Tank level 0-100% = 0-10 V

AI810_2.4 NxxTEMP Tank temperature 0-100% = 0-10 V

AI810_2.5 NxxMIXERCURR Mixer motor current 0-100% = 0-10 V

AI810_2.6 Spare

AI810_2.7 Spare

AI810_2.8 Spare

Table 3.6 Analog output signals

I/O module & channel number

Variable name Object Miscellaneous

AO810_1.5 NxxV3REF Control valve V3 for inflow 0-100% = 0-20 mA

AO810_1.6 NxxV4REF Control valve V4 for outflow 0-100% = 0-20 mA

AO810_1.7 NxxMIXERREF Mixer speed reference 0-100% = 0-20 mA

AO810_1.8 NxxHORNREF Variable volume alarm 0-100% = 0-20 mA

Nxx = Node number of the AC800M (xx = the last two numbers in the IP address)

Page 37: 530

Course T530

3BSE 022 840/C 3-9

Table 3.7 Digital input signals

I/O module & channel number

Variable name Object Miscellaneous

DI801_2. 1 NxxLEVELMAX Tank level limit, max. level 1=MAX

DI801_2.2 NxxLEVELMIN Tank level limit, min. level 1=MIN

DI801_2.3 NxxV1CLOSED Feedback for on/off valve V1 1=CLOSED

DI801_2.4 NxxV2CLOSED Feedback for on/off valve V2 1=CLOSED

DI801_2.5 NxxHEATERIND Feedback main contactor heater 1=ON

DI801_2.6 NxxCOOLERIND Feedback main contactor cooler 1=ON

DI801_2.7 NxxMIXERIND Feedback main contactor mixer 1=ON

DI801_2.8 NxxMIXERPULSE One pulse per revolution

DI801_2.9 NxxV6OPEN Feedback for on/off valve V6 1=OPEN

DI801_2.10 NxxV5OPEN Feedback for on/off valve V5 1=OPEN

DI801_2.11 NxxV6CLOSED Feedback for on/off valve V6 1=CLOSED

DI801_2.12 NxxV5CLOSED Feedback for on/off valve V5 1=CLOSED

DI801_2.13 NxxV1OPEN Feedback for on/off valve V1 1=OPEN

DI801_2.14 NxxV2OPEN Feedback for on/off valve V2 1=OPEN

DI801_2.15 NxxOVERFLOW Tank overflow

DI801_2.16 Spare

Page 38: 530

Course T530Chapter 3 Training Equipment Overview

3-10 3BSE 022 840/C

Table 3.8 Digital output signals

I/O module & channel number

Variable name Object Miscellaneous

DO801_2.1 NxxV5ORD On/off valve V5, inflow 1=OPEN

DO801_2.2 NxxV6ORD On/off valve V6, outflow 1=OPEN

DO801_2.3 NxxV1ORD On/off valve V1, inflow 1=OPEN

DO801_2.4 NxxV2ORD On/off valve V2, outflow 1=OPEN

DO801_2.5 NxxHEATERORD Main contactor heater 1=ON

DO801_2.6 NxxCOOLERORD Main contactor cooler 1=ON

DO801_2.7* NxxMIXERORD Main contactor mixer motor 1=ON

DO801_2.8 NxxCOUNTERORD Pulse to counter display

DO801_2.9 NxxALARMORD Alarm indication LED’s 1=ON

DO801_2.10 NxxCOUNTERDIR Counting direction 0=UP; 1=DOWN

DO801_2.11 NxxCOUNTERRES Counter reset 1=RESET

DO801_2.12 Spare

DO801_2.13 Spare

DO801_2.14 Spare

DO801_2.15 Spare

DO801_2.16 Spare

* For the mixer motor to run it must have a non-zero speed reference (AO1.7),and the mixer main contactor must be active.

Page 39: 530

Course T530

3BSE 022 840/C 3-11

3.3.3 Connection Between Process Model Simulation and AC 800MTable 3.9 Analog output signals

I/O module & channel number

Variable name Object Miscellaneous

AO801_2.1 NxxINFLOW_SIM Tank inflow simulation 0-100% = 0-20 mA

AO801_2.2 NxxOUTFLOW_SIM Tank outflow simulation 0-100% = 0-20 mA

AO801_2.3 NxxLEVEL_SIM Tank level simulation 0-100% = 0-20 mA

AO801_2.4 NxxTEMP_SIM Tank temperature simulation 0-100% = 0-20 mA

AO801_2.5 NxxMIXERCURR_SIM Mixer motor current simulation 0-100% = 0-20 mA

AO801_2.6

AO801_2.7

AO801_2.8

Table 3.10 Digital output signals

I/O module & channel number

Variable name Object Miscellaneous

DO801_3.1 NxxLEVELMAX_SIM Tank level limit, max. level simulation

DO801_3.2 NxxLEVELMIN_SIM Tank level limit, min. level simulation

DO801_3.3 NxxV1CLOSED_SIM Feedback for on/off valve V1 simulation

DO801_3.4 NxxV2CLOSED_SIM Feedback for on/off valve V2 simulation

DO801_3.5 NxxHEATERIND_SIM Feedback main contactor heater simulation

DO801_3.6 NxxCOOLERIND_SIM Feedback main contactor cooler simulation

DO801_3.7 NxxMIXERIND_SIM Feedback main contactor mixer simulation

DO801_3.8 NxxMIXERPULSE_SIM One pulse per revolution simulation

DO801_3.9 NxxV6OPEN_SIM Feedback for on/off valve V6 simulation

DO801_3.10 NxxV5OPEN_SIM Feedback for on/off valve V5 simulation

DO801_3.11 NxxV6CLOSED_SIM Feedback for on/off valve V6 simulation

DO801_3.12 NxxV5CLOSED_SIM Feedback for on/off valve V5 simulation

DO801_3.13 NxxV1OPEN_SIM Feedback for on/off valve V1 simulation

DO801_3.14 NxxV2OPEN_SIM Feedback for on/off valve V2 simulation

DO801_3.15 NxxOVERFLOW_SIM Tank overflow simulation

DO801_3.16 Spare

Nxx = Node number of the AC800M (xx = the last two numbers in the IP address)

Page 40: 530

Course T530Chapter 3 Training Equipment Overview

3-12 3BSE 022 840/C

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.

Page 41: 530

Course T530

3BSE 022 841/B 4-i

Chapter 4 The IEC 61131-3 Concept and ABB Extensions

TABLE OF CONTENTS

Chapter 4 The IEC 61131-3 Concept and ABB Extensions ..................................4-14.1 General Information......................................................................................4-1

4.1.1 Description......................................................................................4-14.1.2 Objectives .......................................................................................4-14.1.3 Reference Documentation...............................................................4-1

4.2 Lesson 1 - IEC 61131-3, the Concept and Common Elements.....................4-24.2.1 Description......................................................................................4-24.2.2 Objectives .......................................................................................4-24.2.3 IEC 61131-3 – Overview................................................................4-2

4.2.3.1 The IEC 61131-3 Standard............................................4-34.2.3.2 The 5 Languages of IEC 61131-3 .................................4-34.2.3.3 Instruction List (IL) .......................................................4-44.2.3.4 Structured Text (ST)......................................................4-44.2.3.5 Ladder Diagram (LD)....................................................4-54.2.3.6 Function Block Diagram (FBD)....................................4-54.2.3.7 Sequential Function Chart, SFC....................................4-54.2.3.8 The IEC 61131-3 Standard............................................4-64.2.3.9 IEC 61131-3: Common Elements .................................4-64.2.3.10 IEC 61131-3: Common Elements (2)..........................4-64.2.3.11 IEC 61131-3 Standard Datatypes ................................4-7

4.3 Lesson 2 – IEC 61131-3, the Software Model and Compliance...................4-84.3.1 Description......................................................................................4-84.3.2 Objectives .......................................................................................4-8

4.3.2.1 IEC 61131-3 Software Model .......................................4-84.3.2.2 Control Builder Pro – Software Model .........................4-94.3.2.3 IEC 61131-3: Common Elements (5)............................4-94.3.2.4 IEC 61131-3 Standard Functions ................................4-104.3.2.5 IEC 61131-3 Standard Functions Blocks ....................4-104.3.2.6 POU = Program Organization Unit .............................4-104.3.2.7 The Essence of Compliancy ........................................4-114.3.2.8 Compliancy: Portability Level ....................................4-114.3.2.9 TC3: PLCopen Compliancy Levels.............................4-11

Page 42: 530

Course T530

4-ii 3BSE 022 841/B

4.4 Lesson 3 – ABB Extensions and Simplifications of IEC 61131-3............. 4-124.4.1 Description................................................................................... 4-124.4.2 Objectives..................................................................................... 4-124.4.3 Configuration ............................................................................... 4-124.4.4 Program Organization Units (POU)............................................. 4-12

4.4.4.1 Applications................................................................ 4-124.4.4.2 Control Modules ......................................................... 4-12

4.4.5 Task Connections......................................................................... 4-134.4.5.1 Task Connections to Function Blocks ........................ 4-134.4.5.2 Task Connections to Control Modules ....................... 4-13

4.4.6 Project Constants.......................................................................... 4-13

Page 43: 530

Course T530

3BSE 022 841/B 4-1

Chapter 4 The IEC 61131-3 Concept and ABB Extensions

4.1 General Information

4.1.1 Description

This chapter contains the IEC 61131-3 standard and extensions and simplifications of this standard implemented by ABB in Control Builder.

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.3 Reference Documentation

www.plcopen.org

Online Manual: IEC 61131-3 Control Languages

Page 44: 530

Course T530Chapter 4 The IEC 61131-3 Concept and ABB Extensions

4-2 3BSE 022 841/B

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.3 IEC 61131-3 – Overview

The 5 parts of the IEC 61131 Standard

1 General overview, definitions IS, International Standard

2 Hardware IS

3 Programming Languages IS

4 User Guidelines

5 Messaging Service Specification

Page 45: 530

Course T530

3BSE 022 841/B 4-3

4.2.3.1 The IEC 61131-3 Standard

Programming Languages

Common Elements

4.2.3.2 The 5 Languages of IEC 61131-3

Instruction List

LD A

ANDN B

ST C

Function Block Diagram

A C

B

C:= A AND NOT B;

Structured Text

A B C

-| |--|/|----------------( )

Ladder Diagram

Step 1 N FILL

Step 3

Step 2 S Empty

Transition 1

Transition 2

Sequential Function Chart

AND

Page 46: 530

Course T530Chapter 4 The IEC 61131-3 Concept and ABB Extensions

4-4 3BSE 022 841/B

4.2.3.3 Instruction List (IL)

Single Accumulator based execution model

Based upon the German ‘Anweisungsliste’, AWL

One operation such as storing a value in the accumulator register, is allowed per line

LD A

ANDN B

ST C

4.2.3.4 Structured Text (ST)

High level language, block structured

Syntax resembles PASCAL

Complex statements and nested instructions possible

Support for

Iteration loops (REPEAT-UNTIL; WHILE-DO)

Conditional execution (IF-THEN-ELSE; CASE)

Functions (SQRT(), SIN())

C:=A AND NOT B;

Page 47: 530

Course T530

3BSE 022 841/B 4-5

4.2.3.5 Ladder Diagram (LD)

Standardised, rationalised set of relay ladder programming symbols

Based on well-known North American style of programming, resembling US-type of electrical drawing standard

A B C

| |---|/|--------------( )

4.2.3.6 Function Block Diagram (FBD)

Graphical language, widely used in Europe

Allows program elements which appear as blocks to be "wired" together in a form analogous to a circuit diagram

Used in many applications that involve the flow of information or data between control components

A C

B

chemistry

AND

4.2.3.7 Sequential Function Chart, SFC

Powerful graphical technique for describing the sequential behaviour of a control program

Used to partition a control problem

Shows overview, also suitable for rapid diagnostics

The basic elements are STEPS with ACTION BLOCKS and TRANSITIONS

Support for alternative and parallel sequences

Step 1 N FILL

Step 3

Step 2 S Empty

Transition 1

Transition 2

Page 48: 530

Course T530Chapter 4 The IEC 61131-3 Concept and ABB Extensions

4-6 3BSE 022 841/B

4.2.3.8 The IEC 61131-3 Standard

Programming Languages

Common Elements

4.2.3.9 IEC 61131-3: Common Elements

COMMON ELEMENTSa.o.

Data Types & Variables

• Symbolic representation via labels

• Restricted area for I/O mapping

• Hardware independent of code

What is this?

01010101 10101010

4.2.3.10 IEC 61131-3: Common Elements (2)

COMMON ELEMENTSa.o.

Data Types & Variables

such as:BOOLBYTEINTEGERREALDATETIME_OF_DAYSTRING

Page 49: 530

Course T530

3BSE 022 841/B 4-7

4.2.3.11 IEC 61131-3 Standard Datatypes

Bit string types (BOOL, BYTE, WORD, DWORD, LWORD)

Integer types (SINT, INT, DINT, LINT)

Unsigned integer types (USINT, UINT, UDINT, ULINT)

Real types (REAL, LREAL)

Time types (TIME, DATE, TIME_OF_DAY, DATE_AND_TIME)

Character types (STRING)

Vendor and user defined data types are possible

Direct derived, subrange, enumeration

Array, structure

Page 50: 530

Course T530Chapter 4 The IEC 61131-3 Concept and ABB Extensions

4-8 3BSE 022 841/B

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.3.2.1 IEC 61131-3 Software Model

Global and direct variables

Access path

Executioncontrol path

Variableaccess path

FBTask

Program Program

FB FB

Task

Program

Task

Program

FB FB

Task

Resource Resource

Configuration

Communication Function

FunctionBlock

Variable

Page 51: 530

Course T530

3BSE 022 841/B 4-9

4.3.2.2 Control Builder M Professional – Software Model

Global variables

Access path

Executioncontrol path

Variableaccess path

FBTask

Program Program

FB FB

Task

Application

Communication Function

FunctionBlock

VariableProgram

FB FB

Task . . . 16

. . . 64

4.3.2.3 IEC 61131-3: Common Elements (5)

COMMON ELEMENTSa.o.

Data Types & Variables

Configuration, Resources, Tasks

Programming Organization Units

* Functions

* Function Blocks

* Programs

Page 52: 530

Course T530Chapter 4 The IEC 61131-3 Concept and ABB Extensions

4-10 3BSE 022 841/B

4.3.2.4 IEC 61131-3 Standard Functions

Bit string functions (AND, OR, XOR, NOT, SHL, SHR, ROL, ROR)

Numerical functions (ADD, SUB, MUL, DIV, MOD, EXPT, ABS, SQRT, LN, LOG, EXP, SIN, COS, TAN, ASIN, ACOS, ATAN)

Type conversions (e.g. USINT_TO_DINT, BOOL_TO_BYTE)

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)

Vendor and user defined functions are possible

4.3.2.5 IEC 61131-3 Standard Functions Blocks

Bistables (SR, RS, SEMA)

Edge detection (R_TRIG, F_TRIG)

Counters (CTU, CTD, CTUD)

Timers (TP, TON, TOF, RTC)

Vendor and user defined function blocks are possible.

4.3.2.6 POU = Program Organization Unit

POU’s enable re-use of software from macro level (Programs) to micro level (FB and Functions). A POU consists of a header (variable declaration) and the body (instructions).

POU Type Replicated as: Comments

Program Program instance Main program

Function Block FB instance Subroutine with own memory, several in- and outputs possible

Function Function Subroutine without memory only one output possible

Page 53: 530

Course T530

3BSE 022 841/B 4-11

4.3.2.7 The Essence of Compliancy

Without testing there is no standard

The IEC 61131 standard gives only basic rules for compliancy

Certification gives guidance for users towards real IEC 61131-3 programming systems (e.g. PLCopen certified list shows compliant products)

4.3.2.8 Compliancy: Portability Level

Definition Portability Level

Portability Level provides the exchange of Functions and Function Blocks between programming systems of different manufacturers, with the same functionality to the user.

NB. this is NOT a part of IEC 61131-3

4.3.2.9 TC3: PLCopen Compliancy Levels

ApplicationProgram

FBFB

Variable

CodeBody

FB

Variable

CodeBody

ApplicationProgram

FBFB

Variable

CodeBody

FB

Variable

CodeBody

Full ComplianceLevel

Portability ofapplications

Portability LevelPortability of Function (Block)

libraries

Base LevelPortability of minimal systems

Page 54: 530

Course T530Chapter 4 The IEC 61131-3 Concept and ABB Extensions

4-12 3BSE 022 841/B

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.4.4 Program Organization Units (POU)

4.4.4.1 Applications

An Application is a code container replacing the combination of Configuration and Resource of the IEC 61131 Software model. There is however, no direct correlation between an application and a controller. An application can contain Programs and Control Modules and these can be downloaded to different controllers independently.

4.4.4.1.1 Variables in the Application Editor

To handle communication between top level Control Modules, it is possible to declare variables in the application editor. These variables only serve the Control Modules, i.e. they are not used for communicating between programs. Use Global Variables for this.

4.4.4.2 Control Modules

Control Modules are code containers replacing both first level (Programs) and second level units (Function blocks) of the IEC software model. Control Modules display several improvements compared to IEC POU:s , e.g. code sorting and a graphical interface. Control Modules will be discussed in detail in chapter 17.

Page 55: 530

Course T530

3BSE 022 841/B 4-13

4.4.5 Task Connections

4.4.5.1 Task Connections to Function Blocks

Function blocks within function blocks can be connected to tasks independent of the task of the program or of the first level function block. This is an extension to the IEC standard, which requires individual connections only for first level function blocks.

4.4.5.2 Task Connections to Control Modules

Control Modules at any depth can be individually task-connected.

4.4.6 Project Constants

Project Constants are extensions to the standard. The standard requires the possibility to lock the value of variables by declaring them as constants. Project Constants are discussed in chapter 6.

Page 56: 530

Course T530Chapter 4 The IEC 61131-3 Concept and ABB Extensions

4-14 3BSE 022 841/B

Page 57: 530

Course T530

3BSE 022 842/D 5-i

Chapter 5 Getting Started

TABLE OF CONTENTS

Chapter 5 Getting Started ........................................................................................5-15.1 General Information......................................................................................5-1

5.1.1 Description......................................................................................5-15.1.2 Objectives .......................................................................................5-15.1.3 Reference Documentation...............................................................5-1

5.2 Lesson 1 – Starting a Project.........................................................................5-25.2.1 Description......................................................................................5-25.2.2 Objectives .......................................................................................5-25.2.3 Installation ......................................................................................5-2

5.2.3.1 Release Notes ................................................................5-25.2.3.2 Control Builder Software ..............................................5-25.2.3.3 Languages and License..................................................5-2

5.2.4 Start of the Control Builder ............................................................5-35.2.4.1 Open a Project ...............................................................5-35.2.4.2 Creating a New Project and Selecting the Template .....5-3

5.2.5 Overview – the Project Explorer ....................................................5-35.2.5.1 The Structure .................................................................5-45.2.5.2 Toolbar Buttons.............................................................5-55.2.5.3 Project Tree ...................................................................5-65.2.5.4 Lower Pane....................................................................5-8

5.3 Exercise 5.1 – Project Explorer.....................................................................5-85.4 Lesson 2 – The POU Editor ..........................................................................5-9

5.4.1 Description......................................................................................5-95.4.2 Objectives .......................................................................................5-95.4.3 The POU Editor ..............................................................................5-95.4.4 Opening the POU Editor...............................................................5-10

5.4.4.1 Toolbar Icons...............................................................5-115.4.5 Variable Declaration Pane ............................................................5-11

5.4.5.1 Variables......................................................................5-115.4.5.2 Function Blocks...........................................................5-12

5.4.6 Message Pane................................................................................5-125.4.6.1 Description ..................................................................5-125.4.6.2 Check...........................................................................5-125.4.6.3 Find in Editor...............................................................5-12

Page 58: 530

Course T530

5-ii 3BSE 022 842/D

5.4.7 Code Pane .................................................................................... 5-135.4.7.1 Changing the Language .............................................. 5-135.4.7.2 Inserting Code Blocks................................................. 5-135.4.7.3 Arranging Code Blocks .............................................. 5-135.4.7.4 Deleting Code Blocks ................................................. 5-135.4.7.5 Selecting Code Blocks................................................ 5-135.4.7.6 Renaming Code Blocks .............................................. 5-14

5.5 Checking, Applying and Saving the Program............................................ 5-145.5.1 Error Messages............................................................................. 5-14

5.6 Exercise 5.2 – Inserting and Arranging Code Blocks ................................ 5-145.7 Lesson 3 – Simulation and On-line Help ................................................... 5-15

5.7.1 Description................................................................................... 5-155.7.2 Objectives..................................................................................... 5-155.7.3 Simulation .................................................................................... 5-15

5.7.3.1 Error Messages ........................................................... 5-155.7.4 On-line Help................................................................................. 5-15

5.7.4.1 Help Topics................................................................. 5-155.7.4.2 Help About the Project Explorer ................................ 5-165.7.4.3 Manuals ...................................................................... 5-165.7.4.4 About Control Builder M Professional....................... 5-16

5.8 Exercise 5.3 – The Online Help System..................................................... 5-165.9 Exercise 5.4 – Simulation of a Project ....................................................... 5-16

Page 59: 530

Course T530

3BSE 022 842/D 5-1

Chapter 5 Getting Started

5.1 General Information

5.1.1 Description

This chapter introduces the configuration of Control Builder.

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.3 Reference Documentation

In the Online help: Contents tab, System Introduction.

In the Online help: Contents tab, Project Explorer.

In the Online help: Contents tab, Application Programming.

Page 60: 530

Course T530Chapter 5 Getting Started

5-2 3BSE 022 842/D

5.2 Lesson 1 – Starting a Project

5.2.1 Description

This lesson contains information about how to start a project.

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.

5.2.3.1 Release Notes

It is possible to read the Release Notes located on the CD before you install the programs on your computer.

5.2.3.2 Control Builder Software

It is necessary to install:

Control Builder M Professional

Updated help files. These files should be manually copied from the CD to the installation folder. Read the instructions on the CD if more information is needed.

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.

5.2.3.3 Languages and License

You can change the language used in the menus of the Control Builder, by using the Setup Wizard. You will find the Setup Wizard by selecting Start > ABB Industrial IT> Engineer IT > Control Builder M Professional 3.1 > Setup Wizard from the desktop of your computer.

Page 61: 530

Course T530

3BSE 022 842/D 5-3

5.2.4 Start Control Builder M Professional

You start Control Builder M Professional from the start menu of Windows (Start > ABB Industrial IT > Engineer IT > Control Builder M Professional 3.1 > Control Builder M Professional 3.1). It is also possible to use the short cut on the desktop.

5.2.4.1 Open a Project

Select File > Open Project from the menu of the Project Explorer. You can find Tutorials at C:\Program Files\ABB Industrial IT\ Engineer IT > Control Builder M Professional 3.1\Examples.

Any projects you have created yourself are located at C:\ABB Industrial IT Data\Engineer IT Data\Control Builder M Professional 3.1\Projects\.

5.2.4.2 Creating a New Project and Selecting the Template

Select File >New project from the menu of the Project Explorer. Select a suitable template (the Controller you intend to use) and give your project a name. You can accept the suggested storage location for the project or choose another file path.

5.2.5 Overview – the Project Explorer

The Project Explorer is a separate window with a menu bar and a Toolbar. The window is split into two separate viewing areas (panes). In the upper pane, the project is displayed in a tree view control with folders and in the lower pane there are three tab controls for Description, Check and Message.

The Project Explorer is a tool you can use to create, modify and navigate in a project. You can select all objects such as data types, functions and function block types and display them in an editor. The software and hardware is configured in the Project Explorer.

For general window information about the Project Explorer, the drop-down menu entries and the toolbar commands, look in the on-line help.

Page 62: 530

Course T530Chapter 5 Getting Started

5-4 3BSE 022 842/D

5.2.5.1 The Structure

Page 63: 530

Course T530

3BSE 022 842/D 5-5

5.2.5.2 Toolbar Buttons

The menu bar includes a set of entries, which provide access to drop-down menus. The Toolbar provides quick access to frequently used commands or options.

Toolbar icon Menu item Hot-key Description

File > New Project

Ctrl + N Use this button to create a new project.

File > Open Project

Ctrl + O Use this button to open an existing project.

File > Save Project

Ctrl + S Use this button to save the project to file.

Tools > Simulate Project

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.

Tools > Online F5 Use this button to connect to the controller, e.g., if you want to debug the program code in running mode.

Tools > Stop Simulate

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.

Tools > Download Project and Go Online

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.

Help Topics Use this button to enter the online help.

Page 64: 530

Course T530Chapter 5 Getting Started

5-6 3BSE 022 842/D

5.2.5.3 Project Tree

The project is displayed in a tree view control with the contents indented in an outline based on their logical hierarchical relationship. The objects in the Project Explorer are each represented by a name and an icon. By clicking on the button with a plus or minus sign beside the folder, you can expand or collapse an icon and the corresponding container.

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.

Page 65: 530

Course T530

3BSE 022 842/D 5-7

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.

Page 66: 530

Course T530Chapter 5 Getting Started

5-8 3BSE 022 842/D

5.2.5.4 Lower Pane

The Lower pane consists of three tabs: Description, Check and Message.

5.2.5.4.1 Description Tab

A description, written in the editor (e.g. the program editor), of the selected object in the tree view control is displayed in the Description tab.

5.2.5.4.2 Check Pane

A check of a selected object, e.g., an Application and its contents is performed when you select Check in the pop-up menu (click with the right mouse button). If any errors are found, they are displayed in the Check pane. Double-click on an error to locate the exact position of the error in an editor (or select Editor in the pop-up menu). If Go to Error in Project Explorer is selected, the POU containing the error is marked in the Project Explorer.

5.2.5.4.3 Message Tab

The Message tab displays system activity messages, e.g., going from offline to online mode and opening files.

5.3 Exercise 5.1 – Project Explorer

Please do exercise 5.1

Page 67: 530

Course T530

3BSE 022 842/D 5-9

5.4 Lesson 2 – The POU Editor

5.4.1 Description

This lesson contains information about the POU Editor.

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.4.3 The POU Editor

The IEC 61131 standard describes Programs, Function Blocks and Functions as Program Organization Units or POUs. These units help you organize your automation project into code blocks to minimize code writing and optimize the code structure and code maintenance. The Function Blocks and Functions POUs are not limited to "one-time-use". You can use them repeatedly and in a recursive structure. In addition to these two POUs, you have the Program. Although the program is the only POU that cannot be reused in any of the other POUss it is defined as a POU. The figures below describe the hierarchical structure of the POUs. As you can see, you can use both the Function Block and the Control Module recursively to an unlimited depth whereas the program or Control Module is a "top-level" POU. The Application contains the program code that is to be compiled and downloaded for execution in the controller.

Page 68: 530

Course T530Chapter 5 Getting Started

5-10 3BSE 022 842/D

5.4.4 Opening the POU Editor

You open the POU editor by double clicking on it. The POU editors of Program, Function Blocks and Control Modules have basically the same look and functionality. This chapter will explain the functions and functionality of a Program, for more details about Control Modules and Function Blocks see the chapters about Functions and Function Blocks and Control Modules. The figure below shows the POU editor of a Program.

Page 69: 530

Course T530

3BSE 022 842/D 5-11

5.4.4.1 Toolbar Icons

The tables below describe menu commands, toolbar icons and keyboard short cuts common to all editors. Editor-specific functions are described in the chapter of respective editors.

Toolbar icon

Keyboard hot key

Description

Ctrl + U 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.

Ctrl + W Same as Apply and close except it does not close the editor.

Ctrl + B 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+J Insert Variable, Type Attribute.

5.4.5 Variable Declaration Pane

You can use the declaration pane to declare variables, parameters, Function Blocks and Data Type components. Depending on which editor you use, different declaration grids can be displayed by selecting the tabs at the bottom of the declaration pane. The figure below shows the declaration pane for a program. More information about the different columns can be found in the next chapter Variables and Data types.

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.

Page 70: 530

Course T530Chapter 5 Getting Started

5-12 3BSE 022 842/D

5.4.5.1.1 Using Excel

It is possible to write variables in Microsoft Excel and the use the copy and paste function to move the variables to the declaration pane of the POU editor.

5.4.5.2 Function Blocks

Function Blocks must be declared in the Function Blocks tab before they are used in the ST or IL langauges (Not necessary in the FBD and LD editor).

5.4.6 Message Pane

The message pane consists of three tabs: Description, Check and Find in editor.

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.4.6.3 Find in Editor

When you search for text strings, the result of the search is displayed in this pane. Double-click on a line in this report to go quickly to the place the line references.

Page 71: 530

Course T530

3BSE 022 842/D 5-13

5.4.7 Code Pane

The code pane is divided into code blocks. Each tab contains a code block in one of the different programming languages.

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, CodeBlock2and 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.4.7.1 Changing the Language

Right click on the tab of a code block and select Change Language… to change language on a code block.

5.4.7.2 Inserting Code Blocks

Right click on the tab of a code block and select Insert… to insert a code block.

5.4.7.3 Arranging Code Blocks

Right click on the tab of a code block and select Arrange… to arrange the code blocks.

5.4.7.4 Deleting Code Blocks

Right click on the tab of a code block and select Delete to delete a code block.

5.4.7.5 Selecting Code Blocks

Right click on the tab of a code block and select Select… to select a code block from the pop up window.

Page 72: 530

Course T530Chapter 5 Getting Started

5-14 3BSE 022 842/D

5.4.7.6 Renaming Code Blocks

Right click on the tab of a code block and select Rename… to change name on the

code block.

5.5 Checking, Applying and Saving the Program

Use this button to check and then this button to save the program, the

window is saved and closed with this button .

5.5.1 Error Messages

If, following a check, there is an error in your program, an error message is written in the Check tab in the message pane of the POU Editor. The error message below says that the variable Start in the code block FBD_Code is not declared.

5.6 Exercise 5.2 – Inserting and Arranging Code Blocks

Please do exercise 5.2

Page 73: 530

Course T530

3BSE 022 842/D 5-15

5.7 Lesson 3 – Simulation and On-line Help

5.7.1 Description

This lesson contains information about how to simulate and test a project and use On-line Help.

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.7.3.1 Error Messages

If there are errors in the project when you try to simulate it, an error message is written in the Message tab of the Project Explorer.

5.7.4 On-line Help

There is a powerful online help in the Control Builder. Start the help with the help icon or select Help >Help Topics from the menu. If you select Help> Manuals you get access to data sheets and manuals.

5.7.4.1 Help Topics

The Help Topics dialog box enables you to locate topics in the help files by using the table of contents (Contents tab), by selecting keywords that are assigned to topics (Index tab), or by searching for any words within the file (Find tab). To call the system's online help, use the Help menu, which is available in the Project Explorer and the editors. You can also press < F1 >, which provide context sensitive help on the item currently selected.

Page 74: 530

Course T530Chapter 5 Getting Started

5-16 3BSE 022 842/D

5.7.4.2 Help About the Project Explorer

This menu entry brings the Introduction help topic of the Project Explorer.

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.7.4.4 About Control Builder M Professional

Displays system information such as System Identity (IP address) and which version of Control Builder you are running.

5.7.4.4.1 License Information

Displays information about the licence.

5.7.4.4.2 List All Information

Displays information about language, system identity, libraries etc.

5.8 Exercise 5.3 – The Online Help System

Please do exercise 5.3

5.9 Exercise 5.4 – Simulation of a Project

Please do exercise 5.4

Page 75: 530

Course T530

3BSE 022 843/B 5-1

Exercises 5 Getting Started

5.1 Getting Started – Exercise 5.1

5.1.1 Description

This exercise introduces the navigation in the Project Explorer.

5.1.2 Objectives

After this exercise you will be able to:

Navigate in the Project Explorer.

Open existing projects.

5.1.3 Reference Documentation

In the Online Help: Contents tab, Project Explorer.

5.1.4 Missions

5.1.4.1 Open a Project

Start Control Builder Professional and open the project Oslo_FB.

…………………………………………………………………………………….

Page 76: 530

Course T530Exercises 5 Getting Started

5-2 3BSE 022 843/B

5.1.4.2 Explore Library

Expand the Libraries icon in the project tree.

Which Function Block types are defined in the library OsloLib ?

…………………………………………………………………………………….

…………………………………………………………………………………….

Which Data Types are defined in the library OsloLib ?

…………………………………………………………………………………….

…………………………………………………………………………………….

5.1.4.3 Explore the Application

Expand: Applications > ApplicationOslo in the Project tree.

Which Function Block types are defined in the ApplicationOslo?

…………………………………………………………………………………….

Which Data Types are declared in the ApplicationOslo?

…………………………………………………………………………………….

Page 77: 530

Course T530

3BSE 022 843/B 5-3

5.1.4.4 Explore the Controllers in the Project

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?

…………………………………………………………………………………….

Page 78: 530

Course T530Exercises 5 Getting Started

5-4 3BSE 022 843/B

5.1.5 Solutions – Exercise 5.1

5.1.5.1 Solution : Open a Project

1. From Windows desktop, use the Control Builder Professional icon.

2. Select File > Open Project… from the menu of the Project Explorer.

3. Open folder Oslo_FB and open file Oslo_FB.prj

5.1.5.2 Solution: Explore Library

1. Expand the project tree by clicking on the plus icon in front of Libraries

Expand OsloLib and the Function Block types.

The following Function Block types are defined:

AnalogValve

Cooler

Heater

Mixer

Tank

Valve

ValveGroup

2. Expand the Data Types.

The following Data Types are defined:

TankType

5.1.5.3 Solution: Explore the Application

The following Function Block Types are defined:

CourseFB

The following Data Types are defined:

CourseDataType

Page 79: 530

Course T530

3BSE 022 843/B 5-5

5.1.5.4 Solution: Explore the Controllers in the Project

The type of the controller is AC 800M and the name is Controller_1.

There are 3 Tasks defined.

The name of the application running in the controller is ApplicationOslo.

Page 80: 530

Course T530Exercises 5 Getting Started

5-6 3BSE 022 843/B

5.2 Getting Started – Exercise 5.2

5.2.1 Description

This exercise introduces how to handle Code Blocks.

5.2.2 Objectives

After this exercise you will be able to:

Open the POU Editor.

Arranging Code Blocks.

Rename Code Blocks.

5.2.3 Reference Documentation

In the Online Help: Contents tab, Application Programming > Code Blocks.

5.2.4 Missions

5.2.4.1 Arranging 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?

…………………………………………………………………………………….

Page 81: 530

Course T530

3BSE 022 843/B 5-7

5.2.4.2 Rename Code Blocks

Rename the code blocks according to the information in the Description Tab in Program2 and save the project.

…………………………………………………………………………………….

…………………………………………………………………………………….

Page 82: 530

Course T530Exercises 5 Getting Started

5-8 3BSE 022 843/B

5.2.5 Solutions – Exercise 5.2

5.2.5.1 Solution: Arranging Code Blocks

1. In the Project Tree, Double-click on Program2

Right-click on a Code Tab and select Arrange…

2. To save the project, use the save icon in the Project window

3. The execution order is changed when the Code Blocks are reorganized.

5.2.5.2 Solution: Renaming Code Blocks

Double-click on Program2 in the project tree.

Click on the button in the toolbar of the POU editor to display the Message Pain.

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

Page 83: 530

Course T530

3BSE 022 843/B 5-9

5.3 Getting Started – Exercise 5.3

5.3.1 Description

This exercise shows how to use the Online Help system.

5.3.2 Objectives

After this exercise you will be able to:

Find information in the Online Help system.

5.3.3 Reference Documentation

In the Online Help: Contents Tab, System Introduction > Online Help.

5.3.4 Missions

Find information in the Online Help about:

5.3.4.1 About Icons in the Help

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.

…………………………………………………………………………………….

5.3.4.2 About Simulation

Read in the Online help about Simulation.

Select Index tab, type Simulation in the key word field.Select Simulation Process Objects.

…………………………………………………………………………………….

Page 84: 530

Course T530Exercises 5 Getting Started

5-10 3BSE 022 843/B

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.

…………………………………………………………………………………….

Page 85: 530

Course T530

3BSE 022 843/B 5-11

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.2 Solution: About Simulation

Select Index tab, type Simulation in the key word field.Select Simulation Process Objects.

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.

Page 86: 530

Course T530Exercises 5 Getting Started

5-12 3BSE 022 843/B

5.4 Getting Started – Exercise 5.4

5.4.1 Description

This exercise shows how to simulate a project.

The used project is filling and emptying a tank in a sequence.

For this and following exercises the OSLO PROCESS is used.

The training equipment is described in Chapter 3.

5.4.2 Objectives

After this exercise you will be able to:

Simulate a project.

Run a tutorial.

5.4.3 Reference Documentation

The training equipment is described in Chapter 3.

About simulation, in the Online Help: Contents Tab, Project Explorer > General > Tools Drop Down Menu.

5.4.4 Missions

5.4.4.1 Start Simulation of a Project

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 thevariable Start from False to True.

3. Reset the Start variable when the process has started.

Page 87: 530

Course T530

3BSE 022 843/B 5-13

5.4.4.2 Describe the Process

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?

…………………………………………………………………………………….

At what level does the Drain stop?

…………………………………………………………………………………….

Page 88: 530

Course T530Exercises 5 Getting Started

5-14 3BSE 022 843/B

5.4.5 Solutions – Exercise 5.4

5.4.5.1 Solution: Start Simulation of a Project

1. Select Tools > Simulate Project or use the Simulate icon

2. Open Program2 and look for the variable Start.(You must be in simulation mode).

3. Start the process sequence by changing the value of thevariable Start from False to True.

4. Reset the Start variable when the process has started.

5.4.5.2 Solution: Describe the Process

The process is executed in a sequential order, with the following steps:

Init

Fill

Heat

Mix

Cool

Drain

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

Page 89: 530

Course T530

3BSE 022 844/D 6-i

Chapter 6 Variables and Data Types

TABLE OF CONTENTS

Chapter 6 Variables and Data Types ......................................................................6-16.1 General Information......................................................................................6-1

6.1.1 Description......................................................................................6-16.1.2 Objectives .......................................................................................6-16.1.3 Reference Documentation...............................................................6-1

6.2 Lesson 1 – Declaration of Variables .............................................................6-26.2.1 Description......................................................................................6-26.2.2 Objectives .......................................................................................6-26.2.3 General............................................................................................6-2

6.2.3.1 Why Variables and Data Types? ...................................6-26.2.3.2 Simple Data Types ........................................................6-36.2.3.3 Key Words.....................................................................6-3

6.2.4 Declaring Variables in POU ...........................................................6-36.2.4.1 Name .............................................................................6-36.2.4.2 Data Type ......................................................................6-46.2.4.3 Attributes.......................................................................6-46.2.4.4 Initial Value...................................................................6-46.2.4.5 I/O-address ....................................................................6-46.2.4.6 Access Variables ...........................................................6-56.2.4.7 Description ....................................................................6-5

6.2.5 Data Exchange Between Programs Using Global Variables ..........6-56.2.5.1 The ABB Implementation of External Variables ..........6-5

6.2.6 Data Exchange Between Controllers Using Access Variables .......6-56.3 Exercise 6.1 – Declaration of Variables........................................................6-56.4 Lesson 2 – Data Types ..................................................................................6-6

6.4.1 Description......................................................................................6-66.4.2 Objectives .......................................................................................6-66.4.3 Structured Data Types ....................................................................6-66.4.4 Defining User Defined Structured Data Types...............................6-7

6.4.4.1 Components...................................................................6-76.4.4.2 Dot Notation ..................................................................6-86.4.4.3 Project Constants...........................................................6-8

6.5 Exercise 6.2 – User Defined Structured Data Types.....................................6-8

Page 90: 530

Course T530

6-ii 3BSE 022 844/D

Page 91: 530

Course T530

3BSE 022 844/D 6-1

Chapter 6 Variables and Data Types

6.1 General Information

6.1.1 Description

This chapter contains facts about variables and data types.

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.3 Reference Documentation

In the Online help: Index tab, write data type in the key word field.

Page 92: 530

Course T530Chapter 6 Variables and Data Types

6-2 3BSE 022 844/D

6.2 Lesson 1 – Declaration of Variables

6.2.1 Description

This lesson contains facts about variables.

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.3.1 Why Variables and Data Types?

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. Below is an example of variable declarations.

Page 93: 530

Course T530

3BSE 022 844/D 6-3

6.2.3.2 Simple Data Types

Simple data types are primarily grouped into five categories: numerical, date and time, string, bit string (like bool) and structured data types. Each category can then be subdivided into sub ordinary categories such as numerals (int and real). These can then be subdivided into subordinated items like dint, uint etc. In the table below you will find a table containing some of the predefined data types.

Data type Description Bits Initial value

bool Boolean 1 False, 0

Dint double integer 32 0

Int Integer 16 0

Uint Unsigned integer 16 0

String Character string * ‘’

Word Bit string 16 0

DWord Bit string 32 0

Time Duration T#0s

Date_And_Time Date and time of day 1979-12-31-00:00:00

Real Real number 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.3.3 Key Words

Key words are words that are reserved by the system. For example true is used to indicate a boolean status or if an event is true. Key words can not be used for anything else than the purpose for which they are reserved. If you use a key word incorrectly an error message will be given. You may not use key words as names of variables.

6.2.4 Declaring Variables in POU

The variables used in the POU editor should be declared in the Variables tab of the declaration pane.

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.

Page 94: 530

Course T530Chapter 6 Variables and Data Types

6-4 3BSE 022 844/D

6.2.4.2 Data Type

Press < Ctrl J > in the Data Type column, to find a suitable Data Type depending on the operation that should be done

6.2.4.3 Attributes

The following attribute can be given to a variable:

Name Description

No attribute

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)

retainThe 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.

coldretainThe value of the variable is maintained after a warm or cold restart.

This attribute overrides the retain attributes in a structured data type.

constant

You cannot change the value of the variable once given.

This attribute overrides the coldretain and retain attributes in a structured data type.

hiddenThe variable will not be visible to the OPC server, and therefore not available in the HMI system.

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.4 Initial Value

At the declaration of a basic Data Type variable, you can give the variable an initial value that is assigned to the variable when the application is executed. This setting overrides the default value that would have been used if no initial value were specified. In the table under the header Simple Data Types are some default initial values to the most common data types presented.

6.2.4.4.1 Initial Values at Reboot

If the variable does not have the attribute retain, its value is reset to its initial value at warm boot. At cold boot the value of the variable is set to its initial value, if such a value is given. Otherwise the value of the variable is set to the default value of the data type.

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.

Page 95: 530

Course T530

3BSE 022 844/D 6-5

6.2.4.6 Access Variables

Variables that are to be accessed from another Application must be declared in the Access Variable Editor. This is described in detail in chapter 21, “Communication”. In the POU editor, the Access Variable field is not editable. However, the Access variable editor can be reached by right clicking on the variable and selecting Edit Access Variable.

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.2.5 Data Exchange Between Programs Using Global Variables

Variables that are NOT declared in the declaration pane in the program editor are assumed to be global variables. Global variables are declared in the Global Variables tab of the Application editor, and can be accessed directly without any declaration in the program editor. A global variable can be used in any program, function block or control module within the application where it is declared.

6.2.5.1 The ABB Implementation of External Variables

Described in IEC 61131-3.

If global variables are to be used inside function block types or control modules, they must be declared as external variables in the function block type editor or control module editor.

External variables do not have to be declared in programs. Instead a global variable declared in the Application can be directly accessed from the program.

6.2.6 Data Exchange Between Controllers Using Access Variables

If Controllers should be able to read or write a variable in another Application, the Controller that owns the variable has to share it on the network. Declaring an access path to the variable in the Controller that owns the variable does this sharing.

6.3 Exercise 6.1 – Declaration of Variables

Please do exercise 6.1

Page 96: 530

Course T530Chapter 6 Variables and Data Types

6-6 3BSE 022 844/D

6.4 Lesson 2 – Data Types

6.4.1 Description

This lesson contains facts about data types

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.

6.4.3 Structured Data Types

Structured data types are data types with components of simple or structured data types. This concept is best explained through an example: Given a tank in a factory, the tank has the following characteristics:

Full, i.e., if the tank is full or not.

The volume of fluid (measured in cubic meters).

The temperature of the fluid (measured in Kelvin).

The minimum permitted temperature of the fluid.

The maximum permitted temperature of the fluid (both measured in Kelvin).

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).

Page 97: 530

Course T530

3BSE 022 844/D 6-7

6.4.4 Defining User Defined Structured Data Types

It is possible to create a Data Type in an Application or in a Library. The Data Type can be of a structured type, making nested structured data types possible. The picture below shows the data type editor.

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.2 Data Type

Press < Ctrl+J > in the Data Type column, to find a suitable Data Type depending on the operation that should be done.

6.4.4.1.3 Attributes

Press < Ctrl+J > in the Attribute column, to find a suitable attribute to be assigned.

6.4.4.1.4 Initial Value

You can specify initial values for simple data types only, not for the ‘whole’ structured data type. To assign initial values to a structured data type, specify initial values for the separate components. If the components are also structured, then you must go on to a deeper level until you reach the level where the simple data type is defined. In that respect the initial values are bound to the data type definition and cannot be reset at the declaration of a structured type variable.

Page 98: 530

Course T530Chapter 6 Variables and Data Types

6-8 3BSE 022 844/D

6.4.4.1.5 Description

In the description fields a short description can be written at declaration of the Data Type component.

6.4.4.2 Dot Notation

To get access to the values, you cannot use the tank variable as is, because it is a name for the entire (main) structure. To gain access to the components, use the syntax

<main_identifier>.<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.4.4.3 Project Constants

Use project constants for useful software settings you want to make globally available to libraries and applications. With project constants, you can adapt such settings to an individual project without having to modify any source code or having to introduceparameters passing values to all concerned types.

Project constants are declared at the top level of libraries and projects. They are globally visible, and can be used wherever a constant value is permitted, e.g., in program code and for variable initialization.

Typically, project constants are declared in a library and given default values. They are then used, for example, in code inside function block types. In a project that includes the library, the project constant settings can be overridden by project specific settings, which are kept and saved with the project.

6.4.4.3.1 Defining User Defined Project Constants

You can insert, edit and group project constants in the Project Constant editor. It is possible to define your own Project Constants in a library or project. Select Tools> Project Constants from the menu in the project explorer or right click on the Library (must be a user defined library) and select Project constants. Any project constant declared in a library will be a part of that library. They will however also be incorporated in the main list of project conctants in the Tools>Project Constantsmenu.

6.5 Exercise 6.2 – User Defined Structured Data Types

Please do exercise 6.2

Page 99: 530

Course T530

3BSE 022 845/B 6-1

Exercises 6 Variables and Data Types

6.1 Variables and Data Types – Exercise 6.1

6.1.1 Description

This exercise introduces the declaration of variables.

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.

6.1.3 Reference Documentation

In the Online help: Index tab, write Variables in the key word field.

6.1.4 Missions

6.1.4.1 Create a New Project

Create a New project. Select AC 800M as template.Accept the suggested location.Name the project: CourseProject

……………………………………………………………………………………

Page 100: 530

Course T530Exercises 6 Variables and Data Types

6-2 3BSE 022 845/B

6.1.4.2 Declaration of Variables

Declare the following variables in Program2.

Name Data Type Attributes Initial value

Constant1 dint constant 4

Integer1 dint

Sum dint coldretain

……………………………………………………………………………………

……………………………………………………………………………………

6.1.4.3 Saving the Project

Save the project by using the save icon in the Project Explorer Window.

……………………………………………………………………………………

Page 101: 530

Course T530

3BSE 022 845/B 6-3

6.1.5 Solutions – Exercise 6.1

6.1.5.1 Solution: Create a New Project

1. Select (File > New project) from the menu of the Project Explorer, or use the new

project button .

2. Write like this in the dialog box.

3. Press the OK button

6.1.5.2 Declaration of Variables

1. Expand the Project tree and double click on Program2.

2. Declare variables as shown in the picture below.

3. Use the check button to check for errors.

4. Apply and close the editor of Program2 with this button .

6.1.5.3 Saving the Project

Use the save icon in the Project window

Page 102: 530

Course T530Exercises 6 Variables and Data Types

6-4 3BSE 022 845/B

6.2 Variables and Data Types – Exercise 6.2

6.2.1 Description

This exercise explains how to define user-defined Structured Data Types.

6.2.2 Objectives

After this exercise you will be able to:

Define user-defined Structured Data Types.

6.2.3 Reference Documentation

In the Online help: Index tab, write Data Type in the key word field.

6.2.4 Missions

6.2.4.1 Creating Structured Data Types

Create a new Data Type named Motor_Type in the Application_1 of yourCourseProject

Declare the components Start, Stop and Run of the data type bool.

This data type will be used later on in a student activity.

……………………………………………………………………………………

……………………………………………………………………………………

……………………………………………………………………………………

Page 103: 530

Course T530

3BSE 022 845/B 6-5

6.2.5 Solutions – Exercise 6.2

1. Right click on the Data types icon in the Application_1 and select New Data Type

Write Motor_Type like below in the dialog box.

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.

Page 104: 530

Course T530Exercises 6 Variables and Data Types

6-6 3BSE 022 845/B

This page is intentionally left blank

Page 105: 530

Course T530

3BSE 022 846/C 7-i

Chapter 7 Function Block Diagram (FBD) Language

TABLE OF CONTENTS

Chapter 7 Function Block Diagram (FBD) Language ...........................................7-17.1 General Information......................................................................................7-1

7.1.1 Description......................................................................................7-17.1.2 Objectives .......................................................................................7-17.1.3 Reference Documentation...............................................................7-1

7.2 Lesson 1 - FBD Language.............................................................................7-27.2.1 Description......................................................................................7-27.2.2 Objectives .......................................................................................7-27.2.3 General............................................................................................7-2

7.2.3.1 FBD Pane ......................................................................7-37.2.3.2 Toolbar buttons..............................................................7-4

7.2.4 Insert Function/Function Block ......................................................7-47.2.4.1 The EN input parameter ................................................7-57.2.4.2 Functions in FBD ..........................................................7-57.2.4.3 Edit Parameter Properties..............................................7-6

7.2.5 Connections ....................................................................................7-77.2.5.1 Connection of Variables and Constants ........................7-87.2.5.2 Connection to Previous Selection..................................7-97.2.5.3 Quick connection from one function block to

another ...................................................................7-107.2.6 Comments .....................................................................................7-10

7.2.6.1 Edit Comments of Function Blocks and Functions.....7-107.2.6.2 Edit Page Comments ...................................................7-10

7.2.7 Structure Pane...............................................................................7-107.2.8 Execution Rules ............................................................................7-11

7.3 Exercise 7.1 – Use the FBD Language .......................................................7-117.4 Lesson 2 – The Use of Multiple Pages in FBD Language ..........................7-12

7.4.1 Description....................................................................................7-127.4.2 Objectives .....................................................................................7-127.4.3 Pages .............................................................................................7-12

7.4.3.1 Page Setup ...................................................................7-127.4.3.2 Insert Page Break.........................................................7-137.4.3.3 Page References ..........................................................7-13

7.5 Exercise 7.2 – Using Multiple Pages in the FBD Language.......................7-13

Page 106: 530

Course T530

7-ii 3BSE 022 846/C

Page 107: 530

Course T530

3BSE 022 846/C 7-1

Chapter 7 Function Block Diagram (FBD) Language

7.1 General Information

7.1.1 Description

This chapter describes the use of the programming language FBD.

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.3 Reference Documentation

In the Online Help: Contents tab, Function Block Diagram Editor.

Page 108: 530

Course T530Chapter 7 Function Block Diagram (FBD) Language

7-2 3BSE 022 846/C

7.2 Lesson 1 - FBD Language

7.2.1 Description

This lesson describes how to build a small FBD code block (not using more than one page of code),

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:

Page 109: 530

Course T530

3BSE 022 846/C 7-3

7.2.3.1 FBD Pane

The FBD panes are the right upper and lower sub panes within the code pane if you are working with the FBD editor. They contain the Function Block Diagram of the POU you are programming. The FBD panes contain:

Graphic symbols of function and function block (boxes).

Instance names of the function blocks*.

Comments attached to the function blocks and functions.

Assignment of parameters in form of connection lines between the graphic symbols.

Comment of the page and footer.

*) 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.

Use the FBD panes to:

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

Page 110: 530

Course T530Chapter 7 Function Block Diagram (FBD) Language

7-4 3BSE 022 846/C

7.2.3.2 Toolbar buttons

There is a special toolbar in the Function Block Diagram editor, with shortcuts to many of the commands found in the menu bar (or in the pop-up menus). You can see a brief explanation (tool tip) of each button, if you hold the cursor over the button.

Toolbar button

Menu Command Key Description

Insert > Function/Function Block

Ins Insert new function or function block

Tools > Edit Parameters >Connect

Use this command to assign variables and constants to the selected parameter of a function block or function.

Tools > Edit Parameters >Disconnect

Ctrl + D Use this command to de-assign a variable or constant from the selected parameter of a function block or function.

Tools > Edit Parameters > Invert

Use this command to invert a Boolean input parameter of a function block or function.

7.2.4 Insert Function/Function Block

There are several ways to insert a function/ function block; 1) use the toolbar button

, 2) choose Insert> Function/Functionblock from the POU menu, 3) Use the Insert key or 4) right click in the code pane and choose Insert Function/Function block.

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.

It is also possible to use the Browse button to get an explorer-like overview of all libraries and Applications and their functions and function blocks.

Page 111: 530

Course T530

3BSE 022 846/C 7-5

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.1 The EN input parameter

The EN property for functions and function blocks in FBD makes it possible to write code that corresponds to if statements in the Structured Text language. The figure shows how the EN input can be used to produce an If-Else statement.

The EN parameter should be connected to a boolean variable just as any other boolean parameter. If a function has an EN input, it must be connected.

When the EN input is true, the function or function block will be executed, otherwise not. When the EN input becomes false, all outputs will keep their values from the previous cycle of execution.

The EN parameter can be turned on/off when inserting a new function or function block (see Insert Function/Function Block dialog section), or when editing the parameter properties (see Edit Parameter Properties section).

7.2.4.2 Functions in FBD

The following basic functions corresponding to operators of textual programming languages are available in the FBD language:

7.2.4.2.1 Assignments

Function Description

Move, := Assigns the value (number, logical or string) of the input parameter to the output parameter.

Page 112: 530

Course T530Chapter 7 Function Block Diagram (FBD) Language

7-6 3BSE 022 846/C

7.2.4.2.2 Boolean Operators

Function Description

NOT Negates the Boolean value (1/0, on/off or True/False).

AND, & Boolean AND.

XOR Boolean XOR.

OR, >=1 Boolean OR.

7.2.4.2.3 Arithmetic Operators

Function Description

EXPT, ** Exponential, i.e. raising to the power.

MUL, * Multiplication.

DIV, / Division.

ADD, + Addition.

SUB, - Subtraction.

MOD Modulus.

ABS Absolute value.

7.2.4.2.4 Relational Operators

Function Description

LT, < Less than.

GT, > Greater than.

LE, <= Less than or equal to.

GE, >= Greater than or equal to.

EQ = Equal to.

NE, <> Not equal to.

7.2.4.3 Edit Parameter Properties

By clicking with the right mouse button select a Function (box) of which you want to change the type or size. Select the Edit Parameter Properties command to change the size or type of the function.

Page 113: 530

Course T530

3BSE 022 846/C 7-7

The checkbox activates the Enable parameter which is optional. This is shown in the figure.

And function with/without the Enable parameter.

7.2.4.3.1 Insert Parameters

By clicking with the right mouse button select a parameter (pin) of the function block or function to which you want to add a new parameter (pin). Select the Insertcommand to add a new, last parameter (pin). Note! This is only possible if the function or function block is expandable.

7.2.4.3.2 Delete Parameters

By clicking with the right mouse button select a parameter (pin) of the function block or function to which you want to add a new parameter (pin). Select the Deletecommand to add a new, last parameter (pin).

7.2.4.3.3 Invert

By clicking with the right mouse button select the parameter (pin). Select the Invertcommand 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.)

Page 114: 530

Course T530Chapter 7 Function Block Diagram (FBD) Language

7-8 3BSE 022 846/C

7.2.5.1 Connection of Variables and Constants

There are basically two ways of connecting the parameters (pins) of a function or function block: Either you connect the parameters one-by-one or you connect them all at once.

7.2.5.1.1 Connecting each parameter separately

To connect a variable or a constant to a specific parameter, do as follows:

1. Right click on the parameter (pin) of the function block or function (box) to which you want to assign a variable or a constant and select the Connect command from the context menu.

2. Fill in the To field with a constant value or a variable name. To display a list of all available variables, press Ctrl+J. If you want to connect an OUT parameter to several variables, separate the names with ‘,’ (comma). For example:

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.

Start1,Start2

Page 115: 530

Course T530

3BSE 022 846/C 7-9

7.2.5.1.2 Connecting all parameters

If you want to be able to connect several of the parameters in one action, it is best to bring up the Parameter Connections editor from the context menu. Right click and select Edit Parameter List.

Fill in the name of the variable in the Actual Parameter field. Use the button to get a tree-like overview of the POU and its variables.

7.2.5.2 Connection to Previous Selection

To connect a parameter of a function block to another parameter, select the first parameter by clicking on it with the left mouse button. The selection of the parameter (pin) is shown by highlight. Click on another parameter (pin) that you want to connect to with the right mouse button. By this, you select the second parameter, though the selection of the first one remains, and you open the context menu. Be sure you select

Page 116: 530

Course T530Chapter 7 Function Block Diagram (FBD) Language

7-10 3BSE 022 846/C

one input parameter and one output parameter. Select the Connect to Previous Selection command from the context menu to accomplish the connection.

7.2.5.3 Quick connection from one function block to another

To connect two function block parameters to each other, select one parameter (pin) by clicking on it with the left mouse button. Press the Ctrl key while clicking with the left mouse button on the other parameter (pin) that you want to connect to. Be sure that you select one input parameter and one output parameter.

7.2.6 Comments

It is possible to write comments to functions/function blocks and pages.

7.2.6.1 Edit Comments of Function Blocks and Functions

Select the function block or function to which you want to assign a comment or the comment of which you want to change. Select the Edit Comment… command from the context menu. Edit the comment in the Comment dialog box.

7.2.6.2 Edit Page Comments

If you want to add a comment for a page in FBD, just right click and select Edit Page Comment… from the context menu.

7.2.7 Structure Pane

The structure pane is the left sub pane within the code pane. It contains a list of all function blocks and functions of the current POU.

Use the structure pane to:

Get an overview of the POU.

Select, copy and paste function blocks and functions.

Create, modify and delete function blocks and functions.

Edit instance name of function blocks, edit comments.

Change the pagination and page comments.

Check pagination and repaginate.

Check text of the footer.

Navigate within the program.

Change the order of execution in the FBD code pane.

Page 117: 530

Course T530

3BSE 022 846/C 7-11

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.2.8 Execution Rules

The evaluation of parameter values corresponds to the execution order of the function block and functions within the POU. The execution order of function blocks and functions is defined at first by the order of their creation. The execution order is represented by the order of the graphic symbols (boxes) in FBD "from the left to the right" and "from the top to the bottom". You can change the execution order later by moving the selected function blocks and functions "up" or "down" within the Structure pane. Just drag-and-drop the function block within the structure pane .

7.3 Exercise 7.1 – Use the FBD Language

Please do exercise 7.1

Page 118: 530

Course T530Chapter 7 Function Block Diagram (FBD) Language

7-12 3BSE 022 846/C

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.4.3 Pages

7.4.3.1 Page Setup

It is possible to change the layout of the FBD pane by selecting Tools > Page Layout > Page Setup in the menu bar. The settings in this page determine the page layout of the currently displayed FBD or LD code block. The settings will be remembered by the system even if the editor is closed.

The Template setting determines the page orientation and size.

Page 119: 530

Course T530

3BSE 022 846/C 7-13

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.4.3.2 Insert Page Break

Select the function block or function to which you want to attach a page break. Select the Insert Page Break command from the context menu. The FBD editor inserts the page break above this function block or function and repaginates the Function Block Diagram code block.

7.4.3.3 Page References

By clicking with the right mouse button select a line that connects the pins of function blocks and functions and symbolizes the assignment of variables to parameters. If you have clicked near to an input pin, use the Go To Source command to navigate to the source of the variable that is assigned to the selected parameter.

If you have clicked near to an output pin, use the Go to Sink command to navigate to the parameter(s) to which the selected parameter is assigned. In case of multiple sinks browse with the "<-" and "->" buttons in the Go To Sink dialog box.

7.5 Exercise 7.2 – Using Multiple Pages in the FBD Language

Please do exercise 7.2.

Page 120: 530

Course T530

3BSE 022 847/B 7-1

Exercises 7 Function Block Diagram (FBD) Language

7.1 Use the FBD Language – Exercise 7.1

7.1.1 Description

This exercise describes the use of the programming language FBD.

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.3 Reference Documentation

In the Online Help: Contents tab, Function Block Diagram Editor.

Page 121: 530

Course T530Exercises 7 Function Block Diagram (FBD) Language

7-2 3BSE 022 847/B

7.1.4 Missions

7.1.4.1 Using the FBD Language

Use your CourseProject

1. Open Program2 and change language of thecode block to FBD language.

Write the mathematical expression below, by using the function Add.

Sum = Constant1 + Integer1

2. Save and simulate the project

……………………………………………………………………………………

……………………………………………………………………………………

……………………………………………………………………………………

7.1.4.2 Attributes of Variables

There is something wrong about the attributes of the variables used in the previous exercise. Can you find out what?

……………………………………………………………………………………

……………………………………………………………………………………

……………………………………………………………………………………

Page 122: 530

Course T530

3BSE 022 847/B 7-3

7.1.4.3 Variable Values

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

……………………………………………………………………………………

……………………………………………………………………………………

……………………………………………………………………………………

Page 123: 530

Course T530Exercises 7 Function Block Diagram (FBD) Language

7-4 3BSE 022 847/B

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.

11. Use these icons and to check and close the window.

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.1.5.2 Solution: Attributes of Variables

The value of the variable Sum will be calculated since Integer1 and Constant1 retain their values. The order of the code will be significant.

7.1.5.3 Solution: Variable Values

1. Give the variable Integer1 the attribute coldretain.

2. It is not necessary to have the attribute coldretain on the variable Sum, because a function does not save the output value.

Page 124: 530

Course T530

3BSE 022 847/B 7-5

7.1.5.4 Solution: Motor_Type

1. Declare the variable Motor1 of the data type Motor_Type in the declaration pane of Program2.

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 ANDbox 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.

Page 125: 530

Course T530Exercises 7 Function Block Diagram (FBD) Language

7-6 3BSE 022 847/B

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.

Page 126: 530

Course T530

3BSE 022 847/B 7-7

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.3 Reference Documentation

In the Online Help: Contents tab, Function Block Diagram Editor.

7.2.4 Missions

Page 127: 530

Course T530Exercises 7 Function Block Diagram (FBD) Language

7-8 3BSE 022 847/B

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

……………………………………………………………………………………

……………………………………………………………………………………

……………………………………………………………………………………

Page 128: 530

Course T530

3BSE 022 847/B 7-9

7.2.5 Solutions – Exercise 7.2

7.2.5.1 Solution: Copy/Paste

1. Open the editor of Program2.

2. Declare the variable Motor2 of the data type Motor_Type.

3. Expand the structure pane (the pane to the left of the FBD panes).

4. Press Shift key and click with the left mouse button on the OR and then AND.

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.

Page 129: 530

Course T530Exercises 7 Function Block Diagram (FBD) Language

7-10 3BSE 022 847/B

7. The structure pane will now look like this.

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.

Page 130: 530

Course T530

3BSE 022 847/B 7-11

13. The FBD pane will now look like this.

14. Save and simulate.

15. Stop simulation

Page 131: 530

Course T530Exercises 7 Function Block Diagram (FBD) Language

7-12 3BSE 022 847/B

This page is intentionally left blank

Page 132: 530

Course T530

3BSE 022 848/C 8-i

Chapter 8 Ladder Diagram (LD) Language

TABLE OF CONTENTS

Chapter 8 Ladder Diagram (LD) Language...........................................................8-18.1 General Information......................................................................................8-1

8.1.1 Description......................................................................................8-18.1.2 Objectives .......................................................................................8-18.1.3 Reference Documentation...............................................................8-1

8.2 Lesson 1 - LD Language...............................................................................8-28.2.1 Description......................................................................................8-28.2.2 Objectives .......................................................................................8-28.2.3 General............................................................................................8-2

8.2.3.1 LD Pane.........................................................................8-38.2.3.2 Toolbar Buttons.............................................................8-4

8.2.4 Insert Rung......................................................................................8-58.2.5 Insert Contact..................................................................................8-5

8.2.5.1 Edit Contact Type..........................................................8-58.2.5.2 Edit Coil Type ...............................................................8-5

8.2.6 Insert Function/Function Block ......................................................8-58.2.6.1 Functions in LD.............................................................8-58.2.6.2 Edit Parameter Properties..............................................8-6

8.2.7 Connections ....................................................................................8-78.2.7.1 Variables and Constants to Parameter...........................8-78.2.7.2 Quick Connection..........................................................8-78.2.7.3 Disconnect .....................................................................8-7

8.2.8 Comments .......................................................................................8-88.2.8.1 Rung Comments ............................................................8-88.2.8.2 Item Comments .............................................................8-88.2.8.3 Page Comments.............................................................8-8

8.2.9 Structure Pane.................................................................................8-88.2.10 Execution Rules ..........................................................................8-108.2.11 Pages ...........................................................................................8-10

8.2.11.1 Page Setup .................................................................8-108.2.11.2 Insert Page Break.......................................................8-118.2.11.3 Page References ........................................................8-11

8.2.12 Inspect and Navigate...................................................................8-11

Page 133: 530

Course T530

8-ii 3BSE 022 848/C

Page 134: 530

Course T530

3BSE 022 848/C 8-1

Chapter 8 Ladder Diagram (LD) Language

8.1 General Information

8.1.1 Description

This chapter describes the use of the programming language LD.

8.1.2 Objectives

On completion of this chapter you will be able to:

Describe and identify ladder diagram constructs.

8.1.3 Reference Documentation

In the Online help: Contents tab, Ladder Diagram Editor.

Page 135: 530

Course T530Chapter 8 Ladder Diagram (LD) Language

8-2 3BSE 022 848/C

8.2 Lesson 1 - LD Language

8.2.1 Description

This lesson describes the theory of the LD Language.

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 editor’s usage is especially advantageous in case of small systems and if you are familiar with electrical wiring diagrams and relay control.

Page 136: 530

Course T530

3BSE 022 848/C 8-3

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

Page 137: 530

Course T530Chapter 8 Ladder Diagram (LD) Language

8-4 3BSE 022 848/C

8.2.3.2 Toolbar Buttons

There is a special toolbar in the Ladder Diagram editor, with shortcuts to many of the commands found in the menu bar (or in the pop-up menus). You can see a brief explanation of each button, if you hold the cursor over the button.

Toolbar button

Menu Command

Hot key Description

Tools > Edit Parameters >Connect

Use this command to assign variables and constants to the selected parameter of a function block, function, coil or contact.

Tools > Edit Parameters >Disconnect

Ctrl + D Use this command to de-assign a variable or constant from the selected parameter of a function block or function.

Tools > Edit Parameters > Invert

Use this command to invert a Boolean input parameter of a function block or function.

Insert > Rung Use this command to create a rung below the selected rung.

Insert >Parallel Contact

Use this command to create a new contact parallel with the selected coil, contact, function block or function.

Insert >Right Contact

Use this command to create a new contact on the right of the selected coil, contact, function block or function.

Insert > Left Contact

Use this command to create a new contact on the left of the selected coil, contact, function block or function.

Insert >Parallel Function/functionblock

Use this command to create a new function block or function parallel with the selected coil, contact, function block or function.

Insert >LeftFunction/functionblock

Use this command to create a new function or function block on the left of the selected coil, contact, function block or function.

Insert > Right Function/functionblock

Use this command to create a new function or function block on the right of the selected coil, contact, function block or function.

Page 138: 530

Course T530

3BSE 022 848/C 8-5

8.2.4 Insert Rung

When you start with an empty code block:

Right click in the LD pane and select Insert Rung.

When you have one or several Rungs in the code block:

Right click on a Rung and select Insert Rung.

8.2.5 Insert Contact

You insert a Contact by right clicking on a coil or contact and select Insert Right, Left or Parallel Contact from the menu.

8.2.5.1 Edit Contact Type

You edit the Contact Type by clicking with the right mouse button on the coil and select Edit Contact Type from the menu.

8.2.5.2 Edit Coil Type

You edit the Coil Type by clicking with the right mouse button on the coil and select Edit Coil Type from the menu.

8.2.6 Insert Function/Function Block

You insert a Function/Function Block by right clicking on a coil or contact and select Insert Right, Left or Parallel Function/Functionblock from the menu.

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 Description

Move, := Assigns the value (number, logical or string) of the input parameter to the output parameter.

Page 139: 530

Course T530Chapter 8 Ladder Diagram (LD) Language

8-6 3BSE 022 848/C

8.2.6.1.2 Boolean Operators

Function Description

NOT Negates the Boolean value (1/0, on/off or True/False).

AND, & Boolean AND.

XOR Boolean XOR.

OR, >=1 Boolean OR.

8.2.6.1.3 Arithmetic Operators

Function Description

EXPT, ** Exponential, i.e. raising to the power.

MUL, * Multiplication.

DIV, / Division.

ADD, + Addition.

SUB, - Subtraction.

MOD Modulus.

ABS Absolute value.

8.2.6.1.4 Relational Operators

Function Description

LT, < Less than.

GT, > Greater than.

LE, <= Less than or equal to.

GE, >= Greater than or equal to.

EQ = Equal to.

NE, <> Not equal to.

8.2.6.2 Edit Parameter Properties

By clicking with the right mouse button select a Function (box) of which you want to change the type or size. Select the Edit Parameter Properties command to change the size or type of the function.

8.2.6.2.1 Insert Parameters

By clicking with the right mouse button select a parameter (pin) of the function block or function to which you want to add a new parameter (pin). Select the Insertcommand to add a new, last parameter (pin).

Page 140: 530

Course T530

3BSE 022 848/C 8-7

8.2.6.2.2 Delete Parameters

By clicking with the right mouse button select a parameter (pin) of the function block or function, the last input parameter of which you want to delete. Select the Deletecommand to delete the last input parameter (pin).

8.2.6.2.3 Invert

By clicking with the right mouse button select the parameter (pin). Select the Invertcommand 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.1 Variables and Constants to Parameter

Select the pin, contact or coil to which you want to make a connection to. Right click on it and select Connect.

To display all available variables in a list box, press< Ctrl J >.

Fill the To field with a constant value or a variable or edit it.

8.2.7.2 Quick Connection

To prepare assignment of parameters, select one parameter (contact, coil or pin) by clicking on it with the left mouse button. Press < Ctrl > and hold it down while click with the left mouse button on the other parameter (contact, coil, pin) that you want to assign to the selected one (connect to the marked one).

Be sure you select an input parameter and you select an output parameter, or vice versa.

8.2.7.3 Disconnect

By clicking with the right mouse button select the parameter assignment. Select the Disconnect command to remove the assignment.

Page 141: 530

Course T530Chapter 8 Ladder Diagram (LD) Language

8-8 3BSE 022 848/C

8.2.8 Comments

It is possible to write comments to functions/function blocks, Rungs and pages.

8.2.8.1 Rung Comments

Select the Rung to which you want to assign a comment or the comment of which you want to change. Right click and select Edit Rung Comment.

8.2.8.2 Item Comments

Select the item to which you want to assign a comment or the comment of which you want to change. Right click and select Edit Comment….

8.2.8.3 Page Comments

Select the rung to which you want to assign a comment or the comment of which you want to change. Right click and select Edit Page Comment….

8.2.9 Structure Pane

The structure pane is the left sub pane within the code pane. It contains the list of all rungs of the POU you are programming. The order of elements from the top to the bottom corresponds to the order of their execution.

The structure pane consists of the following sizable and movable columns:

Rung shows the order number of the rungs

Comment shows the comment attached to the rung, function block or function

Page Number is given at the first rung of every page of the Ladder Diagram and

Page Comment shows the comment on the top of the corresponding Ladder Diagram page.

Page 142: 530

Course T530

3BSE 022 848/C 8-9

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

Page 143: 530

Course T530Chapter 8 Ladder Diagram (LD) Language

8-10 3BSE 022 848/C

8.2.10 Execution Rules

The evaluation of parameter values corresponds to the execution order of the rungs, function block and functions within the POU. The execution order of rungs is defined at first by the order of their creation. The execution order is represented by the order of rungs in LD "from the top to the bottom".

You can change the execution order later by moving the selected rungs "up" or "down" within the POU, for example, by cutting and pasting or move them in the Structure pane.

The execution order of function blocks and functions within a rung is defined by the place of their creation. They are executed from the left to the right, "as the current flows from the left power rail to the right one".

You can change the execution order later, for example, by deleting some function blocks and functions and creating them at an appropriate place again.

8.2.11 Pages

8.2.11.1 Page Setup

It is possible to change the layout and size of the code pane, select Tools > Setup>FBD/LD in the menu bar. This setting determines the layout of new code blocks. It does not however affect the current code block.

Page 144: 530

Course T530

3BSE 022 848/C 8-11

If you want to change the layout of the current code block, go to Tools > Page Layout >Page Setup.

8.2.11.2 Insert Page Break

Right click on the Rung (in the structured pane) to which you want to attach a page break and select the Insert Page Break command. The LD editor inserts the page break above this rung and repaginates the Ladder Diagram of the POU.

8.2.11.3 Page References

By clicking with the right mouse button select a line that connects the pins of function blocks and functions and symbolizes the assignment of variables to parameters. If you have clicked near to an input pin, use the Go To Source command to navigate to the source of the variable that is assigned to the selected parameter.

If you have clicked near to an output pin, use the Go to Sink command to navigate to the parameter(s) to which the selected parameter is assigned. In case of multiple sink browse with the "<-" and "->" buttons in the Go To Sink dialog box

8.2.12 Inspect and Navigate

Select a rung in the structure pane for navigating in the Ladder Diagram editor: the corresponding page appears in the recently selected LD pane with the selected rung in the focus.

Page 145: 530

Course T530Chapter 8 Ladder Diagram (LD) Language

8-12 3BSE 022 848/C

Page 146: 530

Course T530

3BSE 022 850/C 9-i

Chapter 9 Structured Text (ST) Language

TABLE OF CONTENTS

Chapter 9 Structured Text (ST) Language.............................................................9-19.1 General Information......................................................................................9-1

9.1.1 Description......................................................................................9-19.1.2 Objectives .......................................................................................9-19.1.3 Reference Documentation...............................................................9-1

9.2 Lesson 1 – ST Language...............................................................................9-29.2.1 Description......................................................................................9-29.2.2 Objectives .......................................................................................9-29.2.3 General............................................................................................9-2

9.2.3.1 Functions Simplifying While Editing............................9-29.2.3.2 Using Microsoft Word...................................................9-3

9.2.4 Comments and the ABB Extension ................................................9-39.2.5 Instructions .....................................................................................9-3

9.2.5.1 Assignment Operators ...................................................9-39.2.5.2 Expressions....................................................................9-4

9.2.5.2.1 Boolean Expressions and Operators .........9-49.2.5.2.2 Arithmetic Expressions and Operators .....9-49.2.5.2.3 Relational Expressions and Operators ......9-5

9.2.5.3 Statements .....................................................................9-59.2.5.3.1 Conditional Statements .............................9-59.2.5.3.2 Iteration Statements ..................................9-69.2.5.3.3 Return Statements .....................................9-7

9.2.5.4 Execution Order ............................................................9-79.2.5.5 Simulate.........................................................................9-7

9.3 Exercise 9.1 – Use the ST language..............................................................9-7

Page 147: 530

Course T530

9-ii 3BSE 022 850/C

Page 148: 530

Course T530

3BSE 022 850/C 9-1

Chapter 9 Structured Text (ST) Language

9.1 General Information

9.1.1 Description

This chapter describes the use of the programming language ST.

9.1.2 Objectives

On completion of this chapter you will be able to:

Use the ST Language.

9.1.3 Reference Documentation

In the Online help: Contents tab, Programming Languages > ST–Structured Text.

Page 149: 530

Course T530Chapter 9 Structured Text (ST) Language

9-2 3BSE 022 850/C

9.2 Lesson 1 – ST Language

9.2.1 Description

This lesson describes the use of the ST Language.

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.3.1 Functions Simplifying While Editing

Press < Ctrl I > to insert Statement in the code pane or use the button.

Press < Ctrl J > to insert declared variables in the code pane.

Page 150: 530

Course T530

3BSE 022 850/C 9-3

9.2.3.2 Using Microsoft Word

It is possible to write the code in Microsoft Word and then use the copy and paste function to move the code to the code pane if you are using the Structured Text editor.

9.2.4 Comments and the ABB Extension

Comments can be inserted wherever it is acceptable to insert one or more spaces in the code.

You can insert comments in the code by framing them with the characters (* and *)according to IEC 1131-3. You can not nest comments using this syntax.

If you need to nest comments you can frame the comment with the characters (# and #). You can nest (*...*) comments inside (#...#) comments. This is useful for commenting out large blocks of code containing comments.

Operator 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.

9.2.5.1 Assignment Operators

Operator 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.

Page 151: 530

Course T530Chapter 9 Structured Text (ST) Language

9-4 3BSE 022 850/C

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.

9.2.5.2.1 Boolean Expressions and Operators

Operator Description

NOT, Negates the Boolean value (1/0, on/off or True/False).

AND Boolean AND.

& Boolean AND. See AND.

XOR Boolean XOR.

OR Boolean OR.

Example of a Boolean expression:

Activated := Start and not Stop;

9.2.5.2.2 Arithmetic Expressions and Operators

Operator Description

** Exponential, i.e. raising to the power.

* Multiplication

/ Division.

+ Addition.

- Subtraction.

MOD Modulus.

Example of an Arithmetic expression:

Value:= Value +1;

Page 152: 530

Course T530

3BSE 022 850/C 9-5

9.2.5.2.3 Relational Expressions and Operators

Operator Description

< Less than.

> Greater than.

<= Less than or equal to.

>= Greater than or equal to.

= Equal to.

<> Not equal to.

Under the headline Conditional Statements, an example is given with Relational Expressions.

9.2.5.3 Statements

9.2.5.3.1 Conditional Statements

Operator Description

If..then..

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;

If..then..

else..

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;

If..then..

elsif..

else..

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;

case <integer> of <integer literal> : <statements>end_case;

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.

case <integer> of <integer literal> : <statements> <integer literal> : <statements> <integer literal> : <statements> else <statements>

end_case;

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.

Page 153: 530

Course T530Chapter 9 Structured Text (ST) Language

9-6 3BSE 022 850/C

An example of a conditional statement using If..then..elsif..:

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.

9.2.5.3.2 Iteration Statements

Operator Description

For 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.

While 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.

Repeat 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.

Exit Use the exit statement whenever you want to terminate a loop immediately and continue execution from the first line after the iteration statement.

Page 154: 530

Course T530

3BSE 022 850/C 9-7

9.2.5.3.3 Return Statements

Operator Description

Return 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.

9.2.5.4 Execution Order

The priority of operators decides the order of evaluation of an expression. Below is a summary of available operators, in descending priority:

Operator Description Priority

(…) Parenthesized expression. Highest

Function (…) Parameter list of a function, function evaluation.

Not, - 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.

*, / ,mod Multiplication, division and modulus.

+, - Addition and subtraction.

<, >, <=, >= Comparison operators

=, <> Equality and inequality.

and, & Boolean AND.

xor Boolean exclusive OR

or Boolean OR 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.3 Exercise 9.1 – Use the ST language

Please do exercise 9.1

Page 155: 530

Course T530Chapter 9 Structured Text (ST) Language

9-8 3BSE 022 850/C

Page 156: 530

Course T530

3BSE 022 851/A 9-1

Exercises 9 Structured Test (ST) Language

9.1 Use the ST Language – Exercise 9.1

9.1.1 Description

This exercise describes the use of the ST Language

9.1.2 Objectives

After this exercise you will be able to:

Use the ST Language.

9.1.3 Reference Documentation

In the Online help: Contents tab, Programming Languages > ST–Structured Text.

9.1.4 Missions

9.1.4.1 Assignment Statement

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 Celsius

0

32

100

……………………………………………………………………………………

……………………………………………………………………………………

Page 157: 530

Course T530Exercises 9 Structured Test (ST) Language

9-2 3BSE 022 851/A

9.1.4.2 Setup Presentation Form

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.

……………………………………………………………………………………

……………………………………………………………………………………

9.1.4.4 Text Comments

Write some comments (in the code pane) to the code in the previous exercise (Exercise 9.1.4.1 - 9.1.4.3).

……………………………………………………………………………………

……………………………………………………………………………………

9.1.4.5 Comment Out Code

Comment out the code and comments in the previousexercise (the If statement). Use nested comments!

……………………………………………………………………………………

……………………………………………………………………………………

Page 158: 530

Course T530

3BSE 022 851/A 9-3

9.1.5 Solutions – Exercise 9.1

9.1.5.1 Solution: Assignment Statement

1. Insert a new code block to Program2

2. Name the code block ST1 and select ST language

3. Declare the variables and write the code as below

The conversion will give the result as follows

Fahrenheit Celsius

0 - 17.778

32 0.0

100 37.778

9.1.5.2 Solution: Setup Presentation Form

1. In simulate mode, Select (Tools > Setup) from the menu of the POU editor.

2. Click on the Structured Text tab and select Function Diagram.

Page 159: 530

Course T530Exercises 9 Structured Test (ST) Language

9-4 3BSE 022 851/A

9.1.5.3 Solution: If Statement

9.1.5.4 Solution: Text Comments

In simulate mode:

Page 160: 530

Course T530

3BSE 022 851/A 9-5

9.1.5.5 Solution: Comment Out Code

Page 161: 530

Course T530Exercises 9 Structured Test (ST) Language

9-6 3BSE 022 851/A

This page is intentionally left blank

Page 162: 530

Course T530

3BSE 022 852/B 10-i

Chapter 10 Instruction List (IL) Language

TABLE OF CONTENTS

Chapter 10 Instruction List (IL) Language ..........................................................10-110.1 General Information..................................................................................10-1

10.1.1 Description..................................................................................10-110.1.2 Objectives ...................................................................................10-110.1.3 Reference Documentation...........................................................10-1

10.2 Lesson 1 – IL Language............................................................................10-210.2.1 Description..................................................................................10-210.2.2 Objectives ...................................................................................10-210.2.3 General........................................................................................10-2

10.2.3.2 The Result Register – RR..........................................10-310.2.4 Comments ...................................................................................10-310.2.5 Standard instructions...................................................................10-4

10.2.5.1 Load and Store Instructions.......................................10-410.2.5.2 Boolean Operators.....................................................10-410.2.5.3 Arithmetic Instructions..............................................10-510.2.5.4 Relational and Equality Instructions .........................10-510.2.5.5 Return Instructions ....................................................10-510.2.5.6 Jump Instructions ......................................................10-610.2.5.7 Function Block Call Instructions...............................10-6

10.2.6 Execution Rules ..........................................................................10-6

Page 163: 530

Course T530

10-ii 3BSE 022 852/B

Page 164: 530

Course T530

3BSE 022 852/B 10-1

Chapter 10 Instruction List (IL) Language

10.1 General Information

10.1.1 Description

This chapter describes the use of the programming language IL.

10.1.2 Objectives

On completion of this chapter you will be able to:

Describe and identify instruction list constructs.

10.1.3 Reference Documentation

In the Online help: Contents tab, Programming Languages > IL-Instruction List.

Page 165: 530

Course T530Chapter 10 Instruction List (IL) Language

10-2 3BSE 022 852/B

10.2 Lesson 1 – IL Language

10.2.1 Description

This lesson describes the theory of the IL Language.

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:

Figure 10.1 The instruction list above corresponds to (A OR B) AND C =D:

Page 166: 530

Course T530

3BSE 022 852/B 10-3

10.2.3.2 The Result Register – RR

The current (or last calculated) result is always placed in the result register. The contents of the result register must be explicitly stored into a variable for storage using the ST instruction or loaded into the result register from a variable using the LD instruction.

The IL instructions can be grouped into four categories depending on how they change the result register.

The LD instruction resets and puts a new value in the result register.

The ST, STN, S and R instructions copy the contents of the result register to an output. (STN copies the negated.)

The JMP (jump) and CAL (call) instructions do not change the result register. For unconditional jump/call the result register is not consulted. For conditional jump/call, the contents of the result register determine whether or not to jump/call.

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.

Figure 10.2 Comments in the IL editor.

Page 167: 530

Course T530Chapter 10 Instruction List (IL) Language

10-4 3BSE 022 852/B

10.2.5 Standard instructions

The following instructions are available in the IL language.

10.2.5.1 Load and Store Instructions

Operator Description

LD Load a value

LDN Load a negated value

ST Store the current value.

STN Store the negated current value

S Set the value of the operand to 1 (True, on) if the value in the result register is 1 (True, on).

R Set the value of the operand to 0 (False, off) if the value in the result register is 0 (False, off).

10.2.5.2 Boolean Operators

Operator Description

NOT Change the value to its negated value.

AND Boolean AND. If the arguments are multi bit then bit wise AND is used.

& Same as AND.

ANDN Boolean inverted AND. If the arguments are multi bit then bit wise ANDNis used. Note: the expression is equal to (result register AND NOT operator).

OR Boolean OR. If the arguments are multi bit then bit wise OR is used.

ORN 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).

XOR Boolean exclusive OR. If the arguments are multi bit then bit wise XOR is used.

XORN 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).

Page 168: 530

Course T530

3BSE 022 852/B 10-5

10.2.5.3 Arithmetic Instructions

Operator Description

ADD Addition

SUB Subtraction

MUL Multiplication.

DIV Division.

10.2.5.4 Relational and Equality Instructions

Operator Description

GT Greater than. The result is of type bool

GE Greater or equal than. The result is of type bool

EQ Equal to. The result is of type bool.

LT Less than. The result is of type bool.

LE Less or equal than. The result is of type bool.

NE Not equal to. The result is of type bool.

10.2.5.5 Return Instructions

Operator Description

RET Unconditional exit of a list and termination of the current POU

RETC Conditional exit of a list and termination of current POU if the value of the result register is True (1).

RETCN Conditional exit of a list and termination of current POU if the value of the result register is False (0).

Page 169: 530

Course T530Chapter 10 Instruction List (IL) Language

10-6 3BSE 022 852/B

10.2.5.6 Jump Instructions

Operator Description

JMP 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.

10.2.5.7 Function Block Call Instructions

Operator Description

CAL Call to a function block.

CALC Calls a function block if the value in the result register is True (1).

CALCN Calls a function block if the value in the result register is False (0).

10.2.6 Execution Rules

The instruction list is executed line by line regardless of what is on the next line, as long as there are no parenthesis.

Page 170: 530

Course T530

3BSE 022 854/C 11-i

Chapter 11 Functions and Function Blocks

TABLE OF CONTENTS

Chapter 11 Functions and Function Blocks..........................................................11-111.1 General Information..................................................................................11-1

11.1.1 Description..................................................................................11-111.1.2 Objectives ...................................................................................11-111.1.3 Reference Documentation...........................................................11-1

11.2 Lesson 1 - Using Functions and Function Blocks.....................................11-211.2.1 Description..................................................................................11-211.2.2 Objectives ...................................................................................11-211.2.3 The difference between Functions and Function Blocks............11-2

11.2.3.1 Functions ...................................................................11-211.2.3.2 Function blocks .........................................................11-2

11.2.4 Inserting libraries ........................................................................11-211.2.5 Some standard functions and function blocks ............................11-3

11.2.5.1 Data type conversion .................................................11-311.2.5.2 Mathematical functions .............................................11-311.2.5.3 Counters and timers...................................................11-3

11.2.6 Using Functions in different languages ......................................11-311.2.6.1 ST and SFC ...............................................................11-311.2.6.2 FBD ...........................................................................11-311.2.6.3 IL ...............................................................................11-411.2.6.4 LD..............................................................................11-4

11.2.7 Instantiation / Using FB Instances in different languages ..........11-411.2.7.1 ST and SFC ...............................................................11-411.2.7.2 FBD ...........................................................................11-511.2.7.3 IL ...............................................................................11-511.2.7.4 LD..............................................................................11-6

11.3 Exercise 11.1 – Using Function Blocks ....................................................11-711.4 Lesson 2 - Creating Function Blocks ........................................................11-8

11.4.1 Description..................................................................................11-811.4.2 Objectives ...................................................................................11-811.4.3 Creating a user library.................................................................11-8

11.4.3.1 Why using libraries?..................................................11-811.4.4 Creating a Function Block Type.................................................11-8

11.4.4.1 Why create Function Block Types? ..........................11-811.4.4.2 Function Block Type Editor ......................................11-9

11.5 Exercise 11.2 – Creating a simple Function Block Type..........................11-911.6 Exercise 11.3 – Creating a more complex Function Block Type..............11-9

Page 171: 530

Course T530

11-ii 3BSE 022 854/C

Page 172: 530

Course T530

3BSE 022 854/C 11-1

Chapter 11 Functions and Function Blocks

11.1 General Information

11.1.1 Description

This chapter describes how to use Functions and Function Blocks in the different languages and how to declare user defined Function Blocks in libraries.

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.3 Reference Documentation

Use the online help, Contents tab, System Functions

Page 173: 530

Course T530Chapter 11 Functions and Function Blocks

11-2 3BSE 022 854/C

11.2 Lesson 1 - Using Functions and Function Blocks

11.2.1 Description

This lesson describes how to use Functions and Function Blocks in the different languages.

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.3.2 Function blocks

Have both input and output parameters.

Can give several output values using parameters.

Retain their values, from the last call, when called the second time. Can give different output values even if the input values are the same.

Have to be used as instances of a type definition.

11.2.4 Inserting libraries

Right click on the Libraries icon and select Insert Library to insert a library to your project.

Page 174: 530

Course T530

3BSE 022 854/C 11-3

11.2.5 Some standard functions and function blocks

The library SystemLib contains a number of predefined Functions and Function Blocks.

11.2.5.1 Data type conversion

There are a number of predefined data type converters in the library SystemLib. For example bool_to_dint, and real_to _dint.

11.2.5.2 Mathematical functions

There are a number of predefined mathematical functions in the library SystemLib. For example sin, cos, add, ln, sqrt.

11.2.5.3 Counters and timers

There are a number of predefined counters and timers in the library SystemLib. For example CTU (Counter Up), CTD (Counter Down), TOn (Timer on delay), Tof (Timer off delay).

11.2.6 Using Functions in different languages

11.2.6.1 ST and SFC

A function call in ST is done by writing the name of the function in the editor or by

using the button, pressing < Ctrl L> or selecting (Insert >Function…). An example with the function Add in ST:

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 avarying number of inputs, you can enter the number in the Properties Size field.

An example with the function Add in FBD:

Page 175: 530

Course T530Chapter 11 Functions and Function Blocks

11-4 3BSE 022 854/C

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.2.7 Instantiation / Using FB Instances in different languages

11.2.7.1 ST and SFC

You must create an instance of the function block before it is used in the ST or SFC editor. The instance is created as follows:

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 instance a suitable name in the Name field.

Write a description in the Description field.

Page 176: 530

Course T530

3BSE 022 854/C 11-5

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.

Page 177: 530

Course T530Chapter 11 Functions and Function Blocks

11-6 3BSE 022 854/C

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.

Page 178: 530

Course T530

3BSE 022 854/C 11-7

11.3 Exercise 11.1 – Using Function Blocks

Please do exercise 11.1

Page 179: 530

Course T530Chapter 11 Functions and Function Blocks

11-8 3BSE 022 854/C

11.4 Lesson 2 - Creating Function Blocks

11.4.1 Description

This lesson describes how to define user defined Function Block types in libraries.

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.

11.4.3 Creating a user library

Right click on the Libraries icon and select New Library to insert a library to your project.

11.4.3.1 Why using libraries?

It is recommended to create own libraries when you work in a larger project, because then you get a better structure of the project. Another major advantages of creating own libraries are that it is possible to reuse the Data types, Function Block types and Control Module types in other projects.

11.4.4 Creating a Function Block Type

Right click on the Function Block Types icon and select New Function Block Type… to create a new Function Block Type. This could be done in an application or a library. Creating the Function Block Type in an application means that this type can only be used in this application. Creating the type in a library makes it possible to use it also in other applications or even other projects.

11.4.4.1 Why create Function Block Types?

By creating your own Function Blocks you can encapsulate code for commonly used functions in your process. These Function Blocks can then be re-used in your project to reduce engineering and improve readability.

Page 180: 530

Course T530

3BSE 022 854/C 11-9

11.4.4.2 Function Block Type Editor

The content of the function block type is displayed in an editor. You can define function block types, which can be used in other POU:s. Parameters, variables and function blocks that are used must be declared in the declaration pane. Code is entered in the code pane. A function block type typically uses the following elements, which are declared in separate tabs in the declaration pane:

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.5 Exercise 11.2 – Creating a simple Function Block Type

Please do exercise 11.2

11.6 Exercise 11.3 – Creating a more complex Function Block Type

Please do exercise 11.3

Page 181: 530

Course T530Chapter 11 Functions and Function Blocks

11-10 3BSE 022 854/C

Page 182: 530

Course T530

3BSE 022 855/C 11-1

Exercises 11 Functions and Function Blocks

11.1 Functions and Function Blocks – Exercise 11.1

11.1.1 Description

This exercise describes how to use Function Blocks in the different languages.

11.1.2 Objectives

After this exercise you will be able to:

Use Function Blocks in the different languages.

11.1.3 Reference Documentation

In the Online Help: Contents tab, System Functions.

11.1.4 Missions

11.1.4.1 Using Function Block in ST

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 declaredwith the following syntax: T#10s.

Give the variables suitable names.

This exercise should be done in the ST-language.

……………………………………………………………………………………

……………………………………………………………………………………

Page 183: 530

Course T530Exercises 11 Functions and Function Blocks

11-2 3BSE 022 855/C

11.1.4.2 Using Function Block in FBD

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 2Photocell 1

Page 184: 530

Course T530

3BSE 022 855/C 11-3

11.1.5 Solutions – Exercise 11.1

11.1.5.1 Solution: Using Function Block in ST

1. Declare the Function Block

2. Declare the Variables and connect them to the Parameters.

Page 185: 530

Course T530Exercises 11 Functions and Function Blocks

11-4 3BSE 022 855/C

11.1.5.2 Solution: Using Function Block in FBD

Page 186: 530

Course T530

3BSE 022 855/C 11-5

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.

11.2.3 Reference documentation

In the online help: Contents tab, System Functions.

11.2.4 Missions

11.2.4.1 Create Function Block Type Motor

Open the project CourseProject.

Create a new library MotorLib

Create a new Function Block Type called Motor.

Motor

Start

Stop

Run

_

_

_

Page 187: 530

Course T530Exercises 11 Functions and Function Blocks

11-6 3BSE 022 855/C

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.2.4.2 Instantiate the Motor in a program

Open Program2.

Delete any content dealing with the motor start.

Declare an instance of Motor called Motor_1.

Make the function block call in the code.

Connect the parameters of Motor_1 to components of the variable Motor1.

Test in Simulate mode.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Page 188: 530

Course T530

3BSE 022 855/C 11-7

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.

4. Double click on the Motor FB type to open the POU editor.

Page 189: 530

Course T530Exercises 11 Functions and Function Blocks

11-8 3BSE 022 855/C

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.

Page 190: 530

Course T530

3BSE 022 855/C 11-9

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.

...........................................................................................................................................

...........................................................................................................................................

Page 191: 530

Course T530Exercises 11 Functions and Function Blocks

11-10 3BSE 022 855/C

11.3 User Defined Function Blocks – Exercise 11.3

11.3.1 Description

This exercise describes how to define user defined Function Blocks in libraries.

The purpose with this exercise is to create a Function Block Type named Tank.

The Tank will contain other function blocks such as Heater, Mixer and Cooler(You will find them in the library OsloLib).

There will also be some additional code in the Function Block Type Tank for level supervision.

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.3.3 Reference Documentation

In the Online Help: Contents tab, System Functions.

FB Tank

FB Mixer

FB Heater

FB Cooler

Additional code

Page 192: 530

Course T530

3BSE 022 855/C 11-11

11.3.4 Missions

11.3.4.1 Create FB Tank

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.

……………………………………………………………………………………

……………………………………………………………………………………

……………………………………………………………………………………

Page 193: 530

Course T530Exercises 11 Functions and Function Blocks

11-12 3BSE 022 855/C

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.

……………………………………………………………………………………

……………………………………………………………………………………

……………………………………………………………………………………

Page 194: 530

Course T530

3BSE 022 855/C 11-13

11.3.4.5 Additional Code

Declare the following parameters in the function block type Tank.

Name Data type Initial value Direction

Level Real In

LevelHigh Bool Out

LevelLow Bool 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.

……………………………………………………………………………………

……………………………………………………………………………………

……………………………………………………………………………………

Page 195: 530

Course T530Exercises 11 Functions and Function Blocks

11-14 3BSE 022 855/C

11.3.4.6 Make an Instance of the Tank

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 Connects to

OrderMixer OsloTank.OrderMixer

AnswerMixer OsloTank.AnswerMixer

ErrorMixer OsloTank.ErrorMixer

OrderCooler OsloTank.OrderCooler

AnswerCooler OsloTank.AnswerCooler

ErrorCooler OsloTank.ErrorCooler

OrderHeater OsloTank.OrderHeater

AnswerHeater OsloTank.AnswerHeater

ErrorHeater OsloTank.ErrorHeater

Level OsloTank.Level

LevelHigh OsloTank.LevelHigh

LevelLow OsloTank.LevelLow

Test the functionality of the Tank by setting the order variables to true.

……………………………………………………………………………………

……………………………………………………………………………………

……………………………………………………………………………………

Page 196: 530

Course T530

3BSE 022 855/C 11-15

11.3.4.7 Make Two Instances of the ValveGroup

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.

Simulate the process by setting values to the variables in the program.

……………………………………………………………………………………

……………………………………………………………………………………

Page 197: 530

Course T530Exercises 11 Functions and Function Blocks

11-16 3BSE 022 855/C

11.3.5 Solutions – Exercise 11.3

11.3.5.1 Solution: Creating FB Tank

1. Right click on Function Block Types in OsloLib and select New Function Block Type.

2. Write Tank.

3. Click OK.

11.3.5.2 Solution: Mixer

To enter the POU Editor, double click on the new Function Block Type Tank.

Page 198: 530

Course T530

3BSE 022 855/C 11-17

11.3.5.3 Solution: Heater

11.3.5.4 Solution: Cooler

Page 199: 530

Course T530Exercises 11 Functions and Function Blocks

11-18 3BSE 022 855/C

11.3.5.5 Solution: Additional Code

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:

Page 200: 530

Course T530

3BSE 022 855/C 11-19

11.3.5.6.2 Using the FBD Language

1. Insert a new code block called Order in Program2. Choose FBD as language.

2. Right click in the code pane. Choose Insert Function/Functionblock or click on the

icon. Choose OsloLib and the function block type Tank. Enter OsloTank1 in the Name field.

3. Connect the parameters by Right clicking>Connect. The figure shows the final result.

Page 201: 530

Course T530Exercises 11 Functions and Function Blocks

11-20 3BSE 022 855/C

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:

Page 202: 530

Course T530

3BSE 022 855/C 11-21

11.3.5.7.2 Using the FBD language

Use the code block Order.

Right click in the code pane and insert two instances of Function Block Type ValveGroup from OsloLib. Name the first one UpperValveGroup1 and the second one LowerValveGroup1.

Connect the parameters of the two function blocks as shown in the figure:

Page 203: 530

Course T530Exercises 11 Functions and Function Blocks

11-22 3BSE 022 855/C

This page is intentionally left blank