# How to convert 10bit ADC data to BCD?

#### Do you have a question? Post it now! No Registration Necessary Translate This Thread From English to

• Subject
• Author
• Posted on How to convert a 10bit digitial signal to three groups of BCD?

For example, the value of 10bit digitial is 789 in decimal.

I would like to ask how to take 7, 8, 9 away and convert each digi to BCD?

p.s. BCD is needed to display a 7-segment display via "BCD to 7-segment
display converter" 74LS48

I am going to use BASIC with Atmel AT90S8535 to do the task.

Thank you very much Re: How to convert 10bit ADC data to BCD? 2 ^ 10 = 1024
10x10x10 = 1000

You cant. Re: How to convert 10bit ADC data to BCD? BCD? ...unless you work over 000 --> 999 and throw away the top 24 counts - which
may be entirely acceptable in your application.

Go to www.piclist.com and search for the algorithm you need then code it to

Have you considered not using the 74LS48's and driving the displays directly
with 3 pins to multiplex them? I'm not familiar with the micro you are using
but it may be an option and save you some parts. Re: How to convert 10bit ADC data to BCD?

Thanks rob and simon,

In case, I can ignore the bit which is over 999 and set the range as 000 to
999 Re: How to convert 10bit ADC data to BCD? Best you ignore the bit over 1012, and under 12 :) Re: How to convert 10bit ADC data to BCD? Best you scale it to 1000 from 1024! Re: How to convert 10bit ADC data to BCD? depends on the type of data really, but point taken :) Re: How to convert 10bit ADC data to BCD? I dont know basic but you want to use the division and modoulus (remainder
after division) operators.

units = adc value modulus 10
tens  = (adc value / 10) modulus 10
hundreds = (adc value / 100) modulus 10 Re: How to convert 10bit ADC data to BCD?

Thank you DAC.

Could you tell me some more why "scale it to 1000 from 1024" is more
suitable?

Thank you very much Re: How to convert 10bit ADC data to BCD? in some versions of BASIC you can do this

ones=number mod 10
number=number \ 10
tens=number mod 10
number=number \ 10
hundereds=number

Bye.
Jasen Re: How to convert 10bit ADC data to BCD? 789/1000   = 0        r789            - thousands
789/100  =  7          r 89             - Hundreds
89/10  = 8               r9                - Tens
r = 9                                           - Units

Discard the upper nibble in 00,07,08,09 and there you have it the BCD result
... Magic aint it - of course I am presuming the Basic you are using can do
reasonably efficent division but either way most division routines will do
this division in less than 10 loops per routine. the BCD output could take 12 I/O lines from the micro so why not add a 7
segment look up table to your Code and drive the display directly from the -
as this at worst will use 11 and save the cost of more chips .... although
if you matrix the output properly I guess you get the output down to 8 lines
using the 74LS48 - I just feel that if you have the I/O spare then doing the
seven segment encoding in the micro is more elegant.

Regards
Richard Freeman Re: How to convert 10bit ADC data to BCD?

sommes wrote: A technique use before the days of uproc was to have 2 counters, a
binary countdown counter and a bcd countup counter. The binary value is
loaded into the countdown counter and it was counted down to zero with
the same count pulses counting up the bcd counter. When the countdown
counter hits zero the bcd counter as the correct value.

The same concept can be used if you are programming in assembly code
instead of a higher level language with math functions.

Dan Re: How to convert 10bit ADC data to BCD?

Thank you for all the kindly reply

#### Site Timeline 