Saturday, December 7, 2013

ADC-part 2



Some important points from the document AVR1300:Using Atmel AVR Xmega ADC

1. Conversion modes : Signed mode cab be used as input mode for differential and single ended.
Unsigned mode is only Available for the single ended or internal input

In unsigned mode the conversion range is from ground to reference voltage.
To be able to have zero cross detection, a delV is subtracted.

This image depicts the stuff needed




** Negative values are not negative inputs on the IO pins, but higher voltage level on the negative input in respect to the positive input. Even the resulting value can be negative, the voltages below GND or above Vcc should under no circumstances be applied to any input port.


**Once again,  when the ADC uses differential input, signed mode must be used.

** Conversion mode is configured for the whole ADC, not individually for each channel.

2. Single ENded input
For signed mode, the negative input is always connected to GND
For unsigned mode, the negative inout is connected to Vref/2 - delV
delV = 0.05*Vref

The offset will typically correspond to value of about 200.

3. Conversion result
     -Signed mode : Result = (Vinp - Vinn)*Gain*Top/Vref
              where
                       Vinp = the positive input
                       Vinn = the -ve input
                        Gain = 1 if not used,
                        Top = highest value - 2048 for 12 bit and 128 for 8bit
    - in signed mode, the signed number is two's complement where the MSB is the sign bit. In 8 bit mode, the sign bit is padded to the entire high byte.
With 12 bit resolution the range from -Vref to +Vref will be -2048 to 2047(0xF800 - 0x07FF)


Unsigned mode
            Result = (Vinp + delV) *Top/Vref
             Top is 4096 for 12 bit, 256 for 8 bit mode.
              result is approx 200 when the input is connected to the ground. This offset is not removed by the ADC and has to be done in software by subtracting 200(or measured offset) from the conversion result.
with 12 bit resolution the range from GND to Vref-delV will be approx 200 to 4095
(0x00C8 to 0x0FF)

Tips for improving accuracy
1. Avoid toggling pins when ADC is converting as it will cause switching noise internally and on power supply
The ADC is the most sensitive to switchig on IO pins powered by analog power supply ie., PortA/PortB (have no idea what this means)
 2. Switch off unused peripherals by setting PRR registers to eliminate noise from unused peripherals.
3. Put xmega into idle sleep mode as soon as ADC conversion starts, to reduce noise from CPU.
4. Load the calibration values from the signature row into the calibration register in the ADC.
5. Use the lowest gain possible to avoid amplifying external noise.





No comments:

Post a Comment