Logging data from a voltmeter to monitor a motorbike battery

Hello,

I'm a beginner in using Arduino. I have been reading some stuff here and there and haven't actually built anything yet. I do have a problem I have to solve with my motorbike and I think that the Arduino could help me diagnose it, so here I am.

The idea is pretty simple. I have to monitor the tension of the battery to see if anything strange, like polarity inversion, happens while charging. To do so, I would have to tape a multi-meter or voltmeter on the tank and keep an eye on it to see what happens. The an idea popped into my mind. What if I could have something record the data for me, so that when something weird happens I can simply look at the log?

Here are some questions:

  • is there a voltmeter shield/module that I can use, or would I have to build it my self?
  • in alternative, is there a small voltmeter that I could somehow hook to the Arduino?
  • My C is very rusty, but the programming part shouldn't be too hard, should it?

An ideal situation would be to have a very small LCD voltmeter/display that I can use to keep an eye on things while driving, while the arduino does its job behind the scenes. The display wouldn't be required though, as long as the logging is working.

So, here it is.

If you read this far, thanks for your time :slight_smile:

Cheers,

Gabe

That's doable....

The Arduino has an analog-to-digital converter (ADC) that can be used to [u]read voltage[/u].

You'll need a [u]voltage divider[/u] (2 resistors) to knock the voltage down to the 0-5V range and [u]protection diodes[/u] to protect the Arduino from unexpected spikes or negative voltages.

The Arduino can be damaged by voltages greater than +5V, or by negative voltages. That means reading a polarity reversal is tricky... But if the input goes negative and the protection diodes kick-in, you'll read zero and that's a pretty clear indication of a problem. (It might be normal to get negative spikes from the starter when starting.)

Hopefully, it won't be necessary, but it's possible to [u]bias the input[/u] to read negative voltages. The Arduino runs at 5V, so you'd typically bias it at 2.5V. Then, you subtract-out the bias and scale the reading, so for example you could read -20V to +20V. (That requires sort-of a "3-way voltage divider".)

The Arduino has limited memory so you can't really "graph" the voltage, but it's simple to set-up minimum & maximum variables and then update those variables when a new minimum/maximum is exceeded. i.e., You initialize "Max" at zero and then the 1st non-zero reading changes that value. "Min" is set to an unrealistically high value, so the 1st real-reading changes that value.

You could also capture the time when these minimum/maximum values happen. The easiest thing would be to capture the relative time (rather than time-of-day) because millis() will return the number of milliseconds since the Arduino was started/reset. Then, your software or a calculator can convert to hours & minutes.

Prodeguerriero:
I have to monitor the tension of the battery to see if anything strange, like polarity inversion, happens while charging.

I agree with all that @DVDoug has said.

But I think there some basic questions to consider...

Why should anything strange happen?
Battery charging for vehicles is a well established activity.

What could you do even if something strange did happen?
Reading the log a few hours after the motorbike burst into flames would be somewhat academic.
(even if the fire did not destroy the Arduino)

Is the probability of something going wrong sufficient to justify the cost of the Arduino?
if the probability is 1 in a 1000 then your Arduino investment would need to be preventing
a £20,000 loss.
Maybe the money would be better spent improving the charging system.

After 327 days without incident will you even bother to check the log?
I know I wouldn't

...R

I think that the probability of a polarity inversion occurring whilst charging is very low.

Perhaps you aught to ask Schrödinger's cat what his/hers opinion is on this matter.

DVDdoug:
That's doable....

...

Thanks!

Robin2:
I agree with all that @DVDoug has said.

Thanks!

Why should anything strange happen?
Battery charging for vehicles is a well established activity.

Sorry, I wasn't clear in explaining what I need the tool for, but I thought it wasn't very important. Something strange is happening, I'm trying to pin point the source of the issue before starting to replace parts. I have to monitor it so that I don't throw money in the trash can buying something I don't need to. :wink:

Is the probability of something going wrong sufficient to justify the cost of the Arduino?
if the probability is 1 in a 1000 then your Arduino investment would need to be preventing
a £20,000 loss.
Maybe the money would be better spent improving the charging system.

