Has it ever happened to you where you stop to put gas after work, you stare at the pump’s little screen count gallon after gallon, and you wondered, “How does the machine know what number to display?” I can’t imagine many people wondering the same thing, but here we will talk about how the display functions and what those functions depend on. Keep in mind that these pumps are overly complex, so we will oversimplify it and the explanations will serve as basic concept. The purpose of this article is to get an idea of just how complicated the world of digital electronics is. There is a lot of explaining to do, but we will keep it as short and as simple as possible.
Voltage
The first thing we need to understand is voltage. Have you ever heard of the phrase, “It’s all just a bunch of 1s and 0s” when talking about anything digital? Those 1s and 0s are states, as in the current state of voltage. A 1 can represent 5 volts and a 0 represents 0 volts. But it depends on what logic family or technology we are talking about. So for the sake of simplicity, we will leave it at 1 = 5 volts and 0 = 0 volts. Also, these 1s and 0s can also represent any of these two states: On (1) or Off (0), Yes (1) or No (0), High (1) or Low (0), and so on. It is a language.
Decimal System
When we count from 1 to 10, we are using what’s called the Decimal System. In the decimal system, we only use numbers 0 through 9. To make bigger numbers, we combine any of the numbers within the decimal system to make any bigger number we need. That’s why, to get past 9, we combine 1 and 0 to make 10, two 1s to make 11, a 1 and a 2 to make 12, and so on. Binary Code is similar.
Binary Code
When it comes to binary code, the only numbers that we use are 1s and 0s. Individually, a 1 or a 0 are referred to as a bit, so if you have two 1s, or two 0s, or a 1 and a 0, you have two bits. Add another bit, like 000, or 111, or even 010, you get three bits. To keep things simple, we will be using four bits. So we can have four 1s, four 0s, or any four bit combination of 1s and 0s.
All of this may sound confusing. And you might be asking yourself, “how do we count in binary if all we have are 1s and 0s?” That is a fun question.
Encoding and Decoding
In the decimal system, we are used to seeing the number ten as a 1 and a 0, put together. It is just the number 10. But in binary, the number ten looks like this: 1010. Which is kind of funny because it looks like it's just two 10s put together one after the other. But here is why 1010 in binary, is the same as 10 in decimal.
In binary, we basically add values to decode them to decimal. These values are increasing powers of 2. Starting from right to left with 1010: the zero all the way to the right has a value of 1, the number one before that zero has the value of 2, the zero before that one has the value of 4, and the one all the way to the left has the value of 8. Remember how we said that 1s and 0s can also represent On or Off? Apply that to 1010, and only add the 1s, or this case, the values that are On, and you will get the number 10 in decimal. Why? Because you are adding the values 2 and 8, which are the only ones that are On, and you are excluding the values 1 and 4 because they are Off (since they are 0s.)
Given all of that binary trivia, we can see that the highest binary number we can use, in four bits, is 1111. You can test yourself to see if you got the hang of it. You got the number 15, right? Easy! Since they are all just 1s, or On, we can add all the values up.
To better visualize what we have covered, here is a table that shows you every possible four bit combination and what decimal number they convert to:
Logic Gates
Moving onto logic gates, they work similar to those electrical key locks where you have to enter a pin in order for them to unlock a door. Logic gates need a specific set of 1s and 0s in order for them to perform their actions. Actions of which they only have two: they can either output a 1 or a 0. But let’s start small.
This is the Buffer gate:
This is going to sound pointless, but all the Buffer does is output its input. That means that if you feed it a 1 at its input, which is the line on the left, it will output a 1 at its output, which is the line on the right. Wow, right? But the Buffer can also become negated, as it is called. In its negated form, the Buffer is called the Inverter. And it looks pretty much the same, the only difference is that it has a little circle at its output. Which looks like this:
And of course, the Inverter does exactly what its name suggests, which is the exact opposite of what its predecessor does. Instead of spitting out its input, it spits out the opposite of its input. So if you feed it a 1 at its input, it will output a 0. This will make a bit more sense once we cover the following two gates. This one is the AND gate:
The AND gate is similar to the Buffer; notice how not only the symbol has a different shape, but there are two inputs now. The top input is input A, and the bottom input is input B. With the AND gate, both inputs need to be a 1 in order to get a 1 at the output, that is two 1s need to be present at inputs A and B in order for the gate to output a 1. If you have a 1 at input A and a 0 at input B, the gate will output a 0. That is why it’s called the AND gate, or the “all or nothing” gate. There is a table called the Truth Table that shows you all the possible input combinations and their outputs to better understand the gates. Here is the truth table for the AND gate:
The last gate we will be discussing is the OR gate. You can have a 1 at one input, or the other, or both and you still get a 1 at the output. It being called the OR gate makes its function easy to remember. The OR gate is often called the “any or all” gate. This image shows you what the OR gate looks like and it also gives you its truth table:
Now that we have gone over the basics of the logic gates and their functions, we can discuss the Seven Segment Display. This component is made up of small light emitting diodes (LEDs) that each can be turned on and off individually or simultaneously. Let’s take a look at what a seven segment display looks like.
The top left image is what a seven segment display looks like; they are commonly found in clock radios and microwaves. The image in the top right is what a seven segment display looks like when applied in a schematic, that is its schematic symbol. And the bottom image with all the red lines explains to us what lighting up the LEDs looks like when we light them up in certain patterns. Obviously, lighting them up in these patterns gives us a visual of the numbers 0 through 9.
Of course, we cannot just go and manually light up each individual LED each time we need the number to change, plus, we know how fast the numbers change when we are pumping gas. We need a way for the numbers to change on their own. This is where the logic gates come into action. Take a look at this confusing puzzle of a maze:
This is the schematic for a decoder, and as you can see, it uses a lot of ANDs, ORs, and inverters. When you input any 4-bit code in the inputs, the code will run through the decoder, going through all the gates and inverters, and it will come out as a decoded output to light up the LEDs in its corresponding pattern. The type of code that this decoder decodes (haha) is binary.
You have inputs A, B, C, and D for the decoder. Let’s say you feed it 0110, those bits will run through the decoder and come out to light up the LEDs to show us the number 6. If you feed it 0101 then the display will show 5.
Of course, there are other factors that are used in order for the gas pump to show you the number accurately, like the mechanism used to calculate the flow of the gas being pumped, the rest of the logic gates (yes, there a few more), multiplexers, microcontrollers, and so on. But learning about the binary system, how it is used with the gates, and how the outcome determines what LEDs will be activated in the seven segment display, all of that is still very interesting and sufficient for now.
Everyday, every single electronic device you can think of is processing digital information one way or another. All the 1s and 0s that were discussed in this article, are just part of a microscopic universe. Our phones process trillions of 1s and 0s among trillions of gates, known as transistors. These transistors are the reason technology exists the way it does today. And as crazy as it sounds, all of those transistors are simply juggling 1s and 0s around.