0% found this document useful (0 votes)
416 views

Chapter - 3 - Basics of PLC Programming

The document discusses PLC programming languages and bit-level logic instructions. It describes the five standard PLC programming languages defined by IEC 61131 including ladder logic, function block diagram, sequential function chart, instruction list, and structured text. It also explains common bit-level logic instructions like examine if closed (XIC), examine if open (XIO), and output energize (OTE) used in ladder logic programs to examine and control data.

Uploaded by

M A
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
416 views

Chapter - 3 - Basics of PLC Programming

The document discusses PLC programming languages and bit-level logic instructions. It describes the five standard PLC programming languages defined by IEC 61131 including ladder logic, function block diagram, sequential function chart, instruction list, and structured text. It also explains common bit-level logic instructions like examine if closed (XIC), examine if open (XIO), and output energize (OTE) used in ladder logic programs to examine and control data.

Uploaded by

M A
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 71

Department Of Mechatronics Engineering

Faculty Of Engineering And Information Technology

An-Najah National University

Programmable
Logic Controllers
(10651572)

Dr. Mohammad Abuabiah


[email protected]

Office: 11-4-130 1
Chapter 3 *

Basics of PLC
Programming

* Chapter 5 in the book (Petruzella 2016) 2


Chapter Objectives 3
Dr. Mohammad Abuabiah

• Define and identify the functions of a PLC memory map


• Describe input and output image table files and types of data files
• Describe the PLC program scan sequence
• Understand how ladder diagram language, Boolean language, and
function chart programming language are used to communicate
information to the PLC
An-Najah National University

• Define and identify the function of internal relay instructions


• Identify the common operating modes found in PLCs
• Write and enter ladder logic programs
3.1 PLC Programming Languages 4

• The term PLC programming language refers to the method by which


Dr. Mohammad Abuabiah

the user communicates information to the PLC.


• The standard IEC 61131 was established to standardize the multiple
languages associated with PLC programming by defining the following
five standard languages:
An-Najah National University
3.1 PLC Programming Languages 5

1) Ladder diagram language is the most commonly used PLC language


Dr. Mohammad Abuabiah

and is designed to mimic relay logic.


• The ladder diagram is popular for those who prefer to define control
actions in terms of relay contacts and coils, and other functions as
block instructions.
An-Najah National University
3.1 PLC Programming Languages 6

2) Function Block Diagram (FBD): a graphical depiction of process flow


Dr. Mohammad Abuabiah

using simple and complex interconnecting blocks. The use of function


blocks for programming of programmable logic controllers (PLCs) is
gaining wider acceptance.
An-Najah National University
3.1 PLC Programming Languages 7

3) Sequential Function Chart (SFC): a


Dr. Mohammad Abuabiah

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

steps with multiple operations


happening in parallel branches.
3.1 PLC Programming Languages 8

4) Instruction List (IL): a low-level, text-based language that uses


Dr. Mohammad Abuabiah

mnemonic instructions. The instructional list consists of a series of


instructions that refer to the basic AND, OR, and NOT logic gate
functions.
An-Najah National University
3.1 PLC Programming Languages 9

5) Structured Text (ST): a high-level, text-based language such as BASIC,


Dr. Mohammad Abuabiah

C, or PASCAL specifically developed for industrial control applications.


Structured text uses statements to define what to execute.
An-Najah National University
3.1 PLC Programming Languages 10

• S7-SIMATIC mainly support three PLC programming languages: LAD,


Dr. Mohammad Abuabiah

FBD and STL.


An-Najah National University
3.2 Bit-Level Logic Instructions 11

• The ladder diagram language is basically a symbolic set of instructions


Dr. Mohammad Abuabiah

used to create the controller program.


• Bit-level symbolic instructions fall into two separate categories:
instructions that examine data and instructions that control data.
• The three fundamental symbols that are used to translate relay control
logic to contact symbolic logic are Examine If Closed (XIC), Examine If
Open (XIO), and Output Energize (OTE).
An-Najah National University
3.2 Bit-Level Logic Instructions 12
Dr. Mohammad Abuabiah

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 Examine If Closed (XIC) instruction resemble a normally-open