Well, assuming that I decided to be on the safe side and change the whole alternator/stator/rectifier/battery set, I would be spending at least 300€.
A cheaper diagnostic tool which would also be a good side project sounds pretty good to me. If I am doing the math right, you are telling me I won't have to invest more than 40€ into this, correct?

After 327 days without incident will you even bother to check the log?
I know I wouldn't

I am not talking about an asymptomatic behavior here, I do notice when the weirdness happens, I just need to understand what is causing it. Not being able to reproduce such weirdness is my biggest problem, so I need to be ready to read the data when I need to. It would be much easier to have a computer do it for me.

What could you do even if something strange did happen?
Reading the log a few hours after the motorbike burst into flames would be somewhat academic.
(even if the fire did not destroy the Arduino)

Even though I didn't explain myself too well and you might have misunderstood what I was going for, I don't see the point in writing this at all. Does every issue you run into go from working 100% to havoc and destruction or do you sometimes manage to fix something before it is completely destroyed? :grin:

I really appreciate your concerns for my diagnostic methods, but I think my game plan is pretty solid. I do need help with the Arduino side of things though, so thanks for taking the time to read/write! :smiley:

JohnLincoln:
I think that the probability of a polarity inversion occurring whilst charging is very low.

That is true, but low is not nil and my CBR is known for having a kinky alternator/rectifier set. The battery is not too old and is behaving strangely, so I'd rather investigate further instead of changing it again and finding myself with the same issue soon.

Perhaps you aught to ask Schrödinger's cat what his/hers opinion is on this matter.

The answer would probably be something along the line of "you won't know until somethings explodes" >D

Don't know about others, but I tend to find diagnosis difficult on the descriptions of " weird, kinky and strange behaviour" as related to anything electrical.

Since you are about to apply logic to an Arduino program, I think you will have problems writing code to cover the above.

bluejets:
Don't know about others, but I tend to find diagnosis difficult on the descriptions of " weird, kinky and strange behaviour" as related to anything electrical.

Since you are about to apply logic to an Arduino program, I think you will have problems writing code to cover the above.

Duly noted. I don't recall asking for help in diagnostics though. What I'd like to be helped with is the tool, not the use. I do appreciate your concern though, so, to ease your mind:

Weird: sometimes, after driving around and stopping I find that the battery doesn't have enough juice to start the bike anymore. It is weird because the battery is supposed to be charging while the bike runs, not draining.

Kinky: the alternator/rectifier set of my CBR 929 is known for having issues. Sorry if I used a word that seems too colloquial. English is not my native language and it might be an issue on my part if I misled you with wrongly placed colloquialism.

Strange behavior: when something does not behave how it supposed to, I usually say it is having a strange behavior. I don't know about others, but I don't like jumping to conclusions and I keep a vague profile until I am sure where the issue is.

I'll try to put all the logic I can muster into this program. I am sure that my knowledge of python and javaScript scripting is going to help me out.




I am new here and I don't like being the jerk around town, so if I am doing something wrong please state it out loud. I want to be clear though, so here it is.

What I need is some help to build a voltmeter that does data logging on a 12V motorbike battery.
DVDdoug has given me a very good series of suggestions, which I am going to follow. If anyone has some more insights, it would be greatly appreciated. I am a newbie with Arduino so I will probably be back for some more help. As I said my C programming is rusty.

What I do not need is:

  • witty comments
  • paternalism
  • lessons on how to diagnose stuff, I have the workshop manual for that
  • anything not relevant to the project in question

So please, if you don't have anything useful to add to DVDdoug's post, refrain from posting. Thanks!

Wasn't trying to be nasty, just quoting the obvious when it comes to programming requirement for the Arduino.

With that in mind, a tip might be to run the Arduino from a seperate supply from the bike system as it appears unreliable and may give false readings.

bluejets:
Wasn't trying to be nasty, just quoting the obvious when it comes to programming requirement for the Arduino.

Let's call it a communication hiccup :wink:

