You are on page 1of 46

IST / DEEC / ACSDC

MEEC 2007-2008

Industrial Automation
(Automao (A t d de P Processos I Industriais) d t i i)

PLCs Programming Languages Ladder Diagram


http://www.isr.ist.utl.pt/~pjcro/courses/api0708/api0708.html
Prof. Paulo Jorge Oliveira pjcro @ isr.ist.utl.pt Tel: 21 8418053 ou 2053 (internal)

API

P. Oliveira

Page. 1

IST / DEEC / ACSDC

MEEC 2007-2008

Syllabus:
Chap. 2 Introduction to PLCs [2 weeks] ... Chap. 3 PLCs Programming Languages [2 weeks] Standard languages (IEC-1131-3): Ladder Diagram; Instruction List, and Structured Text. Software development resources. ... Chap. 4 - GRAFCET (Sequential Function Chart) [1 week]

API

P. Oliveira

Page 2

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

PLCs Programming Languages (IEC 11311131-3) Ladder Diagram Structured Text


If %I1.0 THEN %Q2.1 := TRUE ELSE %Q2.2 := FALSE END_IF

Instruction List
LD AND ANDN OR ST %M12 %I1.0 %I1.1 %M10 %Q2.0

Sequential Function Chart (GRAFCET) 1


(1) m

2
(2) b

Right

3
(3) p

Load

4
(2) a

Left

API

P. Oliveira

Page 3

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Linguagens de programao de PLCs (IEC 11311131-3) Ladder Diagram Structured Text


If %I1.0 THEN %Q2.1 := TRUE ELSE %Q2.2 := FALSE END_IF

Instruction List
LD AND ANDN OR ST %M12 %I1.0 %I1.1 %M10 %Q2.0

Sequential Function Chart (GRAFCET) 1


(1) m

2
(2) b

Direita

3
(3) p

Carrega

4
(2) a

Esquerda

API

P. Oliveira

Page 4

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram

Input Instructions

Output Instructions

API

P. Oliveira

Page 5

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Types of operands:

API

P. Oliveira

Page 6

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Basic Instructions


Load
Open contact: contact is active (result is 1) while the control bit is 1. Close contact: contacto is active (result is 1) while the control bit is 0.
P

Contact in the rising edge: contact is active during a scan cycle where the control bit has a rising edge. edge Contact in the falling edge: contact is active during a scan cycle %Q2.0 the control I1.0 where bit has a falling edge.
t
Q2.0

N %I1.0 P

t API P. Oliveira Page 7

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Basic Instructions


Load operands

API

P. Oliveira

Page 8

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Basic Instructions


Store
The result of the logic function activates the coil. The inverse result of the logic function activates the coil. The result of the logic function energizes the relay (sets the latch). latch) The result of I1.0 the logic function de-energizes the relay %Q2.0 (resets the latch)..
S
Q2.0

R %I1.0 N

t API P. Oliveira Page 9

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Basic Instructions


Store operands

API

P. Oliveira

Page 10

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Allen Bradley notation


Relays with latch and unlatch

API

P. Oliveira

Page 11

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram

Relay-type y yp instructions Example:

API

P. Oliveira

Page 12

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Basic Instructions


AND
%I1.0 %I1.0 %Q2.0

AND of the operand with the result of the previous I1.0 logical operation.
t

AND of the operand with the inverted result of the previous Q2.0 logical operation. t
P

AND of the rising edge with the result of the previous logical operation operation. AND of the falling edge with the result of the previous logical operation.

API

P. Oliveira

Page 13

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Basic Instructions


OR
OR of the operand with the result of the previous logical operation. OR of the operand with the inverted result of the previous logical operation. OR of the rising edge with the result of the previous logical operation. OR of the falling edge with the result of the previous logical operation.

API

P. Oliveira

Page 14

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Basic Instructions


XOR

API

P. Oliveira

Page 15

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Ladder assembling
Input Instructions O t t Output Instructions

The outputs that have a TRUE logical function, evaluated from the left to right and from the top to the bottom, are energized (Schneider, Micro PLCs).
API P. Oliveira Page 16

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example:

API

P. Oliveira

Page 17

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example:

API

P. Oliveira

Page 18

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example:

API

P. Oliveira

Page 19

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example:

API

P. Oliveira

Page 20

10

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
General case of Inputs and Outputs in parallel, with derivations

Note: it is important to study the constraints and potentialities of the development tools.
API P. Oliveira Page 21

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Imbricated contacts and alternative solution

API

P. Oliveira

Page 22

11

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Contacts in the vertical and alternative solution

API

P. Oliveira