Dr. Mohammad Abuabiah

switch/relay. The XIC instruction is also called the Examine-on


instruction. Associated with each XIC is a memory bit linked to the status
of an input device or an internal logical condition in a rung. This
instruction asks the PLC’s processor to examine if the contact is closed.
An-Najah National University
3.2 Bit-Level Logic Instructions 14

• The Examine If Open (XIO) instruction resemble a normally-close


Dr. Mohammad Abuabiah

switch/relay. The XIC instruction is also called the Examine-off


instruction. Associated with each XIC is a memory bit linked to the status
of an input device or an internal logical condition in a rung. This
instruction asks the PLC’s processor to examine if the contact is open.
An-Najah National University
3.2 Bit-Level Logic Instructions 15

• 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

• Examine-on instructions always interpret a 1 status as true and a 0 status


Dr. Mohammad Abuabiah

as false, while Examine-off instructions interpret a 1 status as false and a


0 status as true:
An-Najah National University
3.2 Bit-Level Logic Instructions 17

• Sometimes PLC beginner who are used to thinking in terms of hardwired


Dr. Mohammad Abuabiah

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

(XIC, XIO) & (NO, NC)


Dr. Mohammad Abuabiah
An-Najah National University
3.2 Bit-Level Logic Instructions 19

• The main function of the ladder


Dr. Mohammad Abuabiah

logic diagram program is to control


outputs based on input conditions.
• This control is accomplished through
the use of what is referred to as a
ladder rung.
• In general, a rung consists of a set
An-Najah National University

of input conditions, represented by


contact instructions, and an output
instruction at the end of the rung,
represented by the coil symbol.
3.2 Bit-Level Logic Instructions 20

• Rules: 1) Coils must appear at the end of the Ring


Dr. Mohammad Abuabiah
An-Najah National University
3.2 Bit-Level Logic Instructions 21

• Rules: 2) Only one output can be connected in series with a group of


Dr. Mohammad Abuabiah

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

switch, and used to control a warning horn.

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

• For an output to be activated or energized, at least one left-to-right true


Dr. Mohammad Abuabiah

logical path must exist, as illustrated in Figure


An-Najah National University
3.4 Instruction Addressing 27

• To complete the entry of a relay-type instruction, you


Dr. Mohammad Abuabiah

must assign an address to each instruction.


• An address is a label or number that indicates where a
certain piece of information is located in a PLC’s memory.

I = input Bit number


Q = output

XX.X
An-Najah National University

Byte number

Siemens SIMATIC S7 addressing


3.4 Instruction Addressing 28

• For addressing System Memory is used, that is consist of 5 parts:


Dr. Mohammad Abuabiah

1) PII (Process Image Input): addressing for PLC inputs.


2) PIQ (Process Image Output): addressing for PLC outputs.
3) BM: Bit Memory addressing.
4) Timers: Timers addressing.
5) Counters: Counters addressing.
An-Najah National University
3.4 Instruction Addressing 29

1) Bit addressing I1.2


Dr. Mohammad Abuabiah

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

3) Word addressing Avoid Odd Word Addressing


Dr. Mohammad Abuabiah

7 6 5 4 3 2 1 0 IW1
Byte 0

IW0 Byte 1 IW3


Byte 2

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

4) Double Word addressing Use double


Dr. Mohammad Abuabiah

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

and what PLC output will drive what output device.


An-Najah National University
3.4 Instruction Addressing 34

• Rules: 3) Avoid to place the same addressed OTE instruction on multiple


Dr. Mohammad Abuabiah

rungs.
An-Najah National University
3.4 Instruction Addressing 35

• S7-PLC’s controllers offer a more flexible method of addressing


Dr. Mohammad Abuabiah

memory space. Instead of a fixed device with a fixed address space,


