Maker Pro
Maker Pro

How to convert 10bit ADC data to BCD?

S

sommes

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
 
S

Simon Scott

sommes said:
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

2 ^ 10 = 1024
10x10x10 = 1000


You cant.
 
R

Rob

Simon Scott said:
2 ^ 10 = 1024
10x10x10 = 1000


You cant............


....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
suit your micro. Google usually helps.

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.
 
S

sommes

Thanks rob and simon,

In case, I can ignore the bit which is over 999 and set the range as 000 to
999
 
S

Simon Scott

sommes said:
Thanks rob and simon,

In case, I can ignore the bit which is over 999 and set the range as 000
to 999

Best you ignore the bit over 1012, and under 12 :)
 
D

DAC

sommes said:
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

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
 
S

sommes

Thank you DAC.

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

Thank you very much
 
R

Richard Freeman

sommes said:
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?

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.
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.

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
 
D

Dan H

sommes said:
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

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
 
Top