With that in mind, a tip might be to run the Arduino from a seperate supply from the bike system as it appears unreliable and may give false readings.

Good thinking. What about a battery pack? I don't know which one though. I guess I'll think about it once I have the main board up and running. :smiley:

One issue you're going to have to work out is that the voltage at the battery is going to sag at engine idle speed. I don't know how typical this is, but with my bike, the alternator output at idle is less than the power drawn by the lights and other load. The result is that the battery is not charging at idle and is, in fact, slowly being drained. In normal operation this isn't an issue because the battery is charged when the engine is running above idle.

The resultant problem is that the Arduino has limited memory to log voltage readings and there will be instances of "battery not charging" during normal operation even if the charging system is operating as designed. With a voltmeter display you would recognize that the electrical system running at about 12 volts at idle and 14 volts at higher RPMs is normal, getting that sort of intelligence into a computer program isn't so easy.

Nice to add features to your iron horse, but aren't you overthinking it a bit.

It seems you have a "problem" with your bike.
Something that has to be analysed and fixed.

A simple LED display could tell you instantly when something is wrong.
Leo..

I have now had three alternator failures on my boat (which has 2 alternators) and the only diagnostic tool I needed was a cheap digital multimeter, my eyes and a knowledge of how they work. In the first 2 cases the rectifier needed to be replaced. In the third case (recently) the brushes were worn out. As I was not sure what the problem was this recent time I bought two complete repair kits for £50 so I still have lots of parts for future failures.

How do you know that "Something strange is happening". What symptoms have you noticed.

To my mind the best diagnostic tool you could get (assuming you already have a multimeter) is an oscilloscope. You could program an Arduino as something equivalent to a 'scope - but it would not be nearly as versatile. And you will always wonder if the problem is with your bike or your code.

...R

For logging data I'd suggest an external EEPROM, providing more space than the interal EEPROM. The data can be overridden (circular buffer), so that the EEPROM holds the most recent readings. For huge amounts of data a SD card is another option.

Add means to start and stop logging, and code to dump the logged data to your PC (Serial to COM port). The start/stop conditions can come from switches, or from logic that detects a voltage loss of the battery, or when the motor is started or stopped. I'm not sure, though, whether you can start/stop logging manually while driving.
An LCD display for the current values can be helpful, of course.

I'm not sure whether the battery voltage (and time) represents sufficient information for your bug hunt. The RPM may be of interest as well, in detail for the logging start/stop logic.

MrMark:
One issue you're going to have to work out is that the voltage at the battery is going to sag at engine idle speed. I don't know how typical this is, but with my bike, the alternator output at idle is less than the power drawn by the lights and other load. The result is that the battery is not charging at idle and is, in fact, slowly being drained. In normal operation this isn't an issue because the battery is charged when the engine is running above idle.

The resultant problem is that the Arduino has limited memory to log voltage readings and there will be instances of "battery not charging" during normal operation even if the charging system is operating as designed. With a voltmeter display you would recognize that the electrical system running at about 12 volts at idle and 14 volts at higher RPMs is normal, getting that sort of intelligence into a computer program isn't so easy.

Mine seems to run at around 12.8/12.9 at idle, it gets to 14.5 at 5000rpms, which is on point with the workshop manual.

I would be happy with monitoring it only at startup to begin with, which is when some of the strangeness appear to manifest itself. This way I would be able to read the voltage before starting up the bike, the drop at start-up and then the charging tension while warming up the engine. I could just hook up a voltmeter and doing some logging by hand, but where's the fun in that! :stuck_out_tongue:

Wawa:
Nice to add features to your iron horse, but aren't you overthinking it a bit.

It seems you have a "problem" with your bike.
Something that has to be analysed and fixed.

A simple LED display could tell you instantly when something is wrong.
Leo..

This is what my brother said. I know I am overthinking it, but I was looking for an excuse to build something :stuck_out_tongue:
I was also hoping to find a small LED voltmeter, like the one you linked, that could be somehow used with something that would do the data logging.

