# Karnaugh mapping aids industrial control

## Industrial PLC programmers face many problems. Among them: reducing scan time so lower cost PLCs can be used; eliminating "bugs" in ladder logic rungs; and reducing maintenance costs on old ladder logic.Karnaugh mapping can help with all these problems. Karnaugh mapping is a systematic and pictorial way of applying Boolean algebra to reduce complex digital problems.

01/01/2000

Industrial PLC programmers face many problems. Among them: reducing scan time so lower cost PLCs can be used; eliminating 'bugs' in ladder logic rungs; and reducing maintenance costs on old ladder logic.

Karnaugh mapping can help with all these problems. Karnaugh mapping is a systematic and pictorial way of applying Boolean algebra to reduce complex digital problems.

An example of Karnaugh mapping could begin with writing an organized statement about the conditions for going on a picnic. In this case, the alternatives are Sunday and Clear and Calm or Sunday and Clear and Windy. Common sense analysis of the logic says it doesn't matter whether the wind blows, so the picnic statement becomes Sunday and Clear, a much simpler statement (see diagram).

The picnic statement in ladder logic looks something like this:

As the ladder logic shows, the picnic rung is enabled whether it is calm or not calm-so the rung can be written in a simpler form that reduces scan time:

More complicated programs require a more systematic approach for analysis. The principles of Boolean algebra fit that requirement.

The first step is to make a clear problem statement. The next step is to construct a truth table. The truth table uses all combinations of all variables of the problem-day of week, cloudiness, and wind conditions.

An example of the truth table for the picnic problem includes numeric representations in a binary form that make the truth table easier to manipulate.

 A = Day of week 1 = Sunday 0 = Other B = Cloud cover 1 = None 0 = Cloudy C = Wind conditions 1 = Calm 0 = Windy

 4 2 1 A B C Picnic 0 0 0 0 0 1 0 0 1 0 2 0 1 0 0 3 0 1 1 0 4 1 0 0 0 5 1 0 0 0 6 1 1 0 1 7 1 1 1 1

A truth table has a column for every variable. When you let the number of variables = n, a truth table has 2 to the power n rows.

The next step is to construct a Karnaugh (K) map. The K map is square or rectangular in the proportions 2 to 1 and contains 2 to the n squares-one for each row of the truth table. The three-variable map for our picnic problem is rectangular and has eight squares-one for each row of the truth table.

The squares are numbered the same as the rows on the truth table. However, there is a method to the numbering-such that rows represented by the numbers vary by only one variable in adjacent squares. In this way, adjacent squares represent variables that can be removed.

The following is a typical three-variable map:

 _C C 0000 1001 2010 3011 6110 7111 4100 5101

Now, the picnic's truth table can be mapped on the three-variable K map. Row numbers on the truth table correspond exactly to square numbers in the K map. Each square also has a three-digit binary number for the row on the truth table. Notice that adjacent squares vary by only one bit. The result number is represented in bold type.

_
C

C

 0 0000
 0 1001
 0 2010
 0 3011
 1 6110
 1 7111
 0 4100
 0 5101

The two paths of ladder logic are represented by lines six and seven on the truth table. Their appearance in adjacent squares on the K map indicates a condition for rung (logic) reduction. The entire rung is represented by A and B (the first and second bits) with bit C being superfluous. Therefore, if A and B are true, then we go on the picnic! This is the same result we got by applying common sense.

K maps work, but isn't common sense faster? For this level of problem, yes. However, we are laying a foundation for more challenging problems using and establishing a design methodology.

Back in the early days of computers and integrated circuits-after discrete components and before microprocessors-computer integrated circuits were built with bit slice Arithmetic Logic Units. Suppose we have a simple PLC with no math instructions and we need to add two eight-bit numbers. Do we spend \$5,000 for a capable PLC or is there some technology that we can use to save money?

The specification calls for a bit slice adder. A truth table for one slice woud look like this:

 A B C Carry out Sum 0 0 0 0 0 0 1 0 0 1 0 1 2 0 1 0 0 1 3 0 1 1 1 0 4 1 0 0 0 1 5 1 0 1 1 0 6 1 1 0 1 1 7 1 1 1 1 1

