programmable logic controllers - fferrante.net · plc a programmable logic controller (plc) is an...

41
Programmable Logic Controllers Francesco Ferrante, PhD [email protected] Department of Physics, Engineering, Earth, and Environmental Sciences, and Mechanics Grenoble Image Parole Signal Automatique Université Grenoble Alpes Control Systems Technologies —– Graduate Course Master in Systems, Control, and Information Technologies —– October 1, 2018 Université Grenoble Alpes - 1/38

Upload: hoangdung

Post on 21-Mar-2019

258 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Programmable Logic ControllersFrancesco Ferrante, PhD

[email protected]

Department of Physics, Engineering, Earth, and Environmental Sciences, and

Mechanics

Grenoble Image Parole Signal Automatique

Université Grenoble Alpes

Control Systems Technologies

—–

Graduate Course

Master in Systems, Control, and Information Technologies

—–

October 1, 2018

Université Grenoble Alpes - 1/38

Page 2: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Outline

1. Introduction

◮ Historical Background

2. Structure of a PLC

◮ IEC Standards

◮ CPU

◮ Memory

◮ Input/Output Unit

3. Programming Languages

◮ Ladder Diagrams

◮ Function Block Diagrams

◮ Sequential Function Charts

Université Grenoble Alpes - 2/38

Page 3: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Outline

1. Introduction

◮ Historical Background

2. Structure of a PLC

◮ IEC Standards

◮ CPU

◮ Memory

◮ Input/Output Unit

3. Programming Languages

◮ Ladder Diagrams

◮ Function Block Diagrams

◮ Sequential Function Charts

Université Grenoble Alpes - 3/38

Page 4: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Introduction

PLC

A programmable logic controller (PLC) is an industrial digitalcomputer which has been ruggedised and adapted for the control ofmanufacturing processes.

They are capable of:

◮ storing instructions, such assequencing, timing,counting, arithmetic

◮ manipulating data

◮ communicating overnetworks

◮ controlling industrialmachines and processes.

Université Grenoble Alpes - 4/38

Page 5: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Application Areas

◮ Since its invention, the PLChas been successfully appliedin many industrial fields

◮ PLCs perform a great varietyof control tasks, fromrepetitive ON/OFF controlof simple machines tosophisticated manufacturingand process control.

Université Grenoble Alpes - 5/38

Page 6: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Example of Task

1: function Drill Control2: repeat

3: while Workpiece contactopen do

4: NOP5: end while

6: while Drill contact closed do

7: lower the drill8: end while

9: stop lowering the drill10: while Depth contact closed

do

11: start drilling12: end while

13: stop drilling14: until (1)15: end function

Université Grenoble Alpes - 6/38

Page 7: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Historical Background

◮ The Hydramatic Division of the General Motors Corporationspecified the design criteria for the first programmablecontroller in 1968.

◮ Their primary goal was to eliminate costly and rigidrelay-control systems. The objective was to conceive asolid-state system with computer flexibility able to:

1. survive in an industrialenvironment,

2. be easily programmedand maintained byplant technicians,

3. be reusable

Morley (left) and his team poses with thefirst PLC, the Modicon.

Université Grenoble Alpes - 7/38

Page 8: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Historical Background

“The initial machine, which was never

delivered, only had 125 words of

memory, and speed was not a criteria as

mentioned earlier...You can imagine

what happened! First, we immediately

ran out of memory, and second, the

machine was much too slow to perform

any function anywhere near the relay

response time..”

Richard E. “Dick” Morley.1932-2017. The father of the PLC.

Université Grenoble Alpes - 8/38

Page 9: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Outline

1. Introduction

◮ Historical Background

2. Structure of a PLC

◮ IEC Standards

◮ CPU

◮ Memory

◮ Input/Output Unit

3. Programming Languages

◮ Ladder Diagrams

◮ Function Block Diagrams

◮ Sequential Function Charts

Université Grenoble Alpes - 9/38

Page 10: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

International Electrotechnical Commission

International Electrotechnical Commission

The International Electrotechnical Commission (IEC;in French: Commission électrotechnique

internationale) is an international standardsorganization that prepares and publishes InternationalStandards for all electrical, electronic and relatedtechnologies-collectively known as"electrotechnology".

