Circuit for converting Binary to BCD

Thread Starter

RamsesX2

Joined Jan 27, 2017
8
Right, I began studying electronics about half a month ago or so and I've run into a bit of a problem.

I've come to the point where I want to create my first processor. Mind you, it's going to be rather small (can only add two 3-bit numbers and save them both in memory).

For this I decided to use 5 buttons. 3 for each bit and 2 to save the numbers. My memory would be comprised by 3 D flip-flops for both numbers. From there, I'd use a Full Adder to get the sum of the numbers and from there show the numbers on an indicator.

However, there's the problem. The Decoder that I use can only decode numbers in binary that are up to 9. Once the sum is over that amount, the indicator doesn't show anything.

From there, I realised that I'd need a circuit to actually convert the Binary to BCD so that I could show the number on my indicators instead of having blank ones. I've been searching for a Binary to BCD converter for the past few days and I have found something. One of the things I found was a rather outdated circuit that is not being made anymore, which is the DM74185A. Since this is obviously not an option, I kept searching until I found a converter made of Full Adders and Shift Registers. http://www.electro-tech-online.com/attachments/serial-binary-to-parallel-bcd-gif.31191/
I know and understand the algorithm behind it (shift, add 3), but how the circuit works is still unknown to me.

What I'm asking is if anyone could either point me towards something else or help me understand this circuit.
 

ErnieM

Joined Apr 24, 2011
8,415
This is a sticky messy problem when you use a pile of gates as you need a rather large pile.

What if you just display the binary number itself, one LED for each bit? That is much simpler.

It has historical background too. If you ever watched and old movies where the computer has a bank of flashing lights this is why: they was a light for each bit and it is flashing binary numbers.
 

Thread Starter

RamsesX2

Joined Jan 27, 2017
8
That could be an idea, yes... however, I'd like to show the numbers on indicators and I don't really want to leave something unfinished, which in this case, happens to be converting Binary to BCD.
If there's no simple solution, I'll go that way. However, I firmly believe that there's a simpler solution than using a ton of logic gates
 

MaxHeadRoom

Joined Jul 18, 2013
30,620
There are several avenues Picmicro, Arduino etc.
I personally favour the Picmicro.
It is a microprocessor of varying size, depending on application that has timers and modules that can be configured for several applications.
It is programmable in a variety of ways.
There are many solutions already configured out there for math functions etc.
Max.
 

MrChips

Joined Oct 2, 2009
34,731
You are working with binary arithmetic. It would have been easier if you had started out your design using 4-bit BCD arithmetic.
That is how pocket calculators do their math.
 

Thread Starter

RamsesX2

Joined Jan 27, 2017
8
You are working with binary arithmetic. It would have been easier if you had started out your design using 4-bit BCD arithmetic.
That is how pocket calculators do their math.
Never thought of that. Thanks for the suggestion, I'll try it out.
 

hp1729

Joined Nov 23, 2015
2,304
Right, I began studying electronics about half a month ago or so and I've run into a bit of a problem.

I've come to the point where I want to create my first processor. Mind you, it's going to be rather small (can only add two 3-bit numbers and save them both in memory).

For this I decided to use 5 buttons. 3 for each bit and 2 to save the numbers. My memory would be comprised by 3 D flip-flops for both numbers. From there, I'd use a Full Adder to get the sum of the numbers and from there show the numbers on an indicator.

However, there's the problem. The Decoder that I use can only decode numbers in binary that are up to 9. Once the sum is over that amount, the indicator doesn't show anything.

From there, I realised that I'd need a circuit to actually convert the Binary to BCD so that I could show the number on my indicators instead of having blank ones. I've been searching for a Binary to BCD converter for the past few days and I have found something. One of the things I found was a rather outdated circuit that is not being made anymore, which is the DM74185A. Since this is obviously not an option, I kept searching until I found a converter made of Full Adders and Shift Registers. http://www.electro-tech-online.com/attachments/serial-binary-to-parallel-bcd-gif.31191/
I know and understand the algorithm behind it (shift, add 3), but how the circuit works is still unknown to me.

What I'm asking is if anyone could either point me towards something else or help me understand this circuit.
Simple solution. A PROM or EPROM. An 8-bit wide memory converts from 00 to 99.
 

hp1729

