0% found this document useful (0 votes)
34 views81 pages

Industrial Automation: PLC Programming Languages

Uploaded by

Nuno Monteiro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views81 pages

Industrial Automation: PLC Programming Languages

Uploaded by

Nuno Monteiro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 81

IST / DEEC / API

Industrial Automation
(Automação de Processos Industriais)

PLC Programming languages


Ladder Diagram

http://users.isr.ist.utl.pt/~jag/courses/api1314/api1314.html

Slides 2010/2011 Prof. Paulo Jorge Oliveira


Rev. 2011-2014 Prof. José Gaspar
IST / DEEC / API

Syllabus:
Chap. 2 – Introduction to PLCs [2 weeks]
...

Chap. 3 – PLC Programming languages [2 weeks]


Standard languages (IEC-61131-3):
Ladder Diagram; Instruction List, and Structured Text.
Software development resources.

...
Chap. 4 - GRAFCET (Sequential Function Chart) [1 week]

Page 2
IST / DEEC / API Chap. 3 - PLC Programming languages

PLC Programming languages


(IEC 1131-3 changed to IEC 61131-3)
Ladder Diagram Structured Text
If %I1.0 THEN
%Q2.1 := TRUE
ELSE
%Q2.2 := FALSE
END_IF

Instruction List Sequential Function Chart


1
(GRAFCET)
(1) m
LD %M12 2 Direita
AND %I1.0 (2) b
ANDN %I1.1 3 Carrega
OR %M10 (3) p
ST %Q2.0 4 Esquerda
(2) a

Page 3
IST / DEEC / API

Ladder diagram

A program is a series of instructions


that directs the PLC to execute
actions.

Relay ladder logic, the standard


programming language, is based on
electromagnetic relay control.
Input Output
Instructions Instructions

N S

Page 4
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Types of operands in Schneider DMY 28FK:

Page 5
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Types of operands:

Page 6
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram
Basic Instructions

Load Normally open contact: contact is active (result is 1)


when the control bit is 1.
Normally closed contact: contact is active (result is 1)
when the control bit is 0.

Contact in the rising edge: contact is active during a scan cycle


P
where the control bit has a rising edge.

Contact in the falling edge: contact is active during a scan cycle


N
where the control bit has a falling edge.

%I1.0 %Q2.0 I1.0

P t
Q2.0

t
Page 7
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram
Basic Instructions

Load operands

Page 8
IST / DEEC / API Chap. 3 - PLC 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.

S
The result of the logic function energizes the relay
(sets the latch).

R
The result of the logic function de-energizes the relay
(resets the latch)..

%I1.0 %Q2.0 I1.0

N S t
Q2.0

t
Page 9
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram
Basic Instructions

Store operands

Page 10
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram
Allen Bradley notation
Relays with latch and unlatch

Page 11
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Relay-type instructions

Example:

Page 12
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram
Basic Instructions

AND AND of the operand with the result of the previous


logical operation.

AND of the operand with the inverted result of the previous


logical operation.

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

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

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


N P S t
Q2.0

t
Page 13
IST / DEEC / API Chap. 3 - PLC 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


P logical operation.

OR of the falling edge with the result of the previous


N logical operation.

Page 14
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram
Basic Instructions

XOR

%Q2.3 := %I1.1 XOR %M1;


%Q2.2 := NOT(%M2 XOR %I1.2);
%Q2.2 := %M2 XOR NOT(%I1.2);

Page 15
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Ladder assembling

Input Output
Instructions Instructions

N S

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

Page 16
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Example:

Page 17
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Example:

Page 18
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Example:

If the Stop PB is normally open, then invert its logic in the ladder diagram.

Page 19
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Example:

Page 20
IST / DEEC / API Chap. 3 - PLC 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.
Page 21
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Imbricated (nested) contacts and alternative solution

Page 22
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Contacts in the vertical and alternative solution

Page 23
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Contacts in the vertical and alternative solution

Another example:

Solves the problem of disallowed right to


left scanning (FDBC in fig5.30).

Page 24
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Temporized Relays or Timers