The International Electrotechnical Commission heldits inaugural meeting on 26 June 1906, following dis-cussions among the British Institution of ElectricalEngineers, the American Institute of Electrical Engi-neers, and others, which began at the 1900 Paris In-ternational Electrical Congress. In 1906, Lord Kelvinwas elected as the first President of the IEC.

Some History...

IEC-Central Office,Geneva

Université Grenoble Alpes - 10/38

Page 11: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Standard IEC 61131

IEC 61131 is an IEC standard for programmable controllers. It wasknown as IEC 1131 before the change in numbering system by IEC.IEC 61131 consists of the following parts under the general title:Programmable controllers:

1. General information

2. Equipment requirements and tests

3. Programming languages

4. User guidelines

5. Communications

6. Reserved

7. Fuzzy-control programming

8. Guidelines for the application and implementationprogramming languages for programmable controllers

Université Grenoble Alpes - 11/38

Page 12: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Standard IEC 61131

Digitally operating electronic system, designed for use in an in-dustrial environment, which uses a programmable memory for theinternal storage of user-oriented instructions for implementing spe-cific functions such as logic, sequencing, timing, counting andarithmetic, to control, through digital or analogue inputs and out-puts, various types of machines or processes. Both the PLC andits associated peripherals are designed so that they can be easilyintegrated into an industrial control system and easily used in alltheir intended functions.

PLC Definition IEC 61131

User-built configuration, consisting of a programmable controllerand associated peripherals, that is necessary for the intended au-tomated system. It consists of units interconnected by cables orplug-in connections for permanent installation and by cables orother means for portable and transportable peripherals

PLC-system IEC 61131

Université Grenoble Alpes - 12/38

Page 13: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Structure of a PLC

Université Grenoble Alpes - 13/38

Page 14: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Structure of a PLC

◮ Case◮ ensures the mechanical and electrical interconnections. The

main features are: number of slots, size, degree of protection,size, and mounting type.

◮ Power Supply Module◮ provides stabilized power to the modules. The main features

are: maximum supplied power, the possibility to send ashutdown signal to the PLC in case of power failure, thepresence of buffer batteries and status indicators, etc.

◮ I/O Modules◮ The PLC communicates with the field through digital and

analog I/O modules, which ensure galvanic isolation of theinternal hardware. Transmission occurs in voltage or, moreoften, in current. Analog I/O modules also perform D/A andA/D conversions.

Université Grenoble Alpes - 14/38

Page 15: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Structure of a PLC

◮ Special Modules◮ remote I/O modules (located in a different rack)◮ network modules◮ PID modules◮ specific sensor interfaces◮ human-machine interfaces◮ backup modules (spare CPUs synchronized with the main one)

◮ Programming terminal◮ There are dedicated terminals that connect directly to the PLC

via a communication port and are equipped with a keyboardfor entering instructions and a display for program control.PC-based development systems are increasingly common. Inthis systems, programming is performed off-line. PC terminalsare connected to the PLC either directly or via the network.

◮ CPU module◮ The processor module (CPU) contains one or more

microprocessors, which execute the operating system and theuser code.

Université Grenoble Alpes - 15/38

Page 16: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Mechanical Design

There are two common types of mechanical design for PLCsystems: single box and modular/rack types

The single box type (brick)is supplied as a compactpackage complete withpower supply, processor,memory, and input/outputunits.

The modular type consistsof separate modules oftenmounted on rails within ametal cabinet. Thus it iscomparatively easy toexpand.

Université Grenoble Alpes - 16/38

Page 17: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Let us look inside

Université Grenoble Alpes - 17/38

Page 18: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

CPUThe standard operating mode consists of periodically executing thefollowing steps:

1. Read physical inputs and store the readings into a specific areof the memory;

2. Execute the user program. Variables’ values are taken from thememory and results are transferred toward the memory;

3. Execution of system management programs (e.g. diagnostics);4. Write physical outputs. Values written on the outputs are

taken from a specific are of the memory.

Université Grenoble Alpes - 18/38

Page 19: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

CPUThe standard operating mode consists of periodically executing thefollowing steps:

1. Read physical inputs and store the readings into a specific areof the memory;

2. Execute the user program. Variables’ values are taken from thememory and results are transferred toward the memory;

3. Execution of system management programs (e.g. diagnostics);4. Write physical outputs. Values written on the outputs are

taken from a specific are of the memory.