tags are used for assigning and referencing memory spaces. Tags are
a pure text based addressing scheme and a departure from the more
conventional ways of programming PLCs. For example:
– Stop : I1.0
– Start : I1.1
– Motor : Q3.0
An-Najah National University

I1.0 Q3.0
I1.0
I1.1
Q3.0
I1.1
Stop Start Motor
Example 3.1 Two Hands Control 36

• In this Example, we will learn the


Dr. Mohammad Abuabiah

safety plc logic for two hand control


application.
• The purpose of this program is about
safety to prevent fatal accidents.
The two pushbuttons must be
pressed at the same time to
operate the press machine.
An-Najah National University

• When the operator uses his one


hand to press the button and use his
second hand when plate pushing
against the surface, he can injure
himself.
37
Example 3.1 Two Hands Control
Dr. Mohammad Abuabiah An-Najah National University
Example 3.1 Two Hands Control 38

1) Design a PLC ladder program


Dr. Mohammad Abuabiah

using SIMATIC S7-5.7 program to


operate the two-hand control
system, using:
– Inputs:
• Push Button (S1): I0.0
• Push Button (S2): I0.1
– Outputs:
An-Najah National University

• Press Machine Output (Press) : Q4.0

2) Also, design an HMI-Panel of the


system using WinCC flexible 2008
software (as shown in the Figure).
Example 3.1 Two Hands Control 39

• 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

• SOLUTION: 1) See the video,


Dr. Mohammad Abuabiah
An-Najah National University
Example 3.1 Two Hands Control 41

• SOLUTION: 2) HMI-Panel Operation,


Dr. Mohammad Abuabiah
An-Najah National University
3.5 Branch Instructions 42

• Branch instructions are used to create parallel paths of input condition


Dr. Mohammad Abuabiah

instructions. This allows more than one combination of input conditions


(OR logic) to establish logic continuity in a rung. The rung will be true if
either instruction A or B is true.
An-Najah National University
3.4 Branch Instructions 43

• In the example shown in Figure below, either A and B, or C provides


Dr. Mohammad Abuabiah

logical continuity and energizes output D.

• With output branching, you can program parallel outputs on a rung to


allow a true logic path to control multiple outputs:
An-Najah National University
3.4 Branch Instructions 44

• When there is a true logic path, including extra input conditions on an


Dr. Mohammad Abuabiah

output branch, that branch becomes true:

• Input and output branches can be nested to avoid redundant


instructions and to speed up processor scan time.
An-Najah National University
3.4 Branch Instructions 45

• Nested branching can be converted into non-nested branches by


Dr. Mohammad Abuabiah

repeating instructions to make parallel equivalents.


An-Najah National University
3.4 Branch Instructions 46

• Figure below shows the matrix limitation diagram for a typical PLC. A
Dr. Mohammad Abuabiah

maximum of seven parallel lines and 10 series contacts per rung is


possible. The only limitation on the number of rungs is memory size.
An-Najah National University
3.4 Branch Instructions 47

• Another limitation to branch circuit programming is that the PLC will not
Dr. Mohammad Abuabiah

allow for programming of vertical contacts. A typical example of this


limitation is contact C of the user program drawn in Figure (a). To obtain
the required logic, the circuit would be reprogrammed as shown in
Figure (b).
An-Najah National University