Page 25
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Temporized Relays or Timers (pneumatic)

The instantaneous contacts change state as soon as the timer coil is powered.
The delayed contacts change state at the end of the time delay.
Page 26
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Temporized Relays or Timers

On-delay, provides time delay Off-delay, provides time delay when the
when the relay coil is energized. relay coil is de-energized.

Tables: Relay symbols used for timed contacts.


Page 27
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Temporized Relays or Timers

Page 28
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Temporized Relays or Timers

Page 29
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Characteristics:

Temporized Relays Identifier: %TMi 0..63 in the TSX37

Input: IN to activate
or Timers (PLC)
Mode: TON Timer On delay
TOF Timer Off delay
TP Monostable
%TMi
IN Q Time basis: TB 1mn (def.), 1s,
100ms, 10ms
MODE: TON
Programmed value: %TMi.P 0...9999 (def.)
TB: 1mn
period=TB*TMi.P
TM.P: 9999 Actual value: %TMi.V 0...TMi.P
MODIF: Y (can be read or tested)

Modifiable: Y/N can be modified from


the console

Page 30
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram
TON mode
Temporized Relays

or Timers (PLC)

%TMi
IN Q

MODE: TON
TB: 1mn

TM.P: 9999
MODIF: Y

App. example: start ringing the alarm if N sec after door open there is no disarm of the alarm.

Page 31
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram
TOF mode
Temporized Relays

or Timers (PLC)

%TMi
IN Q

MODE: TOF
TB: 1mn

TM.P: 9999
MODIF: Y

App. example: turn off stairways lights after N sec the lights’ button has been released.

Page 32
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram TP mode


Works as a monostable or as a pulse generator
Temporized Relays (with pre-programmed period)

or Timers (PLC)

%TMi
IN Q

MODE: TP
TB: 100msec

TM.P: 5
MODIF: Y

App. example: positive input edge give a controlled (fixed) duration pulse to start a motor.
Page 33
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Timers in PL7 vs Unity (Schneider)

%TMi
IN Q

MODE: TON
TB: 1mn

TM.P: 9999
MODIF: Y

Page 34
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Timers in the Allen-Bradley PLC-5

Two alternative representations

Page 35
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Timers implementation in the Allen-Bradley PLC-5:

Page 36
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Retentive Timers
Switch-off region

Switch-on region

Motor accumulated
motion (rotation)
defines the on/off
timing.

Page 48
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Example of retentive timers

Page 49
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Retentive Timers

Animated demonstration:
(search on the Schneider PLC or discuss implementation)

Page 50
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Example:

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

Page 51
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Cascaded Timers

Page 52
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Cascaded Timers (bistable system)

Page 53
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Timers for very long time intervals

Page 54
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Example of a semaphore

Page 55
IST / DEEC / API Chap. 3 - PLC Programming languages

Example of a semaphore in both directions

Page 56
IST / DEEC / API Chap. 3 - PLC Programming languages

Example of a semaphore

in both directions

Page 57
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Counters

Some applications...

Page 58
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Implementation of Counters
in the PLC-5 of Allen-Bradley:

Internal structure representation

Page 59
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Implementation of Counters
in the PLC-5 of Allen-Bradley:
Two alternative representations:

Coil-formatted counter and reset Block-formatted counter


instructions instruction

Page 60
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Up-counters

Usage of an
incremental up-counter
and the corresponding
temporal diagram:

PB1 increments counting


PB2 resets the counting
Page 61
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Example

1. Start conveyor motor


2. Passing cases increment counter
3. After 50 cases, stop motor

Page 63
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Up/down-counters

Usage of an incremental
up-down-counter
and the corresponding
temporal diagram:

PB1 increments counting


PB2 decrements the counting
PB3 resets the counter

Page 64
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Up/down-counters

Example:

Finite parking garage

Page 65
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Cascaded Counters

Example:

Page 66
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Cascaded Counters

Example:
Count
24 hours clock

Reset

Page 67
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Incremental Encoder

counter measures rotation angle or


rotation speed (if divided by time)

Page 69
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Incremental Encoder

Example:
counter as a ”length sensor”