In special cases (typically faults or emergencies) a CPU can performoperations with immediate access to the input/output points, typ-ically in response to interrupts. It is advisable to limit the use ofinterrupts as much as possible. Overusing interrupts reduces codereadability.

Université Grenoble Alpes - 18/38

Page 20: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

CPU-Scan time

◮ The processing speed of a CPU is measured by the scan time,that is, the time elapsed between two successive activations ofthe same portion of the user program.

◮ The scan time depends on how many inputs and outputs youneed to update and the size and complexity of the userprogram. It is defined in milliseconds per kiloword of program(with 8 or 16 bit words).

PLC manufacturers typically indicate an average value for the scantime for programs of medium complexity (not all instructions havethe same duration). Typical scan times are about few fractions ofms/kw.

◮ The response time of the PLC is, instead, the longest intervalof time between the detection of a certain event and theexecution of the response action programmed for it. Responsetime accounts also for the delays introduced by the I/Omodules.

Université Grenoble Alpes - 19/38

Page 21: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

CPU-Operating SystemThe operating system of a PLC is a set of permanently storedprograms which:

◮ PLC activities control;

◮ user program execution;

◮ communication tasks;◮ diagnostic and monitoring:

◮ watchdog timer;◮ parity check on memory and communication networks;◮ voltage and backup batteries checks.

A PLC can be in three different operating conditions:

◮ execution The PLC executes user program and updatesoutputs;

◮ validation The PLC executes user program but outputs are notupdated (usually used in debug);

◮ programming This is the operating mode used to transfer thecode to the PLC.

Université Grenoble Alpes - 20/38

Page 22: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Memory

PLC memory is organized in different areas:

◮ operating system area (ROM);

◮ operating system working ares (RAM);

◮ I/O area (RAM);

◮ user program (RAM for development and PROM or EPROMlater)

Memory available to user programs typically ranges from about halfa kiloword to a few hundred kiloword (with 8 or 16 bit words).

Université Grenoble Alpes - 21/38

Page 23: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Input/Output Units◮ The input/output unit provides the interface between the

system and the outside world◮ It is also through the input/output unit that programs are

entered from a program panel◮ Every input/output point has a unique address which can be

used by the CPU.

The input/output channels provide isolation and signal conditioningfunctions. This allows sensors and actuators to be directlyconnected to the PLC.

Université Grenoble Alpes - 22/38

Page 24: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Input/Output Units

Université Grenoble Alpes - 23/38

Page 25: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Outline

1. Introduction

◮ Historical Background

2. Structure of a PLC

◮ IEC Standards

◮ CPU

◮ Memory

◮ Input/Output Unit

3. Programming Languages

◮ Ladder Diagrams

◮ Function Block Diagrams

◮ Sequential Function Charts

Université Grenoble Alpes - 24/38

Page 26: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Programming Languages

The standard IEC 61131 covers differentaspects related to PLC control systems

◮ Devices specifications

◮ programming languages

◮ communication protocols

Université Grenoble Alpes - 25/38

Page 27: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Programming Languages

The standard IEC 61131 covers differentaspects related to PLC control systems

◮ Devices specifications

◮ programming languages

◮ communication protocols

Université Grenoble Alpes - 25/38

Page 28: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Programming Languages

The standard IEC 61131 covers differentaspects related to PLC control systems

◮ Devices specifications◮ programming languages◮ communication protocols

IEC 61131-3 takes care of programming languages standardization.

The standardization of programming languages is the crucial point.That ensures projects portability products interoperability.The main guidelines of the IEC 61131-3 are as follows:

◮ foster the transition toward modern programming concepts,i.e., modularity and structured programming

◮ help software portability◮ streamline software verification◮ reduce developing and training cost

Université Grenoble Alpes - 25/38

Page 29: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Programming Languages

IEC 61131-3 defines five programming languages.Graphical Languages

◮ sequential function charts (SFC)

◮ ladder diagrams (LD)

◮ function block diagram (FBD)

Procedural Languages

◮ instruction list (IL)

◮ structured text (ST)

Usually Integrated Development Environments allow for the use ofseveral IEC 61131-3 languages. Some software enable the user tocombine different languages in the same project.

Université Grenoble Alpes - 26/38

Page 30: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Ladder Diagrams◮ The Ladder Diagram (LD) follows the formalism used in the

old schematics of electro-mechanical control systems. Thismakes it easily acceptable to “old school” technicians.

