MPGuino

From Combustory
(Difference between revisions)
Jump to: navigation, search
(Assemble the Electronics)
Line 260: Line 260:
  
 
Code updated, sketch size 9812, CPU 54%, free mem 602
 
Code updated, sketch size 9812, CPU 54%, free mem 602
 +
 +
<google>Arduino Communications</google>
 +
<google>CH02</google>

Revision as of 15:45, 18 August 2008

Arduino Communications Page


Any questions or comments, send them to - combustor@combustory.com

Contents

Summary

This is an impressive use of the Arduino platform. One that will actually pay for itself too. A small group of folks banded together and created an open platform called http://www.openguage.com where you will not really find much information concerning this device, but there is lots of information in a forum at http://www.ecomodder.com, where you will find tons of useful and fun ways on improving gas mileage for any car. To explain what these folks did for the average working Joe, who can't quite afford a car newer than 1995, is just amazing.

They came up with a way to build a reasonably low-cost device that will gauge your MPG, even for cars that do not have an OBD-II interface in there car. At the moment it is restricted to use in cars with fuel injection, but given enough time they may even find a way to gauge cars with carburetors. To cut to the chase, this device uses inputs from the Vehicle Speed Sensor(VSS) and one fuel injector control wire, both of which are easily found in just about all fuel injected cars, minus mechanical fuel injection, which only Mercedes seemed to make reliably albeit expensively. So, sorry all those 300E owners, you can't play with this toy right now.

The device sports an LCD screen with many display features that include Current,Instant and Tank MPG as well as Trip data for MPG, Mileage, and Tank Gallons. There are many other options and I recommend you reference the User Guide below for more detail.

Functional Description of the Solution

To further detail the solution, the VSS provides a pulse input related to the speed and distance traveled, meaning from this sensor you know how fast the car is going from the pulse frequency and how far the car has traveled by counting the actual number of pulses. Pulses per mile vary from car to car and based on the forum I saw a range in the 4,000 - 10,000 pulses per mile. The injector control wire provides the fuel flow mass. By making the relation of the known flow rate of an injector and the amount of time that the injector is turned on, you can calculate the the actual fuel mass flow rate your car is using.

On the electronics side they used the Arduino platform as the microprocessor and threw in some supporting components to prevent small fires that create anger and horrible smells. I hate the smell of fried electronics, unfortunately I know it too well. The microprocessor polls the sensors in the micro-second realm, and writes the results to the LCD in the 1/2-1 sec. realm. This gives the user a near real time view of the actual data.

There really is not much at the high level design function, but as they say, "The Devil is in the Details".


Theory of Operation

(This section is still being worked on and may not be entirely correct)


Fuel Injectors

To completely simplify a fuel injector, just imagine a water faucet valve. When the valve is open, the water flows out. The amount of water that flows out depends on the size of the faucet opening and the pressure of the water behind the faucet. For a fuel injector, the manufacturers specify a lbs/hr of fuel flow by knowing the opening of the injector and specifying the constant pressure for which the injector supply is supposed to maintain. Therefore, if you provide the proper pressure to the injector as specified and you open the injector for one hour, you should get the specified pounds of fuel flowing out of the injector. For example, a 20 lb/hr injector will supply 20lbs of fuel if left turned on for one hour.

This makes the calculation fairly simple to determine a fuel flow rate for your car by measuring the total amount the injector is open that comes from the Injector Sensor of the MPGuino and it is measured through the pulse width sent to the injector by the car computer. Also known as the injector pulse width. So the total time for each pulse width over a given time is the total time an injector is open. This measurement is usually taken in a second time frame and an injector has a limitation known as a frequency response or a max number of pulses per second, which is related to the mechanical response time that the injector can open or close. The MPGuino measures the total time the injector is open, so we will just take that number as a known measured value.

Ti = Time the injector is open as a ratio of a known time = For calculation purposes we will set it at usec/sec

Fr = Fuel flow rate is a known from the manufacturer in lbs/hr

Therefore:

Fuel usage rate = Fr (lbs/hr) / 3600 (sec/hr) * Ti (usec/sec) /1000 = (lbs/sec)

Fu = \frac{Fr}{3600} * \frac {Ti}{1000}


Example:

Ti = 500 usec/sec as measured by MPGuino

