XMEGA ADC saturating too early

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

I am using ATXmega16A4U. VCC & AVCC are at 3.3V. ARef is at 2.49V (measured), but the ADC saturates (reading 4095) at 2.37V. I have tried both single ended and differential inputs (negative pin tied to ground). The latter saturates even earlier.

 

In my application, I need the readings close to Aref. Please advise.

 

#define ADCACAL0   offsetof(NVM_PROD_SIGNATURES_t, ADCACAL0)
#define ADCACAL1   offsetof(NVM_PROD_SIGNATURES_t, ADCACAL1)

void ADC_Calibrate()
{
	ADCA.CALL = nvm_read_production_signature_row(ADCACAL0);
	ADCA.CALH = nvm_read_production_signature_row(ADCACAL1);
}

void ADC_init(void)
{
	PORTB.DIRCLR = PIN0_bm|PIN1_bm|PIN2_bm|PIN3_bm;

	sysclk_enable_peripheral_clock(&ADCA);

	ADC_Calibrate();
	ADCA.CTRLB      = ADC_RESOLUTION_12BIT_gc;
	ADCA.REFCTRL    = ADC_REFSEL_AREFB_gc;
	ADCA.PRESCALER  = ADC_PRESCALER_DIV128_gc;
	ADCA.CH0.CTRL   = ADC_CH_INPUTMODE_SINGLEENDED_gc | ADC_CH_GAIN_1X_gc;
	ADCA.CH0.MUXCTRL = ADC_CH_MUXPOS_PIN9_gc;
	ADCA.CTRLA      = ADC_ENABLE_bm;
}

 

This topic has a solution.
Last Edited: Fri. Nov 13, 2020 - 07:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ARef is at 2.49V

Why are you talking about 1 part in 4000 but giving references to lt to 1 part in 250???

 

Is the ref 2.490000 V,  2.486 V?  2.4947 V?  You see what I am saying?

at 2.37V.    Do you mean  2.36884 V? 2.37463 V?  If you want to talk about accuracy, be accurate!

 

Is your voltage you measure smooth?  Do you take averages?  What impedance are you supplying? to the ADC  Where is the signal grounded & where is the meter grounded? ...they must be right at the chip negative ref....not some thin wire 10 inches away & 100 mV different.

 

 

 

 

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Fri. Jul 24, 2020 - 08:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What is your ADC clock rate?  Have you tried it with a slower clock rate (longer conversion time)?

And as already mentioned, Analog is a whole nother world, measurements and grounds are critical.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

avrcandies wrote:
Why are you talking about 1 part in 4000 but giving references to lt to 1 part in 250???

 

The measurement is off by 197 out of 4096. Clearly my stated precision of 1 in 250 (as you say) is much more accurate than the 1 in 21 error.

 

All measurements are done in close proximity to the ADC input. No averages taken. The ADC is driven straight out of an op amp.

Last Edited: Fri. Jul 24, 2020 - 09:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jim - ADC clock is 98 kHz. I tried changing it seemingly without any impact on the saturation. I have almost the identical circuit and board with an ATMega328p and it is working fine. I updated to ATXmega for the 12bit ADC.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


ADC seems to be working perfectly according to the datasheet.

Note 0.95 * 2.49V = 2.3655V

 

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


You are absolutely right - I missed that bit. It seems that there is no offset in signed mode, let me try it.

 

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

We've all been trough the pain of the ~200 counts offset, single ended mode will give you 11 bits rather than 12 bits but common people can the use the ADC then.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Yes, verified - in signed mode, there is no offset and I can measure the entire range (within a small offset)... but now I only get 11 bits of precision :-(

Last Edited: Fri. Jul 24, 2020 - 10:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why can't you take two decent (stable) resistors & divide down your voltage slightly, maybe obtain Vout =0.9*Vin?  The exact ratio will be calibrated out.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

but now I only get 11 bits of precision

Which is what I said in  the post above yours.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Hi, 

Set ADC pins as input pins.

It needs some lines of code to turn those pins to input pins.

It may help.

Also please consider that when working in unsigned mode, some offset is seen which was shown in above comments. 

 

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

This feature is there for a reason; i.e. to facilitate the zeroing of any ADC offset. So why not use it rather than fight it.

 

You'll need to waste an analog pin and connect it to 0V.

Use the conversion result from that 0V pin to offset the conversion from your Vin.

 

BTW: Atmel screwed up here by not providing an Internal 0V MUX input for the positive ADC input VINP. Hence the wasted pin.

 

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

purple_beam wrote:
ADC clock is 98 kHz

Min. clock is 100kHz

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

If you have time to over sample, you can gain more bits, there is an app note on over sampling and decimalization that explains how it works. I have used it many times with success.

jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

BTW: Atmel screwed up here by not providing an Internal 0V MUX input for the positive ADC input VINP. Hence the wasted pin.

Agreed.

 

I forgot about this on a recent project and PCB, and then when I really got into the coding I had to  kludge together a solution.

Fortunately, as I called the board a Prototype, I didn't have to acknowledge it as an error on my part! (Compounding an error on MC/Atmel's part)

 

JC  

 

Edit: Typo

Last Edited: Sun. Jul 26, 2020 - 01:10 PM