4 years, 1 month ago.

Inconsistent voltage measurement

Hi

I'm after some advice.

I am trying to measure a constant DC voltage of 42mV on one of my analog inputs. The issue I have is that although the input is fixed at 42 millivolts my actual readings fluctuate meaning that the result is neither accurate or consistent..

Example results

0 Reading = 0.009524 Total = 0.009524

1 Reading = 0.012943 Total = 0.022466

2 Reading = 0.013431 Total = 0.035897

3 Reading = 0.011966 Total = 0.047863

4 Reading = 0.012454 Total = 0.060317

5 Reading = 0.012698 Total = 0.073016

6 Reading = 0.009768 Total = 0.082784

7 Reading = 0.009035 Total = 0.091819

8 Reading = 0.009768 Total = 0.101587

9 Reading = 0.009524 Total = 0.111111

My conversion to millivolts may not be accurate but at the moment this isn't an issue as long as the results are constant.

Any suggestions are much appreciated as I'm not sure how to resolve this and for the project I am working on the reading needs to be accurate and repeatable..

/media/uploads/servicelogic/analogin.cpp

2 Answers

4 years, 1 month ago.

The ADC input full scale voltage is 3300 mV. So 42 mV is rather small and translates to a return value of 0.012 . The small value also means that it is sensitive to noise on the input and to any variation in the ADC reference voltage on the mbed.

You may want to try out a noise free amplifier for the DC voltage (eg 10x, resulting in 420mV) to improve the range and/or provide better shielding and GND between the 42 mV and the mbed ADC. In addition some small capacitor on the ADC input to filter out noise may help.

Also keep in mind that the mbed LPC1768 ADC is prone to noise due to the board design. In case you really need better performance a low-cost external ADC with a digital I2C or SPI interface to the mbed may be your best option.

Thanks Wim.

It looks like a noise free amplifier maybe the best option but will also look at an external ADC.. Maybe both :)

Thanks Gary

posted by Gary Lowe 19 Dec 2017
4 years, 1 month ago.

Much hand waving and approximations follow but the short answer is don't try to do anything requiring accuracy with the built in ADC, it's not that good to start with and the way the mbed was built only made it worse..

Firstly when converting from ADC readings to voltage on the LPC1768 assume that full scale is 3.1V not 3.3V. The reference voltage is the processor power supply which is a 3.3V regulator but that then passes through a diode with a drop of around 0.2 so it's actually running off about 3.1V. Unfortunately this also means that the voltage will change depending on current draw so you'll get a slightly different ADC reading depending on what the IO pins / LEDs are doing etc. Secondly since the ADC reference voltage is the same supply as the main power to the CPU and the LPC1768 module only has a single ground pin you are never going to get accurate or low noise measurements with it, there is always going to be some noise on your references..

The ADC is 12 bits over 3.1 V so in theory the resolution is around 0.76 mV but the part datasheet indicates you should expect errors of up to 4 times this so 3 mV. And that is assuming a decent reference voltage and ground connection which you can't get so double it to allow for that.

And that's before we get into the exact definition of a "constant" voltage input, the ADC will cause a current spike when it samples, depending on the impedance of the connection to the part this can cause the ADC to read a little low. A capacitor right on the input pin can help with this as long as you aren't measuring high frequency signals.

Putting this together I would expect you to see raw ADC readings of around 0.013 +/- 0.002 if reading as a float or 880 +/- 128 if reading it as a unit16_t.

Thanks Andy.

My current reading are similar to your expected figures but for the application I have I need to be very accurate. This being the case and based on your comments about the MBED I think I need to use an external converter.

Thanks for your feedback.. Greatly appreciated and saved me lots of frustrated hours trying to fault find :)

Cheers Gary.

posted by Gary Lowe 19 Dec 2017