Top Banner
Production Systems Control - Prof. Luca Ferrarini A.A. 2011-2012 Automation Engineering 2011 - 2012 Production Systems Control PLC – IEC61131 Prof. Luca Ferrarini Eng. Giancarlo Mantovani Politecnico di Milano – Dipartimento di Elettronica e Informazione A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 2 Index Introduction Basic hardware OS and functional architecture IEC61131 standard Conclusions Hardware di base Architettura OS & Funz. Conclusioni Introduzione IEC61131
32

PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

Feb 18, 2019

Download

Documents

phungdang
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: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

Production Systems Control - Prof. Luca FerrariniA.A. 2011-2012

Automation Engineering 2011 - 2012

Production Systems Control

PLC – IEC61131Prof. Luca FerrariniEng. Giancarlo Mantovani

Politecnico di Milano – Dipartimento di Elettronica e Informazione

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 2

Index

► Introduction

► Basic hardware

► OS and functional architecture

► IEC61131 standard

► Conclusions

Hardware di base Architettura OS & Funz. ConclusioniIntroduzione IEC61131

Page 2: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 3

What is a PLC?

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� The Programmable Logic Controller is an electronic deviceused for programming the control of industrial processes an dmachines

� The hardware structure with internal bus is the bas is for the PC

� PLC replaced wired logic connections of relay control panel s� Reduction in development time and costs

Siemens SIMATIC S7-300

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 4

History

� Before PLCs, plants control logic was performed wit h hardware wired logics in relay panels:

� Not much modifiable and expandable

� Difficult to analyze and test

� Difficult to be interfaced with other control components(computers, terminals, sensors…)

� Not suitable for complex andflexible control systems

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 3: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 5

History...and evolution

� When plant complexity grows, in parallel should gro w:� Reliability, expandibility and flexibility

� Necessary to pass to programming logic:� PLS (Programmable Logic Sequencers)� PLC (Programmable Logic Controllers)

• 1969 in U.S.A. for automotive industry

� Instructions instead of electronic components� Adaptative, simple and quick design� Easy diagnostics� More suitable for complex systems

Solution

PROs

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 6

Hardware architecture

Memory• RAM• ROM

I/O Modules• Digital• Analog

Other Modules• Network• CNC• PID• Etc.

Human Machine Interfaces

Power Supply• AC• DC

EXTERNAL BUSINTERNAL BUS

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 4: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 7

Hardware architecture - CPU

� Equipment dedicated to:

� Data processing

� Control program instructions processing

� Management of operations for PLC internal logics

� Example of processing times:� Operations on bits, words in fixed-point: 0.1-5 µs� Operations in floating-point: 0.5-50 µs� Entire cycle execution: 2-10 ms

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 8

Hardware architecture - Memories

� Memories are divided into:� Volatiles and retentive (“latched”)� Random Access (RAM or active)

or Read Only (ROM or passive)

� Data memory:� PLC’s have a volatile RAM for variables storing; some plant

data, which are particularly important, need to be stored in retentive memories

� Program memory:� ROM memories are preferable in order to limit control programs

corruption or losses (EEPROM/FLASH)

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 5: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 9

� Programming interfaces� Touchscreen LCDs or keyboards� IDE for PC

� Operator panels� Displays

� “Push buttons” modules

� “All inclusive” interfaces

� Touchscreen terminals

� Supervisory Control And Data Acquisition (SCADA)

Hardware architecture - HMI

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 10

Hardware architecture – I/O Modules

� Allow communication with physical process (“field”) :� Digital Input/Outputs

• #I/O: 16-32; Vin: 24V DC; Iin: 4-20 mA;

� Analog inputs• #In: 8; Res.: 12-14 bit; ReadTime: 20 ms• Connectable to termocouples, termoresistances, etc.

� Analog outputs• #Out: 8; Res.: 12-14 bit; WriteTime: 0.5 ms• Vout: ± 10 V, 0 -10 V, 1-5 V• Iout: ± 20 mA, 0 to 20 mA, 4 to 20 mA

� Can be linked to PLC internal bus or remoted

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 6: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 11

Hardware architecture – Special modules

� Axis positioning control boards

� Schede PID� Separate processors implementing PID

� Multiple - core modules (non logic data management: tables, etc.)

� Backup modules� Main board duplication:

• Cold backup: the broken board is replaced

• Hot backup: main board and backup board run in parallel. When the first breaks, the backup one immediately intervenes

� Modules for network connections� Fieldbus : Profibus, Profinet, Ethercat , CAN, Modbus RS232/TCP,

