Introduction
The Celtic Engineer is a weekly newsletter produced by Celtic Engineering Solutions. We hope you enjoy it. If you have any suggestions for topics, would like to give feedback or want your email added to the distribution list please send an email to [email protected].
Boolean Algebra!?
Those of you who hated algebra in school, probably aren’t reading this newsletter anyway. For the rest of us, dust off the cobwebs because you probably don’t use logic gates very often in your designs anymore. Boolean Algebra is a branch of algebra that deals with variables that are either true or false, 1 or 0. This type of logical endeavor did not start with the modern computer, but was alive and well in the mid-1800’s.
The principles of BA are based on three operations, AND, OR and NOT. As you may remember, there are other logical operations such as NOR, NAND and XOR, but these are not basic operations, because their functions can be expressed using the three base operators above. They are referred to as secondary operations.
We could jump into Monotone Laws and Venn diagrams, but then I would lose the two of you who are still reading. This is a rich and active branch of mathematics that most engineers and even programmers only dabble in. And yet the modern computer could not function without the understanding that pioneers in this field, such as Jevons, Schroder and Huntington brought us.
A chip or a line of code?
If you take apart an old piece of electronics, you will find logic chips sprinkled everywhere. But in an age of the $2 microprocessor, do we really need an OR chip? Maybe we should take a step back.

Figure 1 The AND truth table
Each logical operator can be expressed as a truth table. Figure 1, will either bring back fond memories or be seen an alternative to waterboarding. For review, the values of x and y can take on 4 possible combinations, shown in the table. The third column is the combination of those values using the AND operator. Read x AND y. It simply states that the only combination of values of x and y that give a high, or 1, output is when both x and y are high.
We are most likely to come across this kind of thing not in hardware but in software. You can imagine turning on a device when a certain series of conditions are met. Those conditions can be described using combinational logic.
Useless junk
By now you might think a logic gate on a chip is a useless and archaic piece of junk. No need to feel lugubrious, the truth is they still have a place, although that place is shrinking. When you really need speed, hardware still trumps firmware. Logic gates will always be faster than firmware just because of physics. There is a lot less stuff going on in a logic gate than there is when a logic gate is implemented using a microprocessor and code, so it is faster.
Having said that, I can envision some simple circuits where you might not have an MCU at all and do everything using logic gates. It would have to be pretty simple though, because otherwise you might as well drop down an MCU.
I find it often simplifies code to drop down a few logic gates rather than including everything in code. If you will only act on a condition when A and B are high and don’t otherwise need to know their values, it is simpler to drop down an AND gate and tie it to the MCU interrupt line.
The other time I like to use gates is when there is the potential to do damage. For example, if you could possibly directly short a battery to ground, putting some gates down to select when a relay closes adds an additional layer of security. While you can test out a piece of code diligently and prove its reliability similarly to hardware, it is less likely that someone will mess with your hardware in a year and cause a problem then it is that someone will edit your code without fully understanding what you had intended and create a problem.
Open Collectors
While not exclusively used in logic the open collector is used with a pull up. The output line is usually high unless the device provides a ground pulling the signal low. This particular arrangement comes up frequently.
If you only have a push-pull, or driven, output, you can easily turn it into an open collector by connecting it to a FET gate. With a pull up on the drain, which is also the output. Now the output will always be high unless you turn on the FET, connecting the output to ground. This is useful when multiple devices need to vote on a signal. Anybody can pull the line low. This is often referred to as a wired OR. Rather than having a chip what may or may not be a 12 input OR gate you can make your own very simply.
Final thoughts
This newsletter is sponsored by Celtic Engineering Solutions LLC, a design engineering firm based out of West Jordan, Utah, which can be found on the web at: www.celticengineeringsolutions.com. You can find the newsletter on the company blog, LinkedIn or in your inbox by subscribing. Send your emails to The Celtic Engineer at: [email protected], with the subject line SUBSCRIBE.