I made a counter with a button and a seven segment LED display
Вставка
- Опубліковано 19 сер 2024
- Follow along as I count up to 9 button presses on a 7 segment display!
-- Links
SN74LS160N Data Sheet: hlf-ic.cn/uploa...
SN74LS162N Data Sheet: hlf-ic.cn/uploa...
SN74LS48N Data Sheet: hlf-ic.cn/uploa...
7 Segment Display Data Sheet: www.xlitx.com/d...
7 Segment Display: amzn.to/3viAu1l
TTL ICs: amzn.to/40WH75c
Breadboard kit: amzn.to/3MYwfho
Power supply: amzn.to/3uAYxIE
Antistatic mat: amzn.to/49RhcQi
My Wife's Books: amzn.to/47yt9Ji
(Maybe you and/or someone you know will like them!)
The difference between the two chips is that one has a synchronous reset while the other has an asynchronous reset.
I don't know what's really going on but making mistakes is the best way to learn, cool videos mate
You need to debounce the button, add a ceramic capacitor between the button and the counter.
Also if you want to have the counter running without the need for a button, feed it a square wave source, a simple 555 circuit will work to create a clock pulse.
Adding JUST capacitor will increase chance of burning out the switch as you'll be dumping the whole charge stored in capacitor via the contacts. What you need is basically 1st order low pass filter to cut off the high frequency spikes. Which coincidentally also puts extra resistor between capacitor and switch preventing arcing.
@@joruss that would be true of HV, however the voltage is low enough that it won't be an issue, hardly any current there either.
@@RobR386 the bigger capacitor the more charge will be dumped. And these little dome switches can be easily burned out with DC switching. Of course not immediately but i'll wear out over time.
A debouncer other than a capacitor across the switch would be a Schmitt trigger. That adds hysteresis and only changes the signal after a threshold of time and voltage change is reached.
Somewhere in the datasheet, there is usually a schematic for 'typical' uses
To avoid a bounce effect add a 100nF ceramic capacitor between the pins of the push button
From Motorola datasheet: "The LS160A and LS161A have an asynchronous Master Reset (Clear) input that overrides, and is independent of, the clock and all other control inputs. The LS162A and LS163A have a Synchronous Reset (Clear) input that
overrides all other control inputs, but is active only during the rising clock"
add a 0.01 cap from the VCC pin ground for each TTL chip you add. That captures noise from that chip.
BCD stands for Binary Coded Decimal and a capacitor across the pins of the push button will quelch mechanical bounce.
I built a circuit back in the day using a BCD counter circuit to simultaneously display the number on a seven segment display and it's equivalent binary display on LEDs. I struggle to find the dtaa sheets to recreate the circuit again! So little attention is given to discrete logic these days as the likes of Arduino, ESP and Raspberry chips are so cheap!
I use a debounce circuit using two nand gates. I avoid using caps in the debounce circuit, as they are not needed.
You need to look up the IC data sheet for a complete description of the operation of the IC. A book with the digital circuits and the common usage of them might be a good purchase, so you can have the reference handy, when you experiment.
It looks like Enable T enables the Carry Output.
ALL switches bounce.
If you ALWAYS want it to be cleared and at 0 on startup. It is active low, so you need to delay it going high for long enough that the counter chip sees a low. You need a small capacitor in the negative rail and attached to clear. It needs to be pulled up to rail voltage, maybe a 5k and use maybe a 100k shunt across the cap. Play with values or do some math. I'm sure you only need maybe 100ns at most. The shunt kills any charge in the cap sonit is at 0 volts. As you apply power, the cap takes time to charge through your 5k resistor. If the counter chip wakes before the cap is above the threshold voltage (probably something like 2v) then itcs registered as a clear and then as it keeps charging it will stop clearing. After power down, the 100k discharges the cap so you have a fresh start when you power on next time.
So that takes care of your random startup value.
For in circuit button debouncing. All you need is a cap connected to your clock pin to ground. Ground the switch and the other side of the switch, add a pull up resistor. On the output of the switch, use another resistor connected to your clock input+cap.
When the button is released, the pull up will feed the filter resistor connected to your cap which will charge it to a "high" state. When you press the button, it will short the pull up, pulling it to 0v. The filter resistor will begin discharging the cap. As this takes some time (depending on your RC) the intermittnet bounce of the switch is not registered and is filtered out through the RC circuit. Now that the cap is discharged from you pushing the button, when you release, the pull up then begins charging the cap again through the filter resistor.
There are plenty of free calculators online that will help you select the appropriate resistor and capacitor values to achieve the charge/discharge times that you're looking for..
Hth
I think async vs. synch is the difference. Async means you can change things at any time and get a result (while observing setup and hold times), whereas, you can set sync about any time, but it only works on the next clock pulse.
pretty sure HLF's 162 datasheet is wrong. Clear on the 162 should be synchronous, like the load (per TI's datasheets)
I think the P input is meant as an "enable" to turn counting on or off, and the T input is what I'd consider to be the actual count input. The way you have it set up now is constantly adding, so it increments the counter on every clock pulse. But usually you'd have the clock running all the time, and only incrementing when T is high.
Ah ha.. that makes sense!
More debounce to the ounce.