10 CHAPTER 2.
RELAY LOGIC
2.3 A design problem
The best way to learn is by doing examples. We will revisit the tank filling problem and use it as example
to introduce some formal techniques useful in large designs.
Consider the following.
Design a controller to maintain the water level in a tank between two limits. The water level
should not go below a low level point called “Low” and should not exceed a height called
“High.” The level of the water can be increased using an electric pump. A limit switch will
close when the water level is below “Low” and another limit switch will close when the water
level is above the height ”High.” Otherwise both limit switches are open.
Our first step is to change the description of the problem into a form that can be represented by logic
states. One of method of doing this is to write down the logic equation:
Pump = High · On + High · Low = High(On + Low) (2.1)
In this example the logic equation is very simple and very easy also to simplify. In more complex processes
writing down the logic equation directly can be facilitated by using a state diagram. This forces us to
consider the states of the process. In this case, the important state is the state of the pump, whether it is
on or not. The state diagram for the tank filling process is shown in figure 2.9. The red circles indicate
the state of the process and the arrows or edges represent the transitions and what caused them to occur.
From the state diagram we can see that the logic equation is
Pump on = [High · Pump on + (Pump on) · Low] · [High · (Pump on) + (Pump on) · Low] (2.2)
= [High · Pump on + (Pump on) · Low] (2.3)
Tank not low
Tank High
start Pump on Pump off
Tank low
Tank not high
Figure 2.9: A state diagram of the process of filling a tank
We can write down the solution in logic algebra and simplify the equation to a minimum. This process
is facilitated by using a Karnaugh map as shown in table 2.1. The idea behind a Karnaugh map is that
there is only a one bit change from a line to the next line, or from a column to the next column. Look
closely at figure 2.1 and you will see that this is true. In the Karnaugh map, a ”1” indicates that the
pump is ”on” and a ”0” indicates that the pump is ”off”. This is shown in red. The principle of the
Karnaugh map is that if there is a ”1” in neighbouring columns or rows then that value does not matter.
For example, in the first two rows, the ”Low” bit changes from ”0” to ”1” but the ”High” bit does not
change. This means that if ”Pump on” is true then it does not matter what the condition of ”Low” is,
”High” must be zero. Similarly, in the second row, while ”High” is not true and ”Low” is true, it does not
matter about the state of the pump.
2.3. A DESIGN PROBLEM 11
Fluid Level Pump On
< High > Low 0 1
0 0 0 1
0 1 1 1
1 1 0 0
1 0 0 0
Table 2.1: Karnaugh Map of the fluid-tank level controller. Here <High means “Is it greater than the
HIGH level?” and >Low means “Is it less than the LOW level?”
Using the Karnaugh Map shown in table (2.1), we can write the logic expression
Pump = High · On + High · Low = High(On + Low) (2.4)
A flow diagram of this problem is shown in figure 2.10. What is the difference between a state-diagram
and a flow-chart? A flow-chart is related to decisions to do things, whereas the state-diagram is about
transitions from one state to another.
Realization
The next step is the realization of the logic statement. Two realizations are shown in figure 2.11 and figure
2.12.
12 CHAPTER 2. RELAY LOGIC
Figure 1: A flow-chart
Begin
Input Tank Status
Pump On, Fluid High, Fluid Low
Yes
Fluid High? Pump Off
No
Fluid Low?
No
Yes
Pump On? Pump On
No
End
Figure 2.10: Flow chart for water tank pump
2.3. A DESIGN PROBLEM 13
Fluid Level Low
Pump on
Fluid Level High
Figure 2.11: Sample realizations of the water tank controller using logic gates
Fluid Level Low Fluid Level High
Pump On Pump
Figure 2.12: Sample realizations of the water tank controller using relay logic