Page 23

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Contacts in the vertical and alternative solution Another example:

API

P. Oliveira

Page 24

12

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Temporized Relays or Timers

API

P. Oliveira

Page 25

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Temporized Relays or Timers


%TMi IN
MODE: TON TB: 1mn TM.P: 9999 MODIF: Y

Characteristics:
Identifier: Input: Mode: %TMi IN TON TOFF TP TB 0..63 in the TSX37 to activate On delay Off delay Monostable 1mn (def.), 1s, 100ms, 10ms

Time basis: Q

Programmed value: %TMi.P 0...9999 (def.) period=TB*TMi.P Actual value: %TMi.V 0...TMi.P (can be real or tested) Modifiable: Y/N can be modified from the console
P. Oliveira Page 26

API

13

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Temporized Relays or Timers

API

P. Oliveira

Page 27

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example:

API

P. Oliveira

Page 28

14

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example:

API

P. Oliveira

Page 29

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Temporized Relays or Timers


%TMi IN
MODE: TP TB: 100msec TM.P: 5 MODIF: Y
TMi.P IN

Mode:

TP

Works as a monstable or as a pulse generator (with pre-programmed period)

Q
Q
500ms 500ms

TMi.V

API

P. Oliveira

Page 30

15

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Timers implementation in the Allen-Bradley y PLC-5:

Two alternative representations....

API

P. Oliveira

Page 31

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Timers operation in the Allen-Bradley PLC-5

API

P. Oliveira

Page 32

16

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example of timer on-delay

API

P. Oliveira

Page 33

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example of a timer on-delay that sets an output

API

P. Oliveira

Page 34

17

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example of timer on-delay

API

P. Oliveira

Page 35

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example of timer on-delay
Coil is energized if the switch remains closed for 12 seconds

API

P. Oliveira

Page 36

18

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example of timer on-delay
If PB2 is activated, powers on the oil pumping motor. When the pressure augments, PS1 detects the increase and activates the main motor. 15 segunds later the main drive motor starts.

API

P. Oliveira

Page 37

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example of timer programmed as off-delay

API

P. Oliveira

Page 38

19

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example of timer programmed as off-delay

API

P. Oliveira

Page 39

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example of timer programmed as off-delay

API

P. Oliveira

Page 40

20

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example of timers programmed as off-delay and on-delay

API

P. Oliveira

Page 41

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Timers


Example:

API

P. Oliveira

Page 42

21

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Retentive Timers

API

P. Oliveira

Page 43

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example of retentive timers

API

P. Oliveira

Page 44

22

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Timers


Example: (search on the Schneider PLC or discuss implementation)

API

P. Oliveira

Page 45

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Exemplo:
SW ON to start operation Before motor starts, lubrificate 10 s with oil. SW OFF to stop. (lubrificate 15 s more). After 3 hours of pump operation, stop motor and signal with pilot light. Reset available after servicing.
API P. Oliveira Page 46

23

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Cascaded Timers

API

P. Oliveira

Page 47

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Cascaded Timers (bistable system)

API

P. Oliveira

Page 48

24

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Timers for very long time intervals

API

P. Oliveira

Page 49

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example of a semaphore

API

P. Oliveira

Page 50

25

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Example of a semaphore in both directions

API

P. Oliveira

Page 51

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Example of a semaphore in both directions

API

P. Oliveira

Page 52

26

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Counters

Some applications...

API

P. Oliveira

Page 53

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Characteristics: Counters


Identifier: Value progr.: Value Actual: %Ci R S
CP: 9999 MODIF: Y

%Ci %Ci.P %Ci.V Y/N

0..31 in the TSX37 0...9999 (def.) 0...Ci.P (only to be read) can be modified from the console Reset Ci.V=0 Preset Ci.V=Ci.P Count Up Count Down Overrun %Ci.E=1 %Ci.V=0->9999 Done %Ci.D=1 %Ci.V=Ci.P Full %Ci.F=1 %Ci.V=9999->0
P. Oliveira Page 54

E D F

Modifiable:

Inputs:

CU CD

R S CU CD E D F

Outputs:

API

27

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Implementation of Counters in the PLC-5 of Allen-Bradley y:

Internal Structure

Representation

API

P. Oliveira

Page 55

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Implementation of Counters y: in the PLC-5 of Allen-Bradley


Alternative representations

API

P. Oliveira

Page 56

28

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Up-counters

Implementation of an incremental Up-counter and Corresponding temporal diagram


API P. Oliveira Page 57

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Example: p


Counting parts

API

P. Oliveira

Page 58

29

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Example

API

P. Oliveira

Page 59

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Up/down-counters

API

P. Oliveira

Page 60

