EcoModder.com

EcoModder.com (https://ecomodder.com/forum/)
-   OpenGauge / MPGuino FE computer (https://ecomodder.com/forum/opengauge-mpguino-fe-computer.html)
-   -   new feature idea: battery voltage (https://ecomodder.com/forum/showthread.php/new-feature-idea-battery-voltage-15654.html)

meelis11 01-03-2011 07:29 AM

new feature idea: battery voltage
 
Hi,
has this idea been discussed before? At least I haven't seen it.
Anyway, I would like to see battery voltage in MPGuino and started searching how to measure 12V battery voltage (max should be 15V I think) and found this link and some other voltage divider pages.
http://www.clarenceho.net:8123/blog/...test-voltmeter

I am going to build it, probably It even does not need extra input to mpguino - I am going to measure 12V input voltage before voltage regulator. Voltage regulator signal would be used as Vref :)
extra parts needed: 2 resistors and some wire :P
I am choosing resistors to make divide-by-three divider, so signal to atmega input is 0-5V
What ohms should I choose? 10K and more I think?

Also I am going to add coolant temperature to this screen (needs extra input pin) along with liters/hour and RPM
new screen will be "Car sensors" or similar.

Meelis

bobski 01-07-2011 06:01 PM

An alt with a bad voltage regulator can hit 20V+. That doesn't happen often, but it would suck to add your 'duino to the repair bill. I would go for divide-by-5 at least. That should give you a 0-25V range with 0.024V steps. Way more precision than necessary.

meelis11 01-22-2011 06:03 AM

Update: My mpguino is showing battery voltage :)

FalconFour 02-12-2011 03:47 AM

Congrats! Care to share some pics for us drooling geeks? :D

meelis11 02-14-2011 04:58 AM

I can make some pics to show how it is installed but meanwhile that battery voltage is not hard to imagine how it shows on LCD display.
It is like "V 12.21" :)

I have modified format function to replace leading zeroes with spaces - instead "012.34" it shows " 12.34"

Joenavy85 02-14-2011 07:01 AM

Quote:

Originally Posted by bobski (Post 213736)
An alt with a bad voltage regulator can hit 20V+. That doesn't happen often, but it would suck to add your 'duino to the repair bill. I would go for divide-by-5 at least. That should give you a 0-25V range with 0.024V steps. Way more precision than necessary.

i would suspect that if the voltage regulator went out that this mod wouldn't really matter, your just modifying it to display the voltage, it would still be exposed to a voltage spike even if it didn't display it

bobski 02-14-2011 10:16 AM

Quote:

Originally Posted by Joenavy85 (Post 220335)
it would still be exposed to a voltage spike even if it didn't display it

Yes, it would see the increased voltage on the power supply connections, but that would be taken care of by the MPGuino's on board voltage regulator. It's a simple linear regulator so the excess voltage would be dissipated as heat. The additional heat could still cause problems, but it wouldn't immediately damage anything.
The inputs on the other hand are unregulated and designed for TTL-level input - 0 to 5V. A divide-by-3 voltage divider would turn that range into 0-15 volts, which a malfunctioning alternator can exceed. It's entirely possible the inputs can handle voltages in that range without damage, but if we can avoid such an occurrence by simply choosing different resistor values, why take the chance?

glug 03-21-2011 12:18 PM

I think this is a great idea. My old truck sometimes likes to energize the fuel pump just for fun, and it drains the battery. It'd be nice to get some warning when it is in that "mood".

I can imagine unwelcome potential consequences from coupling the raw 12v to the analog inputs of the arduino. I'm not sure voltage dividers would be sufficient. I also want to minimize pin use, and I'd like to free up some pins from the original design.

Thinking about features...

I can see two voltages that would be useful - The running voltage, which would reflect alternator output, etc (call it "running volts", RV). And the lowest voltage from the battery while the vehicle was off ("cold volts", CV).

The CV code would need to ignore the drop in voltage that occurs at startup.

An option could be added to display CV at startup. Maybe it would periodically flash on the display for the first 60 seconds after startup, reducing in frequency over time, and also display on a diag screen?

We might have an option to store the average RV, and flash an alert if it seems low?

It might be neat to have optional code to track a voltage drain over time by monitoring CV. So we might monitor the decrease in CV per hour, and report a voltage drop per hour, or per day.

UFO 03-21-2011 02:13 PM

Quote:

Originally Posted by bobski (Post 220358)
Yes, it would see the increased voltage on the power supply connections, but that would be taken care of by the MPGuino's on board voltage regulator. It's a simple linear regulator so the excess voltage would be dissipated as heat. The additional heat could still cause problems, but it wouldn't immediately damage anything.
The inputs on the other hand are unregulated and designed for TTL-level input - 0 to 5V. A divide-by-3 voltage divider would turn that range into 0-15 volts, which a malfunctioning alternator can exceed. It's entirely possible the inputs can handle voltages in that range without damage, but if we can avoid such an occurrence by simply choosing different resistor values, why take the chance?

Just clamp the input pins to the power rail with diodes. Then you set your divider to what you need for nominal operation.

bobski 03-21-2011 04:58 PM

Quote:

Originally Posted by UFO (Post 226717)
Just clamp the input pins to the power rail with diodes.

Sounds safe. :/
Maybe if you use high value resistors for your divider. Low values might pass enough current to out-feed the power regulator. If the regulator can basically run backwards, that might not be a problem. If it can't, you'll end up with greater than 5V as VCC.
Also, the forward bias voltage of the diode would mean the input hits 5.7 volts (or so, depending on the diode) before it starts clamping down.

UFO 03-21-2011 06:34 PM

Quote:

