Why is ADC so inaccurate?

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

I am making a digital PH-meter and using a Atmega8 with the stk500 board. I have designed a circuit that gives a stable voltage between 0.7V and 4.3V depending on the PH value.
I wish to use 10 bit resolution for the conversions. With 0V being converter value 0 and 5V value 1023 this should convert to a int 143-880.

However the results from the conversions don't respond to small variations in voltage, it jumps like this: 615 -> 620 -> 624 -> 632 hardly ever landing on a value in between.

I have also tried with a pot meter and I get the same results.

All help is appreciated, here is my code:

//this function is run continuously
void control()
{

	// start conversion
	ADCSRA |= (1<<ADSC);

	// wait until conversion completed
	while (ADCSRA & (1<<ADSC));


	// Get ADC result
	control_ph_measured = ADCW;

	_delay_ms(2500);
	

}

//this function is run once
void control_init()
{
	//set MUX channel 7
	ADMUX |= (1 << MUX2); 

	// Set prescaler
	ADCSRA = (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);

	//ADC enable
	ADCSRA = (1<<ADEN);
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The STK500 isn't really designed to give stable ADC readings. You need to design your own PCB.

Leon

Leon Heller G1HSM

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

sausau wrote:

All help is appreciated, here is my code:

You might improve your measurements by averaging some samples. I would get rid of the 2500ms delay and use that time to add up many samples in a uint32_t and divide by the number of samples at the end of the loop.

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

The Mega8 and other AVR ADC converters work just fine--within their specs and the 10-bit resolution. Although the datasheet will give linearity and offset errors, I've never really seen it in practice.

To get near-10-bit results, AVCC, AREF, AGND, and the signal have to be squeaky-clean. this rarely happens in practice, and especially not on a lashup board. If you examine the signals, you will probably see some ripple on the signals mentioned.

Oversampling, as mentioned, is a decent way to get rid of ripple in practice.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Thanks guys.
Turned out that I was using the AREF provided by the stk500 board which was very inaccurate. Adding the line "ADMUX |= (1 << REFS0);" and disabling the AREF jumper on the stk500 board made the results much better. Will also try oversampling.

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

If your sensor is ratiometric, if possible, it is best supply it with the reference supply. AVCC filtering helps, also using AGND for the sensor return.

I have found the ADC meets or exceed specs over the complete specified temperature range. I verified using a mV calibrator and a temperature chamber for several devices.

It all starts with a mental vision.

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

Quote:

which was very inaccurate.

What does that have to do with your orignal problem posting of non-constant conversion results?

That has nothing to do with >>accuracy<<, and I strongly suspect it was indeed noise on the lashup.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

I don't understand your first post. What is VCC? What is VREF?

I infer you want to measure a voltage between .7 and 4.3 volts. Are you connecting that directly to a mux input of the ADC? Or are you using a resistor divider so you can use one of the built-in reference voltages?