PLC File 2
PLC File 2
PLC File 2
PLC Programming
Navrinder Singh
Vishal Singh
INDEX
SR.NO CONTENT PAGE REMARKS
NO.
functions
don’t care.
then 9.
Converter.
Conversion.
Adder
9 PLC Program to Implement Binary to Gray Code
Conversion
Comparator
Code Conversion
decoder.
5.................RESET ALL
26 PRESS 1 (1,2,3) ON `
PRESS 2 1 OFF
PRESS 3 2 OFF
PRESS 4 3 OFF
Without Loop
With Loop
34 3 Motor System
And repeat
circuit.
circuit.
Light System
OBJECTIVE: Execute ladder diagram of AND, OR, NOT, NAND, NOR, X-OR, X-NOR
gate.
THEORY:
A logic gate is an elementary building block of a digital circuit. Most logic gates have two inputs
and one output. At any given moment, every terminal is in one of the two binary conditions low
(0) or high (1), represented by different voltage levels. The logic state of a terminal can, and
generally does, change often, as the circuit processes data. In most logic gates, the low state is
approximately zero volts (0 V), while the high state is approximately five volts positive (+5 V).
There are seven basic logic gates: AND, OR, XOR, NOT, NAND, NOR, and XNOR.
AND gate
The AND gate is so named because, if 0 is called "false" and 1 is called "true," the gate acts in the
same way as the logical "and" operator. The following illustration and table show the circuit symbol
and logic combinations for an AND gate. (In the symbol, the input terminals are at left and the
output terminal is at right.) The output is "true" when both inputs are "true." Otherwise, the output
is "false." Input 1 Input 2 Output
0 0 0
0 1 0
1 0 0
1 1 1
OR gate
The OR gate gets its name from the fact that it behaves after the fashion of the logical inclusive
"or." The output is "true" if either or both of the inputs are "true." If both inputs are "false," then the
output is "false."
XOR gate
The XOR( exclusive-OR ) gate acts in the same way as the logical "either/or." The output is
"true" if either, but not both, of the inputs are "true." The output is "false" if both inputs are
"false" or if both inputs are "true." Another way of looking at this circuit is to observe that the
output is 1 if the inputs are different, but 0 if the inputs are the same.
A logical inverter , sometimes called a NOT gate to differentiate it from other types of electronic
inverter devices, has only one input. It reverses the logic state.
Input Output
1 0
0 1
NAND gate
The NAND gate operates as an AND gate followed by a NOT gate. It acts in the manner of the
logical operation "and" followed by negation. The output is "false" if both inputs are "true."
Otherwise, the output is "true."
NOR gate
The NOR gate is a combination OR gate followed by an inverter. Its output is "true" if both
inputs are "false." Otherwise, the output is "false."
XNOR gate
The XNOR (exclusive-NOR) gate is a combination XOR gate followed by an inverter. Its output
is "true" if the inputs are the same, and"false" if the inputs are different.
Ladder Logic
PROGRAM 2
AIM: PLC program to implement various Boolean functions.
THEORY:
A Boolean function is a special kind of mathematical function f:Xn→Xf:Xn→Xof degree n, where
X={0,1}X={0,1} is a Boolean domain and n is a non-negative integer. It describes the way how to
derive Boolean output from Boolean inputs.
Boolean Expressions
A Boolean expression always produces a Boolean value. A Boolean expression is composed of a
combination of the Boolean constants (True or False), Boolean variables and logical connectives.
Each Boolean expression represents a Boolean function.
Example − AB′CAB′C is a Boolean expression.
Canonical Forms
For a Boolean expression there are two kinds of canonical forms −
A B C Term Minterm
0 0 0 x’y’z’ m0
0 0 1 x’y’z m1
0 1 0 x’yz’ m2
0 1 1 x’yz m3
1 0 0 xy’z’ m4
1 0 1 xy’z m5
1 1 0 xyz’ m6
1 1 1 xyz m7
PROGRAM:
1) f(w,x,y) =∑(1,3,5,7)
2) f(a,b,c,d)=∑(0,1,2,3,5,7,9,11)
SOLUTION:
K-MAP
1)
f(w,x,y) = y
2)
LADDER LOGIC
1)
2)
PROGRAM 3
AIM: PLC program to implement Boolean function with don’t care condition.
THEORY:
In digital logic, a don't-care term for a function is an input-sequence (a series of bits)
for which the function output does not matter. An input that is known never to occur is
a can't-happen term. Both these types of conditions are treated the same way in
logic design and may be referred to collectively as don't-care conditions for brevity.
[1]
The designer of a logic circuit to implement the function need not care about such
inputs, but can choose the circuit's output arbitrarily, usually such that the simplest
circuit results (minimization). Examples of don't-care terms are the binary values
1010 through 1111 (10 through 15 in decimal) for a function that takes a binary-coded
decimal (BCD) value, because a BCD value never takes on such values (so
called pseudo-tetrades).
Don't care" may also refer to an unknown value in a multi-valued logic system, in
which case it may also be called an X value. In the verilog hardware language such
values are denoted by the letter "X".
PROGRAM:
1) f(A,B,C,D)= m(0,4,5,7,11,15) + Σd(1,10,12,13,14)
f(A,B,C,D)=D+A’C’+AC
LADDER LOGIC
PROGRAM 4
AIM: PLC program to implement the combination of logic circuits.
THEORY:
The input to combinations logic circuit is a 4-bit binary number. Design the logic
circuit with two outputs (Y1, Y2) for the following conditions. Also develop PLC
program in Ladder Logic for the same.
Y1=1 if the input binary number is 5 or less than 5.
Y2=1 if the input binary number is 9 or more than 9.
Program Solution
According to the table designed, Y1 and Y2 both will have different equations,
Y1 when input binary number is 5 or less than 5 and Y2 when input is 9 or more
than 9.
LADDER LOGIC:
PROGRAM 5
AIM: PLC program to implement the combination of circuit.
THEORY:
A circuit has 4 inputs (A, B, C, and D) and 2 outputs (Y1, Y2). One of the outputs is
high when majority of inputs are high. The second output is high when all inputs are
of same type. Design the combinational circuit and implement it in PLC using Ladder
Diagram programming language.
Y1=1 if majority of inputs are high.
Y2=1 if A=B=C=D.
Problem Solution
THEORY:
BINARY BCD
Implementing Binary to BCD converter in PLC using Ladder Diagram programming
language.
Problem Solution
Writing truth table showing the relation between Binary as input and BCD as
output.
For each BCD output D4, D3, D2, D1 and D0, write Karnaugh-Map.
From the K-Map, obtaining a simplified expression for each BCD output in
terms of Binary inputs.
And from the same simplified expressions, draw a Ladder Diagram to obtain
BCD output in terms of Binary inputs.
THEORY:
Implementing BCD to Excess-3 code conversion in PLC using Ladder Diagram
programming language.
Problem Solution
Excess-3 code can be derived from BCD code by adding 3 to each number.
THEORY:
A half adder is a type of adder, an electronic circuit that performs the addition of
numbers. The half adder is able to add two single binary digits and provide the output
plus a carry value. It has two inputs, called A and B, and two outputs S (sum) and C
(carry). The common representation uses a XOR logic gate and an AND logic gate
Half Adder truth table:s an example of a simple, functional digital circuit built from
two logic gates. The half adder
1 0 0 1
0 1 0 1
1 1 1 0
AND gate; thus, when voltage is applied A input of the XOR gate, the A input to the
AND gate same voltage.UTY
CIRCUIT DIAGRAM:
K MAP:
Sum = A’B’C + AB’C’+ A’BC’ + ABC Cout = AB + AC +BC
PROGRAM 9
AIM: PLC implementation of binary to grey conversion.
THEORY:
Binary to Gray Code Conversion
This conversion method strongly follows the EX-OR gate operation between binary
bits . The below steps & solved example may useful to know how to perform binary
to gray code conversion.
1. To convert binary to gray code, bring down the most siginificant digit of the given
binary number, because, the first digit or most siginificant digit of the gray code
number is same as the binary number.
2. To obtain the successive gray coded bits to produce the equivalent gray coded
number for the given binary, add the first bit or the most siginificant digit of binary to
the second one and write down the result next to the first bit of gray code, add the
second binary bit to third one and write down the result next to the second bit of gray
code, follow this operation until the last binary bit and write down the results based on
EX-OR logic to produce the equivalent gray coded binary.
THEORY:
2-Bit Comparator
A 2-bit comparator compares two binary numbers, each of two bits and produces their
relation such as one number is equal or greater than or less than the other. The figure
below shows the block diagram of a two-bit comparator which has four inputs and
three outputs.
The first number A is designated as A = A1A0 and the second number is designated as
B = B1B0. This comparator produces three outputs as G (G = 1 if A>B), E (E = 1, if A
= B) and L (L = 1 if A<B).
TRUTH TABLE :
K MAP:
Ladder Logic
PROGRAM 11
AIM: PLC program to implement 4*1 MUX.
THEORY:
Digital Multiplexer
The MUX is the very crucial component of the communication system. This is
because, in such systems, we need to select a single channel from various other
channels. A multiplexer can be considered as a digitally controlled switch. The
controlling code which selects a particular input line can be given as binary input in
the form of selection line. The output will be one of the inputs given to MUX, which
is decided by selection lines.
Truth table
INPUT
DATA SELECT INPUTS INPUT OUTPUT
SELECTED
A B D D Z
0 0 D0 0 0
1 1
0 1 D1 0 0
1 1
1 0 D2 0 0
1 1
1 1 D3 0 0
1 1
Ladder Logic
PROGRAM 12
AIM: PLC program to implement 8*1 MUX.
THEORY:
8-to-1 Multiplexer
An 8-to-1 multiplexer consists of eight data inputs D0 through D7, three input select
lines S2 through S0 and a single output line Y. Depending on the select lines
combinations, multiplexer decodes the inputs.
The below figure shows the block diagram of an 8-to-1 multiplexer with enable input
that enable or disable the multiplexer. Since the number data bits given to the MUX
are eight then 3 bits (23=8) are needed to select one of the eight data bits.
The truth table for an 8-to1 multiplexer is given below with eight combinations of
inputs so as to generate each output corresponds to input.
For example, if S2= 0, S1=1 and S0=0 then the data output Y is equal to D2. Similarly
the data outputs D0 to D7 will be selected through the combinations of S2, S1 and S0
as shown in below figure.
From the above truth table, the Boolean equation for the output is given as
Ladder Logic
PROGRAM 13
AIM: PLC program to implement 3*8 decoder.
THEORY:
3 Line to 8 Line Decoder
This decoder circuit gives 8 logic outputs for 3 inputs and has a enable pin. The
circuit is designed with AND and NAND logic gates. It takes 3 binary inputs and
activates one of the eight outputs. 3 to 8 line decoder circuit is also called as binary to
an octal decoder.
3 to 8 Line Decoder Block DiagramThe decoder circuit works only when the Enable
pin (E) is high. S0, S1 and S2 are three different inputs and D0, D1, D2, D3. D4. D5.
D6. D7 are the eight outputs.
Circuit Diagram
3 to 8 Decoder Circuit3 to 8 Line Decoder Truth Table
The below table gives the truth table of 3 to 8 line decoder.
S0 S1 S2 E D0 D1 D2 D3 D4 D5 D6 D7
x x x 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0 0 1
0 0 1 1 0 0 0 0 0 0 1 0
0 1 0 1 0 0 0 0 0 1 0 0
0 1 1 1 0 0 0 0 1 0 0 0
1 0 0 1 0 0 0 1 0 0 0 0
1 0 1 1 0 0 1 0 0 0 0 0
1 1 0 1 0 1 0 0 0 0 0 0
1 1 1 1 1 0 0 0 0 0 0 0
When the Enable pin (E) is low all the output pins are low.
Ladder Logic
Program – 14
Ladder Logic
Program – 16
Theory :
A motor which is started by pressing a button switch although the switch contact
does not remain closed . It is required that motor continues to run until a stop
button is pressed . It means the latching is used to stay motor run until the
push button is pressed again .
Program – 18
PROGRAM 20
PROGARM:
Input Switch 1 -> Motor 1, Motor 2 ON
Input Switch 2 - > Motor 3, Motor 4 ON
Input Switch 3 - > Motor 1, Motor 3 OFF
Input Switch 4 - > Motor 2, Motor 4 OFF
Ladder Logic
PROGRAM 21
SOLUTION:
Truth table
INPUTS OUTPUTS*
S1 (Chairman) S2 S3 S4 Selection
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 1
0 1 0 0 0
0 1 0 1 1
0 1 1 0 1
0 1 1 1 1
1 0 0 0 1
1 0 0 1 1
1 0 1 0 1
1 0 1 1 1
1 1 0 0 1
1 1 0 1 1
1 1 1 0 1
1 1 1 1 1
K-Map
Selection = S2S3 + S2S4 + S3S4 + S1
Ladder Logic
PROGRAM 22
AIM: Implementation of PLC program for a 1:4 DEMUX.
PROGARM:
Design a 1:4 DEMUX using the ladder logic.Assume the input are connected to input
control signals and the output terminals.
SOLUTION:
Truth table
Ladder Logic
PROGRAM 23
INPUT OUTPUT
ON OFF
1 1 2,3,4
2 2 1,3,4
3 3 1,2,4
4 4 1,2,3
5 ALL
SOLUTION:
Ladder Logic
PROGRAM 24
INPUT OUTPUT
1 1,2,3 ON
2 1 OFF
3 2 OFF
4 3 OFF
SOLUTION:
Ladder Logic
PROGRAM 25
SOLUTION:
Ladder Logic
PROGRAM 26
SOLUTION:
Ladder Logic
*CPU_Input7 is used as a reset bit.
Program 27
Program:
Input Output
I0.1 L1 (ON)
Solution:
Ladder Logic
Program 28
Theory:
PLC timers are instructions that provide the same functions as on-delay and off-delay
mechanical and electronic timing relays. A PLC timer provides a preset delay to the
control actions.
In general, there are three types of PLC timer delays, ON-delay timer, OFF-delay
timer and retentive timer on.
The terms represented in the timer block in the PLC are a Preset value which means
the delay period of the timer, an Accumulated value which is the current delay of the
timer.
A timer begins the counting on time-based intervals and continues until the
accumulated value equals the preset value. When the accumulated value equals the
preset time the output will be energized. Then the timer sets the output.
An ON delay timer is used where we need a time delay before the time delay before
an instruction becomes true.
The timer starts operating when the rung condition becomes true.
The timer delay starts counting when the rung condition starts to
accumulate.
The timed output becomes true sometime after the timer rung
value.
Program:
Turn on an output light, 5 seconds after switch is turned on.
Solution:
Ladder Logic
Program 29
Aim: To implement basic Timer Circuit (TOFF).
Theory:
A TOFF timer will keep the output energized for a preset time after the rung signal
has gone false.
The TOFF timer will have all the contents as in the TON timer, with the similar
function.
When the rung timer is true, the output will be true without any delay. When
the rung signal becomes false the timer starts operating.
The timer starts accumulating times when the rung condition becomes true,
until the accumulated value becomes equal to the Preset value.
The output turns off when the output will turn false when the accumulated
value equals the preset value.
Solution:
Ladder Logic:
Program 30
Solution:
Ladder Logic:
Program 31
Program:
LED ON after
1 2 seconds
2 4 seconds
3 6 seconds
4 8 seconds
Solution:
Ladder Logic
Program 32
Program:
and LED which glows first gets OFF after the next LED gets ON.
LED ON after
1 2 seconds
2 4 seconds
3 6 seconds
4 8 seconds
Solution:
Ladder Logic
Program 33
Program:
SEQUENCE OUTPUT
Ladder Logic
Program 34
Program:
There are 6 LED’s namely L 1,L2,L3,L4,L5 and L6 and they follow a certain
SEQUENCE OUTPUT
Solution:
Ladder Logic
Program 35
Solution:
Ladder Logic
Program 36
Solution:
Ladder Logic
Program 37
Solution:
Ladder Logic
Program 38
Theory:
A pulse is a burst of current, voltage, or electromagnetic-field energy. In practical
electronic and computer systems, a pulse may last from a fraction of a nanosecond up
to several seconds or even minutes. In digital systems, pulses comprise brief bursts of
DC (direct current) voltage, with each burst having an abrupt beginning (or rise) and
an abrupt ending (or decay).
Program:
output
1 5 1,2 ON
2 4 3,4 ON
3 3 All OFF
Solution:
Ladder Logic
Program 39
Program:
There are 15 parking slots in a building and there are 2 status LED’s both
LED STATUS
Solution:
Ladder Logic
Program 40
Theory:
Duty Cycle
When the signal is high, we call this "on time". To describe the amount of "on time" ,
we use the concept of duty cycle. Duty cycle is measured in percentage. The
percentage duty cycle specifically describes the percentage of time a digital signal is
on over an interval or period of time. This period is the inverse of the frequency of the
waveform.
If a digital signal spends half of the time on and the other half off, we would say the
digital signal has a duty cycle of 50% and resembles an ideal square wave. If the
percentage is higher than 50%, the digital signal spends more time in the high state
than the low state and vice versa if the duty cycle is less than 50%. Here is a graph
that illustrates these three scenarios:
50%, 75%, and 25% Duty Cycle Examples
100% duty cycle would be the same as setting the voltage to 5 Volts (high). 0% duty
cycle would be the same as grounding the signal.
Program:
Solution:
Ladder Logic
Program 41
Aim: To implement given conditions on a PLC.
Program:
LED Status
Solution:
Ladder Logic
s Program 42
Program:
Solution:
Ladder Logic
Program 43
Program:
SEQUENCE OUTPUT
Ladder Logic
Program 44
Aim: To implement given conditions on a PLC.
Program:
SEQUENCE OUTPUT
2 seconds after input is triggered L1 ON
2 seconds further L2 ON
2 seconds further L3 ON
2 seconds further L4 ON
2 seconds further L5 ON
Program:
SEQUENCE OUTPUT
As soon as input is triggered Water inlet
2 seconds further Surf inlet
2 seconds further Forward (10 times alternatively)
Backward (10 times alternatively)
Solution:
Ladder logic
Program 46
Program:
Solution:
Ladder logic
Program 47
Program:
Ladder logic