30

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Up/down-counters

API

P. Oliveira

Page 61

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Up/down-counters


Example:
Finite parking garage

API

P. Oliveira

Page 62

31

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Cascaded Counters


Example:

API

P. Oliveira

Page 63

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Cascaded Counters


Example: 24 hours clock

API

P. Oliveira

Page 64

32

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Cascaded Counters


Example: Memory time of event

API

P. Oliveira

Page 65

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Incremental Encoder

API

P. Oliveira

Page 66

33

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Incremental Encoder


Example: counter as a lenght sensor

API

P. Oliveira

Page 67

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example with counters and timers (conts.): Specs:
Starts M1 conveyor upon pushing button . After 15 plates stops M1 and starts conveyor M2 . M2 operates for 5 seconds and then stops. Restart sequence.

API

P. Oliveira

Page 68

34

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example with counters and timers (conts.): Specs:
Starts M1 conveyor upon pushing button . After 15 plates stops M1 and starts conveyor M2 . M2 operates for 5 seconds and then stops. Restart sequence.

API

P. Oliveira

Page 69

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example with counters and timers (conts.): Specs:
Starts M1 conveyor upon pushing button . After 15 plates stops M1 and starts conveyor M2 . M2 operates for 5 seconds and then stops. Restart sequence.

API

P. Oliveira

Page 70

35

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Example with counters and timers (conts.): To use a timer to command a counter, to implement large periods of time.

API

P. Oliveira

Page 71

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram Counters


Example:

API

P. Oliveira

Page 72

36

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Numerical Processing

Algebraic and Logic Functions

API

P. Oliveira

Page 73

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Numerical Processing Arithmetic Functions

API

P. Oliveira

Page 74

37

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Numerical Processing E Example: l Arithmetic functions

Use of a system variable: %S18 flag de overflow


API P. Oliveira Page 75

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Numerical Processing Logic Functions

API

P. Oliveira

Page 76

38

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Numerical Processing E Example: l Logic functions

API

P. Oliveira

Page 77

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Numerical Processing P i iti on the Priorities th execution ti of f the th operations ti

API

P. Oliveira

Page 78

39

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Structures for Control of Flux S b ti Subroutines Call and Return

API

P. Oliveira

Page 79

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Structures for Control of Flux JUMP i instructions: t ti Conditional and unconditional

API

P. Oliveira

Page 80

40

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Structures for Control of Flux E Example: l Use of jump instructions Attention to: INFINITE LOOPS ... It is not a good style of programming!... Does not improove the legibility of the proposed solution.
API P. Oliveira Page 81

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Structures for Control of Flux H lt Halt

Stops all processes! Events masking

API

P. Oliveira

Page 82

41

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
There are other advanced instrauctions (see manuel) Monostable Registers of 256 words (LIFO ou FIFO) DRUMs Comparators Shift-registers ... Functions to manipulate floats
API

Functions to convert bases and types

P. Oliveira

Page 83

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Numerical Tables

API

P. Oliveira

Page 84

42

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Each PLC has limitations in terms of connections E Example: l

API

P. Oliveira

Page 85

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
It is important to learn the potentialities and ... the limitations of the developing tools, i e TO STUDY the manuals is a MUST i.e. MUST.

API

P. Oliveira

Page 86

43

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Learn how to develop and debug programs (and how to do the fine tunning).

API

P. Oliveira

Page 87

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
System information: system bits

See manual for the remaining 100 bits generated...

API

P. Oliveira

Page 88

44

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Informao de Sistema: words de sistema

See manual for the remaining 140 words generated...

API

P. Oliveira

Page 89

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Software Organization
Sas (LD)

MAST Master Task Program Composed by sections


Oven1 (GRAFCET) PRL (LD) Chart POST (IL)

Execution Cyclically or Periodically


Cleaning (IL) Drying (LD)

SR0

API

P. Oliveira

Page 90

45

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Software Organization FAST Fast Task Program Priority greater than MAST Executed Periodically (1-255ms) Verified by aWatchdog, impacts on %S11 %S31 Enables E bl or disables di bl a FAST %S33 gives the execution time for FAST

API

P. Oliveira

Page 91

IST / DEEC / ACSDC

Chap. 3 - PLCs Programming languages

Ladder diagram
Software Organization Event Processes Processes that can react to external changes (16 in the Micro 3722 EV0 a EV15) Priority greater than MAST and FAST!

Event Generators
Inputs 0 to 3 in module 1 1, given transictions Counters Upon telegrams reception %S38 Enables or disables event processes (also with MASKEVT() or UNMASKEVT())
API P. Oliveira Page 92

46

You might also like