C F L P: Hapter OUR Adder Rogramming
C F L P: Hapter OUR Adder Rogramming
C F L P: Hapter OUR Adder Rogramming
LADDER PROGRAMMING
The power lines, or rails, as they are often called, are like the vertical sides
of a ladder, with the horizontal circuit lines similar to the rungs of the
ladder.
PLC Ladder Programming (LAD)
With a normally closed switch |/| there will be an output until that switch
was opened. The output will be off when the input is activated.
In drawing ladder diagrams, the names of the associated variable and
addresses of each element are appended to its symbol. Thus the next figure
shows how the ladder diagram of previous example would appear using (a)
Mitsubishi, (b) Siemens, (c) Allen-Bradley, and (d) Telemecanique
notations for the addresses.
Logic Functions
International
Ladder diagram
Electrical circuit
Truth table
Logic gate symbol
Ladder diagram
4- NAND
NAND gate is an AND gate followed by a NOT gate. The consequence of
having the NOT gate is to invert all the outputs from the AND gate. Either
input A or input B (or both) have to be 0 for there to be a 1 output.
When both inputs A and input B are 1, the output is 0.
Logic gate
symbol Truth table
An alternative that gives exactly the same result is to put a NOT gate on
each input and then follow that with an OR gate.
Ladder diagram
5- NOR
NOR gate is an OR gate followed by a NOT gate. The consequence of having
the NOT gate is to invert the outputs of the OR gate. There is an output
when neither input A nor input B is 1.
Logic gate
symbol Truth table
An alternative, which gives exactly the same results, is to put a NOT gate
on each input and then an AND gate.
Ladder diagram
6- Exclusive OR (XOR)
The OR gate gives an output when either or both of the inputs are 1.
However, sometimes there is a need for a gate that gives an output when
either of the inputs is 1 but not when both are 1.
Logic gate
symbol Truth table
One way of obtaining such a gate is by using NOT, AND, and OR gates as
shown in figure.
Ladder diagram
Latching
With ladder diagrams, there can be more than one output connected to a
contact. The figure shows a ladder program with two output coils. When the
input contacts close, both the coils give outputs.
For the ladder rung shown in the figure, output A occurs when input A
occurs. Output B occurs only when both input A and input B occur.
Example
Other languages that are less popular include instruction list (IL),
sequential function chart (SFC), and structured text (ST).
structured text
(ST).
Boolean Algebra
Ladder programs can be derived from Boolean expressions since we are
concerned with a mathematical system of logic.
In Boolean algebra there are just two digits, 0 and 1. When we have an
AND operation for inputs A and B, we can write:
The figure shows the ladder diagram and the corresponding logic circuit.
Consider a logic diagram with many inputs, as shown in figure below.
Its representation by a Boolean expression and a ladder rung.
Axioms
Single-variable Theorems
During the analysis or synthesis of logic circuits, we often write algebraic
expressions that characterize a circuit’s actual or desired behavior. Boolean
algebra theorems are statements that allow us to manipulate algebraic
expressions to get simpler ones. For example, the theorem X + 0 = X
allows us to substitute every occurrence of X + 0 in an expression with X.
The next table lists Boolean algebra theorems involving a single variable
X. Try to prove it yourself.
21
Table 2
(T1) X + 0 = X (T1) X 1 = X
(T2) X + 1 = 1 (T2) X 0 = 0
(T3) X + X = X (T3) X X = X
(T4) X + X' = 1 (T4) X X' = 0
(T5) (X')' = X
However, Boolean algebra also has the unfamiliar property that the reverse
is true—logical addition distributes over logical multiplication as
demonstrated by theorem T8'. Thus, we can also “add out” an expression to
obtain a product of-sums form:
23
DeMorgan’s Laws (T9 and T9) are probably the most commonly used of
all the theorems of Boolean algebra. These theorems apply to any number
of inputs. Theorem T9 simply says that an n-input AND gate whose
output is inverted is equivalent to an n-input OR gate whose inputs are
inverted. That is, the circuits of the figure (a) and (b) or (c) and (d) are
equivalent.
Equivalent to Equivalent to
Theorems (T10, T10) and (T11, T11) are used extensively in the minimi-
zation of logic functions. For example, if the subexpression X + XY
appears in a logic expression, the absorption theorem T10 says that we
need only include X in the expression.
24
Order Of Operation
The order of priority in Boolean expression is NOT first, AND second, and
OR last, unless otherwise indicated by grouping signs, such as parentheses,
brackets, or braces. According to these rules, in the expression A + B C, B
is ANDed with C first then the result is ORed with A.
Duality
We stated all of the axioms of Boolean algebra in pairs (e.g., (A1) and (A1)).
The primed version () of each axiom is obtained from the unprimed version
by simply swapping (0) and (1) and, if present, () and (+). As a result, we can
state the following metatheorem, a theorem about theorems:
The foregoing axioms and theorems of the Boolean algebra are used in
analysis and synthesis of digital circuits. It can be also used to simplify the
logic expressions. The following example illustrates this:
25
Examples
1. Z = X + XY
Ans.
Z = X1 + XY
= X(1+ Y)
= X1
=X
2. Z = X(X + Y)
Ans.
Z = XX + XY
= 0 + XY
= XY
5. Z = X + XY
Ans.
Z = (X + X)(X + Y)
= 1(X + Y)
=X+Y
27
Standard Representations of Logic Functions
1. Truth table
The most basic representation of a logic function is the truth table. This
representation simply lists the output of the circuit for every possible
input combination. Traditionally, the input combinations are arranged in
rows in ascending binary counting order, and the corresponding output
values are written in a column next to the rows. The general structure of a
3-variable truth table is shown in table below.
Row X Y Z F
0 0 0 0 F(0,0,0)
1 0 0 1 F(0,0,1)
2 0 1 0 F(0,1,0)
3 0 1 1 F(0,1,1)
4 1 0 0 F(1,0,0)
5 1 0 1 F(1,0,1)
6 1 1 0 F(1,1,0)
7 1 1 1 F(1,1,1)
Table 4 General truth table structure 28
for a 3-varible logic function, F(X,Y,Z)
The rows are numbered 0–7 Row X Y Z F
corresponding to the binary input 0 0 0 0 1
combinations, but this numbering is not 1 0 0 1 0
an essential part of the truth table. The 2 0 1 0 0
truth table for a particular 3-variable
3 0 1 1 1
logic function is shown in table 5. Each
4 1 0 0 1
distinct pattern of 0s and 1s in the
5 1 0 1 0
output column yields a different logic
6 1 1 0 1
function; there are 28 such patterns.
7 1 1 1 1
Thus, the logic function shown in the
table is one of 28 different logic Table 5 Truth table for a particular
functions of three variables. 3-varible logic function, F(X,Y,Z)
The truth table for an n-variable logic function has 2n rows. Obviously,
truth tables are practical to write only for logic functions with a small
number of variables.
The information contained in a truth table can also be conveyed
algebraically. To do so, we first need some definitions:
30
There is a close correspondence between the truth table and minterms and
maxterms. A minterm can be defined as a product term that is 1 in exactly
one row of the truth table. Similarly, a maxterm can be defined as a sum
term that is 0 in exactly one row of the truth table. The next table shows
this correspondence for a 3-variable truth table.
Table 6
Row X Y Z F Minterm Maxterm
0 0 0 0 F(0,0,0) XYZ X+YZ
1 0 0 1 F(0,0,1) XYZ X + Y Z
2 0 1 0 F(0,1,0) XYZ X + Y Z
3 0 1 1 F(0,1,1) XYZ X + Y Z
4 1 0 0 F(1,0,0) XYZ X + Y Z
5 1 0 1 F(1,0,1) XYZ X + Y Z
6 1 1 0 F(1,1,0) XYZ X + Y Z
7 1 1 1 F(1,1,1) XYZ X + Y Z
Here, the notation X,Y,Z(0,3,4,6,7) is a minterm list and means “the sum
of minterms 0, 3, 4, 6, and 7 with variables X, Y, and Z.” The minterm list
is also known as the on-set for the logic function. You can visualize that
each minterm turns on the output for exactly one input combination. Any
logic function can be written as a canonical sum.
32
The canonical product of a logic function is a product of the maxterms
corresponding to input combinations for which the function produces a 0
output. For example, the canonical product for the logic function in Table 5 is
Here, the notation X,Y,Z(1,2,5) is a maxterm list and means “the product
of maxterms 1, 2, and 5 with variables X, Y, and Z.” The maxterm list is
also known as the off-set for the logic function. You can visualize that each
maxterm turns off the output for exactly one input combination. Any logic
function can be written as a canonical product.
It’s easy to convert between a minterm list and a maxterm list. For
a function of n variables, the possible minterm and maxterm numbers
are in the set {0, 1, ...., 2n-1}; a minterm or maxterm list contains a subset
of these numbers. To switch between list types, take the set complement,
for example,
A,B,C(0,1,2,3) = A,B,C(4,5,6,7)
X,Y(1) = X,Y(0,2,3)
W,X,Y,Z(0,1,2,3,5,7,11,13) = W,X,Y,Z(4,6,8,9,10,12,14,15) 33
We have now learned five possible representations for a logic function:
1. A truth table.
2. An algebraic sum of minterms, the canonical sum.
3. A minterm list using the S notation.
4. An algebraic product of maxterms, the canonical product.
5. A maxterm list using the P notation.
Each one of these representations specifies exactly the same information;
given any one of them, we can derive the other four.
35
Logic Circuit Analysis
We analyze a logic circuit by obtaining a formal description of its logic
function. Once we have a description of the logic function, a number of
other operations are possible:
We can determine the behavior of the circuit for various input
combinations.
We can manipulate an algebraic description to suggest different circuit
structures for the logic function.
We can use an algebraic description of the circuit’s functional behavior
in the analysis of a larger system that includes the circuit.
Given a logic diagram for a circuit, such as in the shown figure, there are
a number of ways to obtain a formal description of the circuit’s function.
The most primitive functional description is the truth table.
36
Using only the basic axioms of Boolean algebra, we can obtain the truth table
of an n-input circuit by working our way through all 2n input combinations.
For each input combination, we determine all of the gate outputs produced by
that input, propagating information from the circuit inputs to the circuit
outputs. The figure below applies this “exhaustive” technique to our example
circuit. Written on each signal line in the circuit is a sequence of eight logic
values.
Row X Y Z F
0 0 0 0 0
The truth table can be written by transcribing 1 0 0 1 1
the output sequence of the final OR gate, as
2 0 1 0 1
shown in the next table. Once we have the
3 0 1 1 0
truth table for the circuit, we can also
4 1 0 0 0
directly write a logic expression—the
canonical sum or product—if we wish. 5 1 0 1 1
37
6 1 1 0 0
7 1 1 1 1
The number of input combinations of a logic circuit grows exponentially with
the number of inputs, 2n, so the exhaustive approach can quickly become
exhausting. Instead, we normally use an algebraic approach whose complexity
is more linearly proportional to the size of the circuit. The method is simple—
we build up a parenthesized logic expression corresponding to the logic
operators and structure of the circuit. We start at the circuit inputs and
propagate expressions through gates toward the output. Using the theorems
of Boolean algebra, we may simplify the expressions as we go, or we may defer
all algebraic manipulations until an output expression is obtained.
The figure above applies the algebraic technique to our example circuit.
The output function is given on the output of the final OR gate:
38
F = ((X + Y)Z) + (XYZ)
No Boolean-algebra theorems were used in obtaining this expression.
However, we can use theorems to transform this expression into another
form. For example, a sum of products can be obtained by “multiplying
out” (using theorem T8) :
F = XZ + YZ + XYZ
The new expression corresponds to a different circuit for the same logic
function, as shown in figure below.
Similarly, we can “add out” (using theorem T8) the original expression to obtain a
product of sums:
F = ((X + Y)Z) + (XYZ)
= (X + Y + X)(X + Y + Y)(X + Y + Z)(Z + X)(Z + Y)(Z + Z) 39
= 1 1 (X + Y + Z)(X + Z)(Y + Z) 1
= (X + Y + Z)(X + Z)(Y + Z)
The corresponding logic circuit is shown in figure below. Note that the circuits
that synthesized from sum of product logic expressions are often called
AND-OR circuits, while those which are synthesized from product of sum
logic expressions are called OR-AND circuits.
40