Page 70
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Counters in PL7 Characteristics:

Identifier: %Ci 0..31 in the TSX37

Value progr.: %Ci.P 0...9999 (def.)


%Ci Value Actual: %Ci.V 0...Ci.P (only to be read)
R E
Modifiable: Y/N can be modified from
S the console
CP: 9999
MODIF: Y D
Inputs: R Reset Ci.V=0
CU S Preset Ci.V=Ci.P
CD F CU Count Up
CD Count Down

Outputs: E Overrun %Ci.E=1 %Ci.V=0->9999


D Done %Ci.D=1 %Ci.V=Ci.P
F Full %Ci.F=1 %Ci.V=9999->0

Page 76
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Counters in Unity Pro

CU "0" to "1" => CV is incremented by 1


CU "0" to "1" => CV is incremented by 1 CD "0" to "1" => CV is decremented by 1

CV ≥ PV => Q:=1 CV ≥ PV => QU:=1


CV ≤ 0 => QD:=1
R=1 => CV:=0
R=1 => CV:=0 LD=1 => CV:=PV
R has precedence over LD

NOTE: counters are saturated such that no overflow occurs


Page 77
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Numerical Processing

Algebraic and Logic Functions

Page 78
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Numerical Processing

Arithmetic Functions

Page 79
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Numerical Processing

Example:

Arithmetic functions

Use of a system variable:

%S18 – flag de overflow


Page 80
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Numerical Processing

Logic Functions

Page 81
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Numerical Processing

Example:

Logic functions

Page 82
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Numerical Processing

Priorities on the execution of the operations

Page 83
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Structures for Control of Flux

Subroutines

Call and Return

Page 84
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Structures for Control of Flux

JUMP instructions:

Conditional and unconditional

Page 85
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Structures for Control of Flux

Example:

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.

Page 86
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Structures for Control of Flux

Halt

Stops all processes!

Events masking

Page 87
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

There are other advanced instructions (see manual)


• Monostable

• Registers of 256 words (LIFO ou FIFO)

• DRUMs

• Comparators

• Shift-registers

...

• Functions to manipulate floats

• Functions to convert bases and types


Page 88
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram

Numerical Tables

Page 89
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram
System information: system bits

See manual
for the remaining
100 bits generated...

Page 90
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram
System information: system words

See manual
for the remaining
140 words generated...

Page 91
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Software Organization

A program can be built from:


Tasks, that are executed cyclically or periodically.

Tasks MAST / FAST / AUX are built from:


Sections
Subroutines
Event processing, that is carried out before all other tasks.

Event processing is built from:


Sections for processing time controlled events
Sections for processing hardware controlled events

Unity - Project Browser

Page 92
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Software Organization

Sas (LD)
MAST – Master Task Program
Oven1 (GRAFCET)
Composed by sections
Execution Cyclic or Periodic PRL (LD)
Chart

POST (IL)
SR0
Drying (LD)

Cleaning (IL)

Page 93
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Software Organization

FAST – Fast Task Program


Priority greater than MAST

• Executed Periodically (1-255ms)


• Verified by a Watchdog, impacts on %S11
• %S31 Enables or disables a FAST
• %S33 gives the execution time for FAST

Page 94
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Software Organization

Event Processes – Processes that can react to external changes


(16 in the Micro 3722 EV0 to EV15)

Priority greater than MAST and FAST!

Event Generators
• Inputs 0 to 3 in module 1, given transitions
• Counters
• Upon telegrams reception
• %S38 Enables or disables event processes
(also with MASKEVT() or UNMASKEVT())
Page 95
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Development tools

Each PLC has limitations in terms of connections

Example:

Page 96
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Development tools


It is important to learn the potentialities and ...
the limitations of the developing tools,
i.e. STUDYING the manuals is a MUST.

Page 97
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Development tools

Last but not least, learn how to develop and debug programs
(and how to do some fine tuning).

Page 98
IST / DEEC / API Chap. 3 - PLC Programming languages

Ladder diagram Development tools

Last but not least, learn how to develop and debug programs
(and how to do some fine tuning).

Page 99

You might also like