Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Help with BCD to Binary

Status
Not open for further replies.

kgavionics

Full Member level 3
Joined
Jun 12, 2012
Messages
167
Helped
7
Reputation
14
Reaction score
11
Trophy points
1,298
Location
Alberta.Canada
Activity points
2,479
Hello guys
I have built a break-out board based on the keyboard encoder 74c923 hooked up to an Arduino UNO (AVR-GCC using Atmel studio 7), which sends a BCD digit each time I press on a key! All is working fine, but I can't figure out how to store the 3 digits into an 8 bit variable!
In the picture attached, the number 123 is stored in 3 memory locations (each digit is stored in a memory location) and I want to store the entered number in a single memory location (binary).
I can easily convert binary to BCD, but I'm struggling to do it the other way around!
Can someone give me a heads-up how to convert from BCD to Binary please?
Thank you in advance!
keypad.jpg
 

Hi,

I really have no clue how you come to these three numbers.

The only thing I can tell:
123 could be 0b01111011 or 0x7B

****
you surely know that BCD are 4 bits.
with binary value from 0b0000 to 0b1001 and HEX 0x0 to 0x9 and decimal 0 to 9

Klaus
 

Assuming your memory locations are 8 bits wide, the highest number you can store is binary 11111111 or 255 in decimal so you can't store bigger numbers without spanning more locations.

Brian.
 

Assuming your memory locations are 8 bits wide, the highest number you can store is binary 11111111 or 255 in decimal so you can't store bigger numbers without spanning more locations.

Brian.
I'm totally aware that I can't store more than 255! My question is how to convert BCD to binary!
--- Updated ---

Hi,

I really have no clue how you come to these three numbers.

The only thing I can tell:
123 could be 0b01111011 or 0x7B

****
you surely know that BCD are 4 bits.
with binary value from 0b0000 to 0b1001 and HEX 0x0 to 0x9 and decimal 0 to 9

Klaus
I just give an example! I meant any number from 000 to 255 in decimal! I want to implement the 8bit version algorithm, then I can extend it to 16 bits!
Furthermore, I'm aware that BCD numbers are coded in 4 bits! But in my case I store them in one memory location (I set high nibbles to 0).
Now the big question, how to convert BCD number to a binary one!
 
Last edited:

Hi,

the "B" in BCD already means "binary".

Please explain more exactly what you need.

Klaus
 

how to convert BCD number to a binary one!
Multiply the 3rd BCD number by 100, the 2nD BCD number by 10, and then add the three together to get one binary number.
 
Hi,

wow,

this has nothing to do with
* keypad
* encoder 74c923
* BCD
* binary
* memory location

... a lot of confusing information.

btw: what happens if the first of the three digits is 3 or higher?

Klaus
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top