1 Week © Vocational Training Council, Hong Kong. │ Lecture 3 │ Basic Programmable Logic Controller (PLC) Programming EEC3420 Industrial Control Department of Electrical Engineering
1Week © Vocational Training Council, Hong Kong.
│ Lecture 3 │
Basic Programmable Logic Controller (PLC) Programming
EEC3420 Industrial ControlDepartment of Electrical Engineering
2© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Learning Objectives Know different types of programming languages used in
PLC Understand the basic programming techniques of PLC
3© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
IEC 61131 standards for PLC the use of PLC has been standardized by the IEC developed with the input of vendors, end-users and
academics, IEC 61131 consists of five parts: General information Equipment and test requirements PLC programming languages User guidelines Communications
4© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
The IEC 61131-3 programming language the international standard for programmable controller
programming languages specifies the syntax, semantics and display for the
following suite: Ladder diagram (LD) Sequential Function Charts (SFC) Function Block Diagram (FBD) Structured Text (ST) Instruction List (IL)
5© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Ladder diagram (LD) widely spread graphical programming language for
PLCs a programmatically replacement for relays and coils
which can be combined using AND and OR operations best suited to compute Boolean expressions IEC 61131-3 defines a complete LD set of instructions,
consisting of different types of contacts and coils
6© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Ladder diagram (LD) contacts lead (according to their type) the power
from the left to the right coils store the incoming value both, contacts and coils, are assigned to Boolean
variables an LD network can be supplemented by jumps,
returns, labels and comments
7© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Sequential Function Charts (SFC) SFC is the IEC 61131 -3 method to program
sequential controls actions may contain Boolean variables or entire
networks, networks are programmed in Ladder Diagram, true action associations from several steps, several concurrent SFC networks in one diagram
8© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Function Block Diagram (FBD) FBD defined in IEC 61131-3 consists of different
functions and function blocks that are either linked or connected to variables
in FBD networks, jumps, labels and returns can be used similar to the creation of functional diagrams or block
diagrams, with the control logic being created by simply connecting blocks and elements
frequently used in the process industry due to the flow-oriented properties of function blocks
9© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Structured Text language (ST) similar to the high-level language PASCAL or BASIC uses statements like IF...THEN or FOR…NEXT concerned compiler is responsible for syntactically
correct insertion of the language constructions text editor simplifies the programming work through
syntax highlighting syntax and the set of instructions of ST are optimally
suited for mathematical calculations and data manipulations
10© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL) an assembler type textual programming language large (and mostly incompatible) sets of instructions
have been created by many vendors the IEC 61131 Instruction list reduced this set to a
minimum and favours the usage of functions and function blocks for more complex tasks
code in IL consists of a sequence of instructions separated by lines, which consist of one operator ("command"), one operand (variable, constant or instance name) and one optional modifier respectively
11© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL) jumps and labels can be used concerned assembler is responsible for syntactically
correct insertion of the language constructions text editor simplifies the programming work through
syntax highlighting (colour marking of language elements)
mainly used if the processing speed of the PLC program has high priority
12© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL) Basic instructions used in Allen Bradley PLC
Mnemonic Function Mnemonic Function
LD Load ANDN And Not
LDN Load Not ORN Or Not
ST Store MPS Memory Push
STN Store Not MPP Memory Pop
AND And MRD Memory Read
OR Or MCR Master Control Relay
ANB And Block
ORB Or Block
Note: The instruction mnemonic may vary across different series of the Allen Bradley PLCs.
13© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL) Basic instructions used in Omron PLC
Mnemonic Function Mnemonic Function
LOAD Load NOP No Operation
LOAD NOT Load Not TR Temp. Register
OUT Out IL InterLock (eq. to MC)
AND And ILC InterLockClear(eq. to MCR)
AND NOT And Inverted
AND LD And Block
OR Or
OR NOT Or Not
OR LD Or Block
14© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL) Basic instructions used in Mitsubishi PLC FX series
Mnemonic Function Mnemonic Function
LD Load NOP No Operation
LDI Load Inverted MPS Memory Push
OUT Out MPP Memory Pop
AND And MRD Memory Read
ANI And Inverted MC Master Control
ANB And Block MCR Master Control Reset
OR Or
ORI Or Inverted
ORB Or Block
15© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
IL, LD and its associated logic equation
operation labeled with circle 1 is performed first as it is the deepest nested term, and operations proceed with circle 2,circle 3 and circle 4 consecutively
(Mitsubishi PLC codes)
16© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL) A list of commonly used IL operators defined in IEC 61131-3
17© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL) example of IL using the syntax defined in IEC 61131-3
18© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL)
example of IL using the syntax defined in IEC 61131-3
19© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL)
example of IL program using the instructions MPS, MPP & MRD to implement multiple outputs using the syntax defined in IEC 61131-3
20© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL)
example demonstrating the use of TR instruction (similar to MPS, MPP & MRD instructions defined in IEC 6113-3) in Omron PLC
21© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL)
example demonstrating the use of MCR instruction in Allen Bradley PLC
22© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL)
example demonstrating the use of MC & MCR instructions in Mitsubishi PLC
(N0 is the nested number, maximum 7,i.e. a total of 8 nested levels; SP means “space”)
23© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Instruction List (IL)
example demonstrating the use of IL & ILC instructions in Omron PLC
24© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Conversion of more complex logic gates
25© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Multiplexer
26© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Time Related Instruction – the Latch
• a latch in ladder logic uses one instruction to latch, and a second instruction to unlatch
• the output with an L inside will turn the output D on when the input A becomes true
• D will stay on even if A turns off• D will turn off if input B
becomes true
27© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Time Related Instruction – the Latch
28© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Time Related Instruction – the Latch
a typical timing diagram, ignoring the brief pulse
29© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
The SR (Set-Reset) Flip FlopLatches are not used universally by all PLC vendors, others such as Siemens use flip-flops
30© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
The SR (Set-Reset) Flip Flopthe SR Flip Flop may be implemented by using AND-OR functions
31© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
The SR (Set-Reset) Flip Flopthe SR Flip Flop may also be implemented by using SET-RESET functions
32© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
The SR (Set-Reset) Flip Flop implement the SR Flip Flop in Omron PLC
33© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
The Timers• four fundamental types
• on-delay timer will wait for a set time after a line of ladder logic has been true before turning on, but it will turn off immediately
• off-delay timer will turn on immediately when a line of ladder logic is true, but it will delay before turning off
• retentive timer will sum all of the on or off time for a timer, even if the timer never finished
• non-retentive timer will start timing the delay from zero each time
34© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Operation of a TON (non-retentive) Timer
35© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Operation of a RTO (retentive time on) timer
36© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Operation of a TOF (non-retentive t-off) timer
37© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Timers in Mitsubishi PLCs • in FX1N and FX2N series, there are four types of
timers • T0 ~ T199 are non-retentive time on timer with
timing interval of 100 ms• T200 ~ T245 are non-retentive time on timer with
timing interval of 10 ms• T246 ~ T249 are retentive time on timer with timing
interval of 1 ms• T250 ~ T255 are retentive time on timer with timing
interval of 100 m
38© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Using non-retentive time on timer in Mitsubishi FX series PLC
39© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Timers in Omron PLC • in CP series, there are 48 timers/counters with
timing range running • from 0.1s to 999.9s if it is set as common timer • or 0.01s to 99.99s if it is set as high speed timer
40© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Timers in Omron PLC
41© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
The Counters• two basic counter types:
count-up and count-down. • when the input to a count-up counter goes true the accumulator
value will increase by 1, if the accumulator value reaches the preset value the counter DN bit will be set
• a count-down counter will decrease the accumulator value until the preset value is reached
42© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
An up-down counter in Allen Bradley PLC
43© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Counter operation in Mitsubishi PLC
44© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Counter operation in Omron PLC
45© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
The Edge Triggering Instructionsin Mitsubishi FX series PLC, there are two edge triggering instructions, namely, PLS (PuLSe) and PLF (PuLse Falling)
46© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
The Edge Triggering Instructionsin Mitsubishi FX series PLC, there are two edge triggering instructions, namely, PLS (PuLSe) and PLF (PuLse Falling)
47© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
The Edge Triggering Instructionsin Omron PLC, there are similar edge triggering instructions, namely, the DIFU (DIFferentiate Up) and the DIFD (DIFferentiate Down)
48© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
The Edge Triggering Instructionsin Omron PLC, there are similar edge triggering instructions, namely, the DIFU (DIFferentiate Up) and the DIFD (DIFferentiate Down)
49© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Applications of Time Related Instructions
The timers and the counters find their applications in many industrial process controls
50© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Applications of Time Related Instructions
Pulse generator circuit
51© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Applications of Time Related Instructions
Fixed width pulse generator circuit
52© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Applications of Time Related InstructionsDelay off timer - Many PLCs such as Mitsubishi do not provide delay off timer, but this function can easily be built by the delay on timer
53© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Applications of Time Related Instructions
Light flasher
54© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Applications of Time Related InstructionsVariable delay on/variable delay off circuit with Mitsubishi PLC
55© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Applications of Time Related InstructionsVariable delay on/variable delay off circuit with Omron PLC
56© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Summary of Basic PLC Programming ․ The Instruction List programming language uses stack
operation to perform the operations specified.
․ Logic can be represented with basic Boolean operations AND, OR, NOT.
․ Boolean equations can be converted to and from ladder logic or instruction list.
․ The MPS, MPP and MRD enable intermediate results to be pushed, pop and read to facilitate multiple outputs.
․ Use of the MC/MCR instructions simplifies the organization of the ladder logic.
․ The time related instructions realize the sequential functions.
57© Vocational Training Council, Hong Kong.
EEE3420 Industrial Control
Week
Basic PLC Programming
End of Lecture 3
RevisionMitsubishi PLC FX series hardware handbook.Allen Bradley PLC handbookOmron PLC manual