For this problem, two three-variable maps are needed, one for the Carry out and one for the Sum.

Carry out

Sum

_
C

C

_
C

C

0

000

1

001

_
A

0

000

 1 1001

2

010

 1 3011

_
A

 1 2010

3

011

 1 6110

7

111

A

6

110

 1 7111

4

100

6

110

A

 1 4100

6

110

Write the boolean equation for each adjacent pair of two.

AC+BC+AB = Co

This one cannot be simplified, so each one gets a boolean term.

_ _
ABC+ABC+ABC+ABC = Sum

The ladder logic from the equation would look like this:

Maintenance follows much the same approach as design, except that a truth table must be constructed from the old rung. A traditionally designed rung such as:

would have a truth table that looks like this:

 A B C D O 0 0 0 0 0 1 0 0 0 1 2 0 0 1 0 3 0 0 1 1 4 0 1 0 0 5 0 1 0 1 1 6 0 1 1 0 7 0 1 1 1 1 8 1 0 0 0 9 1 0 0 1 1 10 1 0 1 0 11 1 0 1 1 12 1 1 0 0 13 1 1 0 1 14 1 1 1 0 15 1 1 1 1 1

The truth table can then be maintenanced and K mapped to form the new rung.

The next step in PLC logic minimization may be to devise rung software or a hand held rung calculator to perform rung minimization. If PLC manufacturers decide to include this rung minimization software in their design packages, a handheld rung calculator would soon become obsolete. A feature of a rung minimization algorithm is rung entry and optimization using the engineer's favorite methods.

Good luck and good logic!

For more information, a good book on Karnaugh mapping is Computer Logic Design by M. Morris Mano, Prentice Hall, 1972. For a more complete Karnaugh mapping discussion, visit www.controleng.com .

 Author Information Lyle R. Hurst, electronics instructor, ITT Technical Institute, Arnold, Mo., and Gary Mintchell, senior editor,

The Engineers' Choice Awards highlight some of the best new control, instrumentation and automation products as chosen by...
The System Integrator Giants program lists the top 100 system integrators among companies listed in CFE Media's Global System Integrator Database.
Each year, a panel of Control Engineering and Plant Engineering editors and industry expert judges select the System Integrator of the Year Award winners in three categories.
This eGuide illustrates solutions, applications and benefits of machine vision systems.
Learn how to increase device reliability in harsh environments and decrease unplanned system downtime.
This eGuide contains a series of articles and videos that considers theoretical and practical; immediate needs and a look into the future.
Controller programming; Safety networks; Enclosure design; Power quality; Safety integrity levels; Increasing process efficiency
Additive manufacturing benefits; HMI and sensor tips; System integrator advice; Innovations from the industry
Robotic safety, collaboration, standards; DCS migration tips; IT/OT convergence; 2017 Control Engineering Salary and Career Survey
Featured articles highlight technologies that enable the Industrial Internet of Things, IIoT-related products and strategies to get data more easily to the user.
This article collection contains several articles on how automation and controls are helping human-machine interface (HMI) hardware and software advance.
This digital report will explore several aspects of how IIoT will transform manufacturing in the coming years.
Infrastructure for natural gas expansion; Artificial lift methods; Disruptive technology and fugitive gas emissions
Mobility as the means to offshore innovation; Preventing another Deepwater Horizon; ROVs as subsea robots; SCADA and the radio spectrum
Future of oil and gas projects; Reservoir models; The importance of SCADA to oil and gas
Automation Engineer; Wood Group
System Integrator; Cross Integrated Systems Group
Jose S. Vasquez, Jr.
Fire & Life Safety Engineer; Technip USA Inc.
This course focuses on climate analysis, appropriateness of cooling system selection, and combining cooling systems.
This course will help identify and reveal electrical hazards and identify the solutions to implementing and maintaining a safe work environment.
This course explains how maintaining power and communication systems through emergency power-generation systems is critical.