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.

binary to decimal conversion for ADC

Status
Not open for further replies.

mig29fulcrum

Junior Member level 1
Junior Member level 1
Joined
Sep 29, 2011
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,391
hi...
I'm trying to convert ADCREL and ADCRESH contents to decimal values(or ASCII) in PIC18F4550 and show them on seven segment or LCD in assembly (simple volt meter),but i don't know how to implement decimal multiplication,division,subtraction and addition(with decimal point) in assembly and store them(it's easy in C but i wanna leard it in assembly). I also read microchip's document about floating point but i couldn't get enough information(code samples was written for mid-range PICs). I will appreciate if you masters clarify binary to decimal and floating point conversion for me.
thanks
fulcrum
 

Last edited:
Hi,

You do not say what your voltage into the ADC represents.

If it was a simple 10k pot then that would return a 10 bit binary value representing 0 - 1023.

You can use the methods that Papnblg shows but I find using the 10bit to 4 character Ascii converters found on the PicList site very usefull.
No complicated maths needed.

More typically your 10 bit result will represent something like temperature which may first need to go though a lookup table to produce the result, before you convert it to an ascii value for the display.
 
Hello!

it's easy in C but i wanna leard it in assembly

One thing you might have to get right before starting: there
us NOTHING that you can do in assembler and that you cannot do in C.
C is extremely close to ASM. C is portable & reusable, assembly is not.
What you tell us is simply a matter of dividing your input value into
digits, and write each digit to the proper location.

Another thing: on small micro controllers, you should forget about
floating point. An example: you want to measure a voltage. You can
always use tricks, left and right rotations combined with comparisons
iinstead of multiplications or divisions.

For instance, on the micro controllers I use most (MSP430), a 16 bit
integer multiplication can be done in 3 clocks or so. As for a floating
point multiplication, it is about 300 cycles. So as a rule, if you don't
have a floating point unit, don't use float numbers.

Another thing: don't use divisions in real time. You can use one division
at setup time because it will be performed once only. But in real-time,
you shouldn't use divisions.

Dora.
 
Last edited:
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top