Hey all, I want to have an arduino monitor to show me the voltage of the battery on a motorcycle while it's running. I know that the stator can cause some noise while charging but will it be too much to monitor accurately? I was thinking I could sample the voltage 100 times, put it into an array, sort the array by value and then average the middle 25% of the values. I think that would give the most accurate display of voltage.
To read in the voltage I'm going to use a voltage divider and wanted some advice on resistor size. I want it to be accurate but use very little current. I think bike voltage can go up to as much as 16v at max rev so I was going to make my divider = 1/4 battery voltage (12v battery = 3v input, 16v rev = 4v input). For my resistor values I was going to make R1 = 30k and R2 = 10k which would draw around 4mA of current wasted, which is fine for this usage.
Does all of this sound plausible? Thanks for the input!
Yes it's more than plausible. It's quite a sedentary task for any arduino (your calculations seem quite sound). Of course there are plenty of other things you can get it to do at the same time. It's always useful to have a backup speedometer. Pop a sensor on the front forks and you're half way there. Sprinkle a few temperature sensors around and you could have another interesting piece of info. So many possibilities.
I already have a RTC, speedo (hall effect), I'm still working on gas gauge (pressure sensor off fuel line), and compass (not working at all, can only get ranges from 270 degrees to 350 when on a flat plane).
You won't get much value from the system voltage when the engine is running apart from knowing that the generator is working or not - which you probably already know from a light on the instrument cluster. It is not possible to isolate the battery voltage from the system voltage.
If your aim is to detect the state of charge of the battery you should measure the battery voltage after it has been completely unused for 12 or 24 hours.
This is going to be used on a KLR 650, and if you're not familiar, these bikes are great off road long distance motorcycles. Displaying the voltage of the battery will be helpful in notifying the user that there is an issue with their battery/charging system as soon as it becomes apparent. This information could be VERY helpful for someone who might be venturing out away from civilization for a few hours and needs to rethink their journey.
The KLR does not have a sophisticated instrument cluster.
magruder13:
Displaying the voltage of the battery will be helpful in notifying the user that there is an issue with their battery/charging system as soon as it becomes apparent.
That is what I was referring to, and I can see the value if there is no red charge warning light. But you don't need an accurate voltage reading for that. When charging it should be above 13v or maybe 13.5v (for a 12v system, pro rata for 6v I guess). Below 12.5v would probably mean that charging had failed. You could easily do some tests on your bike to determine the appropriate threshold voltage.
I've also been busy building a "Rally console" for my dirtbike that ships without any instrumentation what soever. What I've managed to do so far is temperature (Both ambient and oil) as well as speedometer.
I started with a Hall effect sensor as many Google results suggested but ended up with a reed switch setup that is far
more accurate. I used interrupts but needed to iron out the digital signal.In order to overcome the bouncing of the switch I started with a RC circuit - putting a resistor(10K) and capacitor(10uF) along with the switch.This helped a lot but the RISING signal still resulted in a sine wave so I added s Schmitt trigger and now it's spot on!
I will be adding the voltage divider to add a battery indicator. I also added led strip lights for effect. They cal either be
swotched ON or OFF or FLICKER - this is when we go through a town ship to make kids/etc aware of the bike...
In my experience, any warning of impending problem must be associated with something that grabs your attention.
In your case, a warning light, preferrably one that flashes brightly (red normally accepted as being on the immediate to do list) would do much much better than a digital readout one has to constantly check for fault levels. (end up riding up the back end of a truck)
You will find yourself constantly needing to check and decipher the reading as to whether it is good or bad and as shown in your first example with battery voltage going to 16v (never happen on a healthy system)In most instances a rider may never know what they are looking at but a big flashing red warning light definetely means something is not right.
Used to happen back in the 60's when young blokes would rip out the oil warning light and fit an oil gauge. There were quite a few engines blown up because of that one.
So as Robin2 says, a big red warning light, to monitor generator is the best you will do.
Battery you'll have to test with a different system as suggested.
Pretty easy to do with an LED and a zener.
Wow, lots of replies, and I don't want to make anyone feel bad, but I've already thought / done everything suggested.
Robin2: Normal value for the battery is 12.6v (vehicle off) and can get up to 14.5v when the vehicle is on. Using a 1/4 voltage divider, I'll still get .02v accuracy, perfect for what I want.
mulungu: I have a RCT (clock), ambient temperature, compass, speedometer (hall effect), and this will be the last piece (battery / charging system monitor). My hall effect works within a .2mph accuracy up to 120 mph (above top speed of bike). I didn't want to deal with anything mechanical, so I went with hall effect. Also, the speedo doubles as a trip meter. I might be also adding in a fuel gauge, haven't worked that part out yet though.
bluejets: I understand you're thought process but this is for users that know and understand what values their battery should be at. Some users will have different types of batteries that have different on/off values. Also some users might have updated stators / charging systems that will differ.
Your task is well suited to arduino.
With 22 to 27 V pairs of car batteries in a solar project, I subtract a fixed V through a zener and then have a resistor potential divider below that. 10k resistors seem to behave themselves ok near to a0 analog to digital inputs of the arduino. If you wanted to do what I do, that would be a 6 or 7.5V Zener and then a pair of 10kOhm to ground with the a0 connected at the middle of those two resistors [either directly or through a 1kOhm; the result is the same]
To set up a truncated median filter to operate on an array of 100 recent ad values is probably overkill. If you are using floating point voltage numbers, that is 4 bytes per value, so 400 bytes used, plus about ten more bytes for counters and the result, so 0.41 of 2kb used. I wouldn't bother with that type of filter, which is greedy for memory by comparison to maintaining a rolling average in a single floating point number and putting some if conditions around changing it to skip the buzz while starting the motorbike. Or rig a digital-read pin to skip doing battery V monitoring while the starter motor is on.
magruder13:
bluejets: I understand you're thought process but this is for users that know and understand what values their battery should be at. Some users will have different types of batteries that have different on/off values. Also some users might have updated stators / charging systems that will differ.
As far as I was aware you were looking for a charging system falure which will occur at the same voltage point given a 12v system regardless of what you have in the charging circuit.
As for charge states, in 40 years they haven't changed that much.
As I said above also, a warning light will be seen much more readily than constantly checking and deciphering a readout.
magruder13:
Robin2: Normal value for the battery is 12.6v (vehicle off) and can get up to 14.5v when the vehicle is on. Using a 1/4 voltage divider, I'll still get .02v accuracy, perfect for what I want.
When I suggested experimenting I meant that you need to check what the voltage is immediately after the charger stops. If there is little load on the battery it will stay close to 14.5v (well above 12.5v) for a considerable time. If there is a heavy load (perhaps the motorbike headlamp) it may stay up for a shorter period or it may fall below 12.5 almost instantly.
You need need to decide what you are trying to detect. The nice thing about the usual red warning light is that it detects the direction of flow of current rather than the voltage - the concept has been successful for a very long time.
I was planing on doing a smiliar project and - hopefully - will this year. Monitoring battery voltage is indeed crucial, as a faulty reg/rec or faulty wiring between stator and reg/rec can be monitored perfeclty via battery voltage. any sudden increase or decrease points to a fault in the charging system. A bright alert LED is the minimum you should get.
But I plan on adding other features: when battery voltage is low (e.g. in winter after several starting attempts) I plan on automatically shutting down aux lights (and switch from dual headlights to single headlights) and other non-essential equipment to conserve as much power as possible. That way I'll be able to facilitate charching and I can extend my riding range if the charging system fails. Always with the option to override everything.
Fuel gauge is always a good idea. On the other hand: I don't have one in my bike. I know my range and am fine with such an estimate. Compass and odometer is another thing I plan. And a Geiger counter (just for fun), a clock (essential!) and temperature (just like to when I'm approaching temps around freezing).
But currently haven't worked on anything yet as I'm still figuring out how to make a simple display waterproof without having to mount a big bulky and ugly box to my cockpit / handlebar. Ideas?
marcschneider:
any sudden increase or decrease points to a fault in the charging system
Monitoring the change is a good idea. But be careful to average the voltage over a reasonable time so the Arduino does not respond incorrectly to very short changes caused, for example, when a load switches on or off.
that is indeed true. Most of those classic failures due to corroded connections or old stators come over time. So you'll see a sudden increase/decrease over a long period anyway. And you should indeed look out for that.