Fr = 20 lbs/hr as specified by manufacturer

 Fuel\ usage\ rate = \frac{20}{3600} * \frac{500}{1000} = 0.0028 (lbs/sec)


VSS - Vehicle Speed Sensor

Requirements and Knowledge

  • Basic soldering and electronic building skill
  • The following parts list for the Arduino assembly
    • 2 5.1v zener diodes
    • 1 2n3906 PNP Transistor
    • 1 220 ohm resistor
    • 2 100k resistors
    • 3 tactile switches
    • 1 freeduino arduino clone (any arduino can probably be made to work) i.e. an iduino: http://spiffie.org/kits/iduino/ or a Freeduino
    • 1 LCD (others might work as well, check pinout and chipset, etc). 16x2 LCD Module While Characters Blue Backlight Or a green one from sparkfun or mouser (a number of folks like the green ones better)
    • Sufficient Perfboard
    • A case to hold it all together
  • Additional parts for the iDuino assembly
    • 1 7805 Voltage Regulator
    • 1 1n4004 diode
    • 330 uf cap
    • 1 .1uf cap.
  • You will need to find the wires for the VSS on the vehicle computer or control unit.
  • If you're lucky you won't need much troubleshooting skills

Assemble the Electronics

Here are the schematics. This should be enough for most of you. There are two assemblies that are possible to build. The Arduino or the iDuino. Note the only two output leads for the VSS and the injector, other than that a 12vdc supply, and that is it.

Arduino Assembly Schematic

MPGuino Schematic.GIF


Arduino Assembly Schematic

IDuino Schematic.GIF

User Guide

Screens

1. Instant MPG/Speed Current MPG/Distance

2. Instant MPG/Speed Tank MPG/Distance

3. Large font instant MPG

4. Large font current MPG

5. Large font tank MPG

6. Current MPH, MPG, Miles, Gallons

7. Tank MPH, MPG, Miles, Gallons

8. Instant Raw Data (very useful for connection troubleshooting) Injector open seconds, Injector open microSeconds, Injector pulse count, Vehicle Speed Sensor pulse count

9. Current trip Raw Data Injector open seconds, Injector open microSeconds, Injector pulse count, Vehicle Speed Sensor pulse count

10. Tank trip Raw Data Injector open seconds, Injector open microSeconds, Injector pulse count, Vehicle Speed Sensor pulse count

11. CPU Monitor Max CPU %utilization, Tank running Time mm.ss, Free Memory (bytes)


Start-up Settings

There is also a setup screen that displays the first time the program is run and by pressing all three buttons at once. It walks you through the following setup variables. Use left and right buttons to select the digit you wish to change or the OK or Cancel (XX) items. Use middle button to rotate the current digit or select OK or XX if that is where the cursor is. Selecting OK will save the currently displayed value to the current variable and advance to the next variable. Selecting XX will just advance to the next variable.

1. Contrast - This comes up first on a brand new run and changes on the screen are immediate so if you can't see anything try pressing middle button a few times.

2. VSS Pulses/Mile - use this to adjust displayed speed/miles. If the speed/miles displayed on the mpguino is low then decrease this number by the percentage that it is off and vice versa for high readings. Most asian cars will be a multiple of 8204 and GM will be 10000, we are hoping users will contribute model specific data here.

3. MicroSec/Gallon - use this to adjust displayed fuel consumption. You may want to readjust this initially to get a ballpark MPG reading (after VSS Pulses/Mile is deemed accurate), then calibrate it with a couple fillups. If the mpguino displayed MPG is high or the displayed tank gallons is low at fillup then reduce MicroSec/Gallon by the percentage that the gallons are low or the displayed mpg is high. Like the vss pulses, this would benefit from user contributions about what values work for what specific cars.


4. Pulses/2 revs - not currently used, but a single injector on a 4 cylinder sequential system will make 1 squirt in 2 revolutions. Hope to be able to base RPM on this at some point.

5. Timout(microSec) - defaults to 7 minutes. If there are no injector or speed signals from the car and no buttons are pressed in that time then the display backlight turns off. When activity resumes the display will turn back on and the current trip will reset and the tank trip will be restored to the point of last activity.

6. Tank Gal * 1000 - not currently used, but defaults to 13300 or 13.3 gallons.

