Sunday, 20 January 2013

Hardware Needed

To build this I'm going to be using the Arduino platform. This is a microprocessor platform with a very big community online and lots of tools and accessories. There are a number of 'official' Arduino boards (e.g. the Arduino Uno or Arduino Leonardo) that are developed, plus a whole load of 3rd party compatible boards. they all share a standard shape so that additional boards called 'shields' can be stacked on top. Shields include things like relay boards, wireless boards, motor driver boards, etc.

I'm currently prototyping with an Arduino Uno as that has a USB port and can be easily plugged in to my laptop and programmed. For the actual system I put into the van I'm going to build it on a more 'barebones' board that is cheaper and uses less power.

The additional items needed to be added to a base Arduino to provide the functionality I need:

  • A Real Time Clock (RTC) -- needed to be able to record the current time and date for each voltage and current reading
  • A SD Card reader -- needed to have somewhere to write the readings we are taking from the batteries
  • A way to measure the current being drawn
  • A way to measure the voltage of the batteries
  • A way to measure the temperature of the batteries
I am looking at using a Xino Basic as it is very cheap (£7.68 including the voltage regulator, processor and VAT) and has a small prototyping area directly on the board onto which I should be able to attach the RTC, SD card reader, and sensors.

I've ordered a RTC (£1.73) and a SD card reader (£1.24) from eBay. Both are coming from China and so will take a month to get here, but at that price I couldn't resist. To measure temperature I'm using a Dallas Semiconductor DS18B20 sensor. This is a digital temperature sensor that uses a '1-wire' bus. This means multiple sensor can be daisy chained together on the same pair of wires.

As for measuring voltage and current... that is worthy of a whole separate post....

Battery Terminal Voltage

One of the main measurements you can take of a lead acid battery is measuring the voltage across the terminals. The battery is nominally called a 12 volt battery, but the voltage across the terminals varies quite a bit. Depending on the exact battery type, a fully charged battery is 12.8v and is empty at around 11.8v. When on charge it can go up as high as 14.4v. So being able to measure the battery voltage to an accuracy of 0.1v is pretty important.

To make things more complicated, a lead acid battery has an internal resistance that varies with the state of charge. This means that the voltage measured on the terminals varies with the current being drawn from the battery. Ohm's law states that voltage = current * resistance. And so as the current increases the voltage drop over the internal resistance increases.

So your battery might say it is 12.5v, which might mean that it is about 70% charged with no load on it, or it might be 100% charged, but under a load of maybe 5-6 amps.

So in an ideal world the only way to get a true reading of the state of charge of a battery is to take a reading when it has been sat still for several hours with no charge going in or out ('at rest'). However in the general life of a battery in a motorhome this ideal scenario is very unlikely. The battery is constantly under a load (e.g. the fridge compressor kicking in every 10 minutes or so). Or the solar panels are putting some charge in.

There are two general ways to try and monitor the state of the battery:

  1. Counting the current going in and out (coulomb counting)
  2. Monitoring the raw voltage very closely
The Nasa BM-1 is an example of the first approach. It monitors the current very frequently (maybe many times per second) and keeps track of the current drawn over time. If you have a 100Ah battery and the BM-1 monitors that you draw an average of 2 amps over 24 hours then it knows you have drawn 48 amp-hours (Ah) and so have drawn about half of energy out of the battery. In most cases you don't want to go below around 50% repeatedly from a leisure battery otherwise you will shorten it's life.

To make matters even more complicated there is an effect called Peukert's law which states that the greater the current you draw from the battery, the lower its apparent capacity is. This is why proper leisure batteriers give several 'capacities' depending on how much current is drawn from them. This is normally expressed as a fraction of the total capacity. e.g they may say a 'C/20 capacity of 115Ah' This means this if you draw the capacity of the battery (115Ah) over 20 hours (ie. 5.75A) then it will be a 115Ah battery. If, instead, you draw the total capacity over 5 hours, C/5, ie 23 amps, then is will appear more like a 90Ah battery.

So in short, the greater the current you draw from the battery, the smaller the effective battery capacity.

One battery monitor which doesn't use coulomb counting is the SmartGauge. This *just* monitors the battery voltage and from there attempts to mathematically model the battery and estimate the state of charge. To be honest, it sounds like a good idea, but again, as it doesn't monitor the current being drawn I can't see how it can accurately determine the state of charge of a battery under load.

Oh, and if that is not complicated enough, temperature also plays an effect. The ideal temperature for a lead acid battery is 25 degrees C. If the battery is used in temperatures lower than that then the capacity appears smallers. If above that then the capacity appears greater -- but the battery's life will be shortened by higher temps. Think about how your car battery has a harder time starting the car/van when it is cold. This is why.

A battery at 0 degrees C will only 90% of that of one at 25 degrees.

There is a large number of research papers out there that try to formulate ways to estimate the terminal voltage of a lead acid battery under load. I'm hoping to be able to understand some of them and try and use some of the equations in this project.

Battery Chemistry

The idea of this project is to be able to monitor the leisure batteries in my motorhome. These batteries run things like the fridge, lighting, water pump, etc in the van. It also supplies power to the heater (a diesel-fired Webasto Thermotop) for the water pump, glow plug etc.

There are 3 x 115 Ah leisure batteries connected in parallel giving me a 345Ah 12V battery bank. This is charged by either a 64W solar panel on the roof and/or a 50A Sterling Battery to Battery charger that charges the batteries when the engine is running.

So first to mention, lead acid batteries are pretty much the oldest form of battery type and have stood the test of time well. They are fairly robust (compared to battery chemistries like Lithium Polymer), and fairly forgiving of abuse. That said there is accepted best practise with them, and by using them properly you can extend their life and performance significantly.

Dealing with Lead Acid batteries though is quite a complex issue when you get under the covers. Trying to answer seemingly simple questions such as 'how much charge do I have left?' or 'How much longer until my batteries are empty?' are actually very complex and dependant on a number of factors such as temperature and current load on the batteries.

I am *not* an expert in this, and don't profess to be. I've done a fair bit of reading on the subject and do think I know what I'm talking about, but please feel free to correct me at any point! I'm also not aiming to get a 100% accurate answer. I want an answer that is 'good enough' but at the same time I want a reasonable confidence that the answer is fairly accurate.

And so it begins

And so it begins.... this is an attempt to build an Open Source battery monitor for my motorhome. So why do I want to do this? Several reasons: cost, flexibility, and... just for interest.

The idea is to build something akin to the NASA BM-1 battery monitor. This is a unit that retails in the UK for around £95 incl VAT. So I'm wanting to build something that is cheaper than that.

Three specific things I want to be able to do with this unit, which you can't with the BM-1:

  1. Output the voltage, current and temperature readings real time via a serial port (so it can interface with another general motorhome control project I'm working on)
  2. Record the voltage, current, and temperature to some kind of storage (an SD card most likely) every few seconds so that the data can be subsequently graphed on a computer to get a better idea of battery performance.
  3. Be able to set the meaning of 'empty' for the battery. The BM-1 tells you what the state of charge is as a percentage, but with lead acid batteries you don't want to take them down below 50% state of charge regularly. So when the BM-1 says 50% left, does that mean 50% until the battery is half empty, or 50% until the battery is at 0% and damaged.
I'm going to be building this on top of an Arduino-based system. No doubt there will be mistakes along the way and this might end up costing me more than a BM-1 in the process of learning, but hopefully the end result will be something that can easily be replicated by anyone else.