Back in the day, I purchased a Sparkfun Beginner Parts Kit, which comes with a 7-segment LED. Recently, I ordered a few more 7-segment LEDs and a few BCD-to-7-segment decoders -- 74HC4543's, to be precise. When these all arrived, I learned a few Very Important Lessons:
Looking at the datasheets, it seems that the LCD version (the 74HC4543) might have been the best choice. According to the datasheet, the outputs are rated at +/- 25mA. I think that means I can use the '4543 on either common anode or common cathode 7-segment LEDs. Certainly it worked well on my common anode 7-segment.
I started out with something simple. Four switches and the decoder:
R1 and R2 each allow 16mA into their respective anodes. Even if we only have one LED lit from a given anode, we won't exceed the 25mA limit from the '4543.
A few things I learned while building this circuit:
I happened to have a Dual-Decade Counter (74HC390N) lying around, so let's make the display count:
The breadboard image above includes an extra LED on the switch, put in for some now-forgotten reason. The LED and associated current-limiting resistor do not appear in the schematic.
Counting with the '390 is something of an adventure. There are two decade counters in the '390. Each counter is composed of a divide-by-2 section and a divide-by-5 section. To get it to count to 10, you use the divide-by-2 section as the clock for the divide-by-5 section. That's why pin 3 (QA) is connected to pin 4 (B) on IC2A.
This is the first circuit where I've had to remember to use a pull-down resistor. When S1 is open, we need to ensure that IC2A pin A (the divide-by-2 clock) is low. To do that, we pull that pin low using R3. When S1 is depressed, R3 is ignored, and IC2A pin A is driven high.
Unfortunately, the switch poses a problem, as you can see in this video:
The problem is that pressing the switch doesn't cause an immediate transition from low to high. Instead, the transition is a noisy one, and leaves the poor counter seeing multiple transitions between low and high. That's why the counter sometimes jumps when the button is pressed.
In order to fix the problem we were seeing above, where the counter was jumping by several values with each button press, we need to debounce the switch. Debouncing is described in much more detail here. We're going to use the RC debouncing circuit described on page two of that article. Here's the circuit with the debouncer:
It works much better now. Each press of the button yields one increment by the counter. The only disadvantage of the debounced switch is that a sufficiently-rapid series of button presses will now be interpreted as bouncing, and thus as a single press. I could presumably tune the debouncing circuit a bit more, reducing the margin for error to make it able to respond to button presses.
This circuit departs from the one described in the debouncing article in one respect -- I use two Schmitt-triggered inverters rather than one. The counter triggers on an up edge. With the circuit as described in the article, the clock wave would be low when the button was pressed, and high, when it was released. As a result, the counter would increment only when the button was released. A second inverter fixes this problem. The second inverter didn't have to be a Schmitt-triggered inverter. I was using a 74HC14N, though, which is a hex Schmitt-triggered inverter. As such, I had Schmitt-triggered inverters to spare, and could use one of the extras as the second inverter in the circuit.
Why didn't I analyzing the debouncing more carefully? I could've, but I wanted to make it count by itself even more.
I confess that I went into this circuit without a real understanding of how the 555 timer works, and I'll leave it with almost the same level of ignorance. I now know how to make a 555 timer generate a square wave -- to act as an astable multivibrator. I don't know why it works that way, but I know how to calculate the values to get a particular wave. In this case, I wanted a cycle time of about a second, so I used a 10μF capacitor and two 56KΩ resistors.
I also added a reset button for the counter.
Here's a video of the timer-driven counter:
This was my first real foray into the world of TTL logic. I think it was a success. I learned how to use 7-segment decoders, how to interface them with 7-segment LEDs, and the various forms of same. I also learned how to use counters and debouncers, and dipped my toe into the world of 555 timers. This will all be a great help when it comes time to start in on the microprocessor.