Fuelly Forums

Fuelly Forums (https://www.fuelly.com/forums/)
-   Experiments, Modifications and DIY (https://www.fuelly.com/forums/f9/)
-   -   diy mpg gauge (https://www.fuelly.com/forums/f9/diy-mpg-gauge-5319.html)

itjstagame 10-21-2008 07:05 AM

Good point, I'm sure we could change the code to work in this way possibly. Right now though the code just looks at each injection event. That is the 'pips' we see on the sound graph, it estimates that each pip corresponds to a certain amount of injected fuel and during a longer duty cycle would read as multiple 'pips' depending on how long is lasted. It samples at 44Khz (that's 44,000 times/ sec) and if the value is above a certain threshold it calls that a 'pip' and says fuel was injected.

For VSS is does the same thing, if it samples and sees a value below a certain treshold (like bottom of sine wave), then it knows one rev of the driveshaft (or whatever) has gone by and calculates the appropriate distance that that counts for (based on calibration and setup).

So at any given time we have a pretty fair estimate of injection events/length of injection time and number of VSS 'pulses' and can displaying anything we want based on this data.

Energy Recruitment 11-01-2008 09:54 AM

diy mpg gauge
 
hi,
I just joined this site...and in browsing around, I came across this thread.
Many of us (most?) who drive / want a MPG gauge but don't "speak the language" of electronics ... Jimmy Clark was a sheep rancher ... have a good way out of this dilemma : Buy a ScanGauge! It's a little pricy, but seems sound and bulletproof.
Go to <www.scanguage.com> for details. I've just gotten one, and am tickled with it! -Ted
P.S. While the "edit" button is still hot, let me just say - I went to the "gallery of pics" thread, just to check it out. When I saw the pic of the "Leaf blower", I went ROTFLMAO

Jay2TheRescue 11-01-2008 10:03 AM

Welcome to the site. As I recall that wasn't a leaf blower, it was "Ghetto Ram-air" Lots of people here have Scangauges. I even have one on my 4wd pickup truck.

-Jay

Billman2002 11-09-2008 02:45 PM

Software
 
Can anyone tell me where to get software to work for my ELM327 so I can read constant and instant MPG? miles per gallong.

I am having trouble, I have a 1994 Honda Civic EX. it has a Map Enhancer, I dont know if this makes a diff or not.

Need help

Thanks, Will

theholycow 11-10-2008 04:47 AM

There's many free programs for the ELM327. Here's the names of a few, google for them to get their websites:

OBD-II ScanMaster
scantool.net
obd2crazy / wOBD
EasyOBDII
OBDII Logger

Billman2002 11-10-2008 05:33 AM

Quote:

Originally Posted by theholycow (Post 123750)
There's many free programs for the ELM327. Here's the names of a few, google for them to get their websites:

OBD-II ScanMaster
scantool.net
obd2crazy / wOBD
EasyOBDII
OBDII Logger



thanks, however I need something to display MPG for my ELM327 1.2a

i haven't tried it on another car, only thing I can think of is mine is a MAP sensor, so what program would do the trick as these don't display.

theholycow 11-10-2008 05:41 AM

Oh, now I think I understand what you were saying about MAP in the other thread. In that case, I don't know what you can do. :(

Billman2002 11-10-2008 05:53 AM

Yup it sucks. I dont understand how it can't tell with a MAP sensor. as thousands of people must wanna know this.

Dalez0r 11-29-2008 02:03 PM

Arg! Trying to do this on my 1990 Honda Accord (F22A1 engine, 5 speed), and I can't for the life of me find the VSS. It doesn't match any factory service manual I can find, and the diagram on the last page of this thread doesn't match the box under my passenger seat at all... totally different kind of connector.

Anyone have a hint?

bnapalm 02-11-2009 03:27 PM

Hello, everyone! Although I have just registered, I have been wanting to do my own realization of this kind of gauge for over a year now. And now I've finally started doing it.
The thing is - I don't really want to connect it to my car before it is at least partly ready.. So, I would really appreciate it if anyone could provide me with a stereo sound recording of VSS and injector signals. It would be even better if someone could also provide some values, like total distance covered and fuel spent for the duration of this recording, so I could do some testing with some with "real-life" calibrated values.. but if such data is not available, I would be happy with just a sound file :)
Thank you in advance!

sonyhome 02-11-2009 03:44 PM

There was a sound file published with the software. I know because I used it.

bnapalm 02-11-2009 04:07 PM

Thank you for the quick response.
I could be missing something, but the only sound file I can find in this thread is a 1-channel sound file (injector only, no VSS).
Please correct me if I'm wrong..

EvilToothpaste 02-25-2009 11:04 AM

Hello people. I too have been reading this tread for about a year and just now decided to get my butt in gear.

Though your circuits work fine, the engineer in me chuckles and cringes at the same time. Just a technicality, but the opposing diodes are called a "clip" not a "clamp". Personally I used a Zener diode in reverse bias with an optoisolator because it is adjustable and gives a much cleaner signal than a regular diode in forward bias. Also, when your diodes fail --or when one of those wires shorts out -- you'll be getting the full 50 volt spikes into your laptop. Or your injectors might be shorted to ground when you're trying to impress the girl in the convertable. So be careful.

I am impressed with the Java program, too. I don't know anything about the language, but this project will give me a good excuse to learn it. Some crafty iPhone or G-phone owner could turn this into an App, then have a bluetooth module send the two signals as auido to the phone wirelessly! Now that would be cool.

And a little advice on finding the Vss: it's got to be somewhere on the back of your speedometer. Probably not feeding into the ECU, though, as is the case on my '91 Corolla.

All I need to find now is a laptop!

EvilToothpaste 02-25-2009 11:21 AM

Quote:

Originally Posted by itjstagame (Post 118408)
I was worried since the only diodes I could find at Rad Shack said 50v, but they clamp it to .7V.

You probably should be worried about that 50V because one of the diodes is reverse-biased and injectors create huge spikes in excess of 50V. Usually a diode is rated by its maximum reverse voltage before breakdown.

sonyhome 02-25-2009 11:44 AM

I'd be interrested in your ideas for a cleaner setup.

The audio input however could probably handle the 50V spike, don't you think? It's not eating any amps at all (dunno it's standard impedance though).

Couldn't you add a cheapo resistor bridge?

Else we could use a cheap Op-Amp but it would require an extra power source wire. :(

EvilToothpaste 02-25-2009 03:57 PM

I'll draw a schematic sometime, but it is just as simple as the setup you have already: just replace the two diodes with one zener reverse biased (backwards) then use a few resisters to divide the voltage to whatever you want. I guess you don't really need a cleaner signal, though, as long as there is only one rising and one falling edge per injector cycle.

As for 50v into a laptop, I guess I don't know if it would be bad or not. I'm going to try to avoid it because I'm a big pussy. :thumbup:

I'm going to try wiring this thing up on someone elses laptop tonight ... wish me luck! I'll take pictures of the mess I make.

EvilToothpaste 02-26-2009 06:19 AM

Java program
 
2 Attachment(s)
So I got it all hooked up last night. I recind what I said about the Vss not being on the ECU; it is there on my toyota and it made things really easy to wire up.

I got really good signals into both left and right channels. There is a "drive to work" image of the signals attached below. Injectors on top (using the zener) and Vss in the botom of the image (using the opposing diodes the OP used).

What I could not figure out were the "injThreshold" and "vssThreshold". What is meant by "value above the noise"? And why are some of the values negative? If you look at my image from CoolEdit, none of the samples are negative on an 8-bit recording.

The gage said I was always using .0055 gallons of gas at every instant, whether the car was running or not. The miles were working, I think, but they were not quite right; I'll have to mess with the fudge factor.

I'll make the attached file in just a minute....

bnapalm 02-26-2009 10:00 AM

Hello, EvilToothpaste! Nice to hear I am not the only one left researching this project :) I am actually using this idea as my course project at university (big thanks to skewbe for the idea/java realisation). The difference is that I am coding this in C++ (I really don't like java.. no reason, I just plain don't like it), currently on linux, but if everything works as planned, it will be easy to port to windows or a mac.

EvilToothpaste, seems to me that you know electronics (which I don't). Would be really nice if you drew a schematic for your diode/resistor setup :) Also, since nobody answered my previous question, would you be so kind as to share your recorded sound file with me? Even better if you could also provide the information (like how much fuel you spent on that trip and what distance you covered), so I could work on my software before I hook a laptop to my car. My laptop doesn't have a line-in, and neither does my mother's. So I need to buy an external sound card, but, well, I am broke right now :(

Thank you in advance :)

theholycow 02-26-2009 10:16 AM

What model of laptop comes with audio but no line-in or mic-in?

bnapalm 02-26-2009 12:44 PM

theholycow: it does have mic-in, but that would only give me one channel. so either just speed/distance, or just fuel consumption, but not both..

EvilToothpaste 02-26-2009 03:30 PM

Bnapalm,
 
2 Attachment(s)
Sounds like a good school project. I like the C++, and would be interested to see the final. I know more about that than I do Java, but still not much. I am most familiar with Python.

I made a quick schematic of the circuit I used and attached it below. I have a 6.8 zener only because that's what I had laying around. This particular circuit requires at least 12 volts on its input which means it can only be used on the injectors (my injectors make a 14.7V square wave with a 48V spike at the end of each pulse). You might be able to use it on Vss, actually, but only if it has at least 12v peak to peak. I used the same opposing diode circuit that Skewbe used for my Vss because I was too lazy to drag my o-scope out again to measure it after I had finally found the wire. Worked for him so I just went with it.

I can give you my sound file, but I don't have any gallon values for you because I haven't calibrated my stuff yet. I know that I topped out at 35mph, but that's all the info I have. hope it helps.

...except it's way too large. I'll have to email it to you. message me your email address and I'll send it tomorrow.

bnapalm 02-26-2009 10:53 PM

OK, I sent my e-mail address to you in a private message. Thank you! :)

itjstagame 04-13-2009 11:11 AM

Cool people are doing stuff!

I should clean up my code so people can see if it's useful at all. I wish I had stereo line input so I could debug it and get it working. I have both of my sources to an 1/8" jack but don't have stereo input, I've boughten a PCMCIA and Usb sound card that bought said stereo line input and lined, only mono. Most laptops I look at only have mono too, it's infuriating.

Anyway, let me go over the program a bit.

EvilToothpast: First, in you picture, the values on the right, is this the 8bit value, 0-256? The reason for the negatives is that when we look at the values in Java they're a signed int, that is, -127-127. I'm not sure why or how to change this, but basically that red line in each of your pictures would be 0.

So if the downward pulse is an injector fire, I'd set your injThreshold to anything negative, -100 looks about right but you can see that anything below -10 or -20 is only during a pulse.

For VSS it's the same thing, it's just a square wave and we just want to count cycles, so pick either 80 or -100 and it 'should' work. I say should because it really <b>WON'T</b> work. If you look in the code it does this:
if (val > vssThreshold
and
if (val < injThreshold

So that is, it expects injThresh to be negative and vssThress to be positive, nothing else will work unless you change the code. Based on your picture I'd set inj to -50 and vss to 80.

Now the fudge factors, those turn the useless counts of pulses into useful data. That is, the code isn't super sophisticated, it just checks every Hz (basically checks some times / sec based on sample rate) and if the 8bit value is ever above or below a threshold it sets increments a value.

Then at the rate that we update the front end screen (say once / second or so), we look at how many inj pulses there were, divide by fudge and call it gallons / second (or screen refresh time) and same with vss, we take number of vss cycles / fudge and get miles/second.

Here's the code again:

public double miles() {
return vssTot / distanceFudge;
}


public double gallons() {
return injHiTot / fuelFudge;
}

It really doesn't matter, after you calibrate once it will be right, but basically the fuelFudge is how many inj pulses it'd take to equal 1 gallon and the DistanceFudge is number of VSS cycles for one mile.

EvilToothpaste 04-14-2009 03:12 PM

Quote:

Originally Posted by itjstagame (Post 132428)
So that is, it expects injThresh to be negative and vssThress to be positive, nothing else will work unless you change the code. Based on your picture I'd set inj to -50 and vss to 80.

I will post what my values were when I get to my laptop, but I'm pretty sure I tried about every value from -100 to +100 for both Vss and Inj. I'm still getting nonsense for gallons.

Maybe I should invert the signal? It looks like mine is inverse of Skewbe's wave image from the first page. I'm sure that can be done in code somehow ... can I get a few Java pointers on where to find it?

itjstagame 05-19-2009 12:21 PM

Sorry I disappeared there.

Everything happens here and looking at it again I'm very stupid, the -127-128 can be changed at your will, looks like it just gets a byte by default and turns it in to those int values.

Here's the code with my own comments:


void processChunk(byte[] b, int c) {
double ih = 0; #injections, some amount of fuel
double vt = 0; # vss pulses
double rev = 0; # revs of engine

# Read all bytes that happened since we were here last in 2 byte chunks (left and right at 8bit)
for (int x = 0; x < c; x += 2) {

#the first channel (left?) is vss and here's were it manipulates the byte into an int between -127 to 128
int val = ((int) b[x] & 255) - 127;
if (val > vssThreshold && vg) {
# If it's greater than the threshold then add one to the pulse count
vt++;
//System.out.println(" vss going hi "
// + (current.sampleCount + (x / 2)));
vg = false;
}
if (val < 0) {
vg = true;
}

# Parsing the next channel, injector and turning into -127 to 128
val = ((int) b[x + 1] & 255) - 127;
if (val < injThreshold) {
# if less than the threshold then set ig to true
ig = true;
}
if (ig && val > 0)
{
rev += 1;
}
if (val > 0)
ig = false;
# These are my own changes to try to captures revs but it looks wrong rereading it now. Basically I just want to +1 to ih if we're ever less than threshold, but I was doing other stuff to try to count rpms, so I could get < threshold 3 bytes in a row but wanted that to count as 1 revolution (just a longer injection pulse).
if (ig)
ih++;
}
instant.Update((double)c / 2, ih, vt, rev);
current.Update((double)c / 2, ih, vt, rev);
tank.Update((double)c / 2, ih, vt, rev);
if (coastTest.coasting && instant.instantmph()<=coastTest.startmph() ) {
if (instant.instantmph()>=coastTest.endmph()) {
coastTest.UpdateDrag(instant.acceleration(), instant.instantmph());
} else { coastTest.coasting=false; }
}
}


So after looking over it (well my modified code), the real code will be similar but I still say -50 and 80 look good based on your signals, this will trigger correctly to turn a pulse in the audio into an injection or vss pulse.

Gallons are probably way off because your fuel fudge isn't calibrated right.

Gallons is simply the total number of injections we've gotten since last reset (so per/sec for instant, /min for current and /tank for tank) divided by fuelFudge:
public double gallons() {
return injHiTot / fuelFudge;
}

So even though you have the right amount of injections you still need to have the fudge right before the value will make sense. His fudge was
fuelFudge=8000000.00 by default for a 4 cyl (EDIT: this was a 3 Cyl metro, doh!)

You could try calculating, like ignore injector openning closing time and just assume it's 300cc/min injectors and we're sampling every 44Khz * 60 (secs in a min) so 1.136 * 10^4 cc/cycle if on, 1 cc = 0.000264172052 US Gallons, so
3 * 10^-8 gallons/cycle. We're dividing by fudge though, not multiplying so invert: 33.3 * 10^6

This is just completely off the cuff but matches fairly closely to the 8 * 10^6 default value. Keep in mind this is one injector you're watching, if you've got a 4cyl with 4 300cc/min injectors we'd have to divide that 33.3 by 4 (that is we're giving 4 times the weight to each pulse because there were actually 4 of them), that's 8.3 * 10^6.

My truck has only 2 throttle body injectors, I think 500-600cc/min each, but basically I just took the 8 * 10^6 default, dividing by 5.7 (thought being that 8 was for total injections to a 1L metro). Still haven't been able to debug in car to know if that value is useful though.


NOTE! Also, it seems obvious that each thing to needs to be on a particular channel. I'm not sure if skewbe mentioned that, but the code clearly works this way. You'd could swap the inj and vss blocks in ProcessChunk if you think you're reading the wrong channel for each. I was just guessing that left was first though.

EDIT: Yeah, skewbe set up VSS as the left channel and inj as the right, so that's probably why it appears first, though looking at it again, the for loop works backwards. We have an array of byte and look at them 2 at a time starting with 0, I'm not sure how this array is given to us or filled but to work the way I imagine in my head, the code uses it like this:
cycle 5 -> cycle 1
RL RL RL RL RL RL
Because it's saying b[0] is the 1st cycle's left or vss and b[1] is right, then adding 2 and saying b[2] is left and b[3] is right.

Skewbe can you comment? I finally have a laptop (and now the truck is dead) so looking to set this up in the Festy and have at it, hopefully sooner rather than later!

EvilToothpaste 06-01-2009 07:04 AM

Well, I wish I could help with your code. The RPM's is a good idea.

I have some ideas of how to debug my problem, but I need to compile Skewbe's code. I've just been running his MPG.zip up to now.

I don't think the fudge-factor is the problem because there is zero change in the gallons value when I rev the engine.

itjstagame 06-10-2009 10:29 AM

Gallons is total gallons used, not GPH or somekind of immediate value.

the 'gallon' is the smallest unit in Skewbe's code. Look at his code and compare to last post, I only have 2 small changes, everything I said in the last post applies to his code that you're using.

itjstagame 06-23-2009 01:09 PM

Could your issue be channel swap?

skewbe set up VSS as the left channel and inj as the right. I noticed on mine that my VSS was obviously the right channel (oops), so I made a simple mod to swap channels based on a config setting.

itjstagame 06-25-2009 02:41 PM

Ok, so I was getting a lot of 'randomness' everytime I tried using the app, even with now sound input.

I've determined that skewbes code to take b[x] - 127 to flip the bit and make it unsigned works fine for playback WAVs, but for real live running it fails.

The reason, he was asking for PCM_SIGNED in the main thread, but then he's flipping the bit later, so I changed this to PCM_UNSIGNED and all works great now. I'm not sure if all WAVs are unsigned by default or that's a seperate setting but now at least I've got this code is a reasonably good shape and trying to make a good coast down solver.

dkjones96 07-10-2009 11:59 AM

Okay, so I've been doing a little(a lot of) research.

I think I can build a system almost exactly like the SG for a hair over $55. It would include the ability to download new features and data logging to a memory card for manipulation later.

masster 12-19-2012 08:02 PM

4 Attachment(s)
Hi
I am new to this forum, I live very far from you (Romania), and I am interested too in an accurate, digital fuel consumption sender/gauge. This is a mandatory first step in order to monitor any fuel saving device.

I've decided to ask some questions in here because there are a few high skilled, motivated members that I am sure can help in my project.

My car is on carburetor. I know, you're into fuel injection solutions, but hear me out, my ideas can apply to all cars.

Basically, I solved the fuel sender poor accuracy by replacing the wire resistor type with a capacitive one. I am in the process of designing a simple PIC-based digital fuel gauge that takes into account the irregular shape of fuel tank.

Now comes the tricky part. There is a feed line coming from fuel pump, and a return line going to fuel tank. I should measure feed flow, subtract return flow, then divide by distance. When idling division is made with respect to time (GPH). My main problem is that I need a differential fuel flow meter for small flows and smart enough to detect if there are bubbles of air with the fuel.

I attached 2 images that describe the installation.
The main advantage is that you neither count injector pulses, nor listen injector clicks. Both are highly inaccurate because you never know for sure how much fuel squirts each injector. All we want is (fuel feed - fuel return)/distance.

Any thoughts?

Jay2TheRescue 12-20-2012 03:11 AM

If your car has a carburetor, there shouldn't be a fuel line returning to the tank. You should just have a mechanical fuel pump going directly to the carburetor.

masster 12-20-2012 05:28 AM

I know my carburetor and many other European carburetors by heart.
Trust me, there is a return line to send back to tank any fuel in excess.
We don't want fuel to overflow past needle float valve, don't we?

Jay2TheRescue 12-20-2012 06:05 AM

I guess. I've just never seen a configuration like that. Only ones I've seen with fuel return lines were fuel injected. There is a line from the carb to the tank in my carbed vehicles, but that is intended for vapor only, and if you actually get fuel in it, you have problems. They are all 80's vintage GM vehicles though, late model European vehicles with carbs may be different.

There used to be an add on mileage computer available in the 80's for carbed vehicles. It included an optical sensor that was installed inline on the fuel line, and was able to measure the fuel rate. They were somewhat problematic, as when the light bulb burned out, the sensor stopped working. I've read about folks who have switched the bulbs out for LED's though.

masster 12-20-2012 07:21 AM

Please have a look in here: https://skontrol.ru/node373/ and tell me if it is the most reliable, accurate, instant fuel consumption sender or not. IMHO it is, since you don't guess anymore if and how much each injector squirts.

Jay2TheRescue 12-20-2012 07:29 AM

It looks pretty good, but as far as being the best or most reliable, that's totally dependent on the design and build quality, which I cannot comment on as I do not have any experience with that product.

masster 12-20-2012 07:44 AM

I guess I wasn't explicit enough. I rephrase: is that a more accurate and easier method to measure instant MPG than what has been discussed till now?

Jay2TheRescue 12-20-2012 08:29 AM

It appears to be something that could prove to be very useful, is there a trip computer that will readily hook up to this device's output?

masster 12-20-2012 11:41 AM

Not to my knowledge, because I didn't look for one.
My intention is to design and build an on-board multifunctional computer.

theholycow 12-20-2012 01:13 PM

Quote:

Originally Posted by masster (Post 168926)
Please have a look in here: https://skontrol.ru/node373/ and tell me if it is the most reliable, accurate, instant fuel consumption sender or not. IMHO it is, since you don't guess anymore if and how much each injector squirts.

I'm not sure I understand your concern about guesswork. Knowing fuel injector duty cycle and fuel pressure gives you dependable consistent data. If you're doing DIY work and want absolute numbers then you need to calibrate your measurements, though you can probably get accurate numbers without calibration if you factor in your fuel injector's specifications.


All times are GMT -8. The time now is 09:55 AM.

Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.