17. Switching Logic
• In logic based control, decisions are made based on available information.
17.1 Boolean Algebra
• Recall the basic rules of Boolean algebra,
- Symbols for Boolean operations may look different
AND, *, •, &
NOT, ~, A
A = B * ( C * ( D + E + C ) + F * C )
A = B * C ------------------------------------ Simplified Form
A = B*C*D + B*C*E + B*C*F + B*C ----- Canonical/Disjunctive normal form
17.2 Discrete Logic
• The basic types of discrete logic problems are,
1. Conditional: if a set of conditions can directly cause an action.
e.g. if the temperature is too high and there is an ingot in only one bay, turn on fan 1.
B1 = bay 1 ingot detect
B2 = bay 2 ingot detect
F1 = fan 1
T1 = temperature overheat sensor
in Boolean F1 = T1 * (B1 EOR B2)
or F1 = T1 * (( B1 * B2 ) + ( B2 * B1 ))
or F1 = T1 * B1 * B2 + T1 * B2 * B1
In ladder logic,
2. Sequential: when the system is in a certain state, the controls will do certain things.
e.g., when an oven is on, the PLC adjusts temperature.When it is off doors can be opened/closed.
• Try the example shown below,
• Consider the more complicated design that follows,
17.2.1 Boolean Algebra for Circuit and Ladder Logic Design
• When we have logical decisions to make, truth tables and Boolean algebra allow formal methods to be used. The use of formal methods improves the overall quality of the design.
• Consider the example of a burglar alarm
1. If alarm is on, check sensors.
2. If window/door sensor is broken (turns off), sound alarm and turn on lights
3. If motion sensor goes on (detects thief) sound alarm and turn on lights.
A = Alarm and lights switch (1 = on)
W = Window/Door sensor (1 = OK)
M = Motion Sensor (0 = OK)
S = Alarm Active switch (1 = on)
• This example was quite simple. To do more complicated problems we will need to review some basic theory first.
17.2.2 Boolean Forms
• Canonical, truth tables
17.3 Simplifying Boolean Equations
17.3.1 Karnaugh Maps for Combinatorial Design
• Karnaugh maps allow us to convert a truth table to a simplified Boolean expression without having to use Boolean Algebra.
• Consider the example below,
Problem 17.1 Design ladder logic for a car that considers,
- doors opened/closed (D)
- windows (W)
- keys in ignition (K)
- motor running (M)
- transmission in park (P)
- etc (?)
17.4 Additional Topics
17.4.1 Negative Logic
• Some applications will use negative logic. Effectively this is the opposite of positive logic.
Positive Logic: a high/low voltage or current level indicates a true/false condition
Negative Logic: a low/high voltage or current level indicates a true/false condition
• This is common in a variety of applications. Reasons include,
we want current to flow when things are alright, consider an E-stop.
a device input “floats high” so that when there is no input it turns on. This is common with many integrated circuits.
17.4.2 Common Logic Forms
• Recognizing certain logic forms allows faster identification and solution of design problems.
• These include,
- Code conversion
22.214.171.124 - NAND/NOR Forms
• Remember the basic forms for NAND and NOR and then apply de’Morgan’s theorem.
126.96.36.199 - Multiplexers
• Multiplexers allow us to select a single output from several inputs.
• In ladder logic this can be done as below,
• Demultiplexers work in reverse.
17.5 Design Cases
17.5.1 Logic Functions
Part A: Develop a program that will cause output D to go true when switch A and switch B are closed or when switch C is closed.
Part B: Develop a program that will cause output D to be on when push button A is on, or either B or C are on.
17.5.2 Car Safety System
Develop Ladder Logic for a car door/seat belt safety system. When the car door is open, or the seatbelt is not done up, the ignition power must not be applied. If all is safe then the key will start the engine.
17.5.3 Motor Forward/Reverse
• Design a motor controller that has a forward and a reverse button. The motor forward and reverse outputs will only be on when one of the buttons is pushed. When both buttons are pushed the motor will not work.
Problem 17.2 Draw a ladder diagram that will cause output D to go true when switch A and switch B are closed or when switch C is closed. The devices are wired to the following locations.
Input A is 001
Input B is 002
Input C is 003
Output D is 201
Problem 17.3 Draw a ladder diagram that will cause output D to be on when push button A is on, or either B or C are on.
Input A is 001
Input B is 002
Input C is 003
Output D is 201
Problem 17.4 Make a simple ladder logic program that will turn on the outputs with the binary patterns when the corresponding buttons are pushed. Assume that the outputs are from 200 to 207 and that 200 is the LSB)
11011011 (input 101)
10101010 (input 102)
10010010 (input 103)
Problem 17.5 Given the truth table below
a) find a Boolean algebra expression using a Karnaugh map.
b) draw a ladder diagram using the truth table (not the Boolean expression).
Problem 17.6 Simplify the Boolean expression below.
Answer 17.6 = C
Problem 17.7 Given the Boolean expression a) draw a digital circuit and b) a ladder diagram (do not simplify).
Problem 17.8 a) Construct a truth table for the following problem.
i) there are three buttons A, B, C.
ii) the output is on if any two buttons are pushed.
iii) if C is pressed the output will always turn on.
b) Develop a Boolean expression.
c) Develop a Boolean expression using a Karnaugh map.
Problem 17.9 a) Given the following truth table, show the Boolean combinations that would give a result of 1.
b) Write the results in a) in a Boolean equation.
c) Simplify the Boolean equation in b)
Problem 17.10 Develop the simplest Boolean expression for the Karnaugh map below,
b) by Boolean Algebra
Problem 17.11 Setup the Karnaugh map for the truth table below.
Problem 17.12 a) Develop the Boolean expression for the circuit below.
b) Simplify the Boolean expression.
c) Draw a simpler circuit for the equation in b).
Problem 17.13 Is the ladder logic below for,
c) both a) and b)
d) none of the above
Answer 17.13 a
Problem 17.14 Simplify the following Boolean equations,
Answer 17.14 a)
Problem 17.15 Simplify the following boolean equations
Problem 17.16 Convert the following ladder logic to a Karnaugh map.
Problem 17.17 Simplify the following and implement the original and simplified equations with gates and ladder logic.
Problem 17.18 Write the simplest Boolean equation for the Karnaugh map below,
Problem 17.19 Given a system that is described with the following equation,
a) Simplify the equation using Boolean Algebra.
b) Implement the original and then the simplified equation with a digital circuit.
c) Implement the original and then the simplified equation in ladder logic.
d) Implement the simplified equation in a Basic Stamp program. Assume the inputs and outputs are on pins A=1, B=2, C=3, D=4, E=5, X=6)
Problem 17.20 Given the truth table below find the most efficient ladder logic to implement it. Use a structured technique such as Boolean algebra or Karnaugh maps.
Problem 17.21 For the following Boolean equation,
a) Write out the logic for the unsimplified equation.
b) Simplify the equation.
c) Write out the ladder logic for the simplified equation.
Problem 17.22 Use a Karnaugh map to simplify the following truth table, and implement it in ladder logic.
Problem 17.23 Convert the following Boolean equation to the simplest possible ladder logic.