Converting a decimal number to binary

toothpick5

Joined Sep 28, 2009
4
I'm trying to build a circuit that will convert decimal numbers into binary with a keypad.
It is no problem as long as the number is a single-digit, but it gets confusing when the user clicked 2 buttons or more.

for example when the user clicked digit number 1 and then 2, the circuit has to multiply the first digit by 10, and then add the 2.

I have circuits that can add binary numbers and multiply them (and I prefer not having any IC's in this part of circuit).

anyone has a suggestion or can reference me to a useful article i can read about it?

Thanks.

blueroomelectronics

Joined Jul 22, 2007
1,757
A microcontroller sounds like the way to go.

toothpick5

Joined Sep 28, 2009
4
i know, but im trying to avoid the 'easier' option

blueroomelectronics

Joined Jul 22, 2007
1,757
And without ICs that's an odd request.

beenthere

Joined Apr 20, 2004
15,819

SgtWookie

Joined Jul 17, 2007
22,227
You really don't want to convert back and fourth from BCD (binary coded decimal) to binary without using a microcontroller.

If you don't believe me, find the datasheet that Texas Instruments published for the SN74184 and SN74185. These are IC's dedicated to converting BCD to binary ('184) and binary to BCD ('185).

To convert a 2-digit number from BCD to binary requires two '184 IC's.
To convert a 3-digit number from BCD to binary requires six '184 IC's.
To convert a 6-digit number from BCD to binary requires twenty eight '184 IC's.

If you want to go the other way, with a 16 bit binary number to BCD only requires sixteen '185 IC's to get a 5-digit BCD output.

Now if you want to try building the code converters out of individual logic gates, be my guest. You will need a circuit board about the size of your living room, a gigantic pile of logic ICs, and a 20lb spool of solder to connect everything up. Oh, don't forget the vacuum cleaner to pick up the hair from the floor that you'll be pulling out of your head.

If you wanted to get "sneaky", you could use a couple of EEproms with the conversions burned into it. Most people don't have EEprom programmers anymore though. Just as easy to burn the tables into a uC; but you don't have to do that either.

BillB3857

Joined Feb 28, 2009
2,565
You could look up the ICs you have that do the multiply and add functions and get the data sheets for them. They sometimes show the internal logic and you could use diodes and transistors to duplicate that logic. Sure seems like a lot of work........

toothpick5

Joined Sep 28, 2009
4
You could look up the ICs you have that do the multiply and add functions and get the data sheets for them. They sometimes show the internal logic and you could use diodes and transistors to duplicate that logic. Sure seems like a lot of work........
i came up with the multiply and add functions using some Or, And and Xor gates, it wasnt that much of a problem.

toothpick5

Joined Sep 28, 2009
4
ok... so how does the BCD to binary or binary to BCD IC's really work?

beenthere

Joined Apr 20, 2004
15,819