Programmable Logic Controller 2- 1
CHAPTER: 2
BASIC PLC PROGRAMMING
The IEC (International Electro technical Commission) has published the IEC 61131
standard for PLCs which should be followed by all users worldwide, and it has a
section specifically for PLC programming languages, the IEC 61131-3.
The IEC 61131-3 standard defined the five standard languages that are used in PLC
programming.
PLC programming language refers to the set of semantics or methods that allow the
user to communicate information to the PLC.
Programming languages:
1. Instruction list(IL)
2. Structured list(SL)
3. Functional block diagram(FBD)
4. Sequential functional chart(SFC)
5. Ladder diagram(LD)
1. INSTRUCTION LIST (IL):
The instruction list uses lower level language.
In programming, lower level language means that it gets closer to machine language
(the 1’s and 0’s) and the commands closely resemble that of the microprocessor’s
programs.
It gives a series of instructions for each new line and uses mnemonics for each
one.
In instruction list operation shown on left and operand on right.
Example: NETWORK 1
LD I0.0
A I0.1
= Q0.0
NETWORK 2
LD I0.4
O I0.5
= Q0.1
PREPARED BY SARASWATHI K
Programmable Logic Controller 2- 2
2. STRUCTURED LIST (SL)
The structured text is a high-level language developed for industrial control.
The structured text language is written as a series of statements terminated by
semicolons (like in C).
Text uses operator such as logical branching, multiple branching and loops.
Example : LIGHT = SWITCH A or SWITCH B;
3. FUNCTIONAL BLOCK DIAGRAM (FBD):
The function block diagram is a simple way of PLC programming where there
are “Function blocks” (hence the name) are available in the programming
software.
Example:
[Link] FUNCTIONAL CHART (SFC):
Sequential Function charts represent each function in a PLC control system in
a sequential fashion.
A sequential function chart is a visual representation of the system’s operation
to display the sequence of actions involved in the operation.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2- 3
5. LADDER DIAGRAM (LD):
The most commonly used PLC programming language is the Ladder Logic Diagram.
The ladder logic diagram consists of two fundamental parts, which you can see as the
vertical and the horizontal lines. They are called, respectively, the rails and the rungs.
The two vertical rails represent the Vdc source and the other one the 0 Vdc terminal
They are power rails. The devices on a rung must provide continuity from the left rail
to the right rail for an output element to become powered up.
To scan the program for continuity of rungs, the PLC uses a top to bottom, left to right
sequence (reading like a book), thus checking continuity between the two rails for
each scan.
SYMBOLS IN LADDER DIAGRAM:
NORMALLY OPENED CONTACT
NORMALLY CLOSED CONTACT
SPECIAL TASK INSTRUCTION
OUTPUT COILS
PREPARED BY SARASWATHI K
Programmable Logic Controller 2- 4
PLC INPUT INSTRUCTIONS:
The input is labelled in different manners by different manufacturers. The labels
used are words, letters, numbers, letter-word combination and instructions.
The various types of inputs include:
1) Normally opened contact
When this contact closes, the function carries out some kind of action.
Normally open inputs do not by default create a connection between the two rails
when connected. When activated, only then it will create the connection. These inputs
could be any input device or sensor
2) Normally closed contact
When this contact opens, the function carries out some kind of action.
Normally closed inputs, already creates a connection between the two rails when
connected. When activated, only then it will BREAK the connection. Normally closed
inputs are most commonly used for STOP buttons or emergency shut down devices
.
3) Latch/unlatch system
The latch input turns the function on or causes it to change state. The function
then stays ON even if the latch input is turned off. To turn the function off,
another input, unlatch is turned on, which turns the function off. If unlatch is
then turned off, the function remains off.
4) Rising-edge actuation
This involves turning the function on for one scan time at the leading edge of
an input signal pattern.
5) Falling-edge actuation
This involves turning the function on for one scan time at the trailing edge of an
input signal pattern.
In PLC system each input is assigned a number on the input and in the CPU.
PLC OUTPUT INSTRUCTIONS:
1) Outputs are also labelled in different manners by different manufacturers.
Common output labels are OUT, numbers, letters and CR (control relay).
2) Output Coils in a PLC program are related to output signals that are sent to
external devices. An output is energized through the output module when its
corresponding coil number is turned ON in the PLC ladder diagram.
3) Many coils are used for internal logic only. Internal relays are elements that
hold data to serve as relays for the system. These internal relays rely in bits on
the memory of the PLC but can be treated the same way as an external coil
relay.
To differentiate from output coil , they are labelled differently than output coils.
4) The output device, voltages and current requirement must be matched for the
output module value.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2- 5
CONSTRUCTION OF PLC LADDER DIAGRAMS
1) A contact must always be inserted in the upper left.
2) A coil must be inserted at the end of a rung
3) All contacts must run horizontally. No vertically oriented contacts are allowed.
4) The number of contacts per matrix (network) is limited.
5) Only one output may be connected to a group of contacts.
6) Flow must be from left to right.
7) Contact progression should be straight across ( reading like a book).
PLC SCAN OR SCAN CYCLE
PREPARED BY SARASWATHI K
Programmable Logic Controller 2- 6
BASIC LADDER PROGRAMMING
RELATION OF DIGITAL GATE LOGIC TO CONTACT/COIL LOGIC
AND GATE
(Y=A.B)
INPUT OUTPUT
A B Y
0 0 0
0 1 0
1 0 0
1 1 1
The AND gate operation is when all inputs are high(1) ,output is high.
The two inputs must BOTH have continuity (high) in order for the output
to turn on.
The AND condition in ladder logic is, all inputs are to be in series with
each other .
NOT GATE
Y=A
INPUT OUTPUT
A Y
0 1
1 0
An output is high when input is zero.
The output is inverse of the input.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2- 7
In Ladder Logic, a NC contact is connected in series with output coil.
OR GATE
(Y=A+B)
OUTPU
INPUT
T
A B Y
0 0 0
0 1 1
1 0 1
1 1 1
OR gate logic is, if any or all the inputs are high the output is high.
ANY of them high may create continuity between the two power rails thus
turning the output ON.
OR condition in ladder logic is, all the inputs are connected in parallel.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2- 8
NOR GATE
INPUT OUTPUT
A B Y
0 0 1
0 1 0
1 0 0
1 1 0
The NOR condition is just a negated version of the OR condition.
The output is high only when both the inputs are low.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2- 9
NAND GATE
The NAND condition is a negated version of AND condition.
The output is low only when both inputs are high.
INPUT OUTPUT
A B Y
0 0 1
0 1 1
1 0 1
1 1 0
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 10
X OR GATE
A B+A B
OUTPU
INPUT
T
A B Y
0 0 0
0 1 1
1 0 1
1 1 0
Only ONE input variable is allowed to control the output AT A TIME.
The output is high only when one of the inputs is high.
XNOR GATE
A B+A B
XNOR have a negated output for XOR.
An output exists when both inputs are high or low.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 11
INPUT OUTPUT
A B Y
0 0 1
0 1 0
1 0 0
1 1 1
POINTS TO BE CONSIDERED WHILE WRITING A LADDER DIAGRAM
Insert Normally open contact for closing the circuit when its input is high(1).
Insert NO contact for normal input (A) in Boolean expression
Insert Normally closed contact in ladder diagram for closing the circuit
when its input is low(0)
Insert NC contact for negated input in Boolean expression.
Connect the contacts in series for AND operation (AB).
Connect the contacts in parallel for OR operation (A+B).
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 12
CONTACTS AND COIL INPUT/OUTPUT PROGRAMMING
EXAMPLES
1. SIMPLE ONE-CONTACT, ONE-COIL CONTACT
A simple circuit with one switch as a contact and one output as a coil.
As the switch is closed or opened, the output goes on or off.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 13
2. STANDARD-START- STOP-SEAL CIRCUIT, ALTERNATE LATCH-UNLATCH
CIRCUIT
a) Standard-start- stop-seal circuit
b) PLC latch-unlatch circuit
When the start button is depressed the coil energizes. When the button is
released the coil remains ON. It is held ON by a sealing circuit that is in a
parallel with the start button. The sealed contact closes when the output goes
ON. If the stop button is depressed the coil goes OFF and stay OFF.
The latch/unlatch function is used in many types of PLC. One input switch
latches the output ON. A different input switch latches the output OFF. The
latch/unlatch PLC coil may be an internal one. A contact from its coil may have
to be used to control a coil that corresponds to an output terminal.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 14
3. FORWARD-REVERSE-STOP WITH MUTUAL INTERLOCKS
Relay logic
Plc Logic
1. In forward-reverse circuit each directions coil has its own start button. The
single stop button stops either coil operation.
2. When start push button is pressed, the respective direction coil is on and
remains on through latch even if push button is released.
3. In this circuit you must push stop button to stop before changing the direction.
4. Interlocks are provided so that both outputs cannot be energized at the same
time.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 15
4. START-STOP JOG
Relay logic
In start-stop jog circuit the start-stop works in the regular method.
When start push button is pressed, the output is on and remains on even if
input is removed. When stop push button is pressed the output is off.
Jogging is a momentary ON control capability with one push button. It is often
used for a final adjustment of a machines position. For this reason jogging is
sometimes called “inching”. It is necessary to push stop button before going
from run to jog in the circuit.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 16
5. ALARM SYSTEM
An alarm system operates as follows:
a) If one input is ON, nothing happens
b) If any two inputs are ON, a red pilot light goes ON
c) If any three inputs are ON, an alarm siren sounds
d) If all four are ON, the fire department is notified
BOOLEAN EXPRESSION TO GATE LOGIC AND LADDER LOGIC
1. Y= (A+B+C). (DEF)
Gate Logic
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 17
Ladder diagram
.
2. BOOLEAN EXPRESSION
Gate logic
Ladder Diagram
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 18
3. BOOLEAN EXPRESSION
Gate Logic
Ladder Diagram
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 19
PLC LADDER DIAGRAM TO EQUIVALENT GATE DIAGRAM AND BOOLEAN
EXPRESSION
1. Ladder diagram
2. Ladder diagram
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 20
3. Ladder Diagram
CONVERSION OF WORD DESCRIPTION TO LADDER DIAGRAMS
1. Two switches have to be closed for a motor to operate.
2. A lamp is to be switched ON if there is an input from sensor A or sensor B.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 21
3. A motor is switched ON by pressing a spring return push button and the motor
remains ON until another spring return push button stop switch is pressed.
4. For safety reasons machines are often set up to ensure that a machine can
only be operated by the operator. Pressing two switches simultaneously one from
the right hand and one from the left hand. This is to ensure that the operators both
hands will be on the switches and cannot be in the machine when it is operating.
5. Conveyor is to run when any one of the three start inputs is ON and it is to s
top when any one of three stop inputs is ON.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 22
6. A process fan is to run only when all of the following conditions are met:
a) Input 1 is OFF
b) Input 2 is ON or input 3 is ON or both 2 & 3 are ON.
c) Input 4 and 5 both are ON
d) One or more of the inputs 6, 7 or 8 is ON
7. Outputs A, B and C are switched ON in the sequence given by the input
switches S1, S2 and S3. Until input S1 is closed none of the other Output will be
switched. When the input S1 is closed output A is switched ON and then input S2 is
closed output B is switched ON, finally when input S3 is closed output C is
switched ON.
LADDER DIAGRAM TO WORD DESCRIPTION:
1.
Output is ON when sensor 1 is ON and sensor 2 is OFF.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 23
2.
The light is ON when any one of switch S1 or S2 is ON.
3.
Conveyor is ON when any one of three start pushbutton is ON and the
conveyor is OFF when any one of three stop push button is ON.
4.
Fan is ON when all the following conditions are met:
a) When S1 is ON
b) When S2 or S3 is ON, or both S2 or S3 are ON
c) When S4 is OFF
d) When any one of the three switches S5, S6 OR S7 is ON or when all the three
switches are ON.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 24
SET AND RESET:
If an output remains ON even if the input trigger is removed it is called latch.
Another function that is often available to perform similar function is SET and RESET
an internal relay. The SET instruction latches the relay output (causes the relay to
self-hold) it then remains in that condition until the RESET instruction is received.
In the above ladder diagram activation of the first input A causes the output to
be turned ON (set) i.e., latch. If the first input is turned OFF the output remains ON.
Activation of the second input B causes the output to be reset i.e., turned OFF
and latched OFF.
The output is ON from a momentary pushbutton switched ON and switched
OFF from a momentary switch ON.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 25
QUESTION BANK
PROGRAMMABLE LOGIC CONTROLLER ( DMCH VS 501)
UNIT 2 – BASIC PLC PROGRAMMING
FILL IN THE BLANKS:
1) The contact NC is used for ________ switch in ladder diagram.
2) The contact NO is used for ________ switch in ladder diagram.
3) Reading PLC ladder program is similar to reading a ________
4) Ladder diagram is _________ of PLC.
5) NC contact is used when the condition requirement is ________ .
6) ______ is used to hold the output high even if the input trigger is removed,
7) The two input contacts normally used in ladder diagram are ______
8) SET and RESET instruction replaces _________
9) The contacts are put in ______ for Y= A+B.
10) The contacts are put in ________ for Y = A.B.
MULTIPLE CHOICE QUESTIONS:
1) In ladder diagram the contacts are put in ________ for AND operation.
a) series b) parallel
c) series and parallel d) None of them
2) In ladder diagram the contacts are put in ________ for OR operation.
a) series b) parallel
c) series and parallel d) None of them
3) In ladder diagram the contacts are put in series when the condition required is
_______.
a) AND b) OR
c) NOT d) EXOR
4) In ladder diagram the contacts are put in parallel when the condition required is
_______
a) AND b) OR
c) NOT d) EX NOR
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 26
5) ________ contact is connected in series to coil to get an output ON when its input
is zero.
a) NC b) NO
c) latch d) NC or NO
6) Latch is always connected across ________ push button switch in a ladder
diagram.
a) Start b) stop
c) output coil d) internal logic
7) ________ contact is connected in series to coil to get an output ON when its input
is high.
a) NC b) NO
c) latch d) NC or NO
2 Marks questions:
1) An output is ON when any one of the three switches is ON. Write ladder diagram
2) An output is ON when all the three switches is ON. Write ladder diagram
3) Draw the symbols for open switch and closed switch used in ladder diagram.
4) Write the function of a NO contact and NC contact in a ladder diagram.
5). An output is ON when sensor 1 is OFF and sensor 2 is ON. Write ladder diagram.
6) Write any two programming languages of PLC.
7) Write the difference between internal relay coil and output coil in ladder diagram.
8) What is SET and RESET instruction.
9) Write the symbols used in ladder diagrams.
10) Define Latch.
3 Marks questions
No weightage of marks in this section in Question Paper
5 Marks questions.
1) Explain standard start stop seal circuit (latch).
2) Explain PLC input instructions.
3) Explain ladder programming.
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 27
4) Mention different PLC programming standards. Explain any one
5) Explain PLC output instructions.
6) Write the ladder diagram for OR gate, AND gate and NOT gate.
7) Write the digital gate logic and ladder diagram for XOR gate and XNOR gate. .
8) Write the digital gate logic and ladder diagram for NOR gate and NAND gate.
8 Marks questions.
1) Construct the PLC Ladder diagram for Forward-reverse-stop with mutual interlocks
circuit and explain.
2) Construct the PLC Ladder diagram for Start-stop-jog circuit and explain.
3) An alarm operates as follows.
a. If one input is ON, nothing happens.
b. If any two inputs are ON, a red light goes ON.
c. If any three inputs are ON, an alarm siren sounds.
d. If all four inputs are ON, the fire department is notified.
4) The Process Fan is to run only when all of the following conditions are met,
a. Input 1 is OFF.
b. Input 2 is ON or Input 3 is ON, or both 2 and 3 are ON.
c. Inputs 4 and 5 are both ON.
d. One or more of the inputs 6,7 or 8 is ON.
Develop the above conditions in the Boolean expression and write the Logic
diagram using gates and PLC Ladder diagram.
5) Write the following Boolean expression to gate logic and ladder diagram
6) Write the following Boolean expression to gate logic and ladder diagram
Y= (A+B+C). (DEF)
7) Convert the following boolean expression to gate logic and ladder logic
PREPARED BY SARASWATHI K
Programmable Logic Controller 2 - 28
8) a. Conveyor is to run when any one of the four start inputs is ON and it is to
stop when any one of four stop inputs is ON.
Develop the PLC Ladder diagram for the above condition
b. A motor is switched ON by pressing a spring return push button and the
motor remains ON until another spring return push button stop switch is pressed.
Develop the PLC Ladder diagram for the above condition.
9) Write the following ladder diagram into word description, boolean expression
and gate logic.
10) Write the following ladder diagram into word description, Boolean expression and
gate logic
PREPARED BY SARASWATHI K