4-bit to 12 outputs decoder in TTL or CMOS - Page 1
Forum section: electronics / projects

author: RES
author_rank: Regular Contributor
timestamp: July 26, 2016, 07:52:42 pm
content: Try to figure out how to create a 4-bit to 12 outputs digital bargraph by using standard TTL of CMOS ics ( gates, counters, adders, etc.)ICs like CD4017 or 74HC138 have single outputs active while you need multiple outputs, and for example 7 segment decoders (4511, 7447) don't have the segment bits in bargraph, only a few. Ofcourse you can use a microcontroller or fpga, but a circuit with logic ic, diagram on paper or from a webpage can be build by a beginner.Truth table:0000 -> 0000000000000001 -> 0000000000010010 -> 0000000000110011 -> 0000000001110100 -> 0000000011110101 -> 0000000111110110 -> 0000001111110111 -> 0000011111111000 -> 0000111111111001 -> 0001111111111010 -> 0011111111111011 -> 0111111111111100 -> 111111111111Outputs can be split into BCD nibbles, 1111 1111 1111.Do I need to use things like Karnaugh maps, boolean algebra or a Demorgan theorem?

author: Ian.M
author_rank: Super Contributor
timestamp: July 26, 2016, 10:55:20 pm
content: You could do a minimal solution using individual logic gates, or you could decode it to a 1 of 16 'dot' (active low) using two 74HC138 chips then use a cascade of AND gates combining each output with the AND chain from the higher outputs. Finally you'd need a job lot of buffers to actually drive the LEDs.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 26, 2016, 11:14:17 pm
content: The term you're looking for isthermometer coding, orunary. Bargraph drivers may also provide a hint (but I don't know of any offhand that are binary input).The inverse problem (highest of N bits, where the lower bits don't need to be all 1's, thus converting one-of-N (as you get from a standard e.g. 74HC138) or thermometer code into binary) is usefully challenging, and thuspriority encodersexist.For the simplest, one-chip solution, you may have to settle with an ugly hack... If the binary is supplied from CMOS (e.g. 74HC, MCU GPIOs, etc.), then you can build a crude R-2R ladder (with fairly high value resistors) to convert binary to analog -- it doesn't need to be terrifically precise, it's only a 4-bit DAC. Connect this to an LM3914, set up so that full scale equals VDD*10/16 (give or take half a step). The outputs are open-collector, so you get digital (CMOS compatible) by using pull-up resistors (1k is enough). There's a little more to setup (one pin controls one-of-N vs. thermometer output, another controls output pin drive strength -- set this to >5mA), but that's described in the datasheet.LM3914 is easily overlooked, but it's a very cheap, versatile, 10-bit unary ADC!Tim

author: Circlotron
author_rank: Super Contributor
timestamp: July 26, 2016, 11:30:20 pm
content: Quote from: Ian.M on July 26, 2016, 10:55:20 pmSimilar but simpler would be to have your one output at a time chip feed OR gates where every final output is high when the Input or next final output is high.

author: Ian.M
author_rank: Super Contributor
timestamp: July 26, 2016, 11:57:46 pm
content: That's just the active high De Morgan Dual of what I said. However 74HC138 active low decoders are slightly easier to find than 74HC238 active high ones + CMOS gate outputs typically sink somewhat more current than they can source, so if you are hoping to drive the LEDs direct without extra buffers, you'd want the active low + AND gate version.

author: Circlotron
author_rank: Super Contributor
timestamp: July 27, 2016, 12:36:26 am
content: Got it.I was thinking you meant multiple layers of and gates. Didn't quite read your post properly.

author: KerryW
author_rank: Regular Contributor
timestamp: July 27, 2016, 12:41:40 am
content: You could use a 4 bit binary counter, shift registers and a magnitude comparator like a 74HC85.When the comparator goes from equal to not equal, clear the shift registers and counter and let the counter start counting and the shift register shift in 1s until equal again.

author: promacjoe
author_rank: Regular Contributor
timestamp: July 27, 2016, 02:06:49 am
content: you could also use a programmable logic chip or even a Parallel ROM chip. How fast does it need to be.

author: Circlotron
author_rank: Super Contributor
timestamp: July 27, 2016, 03:22:19 am
content: ^^ Purpose of OP is to teach something, not to achieve a result per se. Using programmable stuff does the job but a beginner probably hasn't got a programmer. I like the counters and shift register approach. There is a whole generation of people that probably don't even know these great little functions exist.

author: amyk
author_rank: Super Contributor
timestamp: July 27, 2016, 11:06:54 am
content: Quote from: T3sl4co1l on July 26, 2016, 11:14:17 pmI like this solution since it goes into the analogue realm.As for the shift register and counter, that's probably the slowest (and noisiest).