7. Injector DelayuS - Represents the mechanical delay of the injector in microseconds. Advanced topic.


Buttons Functions

1. left: cycle through screeens in reverse

2. middle: cycle through pre-defined brightness settings

3. right: cycle through screeens forward

4. left+middle: tank reset

5. right+middle: current reset

6. left+middle+right: go to setup screen


SW Release notes

Here are the latest release notes as of this writing. Get the latest SW from http://opengauge.googlecode.com/svn/trunk/mpguino/mpguino.pde


8/9/2008 updates for v0.70

More experiments with vss processing. Instant mph is very smooth on saturn but still jumps a bit on the metro. Distance reading on metro appears reasonably accurate (102.6 miles on odo, 102.18 on mpguino using 8208 vsspulses/mile). So the guino is doing a pretty good job of counting the vss pulses, it is a little erratic in timing the pulses though.

want to add EOC miles to the trip next, don't know if it will fit sketch size: 12884


8/1/2008 updates for v0.69

Added event handler and added debouncing on vss. Still trying to clean up reed switch vss signal via software with no luck. will make separate post for vss issue.

Added instantaneous mph (mpg is next), this looks at the time between vss peaks to determine the speed instead of the number of pulses in the last half second, which was jumpy at slow speeds. We are getting really really tight on space. That might also be an issue when 0012 comes out (don't know when).


8/1/2008 updates for v0.68

Removed all dependencies on timer0 so we should be arduino 0012 compatible. This also establishes an ISR under our control for scheduling events. Disabled Timer0 so use millis2(), delay2(), etc.

Knocked off a few hundred bytes by converting LCD to a namespace instead of a class.


7/10/2008 updates for v0.67

Incorporated LCD timings from Yoshi, removed pin 15 code and power up detection code.

moved source code to google/svn Revision 32: /trunk

other happenings: did a test with the scope regarding the voltage drop at peak pulse. I had the guino set a pin high and low within the interrupts receiving high and low and the pulse widths were the same except the generated one was perfectly square. So that is a good thing. Will need to test exactly what voltage level is acceptable.

The power supply on the scope died I think I just need a new TL431C or NTE999 though. I didn't get a chance to witness the vss bounce, the scope died during the attempt.

I am planning on moving all timing critical code to timer 2 with an event handler. I need real interrupt style debouncing for the vss and might as well use it as an event scheduler for debouncing the buttons as well as whatever else. This move will also allow for arduino0012 compatability.


6/27/2008 updates for v0.66

ADDED AN ONBOARD VARIABLE EDITOR!!! VARIABLES STORED IN EEPROM!! Now you can upgrade and not lose your settings and make adjustments in the car. Refer to post 1[/url] for screens and edit usage.

Updated screens descriptions in post 1

Checked source into sourceforge.net, linked post 1 to sourceforge (ran out of room again and wiki didn't like the extension .pde).

Sketch size 11734, 448 bytes free


6/26/2008 updates for v0.65

Added 7 minute activity timeout. It saves the state of the persistent trips (just tank for now) at the point of last activity and after 7 minutes of no injector pulses/vss pulses/or button presses, it turns off the LED backlight and sets up current to be reset and tank to be restored when activity resumes.

Despazed the buttons and Screen labels so they display for a second and accidental double button presses are minimized.

Running out of excuses (and room) to no do the user input/eprom setup screen thing Sketch size 10502 bytes.


6/23/2008 updates for v0.64

Fixed instant/tank screen (was displaying instant/current on that screen).

Improved LCD reinit on reprogram/reset. Can (usually) tell if LCD needs reinitializing. Press left and right buttons to force an LCD init if necessary. Want to free pin 15 for future tasks if it works well enough.

Added a bit of default verbiage to debug mode.

Working on a portable scope deal.


6/20/2008 updates for v0.63

Wrote 64bit arithmetic routines, yay no more messing with "ifs" when it should be math!

Noticed double vss count didn't make it in .62, fixed.

Subtracting 500uS from each injector pulse.

Added cli/sei around top of loop trip copy.

Made big font a smidgeon bolder.

Code updated, sketch size 9812, CPU 54%, free mem 602


Personal tools
Sponsers
Your Ad Here
Your Ad Here