◮ The language is based on the notions of contact and coil andwas initially designed for binary logic functions. Later on it hasbeen extended to deal with integers and real variables.

◮ It is a low-level and unstructured language, not very suitablefor complex systems. However, it is important because it wasthe first graphic language for PLCs. It is present in allindustrial PLCs and is a de facto standard of the US market.

Example of Ladder DiagramUniversité Grenoble Alpes - 27/38

Page 31: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Contacts

Contacts

Université Grenoble Alpes - 28/38

Page 32: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

CoilsCoils

Université Grenoble Alpes - 29/38

Page 33: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Coils Cont’dCoils

Some comments:◮ The transition sensing contacts and coils are useful for

initialization and detecting input transitions, for example, apush button press;

◮ The set and reset coils are used in conjunction with each other;◮ The retentive memory coil instructions are used in a situation

where the state of the output must be retained when the PLCis stopped or power fails.

Université Grenoble Alpes - 30/38

Page 34: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Ladder Rules

1. Current only flows from left to right2. The rungs are explored by the PLC from the top to the

bottom and again. As a result, the rung order is relevant3. The synchronization of the program variables with inputs and

outputs follows the PLC working principle:◮ Input are read (the values remain constant for the whole cycle);◮ all rungs are executed and the each coil got assigned the

corresponding value. Such a value is unchanged until the coilsis rewritten;

◮ Output are updated;◮ the process restarts over.

Design Tips◮ the coil or negated coil instruction referring to a particular

output must only occur once in a ladder program. Consideringthe output coil first and the conditions for which it is active(on) will avoid repeating coils;

◮ For an output to have effect on another rung in the same scan,it must be programmed before such a rung.

Université Grenoble Alpes - 31/38

Page 35: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Dos and Dont’s◮ DO NOT repeat normal output coils or negated coils that refer

to the same tag◮ Use the set (latch) coil and reset (unlatch) coils together. If a

set coil refers to an output, there should also be a reset coil forthat output.

◮ Be careful when using the set/reset coils for physical outputs.If the system involves safety and a set coil is used for a PLCphysical output,simply interrupting the condition on the setcoil rung will not turn off the physical output.

◮ Reverse power flow in the contact matrix is not allowed.

Reverse power flow in ladder diagram.

Université Grenoble Alpes - 32/38

Page 36: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Function Block DiagramsFunction Block Diagram (FBD) is analogous to circuit diagrams,where connections represent signal paths between components.A functional block has two main characteristics: the definition ofdata (inputs and outputs) and an algorithm that processes currentvalues of inputs and internal variables to generate an output.

Example of Function Block Diagram.

Université Grenoble Alpes - 33/38

Page 37: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

FBD Symbols

Université Grenoble Alpes - 34/38

Page 38: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Sequential Function Charts

SFC originates from the French Grafcet (Graphe de coordination

étapes-transitions).

Example of an SFC diagram.

Strongly related to Petri nets.Sequential Functional Chart (SFC) is based on the concepts ofstep, transition, and arcs.

Université Grenoble Alpes - 35/38

Page 39: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Steps

◮ Step: stage in which the system may dwell.◮ Steps can be active or inactive. When a step is active, its

symbol has has marker;◮ each step has a tag, usually a number;◮ an initial step is specified by the programmer;◮ a state variable is associated to each step. The variable is zero

is 1 is the step is active and 0 otherwise.◮ a step can have an action associated.

Université Grenoble Alpes - 36/38

Page 40: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Transitions and Arcs

◮ Transitions

◮ Transition: enable to move from one step the the followingone.

◮ transitions are denoted by a horizontal line;◮ transitions have an identifier;◮ transition may have a logical condition associated;◮ a transition may be enabled or not.

◮ Arcs

◮ represented by segments

◮ connect steps and transitions. No step to step and transitionto transition!

Université Grenoble Alpes - 37/38

Page 41: Programmable Logic Controllers - fferrante.net · PLC A programmable logic controller (PLC) is an industrial digital computer which has been ruggedised and adapted for the control

Evolution Rules

Some initial comments:A transition is enabled if all preceding steps are active.A transition is superable when its associated condition is true.

1. When a transition is superable, it is executed. All precedingsteps are deactivated and all following steps are activated;

2. if multiple transition are superable, those are executedsimultaneously.

Université Grenoble Alpes - 38/38