3 Digit 7-Segment Display Decoder Design Question

Thread Starter

Jastri

Joined Jul 5, 2016
7
I am working on a PCB project where I want to generate a random number from 1 to 100 at the push of a button. The design is still basic, and I'm relatively new at designing electronics, so a lot of this could possibly be wrong.

So far in my design, I am using a 555 timer in astable mode, with a frequency of 1k or more(haven't chosen the resistors or capacitor quite yet), which goes into a ripple counter, acting as a pseudo-random number generator. This counter will reset to zero when it reaches 100 using a NAND, giving the number a range of 0 to 99 in binary. This number is then sent to a pair of 4-bit adders, which I will use to push the number range up to 1-100.

At this point, I would have 8 bit lines that need to go through a decoder of some sort, which then connects to my 3 digit 7-segment display. I've been thinking about the following options:
  1. Somehow convert the 8-bit binary number into its 3 decimal digits(still in binary), and send each set to a BCD to 7-segment decoder, which each control an individual display. I'm not sure how I might g about "splitting" a binary number like this.
  2. Use a decoder with 8-bit parallel input that can run a 3 digit 7-segment display. I have not been able to find one like this.
So my question is, what can I do to go from an 8-bit binary number in parallel to a 3 digit 7-seg display?

Since this is a PCB project, I am avoiding using an Arduino, and an EEPROM would need a significant amount of programming to get working. I have also considered using logic gates, but that would require an obscene number of gates to work.

This project is based on https://www.electronics-project-design.com/digitaldice.html, which only uses one display for a 4-bit number.
 

JohnInTX

Joined Jun 26, 2012
4,787
Welcome to AAC!
You might consider using something like 74xx162 BCD presettable synchronous counters and instead of the fancy adders, just decode 100 and preset the counter to 001 on the next clock pulse. That way, simple 4bit to 7segment decoders can be used. You should avoid ripple counters if you are going to decode the outputs.
http://www.ti.com/lit/ds/symlink/sn...hronous counter&tisearch=Search-EN-Everything
 

BobTPH

Joined Jun 5, 2013
8,813
Or, another way to avoid the adders is to detect the 0 and feed that to the the two segments of the third digit to display a one.

Agree on use of bcd counters.

Bob
 

Thread Starter

Jastri

Joined Jul 5, 2016
7
Welcome to AAC!
You might consider using something like 74xx162 BCD presettable synchronous counters and instead of the fancy adders, just decode 100 and preset the counter to 001 on the next clock pulse. That way, simple 4bit to 7segment decoders can be used. You should avoid ripple counters if you are going to decode the outputs.
http://www.ti.com/lit/ds/symlink/sn54as161.pdf?keyMatch=bcd synchronous counter&tisearch=Search-EN-Everything
So if I understand you correctly, the synchronous counter you are recommending can be used in a pair in order to replace my ripple counter and adders?
 

JohnInTX

Joined Jun 26, 2012
4,787
So if I understand you correctly, the synchronous counter you are recommending can be used in a pair in order to replace my ripple counter and adders?
Yup. one counter per digit. You probably could get away with a single flip flop for the '1' digit but that would still require a third IC. I'd probably just use 3 counters. If you are counting 1-100, the LS bit of the third decade is the signal to 'load' back to 001 on the next clock. No further decoding necessary. Nice.

EDIT: if you're sure that 100 is the terminal count, then you can get away with even less. The two low digits roll from 99-00 by themselves (for the 100) then to 01. If you set a flip flop when the lower digits rolled to 00 (for the '1') then used that Q output to enable resetting of the f/f on the next pulse, you could use just about any counters. That would require some noodling to get the logic right and may not be worth it. Just thinking out loud.
Have fun!
 
Last edited:

dl324

Joined Mar 30, 2015
16,845
what can I do to go from an 8-bit binary number in parallel to a 3 digit 7-seg display?
You could program EPROMs to do the conversion. But for 3 digits, you'd need a device with 16 outputs.

Or you could consider MC14553. It contains 3 decades of counters and multiplexed output for 3 digits in a 16 pin DIP. You just need to add a BCD to 7 segment decoder. If you're really hung up on the count being from 1-100, you could add some glue logic to not let the counter stop at zero or go above 100.

upload_2019-6-21_19-37-9.png
 

BobTPH

Joined Jun 5, 2013
8,813
Of course a microcontroller could do all of it trivially, but I suspect this is an exercise in designing with discrete logic.

Bob
 

djsfantasi

Joined Apr 11, 2010
9,156
Could this be simplified by switching a high speed clock directly with a cheap NO push button? Any glitches introduced by the push button would increase randomness (I once built a single digit RNG for a my Dad’s classroom using just the switch bounce to clock a 7490/7447 combo).

Two daisy chained decade counters and three BCD to 7-segment decoders would count the pulses during the switch press. Feeding the BCD output of both counters into an 8 input NAND gate gives you the third digit, which would be a ‘1’ when the counters are 0.

UPDATE: You could probably omit the third decoder and drive the b-c segments of the third display directly from the NAND gate output. This option has the advantage of blanking the hundreds digit.
 

danadak

Joined Mar 10, 2018
4,057
I understand you want to do this discretely using logic chips. For future
reference this entire project can be done with one chip, excluding LED
display digits of course and current limiting R's for them and push button.

upload_2019-6-22_7-12-42.png

The 7 segment driver on this chip has a single instruction where you give
it the number to display and it does the rest. So your push button could
either be used for a software counter or drag and drop a counter component
(a component is an onchip resource) onto design canvas and use that. In fact
button could be replaced by a cap sense button (pad on PCB) as well. The random
aspect easily accomplished in software ( a single C library instruction). Or hardware
using onchip shift register with feedback. Note this example shows more digits than
you need, you simply right click the component and tell it you only want 3 digits.

I think you could actually do this design with << 10 lines of code as you have
described it.

As you can see in right hand window which keeps track of resources used / left
lots of additional resources for other tasks/features in design should you choose.

Just some thoughts getting into the processor game and programming.

mBlock is a software tool kids 6'th grade and above are using to program robots,
includes 7 seg capability. This is a graphic programming language. Run on Arduino.
You can buy a 7 seg LED hat for it.

Or use above PSOC part, though this is programmed in C.

You will never regret getting in the UP game, its a blast and highly versatile and
productive. Lots of videos for training on web.


Regards, Dana.
 
Top