author: KerryW
author_rank: Regular Contributor
timestamp: July 27, 2016, 01:03:48 pm
content: The thread is "4-bit to 12 outputs decoder in TTL or CMOS"A PIC or a couple of PROMs would be the smallest, cleanest and cheapest way to change the stated inputs to the stated outputs, but that was not the question. The question was "How to do it with standard logic chips".

author: David Hess
author_rank: Super Contributor
timestamp: July 27, 2016, 01:44:05 pm
content: A static EPROM or PROM (or PLA or GAL) can do this in one or two parts. For myself, I would probably use a pair of 74138s or a 74154 driving a diode or transistor matrix instead of 12 4-input NAND gates and some inverters.

author: MarkL
author_rank: Unknown
timestamp: July 27, 2016, 02:05:25 pm
content: I'm assuming this is to be done with combinatorial logic.One way to see this problem is successive stages of a programmable bit shifter. For each individual input bit in your truth table the output bits are shifted by 1, 2, 4, or 8. One's are shifted into the LSB. Some optimization can be done since we're starting with all zero's.There would be four stages in the shifter. The first stage shifts by 1, second by 2, third by 4, and fourth by 8. Each stage is controlled by one of your four input bits.You could implement each stage using 2 line to 1 line data selectors which would either select no shift, or be wired to shift the appropriate number of bits.To save some chips, you can combine the function of 2 to 1 selectors with dual 4 line to 1 line data selectors (74153 or equiv) and have two stages instead of four. It could work something like this:First stage, 2 x 74153, inputs wired high or low to produce the following outputs:Select Output OutputBA Chip1 Chip2-- ----- -----00 00 00 --> 000001 00 01 --> 000110 00 11 --> 001111 01 11 --> 0111Second stage, 6 x 74153, inputs wired to produce the following multiplex, where XXXX is the output from Stage 1:Select Output (all 6)BA-- ---------------00 0000 0000 XXXX01 0000 XXXX 111110 XXXX 1111 111111 1111 1111 1111Data selector chips are handy because they can produce any truth table output you want. The tradeoff is that they're not very dense and there's a lot of input wiring because each combination has to be handled. No doubt further optimization of the above can be done with this in mind.But would I actually do it this way in practice? No, but this sounds like an academic exercise to show the different ways it *could* be done.

author: KerryW
author_rank: Regular Contributor
timestamp: July 27, 2016, 02:20:37 pm
content: Using +15V and 4000 series CMOS, put a constant current source and 12 LEDs in series. Use a 4-16 decoder and PNP transistors to ground the cathode of the appropriate LED. All LEDs above the selected one will light.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 27, 2016, 05:31:23 pm
content: Quote from: KerryW on July 27, 2016, 02:20:37 pmMmmmm, you'll need more than 15V to do this with non-infrared LEDs, I think.If you don't need logic outputs, it's a good approach though!Also, any logic family is fine, as long as you can drive low-side transistors; use a currentsourcefrom an arbitrary supply. 20-30V would be enough for red or green LEDs, I think, and easily supplied by a 2N3906.Tim

author: Andreas
author_rank: Super Contributor
timestamp: July 27, 2016, 07:08:22 pm
content: Quote from: RES on July 26, 2016, 07:52:42 pmno its simple: Just use 12 CD4067 with different input connections.With best regardsAndreas

author: ebclr
author_rank: Super Contributor
timestamp: July 28, 2016, 12:22:08 pm
content: The easy way is to burn a eeprom or flash with the truth table

author: magetoo
author_rank: Frequent Contributor
timestamp: July 28, 2016, 01:13:16 pm
content: Quote from: KerryW on July 27, 2016, 12:41:40 amI like this solution. If we use a pair of '595 shift registers we could use a free running counter and let its overflow/underflow clear the shift registers; the comparator output would latch the value in the shift register to the output register. Just so the update rate stays constant. :-)

author: westfw
author_rank: Super Contributor
timestamp: July 31, 2016, 11:26:50 pm
content: IMO, this is a fine example of why microcontrollers have taken over the world. smaller, cheaper, conceptually simpler. Someone with little programming experience could implement it in a day, including the time needed to go to the local store and buy an Arduino. (though it would take a bit longer to get cheap Arduinos and/or bare-microcontroller solutions. (an 8pin micro should be sufficient.) Also - SO much more flexible: active high, active low, peak detecting, animated, add a second display... All pretty trivial.(oops: driving 12 LEDs with an 8pin micro is easy. Being able to read 4 pins at the same time would be trickier (though still possible, I think.))

author: zapta
author_rank: Super Contributor
timestamp: August 01, 2016, 01:22:20 am
content: Here is an intuitive way (though probably not minimal) to design it. split the 4 bits into two groups of 2 and design a 4 bit decoder for each. Then have 12 two input and gates to generate the outputs, each anding one output from each of the decoders. It's a row and column approach. You can use exactly the same approach to design the two input decoders in step 1.