(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

these values, and energizes or deenergizes the outputs according to


the user program. This process is known as a program scan cycle.
An-Najah National University
3.6 Program Scan 50

• 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

• The controller evaluates ladder logic rung instructions based on the


Dr. Mohammad Abuabiah

rung condition preceding the instruction (rung-condition-in),


An-Najah National University
3.6 Program Scan 52

• Figure below illustrates the scan process applied to a simple single


Dr. Mohammad Abuabiah

rung program.

I3.6 I3.6 Q4.7 Q4.7


An-Najah National University

I3.6 Q4.7
3.6 Program Scan 53

• The operation of the scan process can be summarized as follows:


Dr. Mohammad Abuabiah

– 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

• Ladder programs process inputs at the beginning of a scan and


Dr. Mohammad Abuabiah

outputs at the end of a scan, as illustrated in Figure below:


An-Najah National University
3.6 Program Scan 55

• There are two basic scan patterns that different PLC manufacturers use
Dr. Mohammad Abuabiah

to accomplish the scan function. Allen-Bradley PLCs and Siemens use


the horizontal scan by rung method. Modicon PLCs use the vertical
scan by column method.
An-Najah National University
56
3.6 Program Scan
Dr. Mohammad Abuabiah An-Najah National University
57
3.6 Program Scan
Dr. Mohammad Abuabiah An-Najah National University
3.6 Program Scan 58

• 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

• There are often situations where it is necessary to hold an output


Dr. Mohammad Abuabiah

energized, even when the input ceases. A simple example of such a


situation is a motor, which is started by pressing a push button switch.
An-Najah National University
60
3.7 Latching Instructions
Dr. Mohammad Abuabiah An-Najah National University
3.7 Latching Instructions 61

• The term latch circuit is used for the circuit used to carry out such an
Dr. Mohammad Abuabiah

operation. It is a self-maintaining circuit in that, after being energized, it


maintains that state until another input is received.
An-Najah National University
3.7 Latching Instructions 62

• Thus, even if the input A opens, the circuit will still maintain the output
Dr. Mohammad Abuabiah

energized. The only way to release the output is by operating the


normally closed contact B.
An-Najah National University

NO NO
3.7 Latching Instructions 63

• Thus, even if the input A opens, the circuit will still maintain the output
Dr. Mohammad Abuabiah

energized. The only way to release the output is by operating the


normally closed contact B.
An-Najah National University
3.7 Latching Instructions 64

• Another method for latching is to use the Set and Reset instruction in
Dr. Mohammad Abuabiah

the SIMATIC-S7. The previous example of the motor can implement


using a NO switch to start the motor and a NC switch to stop the motor.
An-Najah National University

NO NC
Be careful this NC switch!
3.7 Latching Instructions 65

• Why Should Stop Switches Normally Be Closed?


Dr. Mohammad Abuabiah
An-Najah National University

NO NO NO NC
3.7 Latching Instructions 66

• A third method for latching is to use RS/SR flip-flop. An RS/SR function is


Dr. Mohammad Abuabiah

represented as a rectangle with a set input S and a reset input R.


• A brief signal state of 1 at set input S sets up the set/reset function. A
brief signal state of 1 at reset input R leads to the set/reset function
being reset (switched off). A signal state of 0 at inputs R and S does not
change the previously set status.
An-Najah National University
3.7 Latching Instructions 67

• The previous example of the motor can implement using SR flip-flop


Dr. Mohammad Abuabiah

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

• Drilling is a cutting process that uses a drill bit to cut a


Dr. Mohammad Abuabiah

hole of circular cross-section in solid materials such as


metal.

• Metal cutting generates heat due to friction and energy


lost deforming the material. Cutting fluid (e.g., oil) is
sometimes used to ease this problem and to prolong the
tool's life by cooling and lubricating the tip and chip flow.
An-Najah National University
Example 3.2 Drill Press Machine 69

1) Design a PLC ladder program using SIMATIC S7-5.7 program to operate


Dr. Mohammad Abuabiah

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

• Oil Pump (PUMP): Q4.1

• Note that the oil pump should start only


if the drilling machine is working. In case
the stop button is pressed both the Drill
and the Oil Pump should be stopped.
Example 3.2 Drill Press Machine 70

2) Also, design an HMI-Panel of the system using WinCC flexible 2008


Dr. Mohammad Abuabiah

software (as shown in the Figure).


An-Najah National University
Example 3.2 Drill Press Machine 71

• SOLUTION: Write the following ladder program:


Dr. Mohammad Abuabiah
An-Najah National University

You might also like