Originally Posted by bobski (Post 226756)
Sounds safe. :/
Maybe if you use high value resistors for your divider. Low values might pass enough current to out-feed the power regulator. If the regulator can basically run backwards, that might not be a problem. If it can't, you'll end up with greater than 5V as VCC.
Also, the forward bias voltage of the diode would mean the input hits 5.7 volts (or so, depending on the diode) before it starts clamping down.

Low resistor divider values would be mistake - they would load your source and you might not get an accurate reading. And circuits that run on 5.0V generally have absolute maximums well above 6V, so a diode drop above 5.0V is not a big concern. If you could handle the leakage current, Shottky diodes have very low drops, they might be a good option.

mcmancuso 03-29-2011 03:54 PM

can someone post a simple wiring diagram of what exactly was done here? And maybe an example of the code added? I mean really, what's the idea of posting hey I got mine to do this! and then not posting anything substantial on how you did it?

glug 03-30-2011 12:25 PM

I don't think we've found a safe way to do it yet.

Another thought - maybe the 12v could be monitored via the analog input for the buttons. That way, it wouldn't tie up another input.

bobski 03-30-2011 12:41 PM

Quote:

Originally Posted by glug (Post 228858)
I don't think we've found a safe way to do it yet.

A 5 to 1 (or thereabouts) voltage divider consisting of 2 resistors should work fine.

Quote:

Originally Posted by glug (Post 228858)
Another thought - maybe the 12v could be monitored via the analog input for the buttons. That way, it wouldn't tie up another input.

I guess you could use the battery voltage signal as the pull-up for one of the button lines. You wouldn't be able to monitor the voltage while the button is actually being pressed, but that shouldn't be a big deal. Also, very low supply voltages (unlikely to occur) could be mistaken as a button press.

glug 03-31-2011 02:04 PM

Quote:

Originally Posted by bobski (Post 228864)
A 5 to 1 (or thereabouts) voltage divider consisting of 2 resistors
I guess you could use the battery voltage signal as the pull-up for one of the button lines. You wouldn't be able to monitor the voltage while the button is actually being pressed, but that shouldn't be a big deal. Also, very low supply voltages (unlikely to occur) could be mistaken as a button press.

I wasn't sure if there would be spikes and noise that might be a complication if the 12v vehicle path is tied to an analog input, etc.

I'd guess the drop in voltage due to the starter would also be a gotcha. The code would probably need to detect that, to avoid false button triggers. Configuring the voltage dividers in a fairly narrow range would probably help reduce false triggers.

The more inputs that are free for pressure, temp, etc, the better.

mcmancuso 03-31-2011 02:24 PM

That's a good idea, most cars won't start if battery V is less than 10V or so, I know a Metro's computer needs at least 9V to run. You could essentially ignore any voltage below 10V or so since if your voltage is below that you will know it via less technical means.

bobski 03-31-2011 03:54 PM

Yep. You could set the minimum even lower if you wanted to be able to diagnose bad battery cells or something; 5V maybe? That would be 1V after the divider, or 200 or less when read in code.
Code:

if(analogRead(pin#) < 200) {doButtonAction;}
else {batteryVoltage = analogRead(pin#) / 40.92;}


meelis11 03-31-2011 05:54 PM

Here is my working function:
Voltage divider ratio could be bigger but I had these resistors and it is working.
* correct R1 and R2 value to resistor values you use. For calibration, you can fine-tune these numbers
* you also must define voltagePin with correct pin number


Code:

#define voltagePin  2

unsigned long batteryVoltage(void){
  float vout = 0.0;
  float vin = 0.0;
  float R1 = 21500.0;    // !! resistance of R1 !!
  float R2 = 9500.0;    // !! resistance of R2 !!
  int value = 0;

  value = analogRead(voltagePin);
  vout = (value * 5.0) / 1024.0;
  vin = vout / (R2/(R1+R2));

  return vin * 1000;
}

Schematic is like this.
12V...R1...VoltagePin...R2...GND
so it means R1 is between 12V and VoltagePin, R2 is between VoltagePin and GND

fastegg 02-10-2012 12:07 AM

MPGuino
 
Quote:

Originally Posted by meelis11 (Post 212670)
Hi,
has this idea been discussed before? At least I haven't seen it.
Anyway, I would like to see battery voltage in MPGuino and started searching how to measure 12V battery voltage (max should be 15V I think) and found this link and some other voltage divider pages.
Also I am going to add coolant temperature to this screen (needs extra input pin) along with liters/hour and RPM
new screen will be "Car sensors" or similar.

Meelis

Yep... having battery voltage is an excellent idea, so is coolant temperature...

lamb.chop 02-14-2012 06:29 AM

Why not just display PID 42 Control module voltage ??

fastegg 02-14-2012 07:14 AM

HP gain
 
In a 4 litre V8 LS400, what % HP gain would you get if you took the fan belt off (just for the exersize).... Like on a dyno, one run... any guesses ?

meelis11 02-16-2012 07:23 AM

Quote:

Originally Posted by lamb.chop (Post 286724)
Why not just display PID 42 Control module voltage ??

Ummm...you probably mix scangauge/ultragauge and mpguino

bobski 02-16-2012 02:59 PM

Quote:

Originally Posted by meelis11 (Post 287254)
Ummm...you probably mix scangauge/ultragauge and mpguino

Right. No OBDII interface means no access to OBDII ECM variables.

ECONORAM 11-23-2012 08:54 PM

Quote:

Originally Posted by fastegg (Post 286730)
In a 4 litre V8 LS400, what % HP gain would you get if you took the fan belt off (just for the exersize).... Like on a dyno, one run... any guesses ?

On my truck its worth approx 8hp. I've been running an Efan for years now. :)

Back on topic, nice work Meelis.


All times are GMT -4. The time now is 08:47 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com