# Measuring tiny voltage variation with Arduino ADC handing the rapid changes in control algo

I'm hoping I can get some advice, I have an industrial laser position sensor from SICK that outputs 0 to 10 volts. I used a voltage divider to scale it down to 0 to 5 volt range, and feeding that into an analog input of an Arduino.

The sensor is very accurate, but it moves about 0.1 (tenth of a volt per inch), and the setpoint of my control system needs to maintain a sensor reading of 2.03 volts (hundrends).

I closed the system loop and it maintains the object at the position but varies from 1.99V to 2.09 volts which is actually a couple inches in each direction.

I found the Arduino can actually read the correct voltage from the sensor but using a laboratory voltmeter the arduino will be off in the hundrends digit sometimes by a few, but I need this to be accurate...

Any suggestions? Can the 10bit ADC even measure the voltage accurately? Also I thought of using a moving exponential average filter to kinda get 10 samples and read the average voltage since it changes so fast...

By the way I'm using the position sensor to measure height of a ping pong ball in a tube, so the ball wobbles a bit, even with PID, so the sensor readings will change like: 2.01 2.03 2.04 2.05

fairly rapidly..

Any help is greatly appreciated!!!!!

A 10-bit ADC at 5V has a resolution of 5mV. Your sensor has a sensitivity of 100mV per inch, which you reduce by your resistor divider to 50mV per inch. That means 10 ADC counts per inch. This isn't much, especially when you think that you'll always have some noise in your readings.

If you're interested in only a small range, like the 1.99V..2.09V, subtract the 1.99V from the input using a difference amplifier and amplify 50-fold to get a range from 0V to 5V.

If R1=R2 and R3=R4 then

$V_{OUT} = \dfrac{R3}{R1} \times (V_2 - V_1)$

I would still use a low-pass filter in software to filter out the noise.

If you do not need to measure the full range of the sensor, then scale accordingly. i.e. if you only want to regulate the system to a limited range, increase the gain of the sensor using 5V rail to rail Op Amp and 2.5V reference. Say you are only interested in 1.9 to 2.1 and you want that to be full scale 0 to 5V then use a 2V offset and instead of /2 you want to x 5 / 0.2 = 25. This will reduce the error in your control system due to ADC noise and offset.

Alternatively your 10 bit ADC has a resolution of 1 in 1024 so head warning to all app notes and specs for regulation and filtering of V+, ground faults with analog and digital grounds etc, shielding form EMI then you should obtain the accuracy and repeatability in the spec. (whatever it is) Test your system with a triangle wave and if you can output the ADC into a DAC to look at the output. Then compare analog in and analog out for linearity and missing code errors due to noise on Vref/Gnd.

Either of these approaches should work, but the 1st gives easier control. If necessary use another op amp to scale the 2.5V or whatever internal accurate ref. to what ever offset you want the system to with 25x gain to obtain. from 0 to 5V..

Of course your noise could be in your sensor, but you never specified that you scoped that.