I've recently bought a solar cell / sun battery which provides 48V DC and 5A at most. I'd like to measure the voltage using my Arduino. I've been googling for an hour but can't seem to find any simple circuit for this. I've already figured out that I need a voltage divider but all I found was only applicable for lower currents.
I'm looking for a curcuit that would fit to my needs. Also some code would be appreciated as well.
If you just want to measure the voltage, the current that the panel is capable of producing is irrelevant.
To measure the voltage with a 5V Arduino, you need a voltage divider that will bring down the absolute maximum voltage of the panel to within the range 0-5V. It would be best to make sure what that maximum is, because exceeding 5V on the Arduino input pin can destroy the chip.
However, assuming that a 10:1 divider would work, that can be made from a 90K ohm and a 10K ohm resistor. The panel goes to the top of the 90K, the input pin to the junction between the 90K and 10K, and ground to the bottom of the 10K. You probably can't buy a 90K resistor, but the next higher value will work (91K is standard). The whole thing will need to be calibrated when you are done, as the resistors typically have 5% or 10% tolerance in the stated value. The calibration can be done by applying a known voltage to the input of the divider (where the panel would connect) and comparing the Arduino output.
Thank you! I think I'll use a 1MOhm and 100kOhm so that it would be a 11:1 ratio allowing me to measure voltage up to 55V which is probably more than enough. Both can be bought in any hardware shop.
How about circuit protection? Any diode or zener diode in the circuit?
Your approach looks good to me. With resistors that large, the input current will be very small, so there is little worry about overvoltage or even reversed polarity on the analog input.
The ADC input on the Arduino does impose some restrictions on the source resistance (impedance). Those restrictions have mostly to do with rapidly changing signals so for your application I don't think those will matter.
I would put a 1uF capacitor across the 100K so the A/D has someplace to get it's charge from. Otherwise your readings may be very unsteady. If you wanted to get fancier, you could do it with a Rail-Rail, single supply Op Amp and put a real filter in the circuit.
I would put a zener diode in series with the divider for the following reason:
The voltage in the battery will probably/hopefully never go below a certain level, lets say 30V. This means that the measuring range of interest lies between 30 and 55V. With a 11:1 divider this gives an anlog input range of 2.72 to 5V which after AD conversion gives values 559 to 1023, a span of 464 units.
If you use a zener of 30V the divider has to handle 0 to 25V which means it should be a 5:1 divider. This gives you a full (theoretically) resolution of 1024 units over the voltage range of interest
A problem with adding a Zener diode in series is that the reverse breakdown voltage depends on the current. For a 1.1 megohm voltage divider, the current through the diode would be in the tens of microamperes range (far from the values at which Zener diode voltages are typically specified), so the voltage drop could depend rather strongly on the solar panel/battery combination. This could add significant nonlinearity to the overall voltage divider response and make calibration difficult. I would not recommend that approach.
To expand a bit on the source input impedance, it is possible that there will be problems with a 1.1 Megohm divider. The impedance of your suggested divider is the parallel combination of the 1M and 100K resistors, or about 90K, which is higher than the recommended value. But, you might be OK, so try it and see!
Quoting from section 23.6.2. of the atmega328 data sheet::
The ADC is optimized for analog signals with an output impedance of approximately 10 k? or
less. If such a source is used, the sampling time will be negligible. If a source with higher impedance
is used, the sampling time will depend on how long time the source needs to charge the
S/H capacitor, with can vary widely. The user is recommended to only use low impedance
sources with slowly varying signals, since this minimizes the required charge transfer to the S/H
capacitor.
rmetzner49:
I would put a 1uF capacitor across the 100K so the A/D has someplace to get it's charge from. Otherwise your readings may be very unsteady.
I second that, however the capacitor doesn't need to be as big as 1uF. A value of 0.022uF or larger will do.
jremington:
A problem with adding a Zener diode in series is that the reverse breakdown voltage depends on the current. For a 1.1 megohm voltage divider, the current through the diode would be in the tens of microamperes range (far from the values at which Zener diode voltages are typically specified), so the voltage drop could depend rather strongly on the solar panel/battery combination. This could add significant nonlinearity to the overall voltage divider response and make calibration difficult. I would not recommend that approach.
I agree.
jremington:
To expand a bit on the source input impedance, it is possible that there will be problems with a 1.1 Megohm divider. The impedance of your suggested divider is the parallel combination of the 1M and 100K resistors, or about 90K, which is higher than the recommended value. But, you might be OK, so try it and see!
It will be OK if either the capacitor is added, or a delay of about 10us or greater is added to the analog read code, between the selection of the correct input from the multuipexer and starting the conversion.
papaiatis:
Thank you! I think I'll use a 1MOhm and 100kOhm so that it would be a 11:1 ratio allowing me to measure voltage up to 55V which is probably more than enough. Both can be bought in any hardware shop.
How about circuit protection? Any diode or zener diode in the circuit?
If you do that you need to add 10nF or so of capacitance to the analog pin (to ground) to
lower the input impedance within spec. Analog input sources should be 10k or less impedance
for accurate readings. The capacitor does that and also rejects any RFI.
nilton61:
I would put a zener diode in series with the divider for the following reason:
The voltage in the battery will probably/hopefully never go below a certain level, lets say 30V. This means that the measuring range of interest lies between 30 and 55V. With a 11:1 divider this gives an anlog input range of 2.72 to 5V which after AD conversion gives values 559 to 1023, a span of 464 units.
If you use a zener of 30V the divider has to handle 0 to 25V which means it should be a 5:1 divider. This gives you a full (theoretically) resolution of 1024 units over the voltage range of interest
That won't work well, high voltage zener's have a big temperature coefficient and the
voltage also depends on the current in a very non-linear manner.
Measuring the current requires a shunt resistor and an op-amp in differential mode to
boost the small voltage across the shunt.
In fact there are modules available with both such a circuit and a voltage divider on board
which might be just the thing (although the ones I know of might be for too large a
current range as they are designed for monitoring RC model power consumption).
I simulated the circuit on the attached picture. Measurements were taken every whole volt from 30V to 55V and the results inserted i an excel sheet. A linear regression analysis as made on the 10 bit quantized vaules in order to simulate the readout values. The max error was 0.4% @30V 0,14%@38V 0,11%@39Vall other errors were 0.1% or lower.(average 0.05% when exluding 30V)
Also the much lower impedance of this circuit makes the AD converters job easier.
So you propose adding 0.4% error in order to improve resolution from about 1 in 500
to 1 in 1000, yet 0.4% is 1 in 250, which is larger than the improvement! And you haven't taken the largest source of error into account, the tempco of the diode. Doesn't make
any sense.