Sunday, 20 January 2013

Measuring Voltage and Current

The main thing this system needs to do is measure the voltage of the batteries and the current going to and from them. This may sound simple, but isn't necessary so. As it is the main function of this device it deserves its own blog post.

At the moment I have two different approaches to measure the current that I am investigating:

There are pro's and cons to each approach, so I've got one of each sensor and will have a play with each of them to see how they go.

ACS714 Hall Effect Sensor

This sensor is good in that is is isolated from the current wire and there is no electrical connection between the sensor and the system being sensed. The sensors however can only measure up to 30A each way. My Sterling B2B charger can put in 50A which would overload this sensor. The sensor would not be damaged, but would just read a maximum of 30A. I have 3 batteries in parallel and so I could attach 3 separate sensors, one to each battery. This means a total of 50/3A or 16A would go through each sensor to each battery. I can then sum the current in software. This has the advantage that I could detect if there are any abnormalities in the batteries, such as a failed cell, that would cause one battery to take a higher/lower current than the others.

One of the main disadvantages of this sensor is that the current itself has to flow through the sensor. This means running a wire from the positive terminal of the battery to the sensor and then from the sensor to my main power distribution point and fusebox. The sensor seems pretty small and I'm not sure how it will like having 16A pushed through it for long periods of time.

The sensor outputs an analog voltage between 0 and 5v that corresponds to a current reading of -30A to +30A. The Arduino has 6 analog inputs that have a 10-bit analog to digital convertor (ADC) . This means it reports values of 0 to 1024. Whilst this will give us a current reading, I would still need a way to get a voltage reading. This is normally done using a pair of resistors to divide the voltage to an appropriate value to be read. In our case, by using, say a 10K Ohm and a 20K Ohm resistor we can scale a voltage of 0 - 15V to 0 - 5V to be read by the Arduino. This does however require us to get very accurate resistors. Another issue is that the Arduino's ADC relies on having an accurate 5v feed in order to accurate measure inputs. If the 5V feed fluctuates or is not exactly 5.00V then the readings from the ADC will be inaccurate.

INA219 High Side DC Current Sensor

This sensor is designed to read the very small voltage drop that occurs over a resistor when a current passes through it. This is the approach the Nasa BM-1 takes and any other system you see that requires a 'shunt' to be fitted. The advantage of this system is that it can be scaled to measure any current by using different resistance shunts. So I could measure 50A in/out of the whole battery bank by using a suitably sized shunt. The accuracy would depend on the accuracy of the shunt, but you can calibrate the sensor based on the resistance of the shunt, so I can measure the shunt resistance once it is installed and adjust accordingly.

This sensor communicates with the Arduino via I2C which is a digital protocol, rather than an analog signal. This means that we are not reliant on the Arduino's ADC to provide accurate readings. Multiple sensors can be attached to the same I2C bus should I want to take separate readings from each battery as above. This sensor also measures the voltage as well, which means we don't need to bother with a voltage divider as detailed above. A library has been created to read the INA219 sensor from an Arduino, which makes it very easy to interface with.

The INA219 is a very very small chip and way beyond my soldering skills to try and solder it directly. Luckily Adafruit have created a INA219 breakout board for it which makes it much easier to work with. The disadvantage with this board is that it has a 0.1 Ohm resistor already attached to it to measure the current. This means that it is only able to measure up to 3.2A. You can however un-solder the 0.1 Ohm resistor and run wires to an external shunt. So I have a 50A shunt on order, again from China via eBay. Once it arrives we will see how it works with the INA219.

1 comment:

  1. Did you get results on this project? I'm facing the same challenge. Regulating 2 solarpanels and 1 small wind turbine to keep my 80Ah battery ready for use in my summerhome.