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-Decimal conversion

Status
Not open for further replies.

bijaypaudel

Member level 1
Joined
Dec 14, 2011
Messages
32
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Activity points
1,489
I want to convert 10 bit value that i got from inbuilt ADC in PIC microcontroller into Decimal.
ex. if the value is 0100110010 then i need to store 306 in a variable
i am using PIC16f877, Hi-tech compiler in C language
 

There is nothing to convert?

Decimal_Variable = 10-bit_value;

Both contain 0100110010, as far as the micro is concerned, there is no difference.
 

**broken link removed**
This link is also good

---------- Post added at 19:36 ---------- Previous post was at 19:30 ----------

What i mean is you can get 0-10 vots or 0-100v or 0-5mv or 0-500 mv from same digital number , so accuracy is better if u use the lower range of dc voltage for a wider binary range.
look at the staircase voltage u can see it is not linear and some voltage values u can not get , and more who r we to decide what is reasonable for him. he may need to build:lol: a 10kv generator.
 
Last edited:

actually i am making a digital voltmeter, so i need to compare voltages and display the value that it read.....
 

To convert to voltage, if you are using 5 Volt supply as A/D ref.

Resolution = 5 / 1024;

Voltage = result * Resolution = 306 * (5/1024) = 1.49 Volts
 

I prefer to use (306 * 5000) /1024 , this way the result is in mV and there is absolutely no need to use float variables,
then you can convert it in ascii chars in an array and place the dot manually when you show it in a display.

'1' '4' '9' '0' can be shown as '1' '.' '4' '9' '0'
 

I want to convert 10 bit value that i got from inbuilt ADC in PIC microcontroller into Decimal.
ex. if the value is 0100110010 then i need to store 306 in a variable
i am using PIC16f877, Hi-tech compiler in C language

If you mean that, the ADC result is in binary, but you want to store it so that it stores decimal, then there's no need. Decimal and binary are just how we look at those numbers. For the microcontroller, it means the same thing as, what is stored at a specific memory location is the binary value. Writing the value in decimal or hexadecimal or even octal is for our convenience, but the microcontroller perceives all of these as binary.

Hope this helps.
Tahmid.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top