xmega128D3 or xmega128A3 A/D converter??

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've read the errata and some feed back on the A/D being 'broken' in the xmega "A" parts, and wonder if the same applies to the "D" series.

What I wanted to do was to measure the battery voltage (LIon) using the A/D unit. From what I've read the single ended mode is subject to considerable 'uncertainty' of about +- 6 bits. To be fair, Atmel does state that there is a 200 count 'noise' floor that needs to be measured and subtracted from all readings in single ended mode.

The recommendation was to use the differential mode. I would use a 2.5 volt external reference (3.3 v power supply) and scale the battery voltage so the expected 4.2 volt maximum reading scales to 2.5 volts. I would then set the negative input at 1.6667 volts which is the expected 2.8 volt minimum battery voltage scaled by the same input factor. This way a zero count represents the 2.8 lower battery voltage and the max count represents the 4.2 max battery reading. I end up with 11 bits of useful data. (The negative input is generated by a resistor divider across the reference voltage).

Only one channel of the A/D would be used as described above. I only need to measure the battery voltage a few times a minute, so I could run the A/D in the repeating mode using an ISR to read the result and update a running average. The update rate could be anything that gave me at least 5 samples per average period to report the current voltage say 4 x per minute.

Does anybody see a problem with this, or is the hardware too 'broken' for this application.?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Usually when folks measure the voltage of a LiIon battery they need it accurate to a very few millivolts. I presume you need the same.

If you use a stable external reference voltage and average a bunch of readings, you'll probably be OK. I've heard that new xmega AVRs with the A/D "fixed" are in the supply chain now so that would help. I haven't seen any myself yet, nor have I seen yet any test results from them. But it's encouraging.

My concern would be your resistor divider across the reference as your negative voltage reference. I'd suggest buffering that with an op-amp to help keep that point stable. Similarly for the voltage-divider across the battery pack.

Make sure you do an analysis of the errors in your system to ensure you're getting the measurement accuracy you need. Or, do a calibration later. The external reference will only be accurate to xx% (depends how much money you spend). If you use 0.1% resistors for your voltage dividers, that's 4 mv of error on a 4V battery. And so forth.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

We were using a Dallas battery "fuel gauge" chip to handle this function but are trying to do a cost reduction on the design. The Dallas part has a 12 bit resolution, but reads from 0 to full scale. By expanding the scale I should be fine with 11 bits. The accuracy of the reference and scaling network is important, agreed.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've been reading the xmegaA documentation and I think I found a slight problem with winavr. In file iox128a3.h the definition of the MUXNEG bits is defined as

typedef enum ADC_CH_MUXNEG_enum
{
    ADC_CH_MUXNEG_PIN0_gc = (0x00<<0),  /* Input pin 0 */
    ADC_CH_MUXNEG_PIN1_gc = (0x01<<0),  /* Input pin 1 */
    ADC_CH_MUXNEG_PIN2_gc = (0x02<<0),  /* Input pin 2 */
    ADC_CH_MUXNEG_PIN3_gc = (0x03<<0),  /* Input pin 3 */
    ADC_CH_MUXNEG_PIN4_gc = (0x04<<0),  /* Input pin 4 */
    ADC_CH_MUXNEG_PIN5_gc = (0x05<<0),  /* Input pin 5 */
    ADC_CH_MUXNEG_PIN6_gc = (0x06<<0),  /* Input pin 6 */
    ADC_CH_MUXNEG_PIN7_gc = (0x07<<0),  /* Input pin 7 */
} ADC_CH_MUXNEG_t;

But this sets bit 2 in the MUXCTRL register for pins4-7 which are defined as the SAME as pins0-3 since the upper or lower 'nybble' is selected by the INPUTMODE (gain or no gain). Bit 2 is reserved and must be set to zero. You need to and the selection with 0x03 for the definitions to be correct.