Chapter - 3 - Basics of PLC Programming
Chapter - 3 - Basics of PLC Programming
Programmable
Logic Controllers
(10651572)
Office: 11-4-130 1
Chapter 3 *
Basics of PLC
Programming
graphical depiction of
interconnecting steps, actions, and
transitions.
• SFC programming is designed to
accommodate the programming of
more advanced processes.
• This type of program can be split into
An-Najah National University
I:1/4 I1.4
I:3/2 I3.2
An-Najah National University
O:3/2 Q3.2
3.2 Bit-Level Logic Instructions 13
• The Output Energize (OTE) instruction looks and operates like a relay coil
Dr. Mohammad Abuabiah
and is associated with a memory bit. This instruction signals the PLC to
energize (switch on) or de-energize (switch off) the output. The
processor makes this instruction true when there is a logical path of true
XIC and XIO instructions in the rung.
An-Najah National University
3.2 Bit-Level Logic Instructions 16
relay control circuits tend to use the same type of contact (NO or NC) in
the ladder logic program that corresponds to the type of field switch
wired to the discrete input.
• While this is true in many instances, it is not the best way to think of!
An-Najah National University
3.2 Bit-Level Logic Instructions 18
contacts:
An-Najah National University
3.3 Hardwired Logic versus Programmed Logic 22
Two limit switches connected in series and used to control a solenoid valve
Dr. Mohammad Abuabiah
Two limit switches connected in parallel and used to control a solenoid valve
An-Najah National University
3.3 Hardwired Logic versus Programmed Logic 23
Two limit switches connected in parallel with each other and in series with a pressure switch.
Dr. Mohammad Abuabiah
Two limit switches connected in parallel with each other and in series with two sets of flow
switches (that are connected in parallel with each other) and used to control a pilot light.
An-Najah National University
3.3 Hardwired Logic versus Programmed Logic 24
Two limit switches connected in series with each other and in parallel with a third limit
Dr. Mohammad Abuabiah
Two limit switches connected in series with each other and in parallel with two other limit
switches (that are connected in series with each other), and used to control a pilot light.
An-Najah National University
3.3 Hardwired Logic versus Programmed Logic 25
One limit switch connected in series with a normally closed pushbutton and used to control
Dr. Mohammad Abuabiah
a solenoid valve.
Exclusive-OR circuit. The output lamp of this circuit is ON only when pushbutton A or B is
pressed, but not both.
An-Najah National University
3.3 Hardwired Logic versus Programmed Logic 26
XX.X
An-Najah National University
Byte number
7 6 5 4 3 2 1 0
Byte 0
X Byte 1
Byte 2
PII
•
•
•
Q2.4 Byte 0
Byte 1
X Byte 2
An-Najah National University
PIQ
•
•
•
X Byte 0
Byte 1
M0.3 Byte 2
BM
•
•
•
3.4 Instruction Addressing 30
2) Byte addressing
Dr. Mohammad Abuabiah
7 6 5 4 3 2 1 0
Byte 0
Byte 1
IB2 Byte 2
PII
•
•
•
Byte 0
QB1 Byte 1
Byte 2
An-Najah National University
PIQ
•
•
•
Byte 0
MB1 Byte 1
Byte 2
BM
•
•
•
3.4 Instruction Addressing 31
7 6 5 4 3 2 1 0 IW1
Byte 0
IW5
PII
Byte 3
Byte 4
Byte 5
Byte 0
Byte 1
Byte 2
QW2
An-Najah National University
PIQ
Byte 3
Byte 4
Byte 5
Byte 0
Byte 1
Byte 2
BM
Byte 3
MW4 Byte 4
Byte 5
3.4 Instruction Addressing 32
7 6 5 4 3 2 1 0 word space
Byte 0
ID0 Byte 1
Byte 2
QD0
PII
Byte 3
QD4
Byte 4
Byte 5
Byte 0 QD8
Byte 1
Byte 2
.
.
An-Najah National University
PIQ
Byte 3
Byte 4 .
Byte 5
Byte 0
Byte 1
Byte 2
BM
Byte 3
Byte 4
Byte 5
3.4 Instruction Addressing 33
• The address indicates what PLC input is connected to what input device
Dr. Mohammad Abuabiah
rungs.
An-Najah National University
3.4 Instruction Addressing 35
I1.0 Q3.0
I1.0
I1.1
Q3.0
I1.1
Stop Start Motor
Example 3.1 Two Hands Control 36
• SOLUTION: 1) Figure below shows the ladder diagram with tags table,
Dr. Mohammad Abuabiah
An-Najah National University
Example 3.1 Two Hands Control 40
• Figure below shows the matrix limitation diagram for a typical PLC. A
Dr. Mohammad Abuabiah
• Another limitation to branch circuit programming is that the PLC will not
Dr. Mohammad Abuabiah
(a) (b)
3.4 Branch Instructions 48
• The processor examines the ladder logic rung for logic continuity from
Dr. Mohammad Abuabiah
left to right only. This situation presents a problem for user program
circuits similar to that shown in Figure (a). If programmed as shown,
contact combination FDBC would be ignored. To obtain the required
logic, the circuit would be reprogrammed as shown in Figure (b).
An-Najah National University
3.6 Program Scan 49
• During each operating cycle, the processor reads all the inputs, takes
Dr. Mohammad Abuabiah
• The time it takes to complete a scan cycle is called the scan cycle
Dr. Mohammad Abuabiah
time and indicates how fast the controller can react to changes in
inputs. The time required to make a single scan can vary from about 1
to 20 ms.
An-Najah National University
3.6 Program Scan 51
rung program.
I3.6 Q4.7
3.6 Program Scan 53
– If the input device connected to address I3.6 is closed, the input module circuitry
senses voltage at the input terminal and a 1 (ON) condition is entered into the input
image bit I3.6
– During the program scan, the processor examines bit I3.6 for a 1 (ON) condition.
– In this case, because input I3.6 is 1, the rung is said to be TRUE or have logic continuity.
The processor then sets the output image table bit O:4/7 to 1.
– The processor turns on output Q4.7 during the next I/O scan, and the output device
(light) wired to this terminal becomes energized.
– This process is repeated as long as the processor is in the RUN mode.
An-Najah National University
– If the input device opens, electrical continuity is lost, and a 0 would be placed in the
input image table. As a result, the rung is said to be FALSE due to loss of logic
continuity.
– The processor would then set the output image table bit Q4.7 to 0, causing the output
device to turn off.
3.6 Program Scan 54
• There are two basic scan patterns that different PLC manufacturers use
Dr. Mohammad Abuabiah
• Rules: 4) For S7-PLC the flow in ladder diagram is always from left to right.
Dr. Mohammad Abuabiah
An-Najah National University
3.7 Latching Instructions 59
• The term latch circuit is used for the circuit used to carry out such an
Dr. Mohammad Abuabiah
• Thus, even if the input A opens, the circuit will still maintain the output
Dr. Mohammad Abuabiah
NO NO
3.7 Latching Instructions 63
• Thus, even if the input A opens, the circuit will still maintain the output
Dr. Mohammad Abuabiah
• Another method for latching is to use the Set and Reset instruction in
Dr. Mohammad Abuabiah
NO NC
Be careful this NC switch!
3.7 Latching Instructions 65
NO NO NO NC
3.7 Latching Instructions 66
with a NO switch to start the motor and a NC switch to stop the motor.
An-Najah National University
NO NC
Example 3.2 Drill Press Machine 68
the Drilling Press machine, using Set (s) and Reset (R) instruction:
– Inputs:
• Start Drilling Button (START): I0.0 -- NO
• Oil Pump Button (OIL): I0.1 ------- NO
• Stop Button (STOP): I0.2 ---------- NC
– Outputs:
• Drilling (DRILL) : Q4.0
An-Najah National University