How to convert from ADC to original analog values? - DEMOQE128

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to convert from ADC to original analog values? - DEMOQE128

8,247 Views
akak
Contributor I
Hello,

I'm trying to read the accelerometer data off of the DEMOQE128 board through the ADC, and I want to get the original analog voltages from the accelerometer. I'm getting values from 0 - 65535. The ADC is set to output 12 bits and I think the reference voltage is 3V but I could be wrong. Is there some formula or conversion to use to get the original voltages going into the ADC?

Thanks!
 
 
 
 
 
 
 
Added p/n to subject.


Message Edited by NLFSJ on 2008-04-24 07:06 AM
Labels (1)
0 Kudos
6 Replies

1,578 Views
akak
Contributor I
Thank you to everyone for your considered replies.

We found out that the ADC, for some reason, left shifts the output 4 bits (which would make the original limit of 4095 go up to 65520). This is using Processor Expert and using the included commands to do a simple reading of the ADC buffer. To get the original voltage readings, we had to right shift 4 bits, then multiply it by Vref/(2^12).

Again, thanks everyone for responding.
0 Kudos

1,578 Views
ProcessorExpert
Senior Contributor III
Please, what method do you use to read the result of the ADC conversion? Processor Expert provide more methods to read the result of the ADC conversion with different functionality.

It seems you are using  GetValue16 method because this method returns the result normalized to 16 bits range. However, if you want the result of the ADC conversion in the format according to the native format of the ADC converter, use the GetValue method instead.

Processor Expert Support Team
www.processorexpert.com

0 Kudos

1,578 Views
Morph19
Contributor I
Imagine that you have an x-y graph with a line, x axis will be the resolution of the ADC and the y axis would be the values that you are getting 0-65535.When the ADC have  the number 0FFF=4095 the line would pass the point (x=4095,y=65535) you can get the equation from those values:

y=(65535/4095)x
or
x=(4095/65535)y

So if you put the values that you are reading 0-65535 in the place of "y" you would get the values that the ADC is giving to you.
The resolution of the ADC for 3V reference is:

resolution= 3Volts / (2^12 - 1)=  3V / (4096-1) = 0.732mV

If you multiply the value of x from the first conversion  with 0.732mV it woul give you the volts that the ADC is getting, asumming that the reference voltaje is 3V and that the acelerometer have a signal conditioning circuit that  gives the microcontroller a signal that spans from 0V to 3V .

But if you want the voltaje given  by the accelerometer search for its resolution ih his datasheet, say that is 4mV-20mV you have to do another x-y graph, this time the slope is :

Slope=(3V -0V)/( 20mV - 4mV)= 187.5   --------------->Equation S

and the equation is:

y=(187.5)x  - 0.75V                            --------------->Equation F
or
x= (y + 0.75V)/187.5

Subtitute  "y" with the value from the second conversion and "x" would be the voltaje given by the acelerometer.

But remember to look carefully in the dataseheet for that sensor , so you can substitute the apropiate values in equation for the slope(Equation S) you can get that data from the characteristic table under Offset and full  scale span, the offset would replace the 4mV value and (full scale span + offset) the 20mV value. And the 0.75V from equation F also change,to obtain his new values resolve the next equation for "B":

0=(new Slope)(new Offset) + B

Its important that you check the documentation for your demo board in order to know if it have a signal conditioning and what accelerometer it uses, if in the user guide dosnt mention anything about that check the electronic diagrams for those circuits.



Message Edited by Morph19 on 2008-04-24 05:53 PM
0 Kudos

1,578 Views
Denn
Contributor I
Hello,
 
As I read this post I understand that you need to know what is the RAW value given by the accelerometer to the ADC.
 
If this is the case then the following would give you the required voltage at the 'tip' of ADC.
 
Since ADC is configured for 12 bits the maximum ADC output should be FFF i.e. 4095.
 
"I'm getting values from 0 - 65535. The ADC is set to output 12 bits "
After ADC conversion, Logical AND the ADC result register(16 bit) with 0xFFF.Sometimes its possible for ADC to give some "extra" values outside 4095 for 12 bit resolution.
 
Also refer the thread for necessity for LOGICAL ANDing of ADC Result register .
 
 
 
The accelerometer voltage =[ (  (ADC Result Register&0x0FFF) /4095)* (VDDAD-VSSAD) ] + VSSAD
 
 
Best Regards,
Denn


Message Edited by Denn*** on 2008-04-24 10:21 AM
0 Kudos

1,578 Views
JimDon
Senior Contributor III
After you resolve those issues, I think you were asking how to get the original voltage that the reading map to.

Suppose that you have an 8 bit converter, and 0xff equals 3v.

voltage = 3 * reading/255

If course this will truncate, so you can to this:

(3 * (reading * 100)/(255*100)) using 16 bit values.

Or use floats.

I also suggest on the accelerometer you dump the last two bits after the reading by right shifting as the reading tends to bounce around quite a bit.



0 Kudos

1,578 Views
bigmac
Specialist III
Hello,
 

akak wrote:
I'm trying to read the accelerometer data off of the DEMOQE128 board through the ADC, and I want to get the original analog voltages from the accelerometer. I'm getting values from 0 - 65535. The ADC is set to output 12 bits and I think the reference voltage is 3V but I could be wrong. Is there some formula or conversion to use to get the original voltages going into the ADC?


I am not sure whereabouts you are observing this range of values.  For 12-bit mode the maximum value output from the ADC module will be 4095 (0x0FFF).
 
For the accelerometer case, keep in mind that the voltage values will swing both positive and negative about a 0g reference level, which is at approximately one half the Vdd supply.  Therefore, this reference level will need to be calibrated for each axis, and the values stored in non-volatile memory.  The offset calibration values would then be subtracted from each raw ADC reading, to provide a signed result, say approximately +/- 2000 maximum.
 
Of course, how much of the available range is used in practice will depend on the volts per g setting of the accelerometer (at the particular Vdd), and the amount of applied acceleration.  VrefH for the ADC should equal Vdd.
 
Regards,
Mac
 


Message Edited by bigmac on 2008-04-24 02:30 PM
0 Kudos