0
\$\begingroup\$

So I have "built" a voltage sensor for an Arduino by using two resistors. The current setup is as shown in the schismatic and the Arduino pins are only 5V tolerant.Schematic of the Voltage Sensor

The accuracy of the sensor is alright when there is little current draw on the battery. But when the battery is powering motors, the voltage tends to jump around a lot. The first thing I will do to this setup is to increase the value of R2 from 100K to 330K. This will lower the max voltage from 55V to 20V, but I should never be pushing more than 20V anyway. That will increase the resolution at which I can measure the battery, but I believe to get very accurate data that I should add smoothing capacitors somewhere in the circuit to make sure the voltage doesn't "jump" around as much. Any thoughts?

EDIT: So after hearing some recommendations in this post I decided to run some tests. I decided to switch out the 1M and 100K resistor with a 10K and 1K respectively. I then used a fully charged 2 cell lipo battery and ran 4 motors on it continuously for about 25 minutes until that battery ran out of juice. The data was recorded in the Serial Mointor and graphed in Excel. I did not start the motors until 20 seconds have passed for recording. Here are my findings. enter image description here enter image description here enter image description here enter image description here

As you can see from the graphs, the data in the first two is all over the place. The "stability" of the signal being recorded does not seem to be dependent on the impedance of that signal (At least for the Atmega32u4). Averaging 20 samples at a time did show usable data that seems consistent with other lipo battery discharge curves.

The following graphs stability could be improved by lowering the ratio of R1 and R2, and I suspect adding a filtering Cap across R2 would also increase accuracy of the measurement.

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

C1 and C2 are not smoothing the voltage: if you want to create a RC lowpass filter, you need to put the capacitor on the correct side of the resistor, and that is across R2, right at the ADC input.

As for the value, it is your choice, it depends on how much filtering you need, just use the usual formula. Remember the R value to use is the output impedance of your voltage divider, and that is the parallel combination of R1 and R2 (not just R2).

Make sure the cap isn't a high-K ceramic like X7R, or you will be manufacturing a piezo microphone. Use electrolytic, film, or C0G ceramic. If you use high value resistors to avoid wasting battery, look at leakage current on the cap's datasheet.

The micro's datasheet says "The ADC is optimized for analog signals with an output impedance of approximately 10 kohm or less." This is true, but there is more to it. When the ADC takes a sample, it will connect its sampling capacitor to the input for a certain amount of time, and the source impedance must be low enough to fully settle the voltage on the sampling cap down to 1LSB during the sampling time. With a 100k source impedance, this doesn't happen, so you will lose precision.

However if you add a cap across R2, then the ADC sampling cap will charge from that larger cap and settle very quickly. Now, the amount of charge used up into the sampling cap shouldn't change the voltage on your filter cap by more than 1 LSB, so the filter cap value should be at least \$ 2^{ADCbits} \$ times the ADC sampling cap. With this trick you can acquire slow signals from very high impedance sources without using an opamp, as long as the sampling frequency is low enough.

\$\endgroup\$
2
\$\begingroup\$

Using too big value for the voltage divider will affect the accuracy and what voltage your arduino "see"

Arduino adc has " impedance " : enter image description here

The datasheet of ATMEGA328 says :"The ADC is optimized for analog signals with an output impedance of approximately 10 kohm or less.", so you shouldn't use too big value for the voltage divider.

In your schematic, your smoothing capacitors are too big. A few microfarads is okand I think a ceramic bypass capacitor should be included to prevent voltage spike cause by the motor.

Because you are interested in 0 - 20 V range, the schematic should be something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
5
  • \$\begingroup\$ I found the following on the Arduino website, "Pins configured this way are said to be in a high-impedance state. Input pins make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 megohm in front of the pin." So is this really that much of an issue? Also the lower current draw from the resistors means marginally better battery performance for long term operation. \$\endgroup\$ Commented Feb 17, 2018 at 9:39
  • \$\begingroup\$ Do you mean this : arduino.cc/en/Tutorial/DigitalPins \$\endgroup\$
    – Long Pham
    Commented Feb 17, 2018 at 13:48
  • \$\begingroup\$ you must know how to distinguish " analog" and "digital ": learn.sparkfun.com/tutorials/analog-vs-digital the digital world has only two state "0" and "1" and INPUT mode is used to read which state the pin is, not analog voltage \$\endgroup\$
    – Long Pham
    Commented Feb 17, 2018 at 13:56
  • \$\begingroup\$ If you want both low power and accuracy, you should use ultra-low-power op amp voltage follower. \$\endgroup\$
    – Long Pham
    Commented Feb 17, 2018 at 14:01
  • \$\begingroup\$ And one more thing, you should average the readings, it will increase the precision, somehow. \$\endgroup\$
    – Long Pham
    Commented Feb 17, 2018 at 14:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.