etc.

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 12

Hardware architecture – Fieldbus

� Fieldbus is an IEC standard term to indicate, in an automaticprocess, the communication standard between different dev ices(nodes), such as:� Fieldbus devices

(sensors, actuators, etc.)� Control devices

(PLCs, DCSs, etc.)

� Communication between nodes is managed with standar d or proprietary protocols

� Connections: Star, token-ring, mixed

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 7: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 13

Hardware architecture – Fieldbus

� FieldBus PROs:� PLC and FIELDBUS are integrable� Comunication with field is digital, reliable and fast� Wiring and installation costs go down� Remote configuration of devices through fieldbus itself� Useful for distributed plants with Real-Time control� Standard physical supports (ethernet, optical fiber, radio,…)� Standard : it is possible to integrate products from different vendors

� FieldBus CONs:� Costs for single modules (for some protocols)� A broken bus stop communications with many devices other than

the broken one (redundancy…EtherCAT!)� Some fieldbus are “open” but not “open-source” (Profibus, Profinet)

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 14

Hardware architecture – Rack

� Racks contain all the modules of PLC system (CPU, m emorie, non-remote I/O, etc.) and allows:� Electrical wiring� Logical connection (bus)� Mechanical connection� Shielding

� Racks are linkable:� Hierchically with suitable interface boards� Local or decentralized

� Racks allow modularity of PLC architecture

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 8: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 15

Hardware architecture – Dimensions

� Criteria for dimensioning:� Modularity� Addressing space� Presence of special modules� Speed

� Dimensions categories:� Compact (or micro):

• Not modular, with tens of I/Os• Home automation

� Small:• Modular, with hundreds of I/Os

� Medium:• Modular, with thousands of I/Os

� Big:• Modular with tens of thousands of I/Os

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 16

Why PLCs?

� PLC vs PC:

� Designed to resist in industrial environment• Vibrations, mechanical or electrical shocks, noise immunity

(electromagnetic, vapors, temperature, toxic substances), galvanicisolation, etc.

� No moving disks (HDD, CD)

� Has “Watch-Dog” (for instructions, user program, etc..)

� Proprietary OS extremely reliable with high diagnostics featuresboth for SW and HW

� Compact, easily storable in electrical cabinet

� Integrable with other control devices

� Alternative: soft-PLC

� Reliable industrial PCs

� Software running on a PC

Advantech ARKIndustrial PC

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 9: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 17

OS and functional architecture

� PLC works as other industrial controllers, connecte d in feedback to the plant:

PLC

Inputboards

Output boards

CPU

Memory

Other boards

ActuatorsSensors

Process

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 18

OS and functional architecture

� PLC Cycle� PLC works with sample signals, so it executes cyclically three

hardware phases:

� NOTE: Cycle time includes OS internal instructions execution!

Input scanning

Output writing

User program execution

Cyc

le ti

me

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 10: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 19

OS and functional architecture

� PLC Cycle

time

Input scanning phase

Program execution phase

Output writing phase

OS functions execution phase

cycle N-1 cycle N cycle N+1

Tciclo

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 20

OS and functional architecture

� PLC Cycle

time

Input scanning phase

Program execution phaseOutput writing phaseOS functions execution phase

high valuelow value

Transition from 0 to 1not detected for this input

It is read here and is low in both cases

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 11: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 21

OS and functional architecture

� PLC Cycle

time

high valuelow value

It is read here, low at first cycle, high at second

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Input scanning phase

Program execution phaseOutput writing phaseOS functions execution phase

Transition from 0 to 1detected for this input

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 22

OS and functional architecture

� PLC Cycle� It is unuseful to update an output value more than once in a cycle

as output are sent to field just once for each cycle (during output writing phase)!

timeOutput are refreshed only in these time slots

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Input scanning phase

Program execution phaseOutput writing phaseOS functions execution phase

Page 12: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 23

The described PLC operation mode is defined Massive Copy (outputwritten all together at the same time and input read all toget her at thesame time).

� Advantages: � Simple to implement: reading and writing phases are ininterrupted

and with clear time boundaries� Easy to simulate: system evolution of outputs (given a set of inputs)

is easily predictable

� Disadvantages:� Limited reactivity: if an input changes just after input scanning the

transition is read after an entire cycle time� Limited resources exploitation: it is necessary to use more

temporary variables to store partial results between reading and writing phases

OS and functional architecture – Massive copy

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 24

� Some PLCs allow even different behaviors:� Reading and writing performed even during program execution. In

