ResolutionAs discussed previously, the Arduino has a 10-bit resolution on its analog read capabilities. That means it can read a voltage between 0 and 5 volts and report a value between 0 and 1,023. If it read with 8-bit resolution, it would generate a value between 0 and 255. If we divide the maximum voltage of 5 volts by the highest resolution value (5/1,023 and 5/255) we get 0.00488 and 0.01960. That number represents the milivolts (mV) for each step in the range. For example, if we have a 8-bit input and we read a value of 134, then that represents 2.6264 volts (134 x 0.01960).
This looks like plenty of resolution. It is obvious from the above examples that 10-bit has 4 times the resolution as 8-bit, but how do you tell if you have enough resolution? Well, it depends on your application. If you are trying to detect if voltage is present, then 1-bit would be enough. That bit could be a 0 or a 1, ON or OFF. But, what if you needed something more precise?
For example, you are trying to charge LiFePo4 batteries and you want to stop charging at exactly 3.65 volts. You definitely want to tell the difference between 3.64 and 3.66 volts to do that. In other words, you need 1/100th of a volt resolution, or 10 mV resolution. If we are using an 8-bit analog input, then the first step after zero volts would be 0.0196 volts, or 19.6 mV. And since 19.6 mV is larger than our minimum requirement of 10 mV, then 8-bits just won't work. But, 0.00488 volts or 4.88 mV would work just fine.
Voltage RangeSo, using a 10-bit analog input will give us a resolution of 4.88 mV when we are reading 0 to 5 volts. But, what if we want to read up to 15 volts? If we take 15 volts and divide by 1,023 steps, we get 14.6 mV which is larger than our previous requirement of 10 mV. The problem gets worse with higher ranges. If we tried to read 0 to 60 volts, we would get a final resolution of 58 mV.
There are some tricks you could use to fix your range so it is more tight. For example, when we measure a 12 V battery, we expect a range of about 10 to 15 volts. That is a 5 volt range, it just happens to start 10 volts too high. Alas, there is a way to fix that!
We can just add a 10 volt zener diode to the circuit. It will drop about 10 volts off of the input, resulting in 0 to 5 volts going to the Arduino.
You could also make a circuit like below to read up to a 48 volt battery bank, which could be upwards of 60 volts. In that case, the 40 to 60 volts would be sent through a pot that would be adjusted until 40 volts in would equal 10 volts out. The zener diode would knock off that 10 volts. But, what would the high end of that range be? Since the pot was adjusted to make 40 volts into 10 volts, there is a 4 times reduction in the pot being used as a voltage divider. That means 60 volts is translated to 15 volts. This works perfectly as an input to the 10 volt zener and will give us 0 to 5 volts as the circuits final output.
You also might want a more modular circuit that can take an input from different battery bank sizes. This circuit is meant to measure one battery bank at a time. If you want to measure more than one at a time, duplicate this circuit and apply it to several different Arduino input pins.
Be aware that R4 is only useful when your zener is reverse biased at something less than 10 volts. A typical zener is rated at 5%. That means a 10 volt zener could start passing reverse current at anywhere from 9.5 to 10.5 volts. But, whatever voltage that zener starts at, it will be consistent at a given temperature. For example, if your zener conducts at 9.7 volts, it will always start conducting reverse current at 9.7 volts. So, you could go through a batch and test zeners until you get ones that are the closest to what you want. In this circuit, you should go slightly under 10 volts instead of over. If you have a true 10 volts coming in to R4 and your zener doesn't start conducting until 10.3 volts, no amount of playing with R4 will make up that 0.3 volts.
Some of you are wondering why I chose the 1k resistor (R1) before the zener diode. Well, I'm assuming a worse case connection is 60 volts into the 12 volt input that has been calibrated for a 12 volt battery. I'll get 50 volts coming out of D4 zener and D2 will redirect 45 volts to ground. And, 45 volts divided by 1000 ohms is 0.045 or 45 mA. The power would be current times volts, or 0.045 amps x 45 volts = 2.025 watts. I'm using a 4 watt zener and I like to limit the power to about half. If you were using a 1 watt, then you would want at least a 4k resistor for R1.
IF YOU'RE INTERESTED IN LEARNING ELECTRONICS
Then Take A Look At This!
Then Take A Look At This!