How nice would it be if you could measure current and voltage of some power source. In my case for my RC plane, I'd like to know how much current the motor is drawing and what the battery voltage is.
To measure current, the theory used is that when current flows through a resistor, a voltage difference can be measured over that resistor (also known as
shunt). So we'd like to measure up to a 100 amps. The analog input pins can measure from 0 to 5 volt. So 0 amps would measure 0 volts and a 100 amps would measure 5 volts.
Some calculations with Ohms law gives us:
I=V/R => 100=11/R => R=11/100=0.11 Ohm
That is one tiny resistor that needs to cope with high currents... And how accurate would that be? Looking through some
RC forums, there was suggested to use copper wire. Copper wire has some resistance, so if you know the resistance per length, you can measure out the length of wire required. The RC guys really like to use a wire that gives you a voltage of 1 mVolt for 1 amp.
Anyway, for our purpose it does not really matter. Just keep your required range of amps, mapped to a measurable range of volts. And above all, we're not tied to 1 mVolt per amp, but we can calibrate the Arduino with our multimeter and use some magic factor in the code.
After I made a nice wire measuring the amps I wanted, it turned out the copper wire was more than 2 meter long. The Arduino has an option to change the measuring range of an analog pin from 0-5 volt to 0-1.1 volt, that is the internal voltage. (analogReference(INTERNAL);) This way, the length can be reduced by approximately a factor 5 and 30 to 40 cm of wire in a small model airplane is way better than 2 meter.
To measure voltage, a simple
voltage divider is used. The theory is that is current flows through a resistor, a voltage difference can be measured over that resistor. So, flowing from + to -, the voltage drops with each resistor. First the voltage should be brought down to acceptable levels for the Arduino, and then a smaller resistor is used to measure the voltage difference. The voltage of a battery is 11 volt (3S lipo).
The formula to use is:
Vout = Vin * R2/R1+R2 where Vin is 11 volt and Vout should be 1.1 volt so the Arduino can use the internal voltage as reference. For example R2=10KOhm and R1=90KOhm are nice values. With 100KOhm the current that will flow through those resistors is: I = V/R = 11/100.000 = 0.11 mAmps.
Again, accuracy is not very important because we can use a multimeter to calibrate and use some magic factor.
The values of R1 and R2 I took are easy to calculate with, but in reality more than 11 volts need to be measured. The values I took are R2=1KOhm and R1=100KOhm. So the maximum voltage we can measure with this shunt:
Vout = 1.1v = Vin * R2/R1+R2 = Vin * 1K/100K =>
Vin = 110v, which is more than enough.
I've combined these two schematics into one, which goes between the battery and electronic speed controller (ESC). The shunt is placed in the wire that runs to the ground of the battery. This because now the volt an amp meters have a common ground. This was only 3 wires are required instead of 4.
So with
my LCD screen working, I got these numbers to display on my LCD screen very easily. And I've also ordered a SD card holder, so I could turn my Ardiuno into a logger like
this, but I'll save that for another blog post.
Currently I'm figuring out how to measure the RPM of a brushless motor, so the most important motor parameters for a logger are covered. Actually, the "figuring out" part is done. Now I'm composing a list of components I want to order for all my great idea's! Somehow the list keeps growing, but I still want to finish my LED matrix clock first.