This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ADC conversion to volt in MSC1210

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

Parents
  • @ Erik:
    Please see below for your queries replies,

    are you taking a bunch of samples within one period?
    Yes, I am collecting 128 samples of the AC signal and look for the maximum sample value to get the PEAK value of the AC signal.

    how do you synchronize you samples to the period?
    Since I am taking 128 samples over 38 cycles of the AC signal, therefore I don't see strong requirement of synchronization of samples to the period.

    what is the frequency of your input?
    My input AC signal frequency is 60Hz. My sampling frequency is 200 sample/sec.

    Just to make it more clear,

    ( Sampling frequency ) 200 samples in 1 sec
    ( 128 samples will take ) 128 samples will take (1/200) * 128 = 0.64 sec
    ( number of AC signal cycles coverage in 0.64 sec are) 60 Hz * 0.64 = 38 cycles (approx)

    How you see the input frequency or sampling frequency may affect the PEAK values collection by ADC?

Reply
  • @ Erik:
    Please see below for your queries replies,

    are you taking a bunch of samples within one period?
    Yes, I am collecting 128 samples of the AC signal and look for the maximum sample value to get the PEAK value of the AC signal.

    how do you synchronize you samples to the period?
    Since I am taking 128 samples over 38 cycles of the AC signal, therefore I don't see strong requirement of synchronization of samples to the period.

    what is the frequency of your input?
    My input AC signal frequency is 60Hz. My sampling frequency is 200 sample/sec.

    Just to make it more clear,

    ( Sampling frequency ) 200 samples in 1 sec
    ( 128 samples will take ) 128 samples will take (1/200) * 128 = 0.64 sec
    ( number of AC signal cycles coverage in 0.64 sec are) 60 Hz * 0.64 = 38 cycles (approx)

    How you see the input frequency or sampling frequency may affect the PEAK values collection by ADC?

Children
  • 200 samples/second - means one sample every 5 ms.

    For a 0.5% error, you need to get a sample within arccos(0.995) = 5.7 degrees of a peak or within (5.7/360) * (1/60) = 0.26 ms.

    But let's say your first sample starts (just an example) at a zero crossing.
    Your samples are taken at 0, 5, 10, 15, 20, 25, ... ms.
    The period of the signal is 1/60 s = 16,67 ms.
    So your samples will happen at angles:
    0, 108, 216, 324, 72, 180, 288, 36, 144, 252, 0, 108, ... degrees.

    As you can see, it doesn't matter how many samples you take - you just get an infinite repetition where you get no samples close to 90 or 270 degrees.

    108 degrees is 18 degrees off.
    288 is 18 degrees off.
    cos(18) is 0.95 - so 5% error.

    And your error will be different (but often large) depending on where in the phase you start to take the first sample.

    You either need to sample at a high enough rate that you get close enough for even a single period. Or you need to make sure there isn't any aliasing between sample frequency and signal frequency, so that it is possible to sample for many periods and get some of the samples close enough to a peak.

  • You either need to sample at a high enough rate that you get close enough for even a single period. Or you need to make sure there isn't any aliasing between sample frequency and signal frequency, so that it is possible to sample for many periods and get some of the samples close enough to a peak.
    or include a zero crossing detector.

    Erik