Joined Nov 23, 2015
2,304
Have you tried to purchase a parallel in and out EEPROM lately? They are now made completely out of unobtanium.
EPROM, not EEPROM. Remember those old UV erasable byte wide chips. Or Flash.
The first 100 addresses contain the BCD equivalent of that address.
 

ErnieM

Joined Apr 24, 2011
8,415
I remember them well. No address contained any data the user did not intend to be there. They typically came with every single bit set as a one.

It's been decades since I purged my obsolete parts bin of these, nearly as long since I tossed my UV eraser.

Edit: To my surprise you can still purchase current production units for EEPROMs. Found many at Mouser from several manufacturers.

Of course they have a huge capacity, well above the 2048 bytes this project would need.

Oh, and to the OP: these would work very well for you, but you need a programmer.
 
Last edited:

hp1729

Joined Nov 23, 2015
2,304
I remember them well. No address contained any data the user did not intend to be there. They typically came with every single bit set as a one.

It's been decades since I purged my obsolete parts bin of these, nearly as long since I tossed my UV eraser.

Edit: To my surprise you can still purchase current production units for EEPROMs. Found many at Mouser from several manufacturers.

Of course they have a huge capacity, well above the 2048 bytes this project would need.

Oh, and to the OP: these would work very well for you, but you need a programmer.
Yes, a programmer would be necessary. I still have one. 2,048 bytes? Only 100 bytes are needed. Could a Programmable Logic Array be used?
 

Thread Starter

RamsesX2

Joined Jan 27, 2017
8
Thanks for all of your advice. I would probably go with the programming option, but I don't want to go that way just yet.

I'll rethink the input and make it that BCD instead of having to convert from Binary. However, if there are still more suggestions on how to convert Binary to BCD without programming, they're very much welcome.
 

Thread Starter

RamsesX2

Joined Jan 27, 2017
8
This post may be of interest.
I'd still like to understand the Binary to BCD converter you posted in that thread.
The converter I'm referring to:
http://www.electro-tech-online.com/attachments/serial-binary-to-parallel-bcd-gif.31191/

What I don't understand is how adding 11 and ignoring the MSB would detect whether or not a correction is necessary.

I'd also like to know where the Binary number comes in. As far as I understand, there are two choices for this. One is the "Binary in MSB First" input, connected to the Shift Register. In that case, the outputs Q0 - Q3 would be connected to the Full Adder inputs B0 - B3. That connection isn't shown however, which leads me to believe that the Binary inputs go directly into the Full Adder. However, then I don't know what P0 would be on the Shift Register. In that case, Carry Out would also be Low (that is, if you insert a number less than 5), which would mean that the Parallel Inputs aren't read at all, which leads me to believe that the first input would be P0 or J/K.
 

EM Fields

Joined Jun 8, 2016
583
Right, I began studying electronics about half a month ago or so and I've run into a bit of a problem.

I've come to the point where I want to create my first processor. Mind you, it's going to be rather small (can only add two 3-bit numbers and save them both in memory).

For this I decided to use 5 buttons. 3 for each bit and 2 to save the numbers. My memory would be comprised by 3 D flip-flops for both numbers. From there, I'd use a Full Adder to get the sum of the numbers and from there show the numbers on an indicator.

However, there's the problem. The Decoder that I use can only decode numbers in binary that are up to 9. Once the sum is over that amount, the indicator doesn't show anything.

From there, I realised that I'd need a circuit to actually convert the Binary to BCD so that I could show the number on my indicators instead of having blank ones. I've been searching for a Binary to BCD converter for the past few days and I have found something. One of the things I found was a rather outdated circuit that is not being made anymore, which is the DM74185A. Since this is obviously not an option, I kept searching until I found a converter made of Full Adders and Shift Registers. http://www.electro-tech-online.com/attachments/serial-binary-to-parallel-bcd-gif.31191/
I know and understand the algorithm behind it (shift, add 3), but how the circuit works is still unknown to me.

What I'm asking is if anyone could either point me towards something else or help me understand this circuit.
An old-timey brute force way to do it is to simultaneously load the output of your full adder (after the addition is done) into a binary down-counter and clear a decade up- counter.

Then, using the same clock to run both counters, proceed until the down counter gets to zero, at which point the decade counter's contents will be the BCD equivalent of the binary full-adder's output.

Like this:

Brute force binary to BCD converter.png
 
Last edited:
Top