Robin2:
I have now had three alternator failures on my boat (which has 2 alternators) and the only diagnostic tool I needed was a cheap digital multimeter, my eyes and a knowledge of how they work. In the first 2 cases the rectifier needed to be replaced. In the third case (recently) the brushes were worn out. As I was not sure what the problem was this recent time I bought two complete repair kits for £50 so I still have lots of parts for future failures.

How do you know that "Something strange is happening". What symptoms have you noticed.

To my mind the best diagnostic tool you could get (assuming you already have a multimeter) is an oscilloscope. You could program an Arduino as something equivalent to a 'scope - but it would not be nearly as versatile. And you will always wonder if the problem is with your bike or your code.

...R

Well, two things happen and I still haven't been able to reproduce them. Therefore the need to log (at least in my mind).

  • I found the battery not on top condition a couple of times (after 7/10 days of not being used you can definitely tell that the alarm system has drained power), but still strong enough to start it. I used it, stopped, tried to start it up again only to find out that somehow the battery was in worse condition than before, as in not able to start the bike anymore.
  • Every now and then, when pushing the start button the bike has a 1sec-long moment of indecision, where power is clearly being drawn (I see the dashboard dimming) but the relay doesn't click and the starter doesn't move. After that, everything goes smoothly.

DrDiettrich:
For logging data I'd suggest an external EEPROM, providing more space than the interal EEPROM. The data can be overridden (circular buffer), so that the EEPROM holds the most recent readings. For huge amounts of data a SD card is another option.

Add means to start and stop logging, and code to dump the logged data to your PC (Serial to COM port). The start/stop conditions can come from switches, or from logic that detects a voltage loss of the battery, or when the motor is started or stopped. I'm not sure, though, whether you can start/stop logging manually while driving.
An LCD display for the current values can be helpful, of course.

I'm not sure whether the battery voltage (and time) represents sufficient information for your bug hunt. The RPM may be of interest as well, in detail for the logging start/stop logic.

Thanks. Reading the rpms would be pretty neat, but would require more data reading. I wouldn't know where to get it though. :stuck_out_tongue:


Thanks for all the help. Bottom line it looks like I might be better of with just an LED voltmeter stuck underneath my nose for a while and see what happens. My hands are itching for some Arduino work though. Damn indecision.

Oh, just so you know, I have bought a battery charger/maintainer, which should help me a bit by keeping the battery always charged. I was also thinking of buying a new Lithium battery, but I wanted to be sure everything else works. I wouldn't want to fry it.

P.S. The bike is almost 15 years old. There is that too to keep in mind. :stuck_out_tongue:

Prodeguerriero:

  • I found the battery not on top condition a couple of times (after 7/10 days of not being used you can definitely tell that the alarm system has drained power), but still strong enough to start it. I used it, stopped, tried to start it up again only to find out that somehow the battery was in worse condition than before, as in not able to start the bike anymore.
  • Every now and then, when pushing the start button the bike has a 1sec-long moment of indecision, where power is clearly being drawn (I see the dashboard dimming) but the relay doesn’t click and the starter doesn’t move. After that, everything goes smoothly.

If you only use the bike occasionally it is easy to check if the battery is charging properly.