this way reactivity is enhanced

� Be careful to distinguish:� An immediata physical variable update� Variable update at execution end

� Alternative: interrupts

OS and functional architecture – Distributed I/Os

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 13: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 25

� Interrupts:1) Stops program execution2) Execute an appropriate subroutine to manage the interrupt3) Give the program the control back at subroutine end

� Hardware interrupts� Generated by external physical sensors (e.g. alarm button). Used

to guarantee a quick response to events

� Cyclic interrupts (SW)� Generated periodically at regular time intervals (tipically used to

sample inputs with a Tsample<Tcycle

OS and functional architecture - Interrupt

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 26

Hardware di base Architettura OS & Funz ConclusioniIntroduzione IEC61131

� Execution mode:� PLC works like a PID: reads inputs, execute control program and

updates the outputs.

� Validation mode:� The PLC executes the program without reading the inputs and

without writing the outputs to the field: intermediate variables are used instead (eventually connected to the programming system e.g. PC)

� Programming mode:� The PLC is connected to the programming system and allows

program memory to be “burned” with user program

OS and functional architecture – Operative modes

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 14: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 27

� It’s a timer associated to various PLC components a nd executed operations

� A maximum time slot is associated to an operation e xecution and if the timer overflows before operation end, an err or is generated (Watch-dog)

� Examples of operations with Watch-Dog:� User instructions� Memory / I/O Boards / Network board access instructions� The entire program� Etc.

OS and functional architecture – Watch-Dog

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 28

Hardware di base Architettura OS & Funz ConclusioniIntroduzione

� Open international standard for PLC published the f irst time in 1993 (second and current edition in 2003)� Part 1: General information � Part 2: Equipment requirements and tests � Part 3: Programming languages � Part 4: User guidelines � Part 5: Messaging service specification � Part 6: Communications via fieldbus (Awaiting completion of fieldbus standards.) � Part 7: Fuzzy control programming� Part 8: Guidelines for the application and implementation of programming languages

� Main goals:� Reduce differences with modern ICT techniques� Formalize in a more abstract and essential way automation and

control problems� Propose a standard in the field of logic control, in order to improve

knowledge reuse and real competition among manufacturers

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

IEC61131

Page 15: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 29

� PLC definition – Programmable Logic Controller

A PLC is an electronic digital device used in industrial environments which has a programmable memory for the internal storage of user-oriented

instructions for the implementation of specific functions, such as logical, sequencing, timing, counting and arithmentic calculation and

can control, through both digital and analog input and outputs, various kinds of machines and processes.

IEC61131

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 30

� IEC61131-3 software architecture� Data type� Variables� Program Organization Units (POU)� Configuration, Resources and Tasks � External links

� Defined languages:� Ladder diagram (LD), graphical � Function block diagram (FBD), graphical � Structured text (ST), textual � Instruction list (IL), textual � Sequential function chart (SFC), graphical

IEC61131-3

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 16: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 31

Task TaskTaskTask

Program ProgramProgram

FB FB

Program

FB FB

Configuration

Resource Resource

Access paths

Global and directly represented variables

Communication functions(defined in IEC 1131-5)

Legenda

Variables

Function BlocksFB

IEC61131-3

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 32

Task TaskTaskTask

Program ProgramProgram

FB FB

Program

FB FB

Configuration

Resource Resource

Access paths

Global and directly represented variables

Communication functions(defined in IEC 1131-5)

Legenda

Variables

Function BlocksFB

Corresponds to a Programmable

Controller System,usually a PLC

IEC61131-3

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 17: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 33

Task TaskTaskTask

Program ProgramProgram

FB FB

Program

FB FB

Configuration

Resource Resource

Access paths

Global and directly represented variables

Communication functions(defined in IEC 1131-5)

Legenda

Variables

Function BlocksFB

Resources act as support for program

execution and are indipendent among

themselves

IEC61131-3

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 34

Task TaskTaskTask

Program ProgramProgram

FB FB

Program

FB FB

Configuration

Resource Resource

Access paths

Global and directly represented variables

Communication functions(defined in IEC 1131-5)

Legenda

Variables

Function BlocksFB

Specifies the activation of programs (or parts

of programs) which are assigned to them

(Cyclic/EventDriven Task )

IEC61131-3

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 18: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 35

Task TaskTaskTask

Program ProgramProgram

FB FB

Program

FB FB

Configuration

Resource Resource

Access paths

Global and directly represented variables

Communication functions(defined in IEC 1131-5)

Legenda

Variables

Function BlocksFB

Are executed under the control of one or more Tasks. Programs are

containers of executable constructs, written with the languages specified

in the standard

IEC61131-3

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 36

� Tasks specify the activation of part of programs or entire programs assigned to tasks themselves. This activation can b e periodical or can happen in response to a particula r event.

� Programs are the entities the control system design er can compose by the use of hierarchical function blocks and functions .

� Function blocks and functions → Modularity!

Cyclic Event Driven

IEC61131-3 – Task vs. Program

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 19: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 37

� Functions are portions of executable constructs , which return a value dependent on inputs, without having “internal ” (state) variables

� IEC 61131 standard allows the definition of a large number of functions already defined in libraries , such as:� Mathematical functions� Trigonometric functions� Logical functions� The standard even allows the definition

of user defined functions which can befreely used in different projects

IEC61131-3 – Functions

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 38

� The standard allows the definition of Function Blocks (to al leffects are real code routines, which can contain internalvariables, or statuses)

� Function blocks can be saved in libraries and used insidedifferent projects in a way indipendent to the language they arewritten with

IEC61131-3 – Function blocks

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 20: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 39

� The modules, which in the standard are defined as P OUs (Program Organisation Units), are:� Programs� Function blocks� Functions

� All the architecture allows an easy (re)use of code portions developed in previous projects or purchased on the market as libraries

IEC61131-3 – POU

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 40

� Global and local variables (declared in a POU) with user defined mnemonic names

� Variable types (B = byte, b = bit)� Bit Strings - groups of on/off values (BOOL (1), BYTE(8), WORD(16), DWORD(32), LWORD(64))� INTEGER - whole numbers (SINT(1B), INT(2B), DINT(4B), LINT(8B))� U - Unsigned - add a U to the type to make it unsigned integer� REAL - floating point IEC 559 (IEEE) (REAL (4B), LREAL (8B))� TIME - duration for timers, processes. � Date and Time of day (DATE, TIME_OF_DAY, DATE_AND_TIME )� STRING - character strings surrounded by single quotes� WSTRING - holds multi-byte strings� ARRAY - multiple values stored in the same variable� Derived - type derived from one of the above types� STRUCT - composite of several variables and types. � Generic (ANY)

� “Retentive” variables are persistent while performi ng hot start

IEC61131-3 – Data Types

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 21: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 41

� POU internal structure can be written in the follow ing IEC61131-3 languages:� Sequential Function Charts (SFC)� Ladder Diagrams (LD)� Function Block Diagrams (FBD)

� Instruction List (IL)� Structured Text (ST)

� Note: SFC is conceived as a POU internal organization tool, even if is at all effects formal and executable.

Graphical

Textual

IEC61131-3 - Languages

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 42

IEC61131-3 – Languages, SFC

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� Few and simple ideas

� Step: sequence execution state

� Transition: passage between two steps during program execution

� Action: every step is associated with one or more actions to be performed

� Logic conditions: enables transition trigger, so execution evolution (true= transition triggered, false = transition stopped)

� Oriented arc: identifies passages between steps through a transitionwhich is enabled by a logic condition

Page 22: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 43

IEC61131-3 – Languages, SFC

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� Step:

� ID (usually an integer sequential number)

� Can be active or inactive

� Graphical representation: square (with double border if starting step)

� Has associated actions to be performed when the step is “active” serie di “azioni. To every action a qualifier is associated, specifyingexecution time or duration (N, S, P, etc.)

2Turn

Motor on

Step

Identifier

Active step is marked

X

Qualifier:• P Activation• N Deactivation• S Set• R Reset• …

Action

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 44

IEC61131-3 – Languages, SFC

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� Transition

� Identifier

� Enabled or disabled

� Can be triggered by a logic condition

� Graphical representation: horizontal segment

C1 AND C2

Transizione Logic condition

Page 23: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 45

IEC61131-3 – Languages, SFC

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� OR divergence

� Two transitions after a single step

NOTE: mutual exclusion is necessary in order to have a deterministicbehaviour of the program

3

4 5

C1 NOT(C1)

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 46

IEC61131-3 – Languages, SFC

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� OR convergence

� One step after two transitions

Page 24: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 47

IEC61131-3 – Languages, SFC

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� AND (parallelism) divergence:

� Simultaneous activation of more than one step

15

13

14

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 48

IEC61131-3 – Languages, SFC

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� AND Convergence

� More than one step are deactivated at the same time (syncronization)

22

20 21

Page 25: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 49

IEC61131-3 – Languages, SFC

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� Evolution rules:� A transition is enabled (by the associated logic condition) if all

the steps before it are active� A transition can be triggered if is enabled and the condition is

true

Active step

17

15

16

true

Condition verified

Transition enabled

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 50

IEC61131-3 – Languages, SFC

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� Evolution rules:� A transition is enabled (by the associated logic condition) if all

the steps before it are active� A transition can be triggered if is enabled and the condition is

true

17

15

16

Transition passed

Page 26: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 51

IEC61131-3 – Languages, Ladder Diagram

� LD - Main aspects:

� Graphical

� Based on the transposition of an electrical network in programming logic based mainly on:� Contacts

� Coils

� LD recalls wired logics used before PLCs → Easier transition to new technologies

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 52

IEC61131-3 – Languages, Ladder Diagram

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Vcc (pole +) Gnd (pole -)

I1 U1Rung

If I1 == 1

U1 = 1

Else

U1 = 0

Meaning: IF i1 contact is CLOSED, THEN current can flow from + pole to - pole, activating U1

coil

Page 27: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 53

IEC61131-3 – Languages, Ladder Diagram

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� Inputs:� Are always located on the left side of the rung

� Normally opened contact

� If associated bit is 1, the contact closes

� If associated bit is 0, the contact opens

� Normally closed contact

� If associated bit is 1, the contact opens

� If associated bit is 0, the contact closes

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 54

IEC61131-3 – Languages, Ladder Diagram

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� Outputs:� Are always located on the right side of the rung� Coil

� Activates when current passes .Associated bit rises to logic value 1 (ON) if logical conditions to its left are verified

� Latch Coil� Keeps the logic state 1 (ON)

even if activation condition is not verified any more (similar to flip-flop SET)

� Unlatch Coil� Drives logic state to 0 (OFF)

similar to flip-flop RESET

Page 28: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 55

IEC61131-3 – Languages, Ladder Diagram

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� Putting rungs in sequence (namely instructions), we cancompose a program.

� Be careful: LD is a language, not an electrical network, so it is necessary to state how rungs are interpreted

� Rungs are processed:

� From top to bottom

� From left to right

� Every rung is processed once per cycle (unless there are jumpinstructions)

Current flow

Program

flow

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 56

IEC61131-3 – Languages, Ladder Diagram

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� Examples:

U3 = NOT (I1)

I1 U3

Page 29: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 57

IEC61131-3 – Languages, Ladder Diagram

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� Examples:

U3 = I1 AND I2

I1 U3I2

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 58

IEC61131-3 – Languages, Ladder Diagram

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� Examples:

U3 = I1 OR I2

I1 U3

I2

Page 30: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 59

IEC61131-3 – Languages, Ladder Diagram

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

� Examples:

U3 = I1 XOR I2 =[ I1 AND NOT(I2)] OR [NOT(I1) AND I2]

I1 U3I2

I1 I2

I1 I2 U3

0 0 0

0 1 1

1 0 1

1 1 0

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 60

AND

OR I1

I2

U1U1

FUNCTIONBLOCK

INPUTS

OUTPUTS

IEC61131-3 – Languages, FBD

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 31: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 61

LD AGT 1000JMPCN V_OKLD VSUB 10

V_OK LD 1ST B

If A>1000 then

V:=V-10;

end_if;B:=1;

IEC61131-3 – Languages, IL

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 62

IF A>B THEND := 1;

ELSEIF A=B+2 THEND:=2;

ELSEREPEAT

D :=D+1;UNTIL (START=Off)END_REPEAT

END_IF;

� Very similar to general purpose languages like C…

IEC61131-3 – Languages, ST

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

Page 32: PLC – IEC61131 - Politecnico di Milanohome.deib.polimi.it/ferrarin/miai_270/files/PLC-EN_01_IEC1131.pdf · The Programmable Logic Controller is an electronic device used for programming

A.A. 2011-2012 Production Systems Control - Prof. Luca Ferrarini 63

� IEC-61131

� Definition of PLC hardware architecture

� Definition of a group of languages for the implementation of control logics

� Graphical (SFC, LD, FBD)

� Textual (IL, ST)

� Variable types, persistency, etc.

� Standard date:

� First edition1993

� The most used nowadays (maybe unique as a standard!)

� Evolutions

� IEC-614499 (Function Block NET)

� Soft PLCs (es. Orchestra Control)

Basic hardware OS and functional architecture ConclusionsIntroduction IEC61131

IEC61131-3 – Conclusions