Hi,
I am using Texas instrument MSC1210 microcontroller (with a clock frequency of 3.6864MHz). This controller has a 24 bit sigma delta ADC unit. I am trying to convert the raw ADC values from it into corresponding volts (or mvolts) signals but unable to do so successfully.
My code specifications are,
1) I am using Keil micro compiler version 4.02 and using C language for programming, with follwoing register configurations - ADMUX = 0x08; // Differential input from channels AIN0(channel 0) and AINCOM (channel 8)
- ADCON0=0x38; //internal voltage source on at 2.5 v, buffer on,PGA 1
- ADCON1=0x00; // bipolar, auto filter, no calibration
- DECIMATION=0x120; // corresponds to 200 samples/second
ACLK = 00; // corresponds to 200 samples/second
From theory, the below menitoned formual should give the correct ADC to signal (volts) conversion,
signal (volts) = ((Raw ADC Value)/ (2^24)) * 2.5V
But in practice the above formula is not giving me the right volts output and is giving a very small value.
While on the other hand I am using the data sheet formual to convert ADC to volts, as follows (from application note for ADC (SBAA097B page 13) of MSC1210, bits to volts conversion)
volts = ((N * Vref)/(GC*0.75*DEC^3*BG)) * RawADC + (Vref/(0.75*DEC^3*BG)) * Offset
OR
volt = K1 * RawADC + K2 * Offset................(1)
(N*Vref)/(GC*0.75*DEC^3*BG) = k1
(Vref/(0.75*DEC^3*BG)) = K2
Where (from the same application note)
N = 2^22 (for bipolar case and N = 2^21 for unipolar case)
Vref = 2.5 volts (reference voltage)
GC = 3143213 (gain calibration)
DEC = 288 (decimation for Vs located in Decimation = ADCON2:ADCON3 registers)
BG = 2^-2 (bit shift gain)
Offset = Offset Calibration (OC) register value = 13 (almost the same value of 13 comes up everytime during program execcution).
This evaluates the values of constant K1 and K2 as,
K1 = 0.0000007448132019 K2 = 0.0000005581632945
Hence equation (1) becomes,
volt = 0.0000007448132019 * RawADC + (0.0000005581632945 * 13) volt = 0.0000007448132019 * RawADC + 0.00007256122................(2)
If I use (2) in my calculation, the rms values of an AC signal is calculated very accurately always. But by right, ADC show give the PEAK (or instantaneous) values of the AC signal not the RMS values.And the ADC values never reaches to reflect the peak value of the AC signal, rather stay near the rms value of the signal.
**************** I have used both ways for ADC conversion but still not able to get the values.Please highlight if there is any thing incorrect I am doing in my calculations and/or registers configurations.
Asad
So - you use Excel for converting from raw ADC values into a voltage. So what is your problem then?
The ADC has a conversion formula A*x + B.
Your simpler formula assumes the gain is 1, when you figure out A. The second formula says the gain isn't 1.
Your simpler formula assumes the offset is zero. The second formula takes into account the offset.
Have you looked into the values used in the second formula? Where do they come from? What does the datasheet say about them? What is the gain in the ADC? And what is the "gain" resulting from the filtering logic outside/inside the ADC?
About filtering? No - I think _you_ should spend some time pondering what happens if you send a signal through a filter, and then let the ADC sample the filtered result.
Do you expect to get the same values as if you sampled an unfiltered signal?
Don't you think the bandwidth represented by the filter will affect if your ADC can read peak values or RMS values or something in between? Exactly what does a filter do? What happens if you send a signal through a high-passs filter? What happens if you send a signal through a low-pass filter?
@ Per Westermark
Also I am able to see a difference in - passing a signal through a filter and passing a signal without a filter.
As I mentioned before that we are using an external filter (R=10k and C=0.1uF) just before the point of taking samples, so for this external filter I calculated the GAIN of the filter which appears to be 0.93, which means that there is a 0.07% signal loss when a sigal passes throgh this external filter. This loss also partially contribute to not able to reach / read the PEAK value of the AC signal.
0.97 does not represent a dampening of 0.07% - it represents 7%.
Sorry, my bad. Yes 0.93 gain of the filter represent the dampening of signal by 7%.