Measure the voltage at the battery while the engine is running. It should be about 14v for a 12v battery (half for a 6v battery. If it is lower you can suspect an alternator problem. But it is unlikely to be an alternator problem because the battery does seem to recharge.

To check the battery is fully charged, after a run disconnect everything (including the alarm) and measure the voltage at the battery 12 hours later. For a 12v battery it should still be at or above 12.6v. Maybe do it again 24 hrs after that.

To check that the battery can produce enough current for the starter (old batteries fail this test) you need a high-current shunt which is not a normal DIY tool. Take it to a battery shop with the tool. The test just takes a few seconds.

To check for an unreasonable drain on the battery when things are supposed to be off just measure the current flowing from the battery. A simple multimeter with a 10 amp range should be fine - you are hoping for a current drain of 1 amp or less.

Your second symptom sounds like a possible bad connection somewhere. It certainly would not lead me to suspect the Alternator - if anything it would lead me to exclude the alternator as a culprit. The poor connection might also cause poor charging. (Indeed I am suffering from a similar problem myself at the moment and have so far been too lazy to sort it out)

With apologies to those who thought they were on the Arduino Forum

…R

Prodeguerriero:
Every now and then, when pushing the start button the bike has a 1sec-long moment of indecision, where power is clearly being drawn (I see the dashboard dimming) but the relay doesn't click and the starter doesn't move. After that, everything goes smoothly.

You may have a problem with the starter, starter relay, or the power cables. When the relay doesn't switch properly, it may not only prevent starting, but it also may keep the starter powered when it shouldn't. I'd monitor the starter voltage, whether it's properly turned on and off when you start the engine.

Robin2:
Measure the voltage at the battery while the engine is running. It should be about 14v for a 12v battery (half for a 6v battery. If it is lower you can suspect an alternator problem. But it is unlikely to be an alternator problem because the battery does seem to recharge.

As per workshop manual, it supposed to be anything above 12.3 at idle and not over 15.5 at 5000 rpm.
As I said before, mine seems to run at around 12.8/12.9 at idle, it gets to 14.5 at 5000rpms, which is on point with the workshop manual.

The doubt I have, given that I am not too experienced with alternators and rectifiers, is this: what if any of the two parts acts up every now and then (the rectifier might simply stop rectifying or, even worse, inverse the polarity; the alternator might have one of the three phases acting stupid)?
If you tell me that this is not possible and when they fail, they fail, I'll take your word for it and put my mind at ease :grinning:

To check the battery is fully charged, after a run disconnect everything (including the alarm) and measure the voltage at the battery 12 hours later. For a 12v battery it should still be at or above 12.6v. Maybe do it again 24 hrs after that.

Done that too. It seems to stay around 12.9, which per workshop manual would be a little below spec (it says 13-13.2 ), but it doesn't get to 13 even after charging it, so I guess it is good enough (or maybe the battery sucks to begin with)

To check that the battery can produce enough current for the starter (old batteries fail this test) you need a high-current shunt which is not a normal DIY tool. Take it to a battery shop with the tool. The test just takes a few seconds.

I'll try that. Thanks.

To check for an unreasonable drain on the battery when things are supposed to be off just measure the current flowing from the battery. A simple multimeter with a 10 amp range should be fine - you are hoping for a current drain of 1 amp or less.

I checked for dispersion and there seems to be none, but I could see how much the alarm system is draining. It is an old unit and it tends to suck a lot of power.

Your second symptom sounds like a possible bad connection somewhere. It certainly would not lead me to suspect the Alternator - if anything it would lead me to exclude the alternator as a culprit. The poor connection might also cause poor charging. (Indeed I am suffering from a similar problem myself at the moment and have so far been too lazy to sort it out)

Agreed.

With apologies to those who thought they were on the Arduino Forum

I second the apologies. Forgive me! :smiley:


I just bough this (EU version): http://www.geniuschargers.com/G1100. Let's see what happens.

Thanks again for the help!

The doubt I have, given that I am not too experienced with alternators and rectifiers, is this: what if any of the two parts acts up every now and then (the rectifier might simply stop rectifying or, even worse, inverse the polarity; the alternator might have one of the three phases acting stupid)?
If you tell me that this is not possible and when they fail, they fail, I'll take your word for it and put my mind at ease

If it were my project I would discount that as a possibility. The usual failure of a rectifier is a diode failure which will show up as a low voltage at the output. From what you have said there is no evidence of that.

Batteries have a finite but unpredictable life. As the alarm is constantly drawing power but you don't use the bike every day the battery may be spending significant periods of time below full charge. You may just have got to the stage where the battery's capacity if only just able to meet the demands of the alarm and retain enough "kick" for one start.

But I would investgate carefully to make sure the whole problem is not due to a poor connection somewhere - maybe a poor earth connection. A faulty starter switch or starter solenoid are other possibilities.

And, I nearly forgot, worn brushes in the starter motor can give the hesitant start symptom.

...R