EcoModder.com

EcoModder.com (https://ecomodder.com/forum/)
-   OpenGauge / MPGuino FE computer (https://ecomodder.com/forum/opengauge-mpguino-fe-computer.html)
-   -   Canadian version for kilometers (https://ecomodder.com/forum/showthread.php/canadian-version-kilometers-7204.html)

mluckham 02-21-2009 05:21 PM

Canadian MPGuino for kilometers
 
1 Attachment(s)
I've modified 0.75 to select US or metric units at compile time.

Eventually I'd like to be able to switch units on the fly or at least select USA/Metric in the configuration and I've started coding in that style, but there wasn't enough program memory on my first attempt.

Updated June 12, 2009: it works on my 95 Neon Sport, 2.0L SOHC, 5MT - VSS/KM=9926, MICROSECONDS/LITRE=57442679.

I'm working on version 76m using the Atmel328 and Arduino IDE 0013 - plenty of space now - have already added RPM and working on L/KM.


Thanks everybody for this most excellent project. Being relatively new at Arduino, it is good to see more advanced code samples using interrupts/etc.

undertaker 03-08-2009 10:38 AM

Thanks, I myself gonna convert units for a while but i'm just too lazy to start. I think this must be included in wiki.

rmccomiskie 03-10-2009 09:08 AM

Well done!

The runtime switch will be difficult if you don't want to reset the MPGuino but just switch the current information from gallons/miles to liters/km or vice versa. It's possible but would require conversion functions everywhere that the units are used. I suppose the data could be kept internally in some arbitrary units and then always converted for display.

I gave up trying to work within the ATmega168 Flash constraints. I'm using an ATmega328 with Arduino-0013. Works just fine and cost $5.00US for the chip.

dcb 03-10-2009 10:31 AM

Just FYI, here is a mega88 (half the flash of a 168), lot of work but can do a lot with not much:

http://www.youtube.com/watch?v=sNCqrylNY-0

I'm working on metric and pulse direction for the 168 cuz there are a lot of 168s out there. Might come down to a "bootloader not installed" compiler flag though.

oldbeaver 08-03-2009 01:12 PM

MPGuino Metric
 
Thank you very much!

By the way, what does 0.75 mean or state for?

Thanks again,

Old Beaver




Quote:

Originally Posted by mluckham (Post 88944)
I've modified 0.75 to select US or metric units at compile time.

Eventually I'd like to be able to switch units on the fly or at least select USA/Metric in the configuration and I've started coding in that style, but there wasn't enough program memory on my first attempt.

Updated June 12, 2009: it works on my 95 Neon Sport, 2.0L SOHC, 5MT - VSS/KM=9926, MICROSECONDS/LITRE=57442679.

I'm working on version 76m using the Atmel328 and Arduino IDE 0013 - plenty of space now - have already added RPM and working on L/KM.


Thanks everybody for this most excellent project. Being relatively new at Arduino, it is good to see more advanced code samples using interrupts/etc.


AlainB7 08-08-2009 08:10 AM

instead of km/l, it will be good to have a l/100km display.

demarco 09-10-2009 07:49 AM

Honda Civic LX 1999 metric
 
Hi,
Thanks to DCB for this great project and Mluckham for the metric conversion. I've built the MPGuino using an iDuino kit, everything went smoothly, installed it on my Honda Civic LX 1999, it's working great! http://forum.ecomodder.com/images/smilies/smile.gif
I'm still in the ballpark about VSS p/km (currently 5100, I estimate it is no more than 10% in error) and uSec/km (using 0087696156 guess it is showing consumption 10 to 20% better than it really is...), need more time and fillups to calibrate better.
http://py2wm.qsl.br/MPGuino/MPGuino.jpg

oldbeaver 09-12-2009 04:32 PM

MPGuino metric by Demarco
 
Hello Demerco!

Nice picture! Congratulations for your work!

I haven´t been able to attach my MPguino to my diesel car yet.

Can you tell me the nature of the vss signal the MPguino wants to receive?

Well, I know it is a digital signal, but, what else?

I have a diesel car with two fuel flow sensors which send a digital signal each.
Computing the difference I have the actual fuel consumption.

Do you figure where can I input this fuel consumption signal to MPGuino as to be understood as real time fuel consumption?

Somewhere in the program, the vss signal si converted to fuel consumption, isn´t it?
Can you help me to identify the program sequence where that variable is inputted?

Thank you much,

OldBeaver

demarco 09-13-2009 07:11 PM

Hello Oldbeaver,

Thanks for the compliments.

My car runs on gas, I don't know how to connect a MPGuino to a diesel car.

About the VSS signals, I suppose they are pulses of 12V and the AVR microprocessor counts how many pulses, each pulse corresponding to a certain distance travelled.

If the motor doesn't have injectors from where to obtain the fuel flow data, instead it has two different fuel flow sensors which requires an arithmetic operation, then I guess MPGuino would need another input and a new software.

I'm a newcomer to microprocessors and I'm not able to help you with program modifications, sorry!

Gud luck,
demarco

oldbeaver 09-14-2009 12:00 PM

Ok to all.

Well, I am not an expert myself. But what you said gave me a idea, that I will test.

Maybe I just need a constant to convert my pulses into MPguino like pulses.

Vocé fala Portugués?

OldBeaver

demarco 09-14-2009 12:11 PM

Yes, português is my native tongue.

AlainB7 09-26-2009 08:50 PM

Is it possible to have a l/100km reading?

I know that 235.2/MPG = L/100km

Can be possible to modified it to have this reading?

Sebastian 10-14-2009 01:42 PM

Quote:

Originally Posted by AlainB7 (Post 130029)
Is it possible to have a l/100km reading?

I know that 235.2/MPG = L/100km

Can be possible to modified it to have this reading?

I'm rewriting the code (based on 0.75m) for european use (L/100km etc). It may be alpha, because I can not test it because of weather atm (motorcycle..).

If someone wants to test it, I will send it to you with pleasure! Then I could correct issues if there are any.. It's also supporting a temperature sensor, if you want to use one.

Superturnier 10-28-2009 04:41 AM

I've been waiting my MPGuino-kit from Fundamental logic for 11 weeks and I'm starting to believe that my package is lost forever. I paid 39 dollars for nothing.:mad:
Trying to save gas seems to be expensive.:(

So I read about the Arduino, and realized that it can be used in many other applications than just mpg computer. Only have to learn some programming:confused:;) or to find ready solutions from the net. Plus some external electronic components, ofcourse.
Anyway I've always wanted to try microcontroller stuff and this Arduino seems to be quite easy way to start.
So today I ordered Arduino Duemilanove Atmega328 and this time from my home country so that it hopefully will not get lost on the way.

How much kb's does the 0.75 version for kilometers need?
Should fit easily to Atmega328, I think, since it has more memory than Atmega168?

AlainB7 11-02-2009 05:07 PM

Quote:

Originally Posted by Sebastian (Post 133754)
I'm rewriting the code (based on 0.75m) for european use (L/100km etc). It may be alpha, because I can not test it because of weather atm (motorcycle..).

If someone wants to test it, I will send it to you with pleasure! Then I could correct issues if there are any.. It's also supporting a temperature sensor, if you want to use one.

I would like to test it.

How I test it? You send the code to dcb and I buy a preasamble kit from im with your code in it?

Sebastian 11-03-2009 01:32 AM

Would be possible, but I don't know if he simply can flash a 0.75
version. If I'm right, he don't uses the original Arduino system
anymore. Also, there should be an error in the code, you would have to
send the unit back to him for a new software version or find someone who
can program it. It has no USB port!
So I would recomend to build your own MPGuino from an Arduino board.
It's simple. If you send me your mail adress, I can give the software to
you. You may want to comment out both of the "#define _funktion"
directives in top of code (_temperature and _lambda) if you don't use an
LM135, 235 or LM335 temperature sensor or lambda readout. Also, there is
a little tricky think to mention: My parameters list (saved from
setup-menue) is not compatible with original code. I removed all of the
unused variables so I don't confuse the users more then neccesary. That
means, if there was an original software on your unit, you first have to
clear the memory or rewrite it with the new parameters. And same in
other direction. Else it will read / write to undefined adresses and
mess up the running program.

mluckham 11-10-2009 10:29 AM

L/100 KM, and Metric Update
 
2 Attachment(s)
I upgraded my MPGuino to the Atmel 328 (double the memory).

Here's the latest version (0.79), which uses the 013 IDE which supports the 328. It features L/100KM, KM/L, RPM, Distance, etc. And it saves the current Tank readings when you stop the vehicle ... handy for when you update the software. I also included some data acquired from a short trip in my 95 Neon, for your interest.

This version contains a new method for calibration, it isn't fully debugged though. Instead of the mathematical method to adjust calibration, it displays the current Kilometers or Litres and you are simply to adjust to the readings from your odometer or the gas pump.

I've been playing around with accelerometers and GPS, and plan to extend this project to collect more statistics and store them on a memory card.

Sebastian 11-10-2009 11:50 AM

Fine, if I count them right now we have 3 L/100km versions :D

Two points to you:
.) I think the rpm function was disabled because it varies to much. Do you get a steady reading in your car?
.) Why are you not using Arduino 17?

mluckham 11-10-2009 12:26 PM

Three versions LOL
 
Agreed that 3 versions is not useful but each has something to contribute ... not just metric, but other additions too? In that light, I will check out the other versions more carefully :)

I found bugs in my original post (.77m) thought it would be nice to post a corrected version. If I should be posting in some other manner, I welcome your suggestion please.

RPM seems stable and correct in my vehicle.

IDE 17 - sure, why not - it's just that when I got the 328 a few months ago, I didn't hit on the latest version.

What's your opinion of replacing the hard-to-understand integer math functions with the regular math library?

Sebastian 11-10-2009 12:37 PM

Quote:

Originally Posted by mluckham (Post 138812)
Agreed that 3 versions is not useful but each has something to contribute ... not just metric, but other additions too? In that light, I will check out the other versions more carefully :)

This was not meant in negative way :) Of course I'm also reading every other source code in hope to find better ideas.

Quote:

What's your opinion of replacing the hard-to-understand integer math functions with the regular math library?
I'm not shure which "standard 64 bit math" library is meant. Is normal x * z 64 bit in arduino?
But if there is a faster one I would use it, because space is no problem with an ATMega328.

mluckham 11-10-2009 12:55 PM

I understand the original developer used the integer math routines, instead of the math.h library, because the library plus his code was too large for the 186. With more memory, this optimization is not necessary. Using the math.h functions will make it easier to modify or extend the program, or discover errors in calculations.

However floating point math takes longer than integer math to execute, which is the main reason embedded developers avoid it ... but I wouldn't think that would be a big issue in this application. Another thing to experiment with ...

Sebastian 11-10-2009 01:36 PM

I have no good experience with float variables in other projects especialy when it comes to big numbers. I didn't check it, but I think there was a reason to choose unsigned long. This goes up to 4,294,967,295. In float this becomes to 4.2949672E9, so we loose the last 2 digits. That may impact acuraty if there are realy numbers larger then 1E7.
As I understand the code, if its faster it's also more precise because of time for interrupts and so on? (See change to 20MHz crystal)

But it may be an option :turtle:

mluckham 11-10-2009 02:39 PM

Floating Point
 
I would never use floating point calculations in an interrupt service routine - in this case, it is just incrementing counters or subtracting integers to get pulse widths, anyway.

The CPU percentage is around 50%, so it should be quite safe to throw in floating point calculations for the twice-per-second display updates.

I have an accelerometer project with lots of floating point, it works fine.

I haven't found any floating point benchmarks for the Arduino, it will be interesting to try and quantify the difference between FP and integer math operations.

Sebastian 11-11-2009 04:12 AM

Quote:

Originally Posted by mluckham (Post 138812)
I found bugs in my original post (.77m) thought it would be nice to post a corrected version. If I should be posting in some other manner, I welcome your suggestion please.

I like the idea with built-in calibration method so I copied some lines from yours. I think I found the mentioned bug, but I also have another suggestion for you.

Your code:
Code:

parms[calibrationDistanceIdx] = tank.distance();  // distance x 1000, for updating parms[vssPulsesPerDistanceUnitIdx]
          parms[calibrationFuelIdx] = tank.fuel();          // fuel x 1000, for updating parms[microSecondsPerFuelUnitIdx]
         
          initGuino();  // edit parms[] array
         
          // if distance or fuel values are different from tank, recalculate VSS and INJECTOR parameters
          if (parms[calibrationDistanceIdx] != tank.distance())
              parms[vssPulsesPerDistanceUnitIdx] = recalculate(missing_parms[]_BugvssPulsesPerDistanceUnitIdx, tank.distance(), parms[calibrationDistanceIdx]);
         
          if (parms[calibrationFuelIdx] != tank.fuel())
              parms[microSecondsPerFuelUnitIdx] = recalculate(parms[microSecondsPerFuelUnitIdx], tank.fuel(), parms[calibrationFuelIdx]);

My one:
Code:

unsigned long tmptankdistance = tank.distance();
          unsigned long tmptankfuel = tank.fuel();

          parms[calibrationDistanceIdx] = tmptankdistance;  // distance x 1000, for updating parms[vssPulsesPerDistanceUnitIdx]
          parms[calibrationFuelIdx] = tmptankfuel;          // fuel x 1000, for updating parms[microSecondsPerFuelUnitIdx]
         
          initGuino(); 
         
          // if distance or fuel values are different from tank, recalculate VSS and INJECTOR parameters
          if (parms[calibrationDistanceIdx] != tmptankdistance)
              parms[vssPulsesPerDistanceUnitIdx] = calibrate(parms[vssPulsesPerDistanceUnitIdx], tmptankdistance, parms[calibrationDistanceIdx]);
         
          if (parms[calibrationFuelIdx] != tmptankfuel)
              parms[microSecondsPerFuelUnitIdx] = calibrate(parms[microSecondsPerFuelUnitIdx], tmptankfuel, parms[calibrationFuelIdx]);

I would recommend to save tank.distance() and tank.fuel() into variables first. On the one hand, you save recaculate them 3 more times. On the other hand, doing not so could lead to unexpected behavior like wrong vssPulsesPerDistanceUnit also if you don't change the values in setup menue.
Simply think at a situation, where you go into setup menue while engine is running or you are still driving.
parms[calibrationFuelIdx] != tank.fuel() will always be true, because tank.fuel() increased since last capture :thumbup:

mluckham 11-11-2009 08:58 AM

Thanks very much, I'll test it. I made an additional change, to save the calculated values:

Quote:

// set values for math-less calibration method
unsigned long tmptankdistance = tank.distance(); // take a snapshot, in case update occurs during the updates
unsigned long tmptankfuel = tank.fuel();
int tmpdirty = 0;

parms[calibrationDistanceIdx] = tmptankdistance; // distance x 1000, for updating parms[vssPulsesPerDistanceUnitIdx]
parms[calibrationFuelIdx] = tmptankfuel; // fuel x 1000, for updating parms[microSecondsPerFuelUnitIdx]

initGuino(); // edit parms[] array

// math-less calibration method:
// if user has altered distance or fuel values to be different from tank, recalculate VSS and INJECTOR parameters
if (parms[calibrationDistanceIdx] != tmptankdistance)
{
parms[vssPulsesPerDistanceUnitIdx] = recalculate(parms[vssPulsesPerDistanceUnitIdx], tmptankdistance, parms[calibrationDistanceIdx]);
tmpdirty = 1;
}

if (parms[calibrationFuelIdx] != tmptankfuel)
{
parms[microSecondsPerFuelUnitIdx] = recalculate(parms[microSecondsPerFuelUnitIdx], tmptankfuel, parms[calibrationFuelIdx]);
tmpdirty = 1;
}

if (tmpdirty)
save(); // save recalculated settings


mluckham 11-11-2009 04:00 PM

Metric Version 0.80m
 
1 Attachment(s)
Thanks for inspiring me to fix up these problems, all the outstanding issues appear to be fixed now - including the alternate "math-less" method of calibrating fuel and distance.

I also changed the Current and Tank L/100KM displays to alternate metric and US MPG equivalent. Now I can throw away the little chart clipped to my sun visor :)

Superturnier 12-03-2009 06:38 AM

Thanks to everybody, who has beem developing this product.:thumbup:

I have used my arduino based mpguino now for 327km and still need some fine tuning with the calibration, but I think I'm quite close already.

I was really surprised about the ecodistance (distance without injection) and the fuel used at idle.
Ecodistance = 17,1 km
Idle Fuel = 2,6 Litres
Have I really gone 17,1 km without any use of fuel?:rolleyes: I've always thought that the engine braking does'nt make much difference.
Have I really spend 2,6 litres just idleing at traffic lights? Maybe the Start-stop automatic in the new cars is not so bad thing afterall:)

One small improvement to the mpguino I would like to have though,
My instant L/100km reading is not steady. On the highway at steady speed it's showing 5,70...6,10...6,30...4,90...5,80...6,30...5,10 L/100km.
Is this normal? How about others? are your instant readings steady?
Would it be possible to have some averaging on the instant reading? Maybe take samples of every 2 seconds and display average from that?
I have studied the code already quite much, but I still don't have the skills to do the averaging stuff.

mluckham 12-03-2009 09:31 AM

Quote:

Originally Posted by Superturnier (Post 143636)
My instant L/100km reading is not steady. On the highway at steady speed it's showing 5,70...6,10...6,30...4,90...5,80...6,30...5,10 L/100km.
Is this normal? How about others? are your instant readings steady?
Would it be possible to have some averaging on the instant reading? Maybe take samples of every 2 seconds and display average from that?

It's normal on mine (5-speed manual). The load on the engine is constantly changing - every little hill and dip in the road, wind change, twitchy accelerator foot - produces a reaction.

I've been thinking of adding a new configuration parameter so the update rate is a user-configurable number of seconds.

Superturnier 12-03-2009 09:52 AM

Thank you for your reply.

Glad to hear it's normal. Then my wiring is propably ok.
I was thinking that the variation on the readings is caused by the closed loop operation of the efi. The mixture is constantly changing between lean and rich, as the oxygen sensor gives feedback signal.

That user-configurable update rate would be nice. :) I mean it would great if it could collect the data for few seconds and calculate the average from that data. Not just update the display at lower rate.:rolleyes:

spitsnrovers 07-26-2010 09:53 PM

Wow, all the code is over my head - but I sure want one of those Canadian litres and kilometers MPGuino!

Is there one available from the original developer yet? I had heard that they were working on it. I'd buy one tomorrow if it is metric.

spitsnrovers 08-12-2010 06:07 PM

Still waiting for an MPGuino unit in the mail. Is it unusual for 2 weeks delay? Have a USPS tracking number, but according to that website, the parcel hasn't actually been sent yet.
Thanks

mluckham 11-03-2010 02:58 PM

Canadian Metric 0.81m
 
1 Attachment(s)
Here's my current version of the MPGuino software, metric version. It is not based on the metric version currently distributed by dcb, it is an evolution of 075metric that I posted last year.

It contains these "improvements":

- built with Arduino IDE 0020, targeting Atmega 328

- I have successfully used my Spiffie MPGuino and Freeduino platforms to program the 328 for a couple of people who asked for it, so far everything has been compatible with the "Official MPGuino" from dcb - just pop out the 168 from the Official MPGuino and pop in the 328

- added SKelly's font hack to make the large fonts more readable

- added big vehicle speed display

- added alternating L/100KM / MPG display for Tank and Current

- modified edit parameter to leave cursor under OK, instead of the first
non-zero digit

- don't calculate MaxLoop (for CPU % statistic) while the user is operating the configuration menu

- added Tank save to EEPROM, reload on power up

- added comments to the code


By the way, I've been concentrating on metric outputs and although the US gallons/MPG are still supposed to work - well, they haven't been testing in awhile. If anyone can test that and report back, it would be great.

I hope this helps somebody :)


Mike

spitsnrovers 11-04-2010 10:30 AM

I did get my MPGuino very shortly after posting (above mluckham's), but haven't have had time to do more than open the package and marvel at the little device. (thanks DCB)

Interesting to hear of your Mods mluckham. I may look into asking to try them in my unit - when I get it mounted.

In the meantime, anyone have any experience putting the MPGuino into a 1988 VW Westfalia? Or any similar VW EFI vehicle?

dvate 02-03-2011 02:57 AM

I just got mine, it has the option of MPG and L/100KM, but i think KM/L is more helpful. Its been ages since i wrote code for anything and am not too keen on tinkering too much with it. Can any1 help me out, I dont mind replacing any of the 2 existing units. Do let me know how to go about it.

dcb 02-03-2011 06:16 AM

Quote:

Originally Posted by dvate (Post 218393)
but i think KM/L is more helpful...

Actually having thought about it a lot, having fuel in the numerator avoids a lot of confusion. It makes the changes to the thing you are trying to conserve,gasoline, linear. I.e. when someone says "I only saved 5MPG with P&G", you can't quantify it. if they were getting 10mpg to start with, then they improved 50%!

For folks who drive mostly fixed commutes, it makes even more sense to put the distance in the denominator.

However, you can have it either way, without any programming. If you calibrate it for km instead of miles and liters instead of gallons, while it is NOT in metric mode, you will get the numbers you seek, though the labels will be a little off.

dvate 02-03-2011 06:32 AM

Hey thanks dcb, yes that seems like a good option. Also, in that case, hardly any programming would be required if i were to try and edit the code to change the labels, if required, right?
I mean if its just a matter of editing labels i can take the help of someone to edit the code, my only concern was to play with the logical part of it, which can be totally avoided, right?
Or am i downplaying the work required?

dcb 02-03-2011 06:45 AM

Changing labels in a text editor is easy. But it is not a trivial thing to learn how to reprogram/test these chips if you haven't done so before, you have a lot of homework ahead of you if you go that route.

dvate 02-03-2011 01:54 PM

Hmmm.. Well could you guide me as to where to start!? as I'd like to do it some time, if not right away. And learning something new is something i'm always up for so what the heck :)

LassiV 04-11-2011 01:38 PM

My first post :) First thank all to great project mpguino.

Big thanks all developers and mluckham to km versio. I look soft and lcd i think why example "big current" are "KM/H" if i get right that should be "L/100km"? I look some youtube clips and there are about 4-5L values in motorway. That don't right if think 5km/L :)

Please tell me why values are that. I see only (L/100km) display example new cars every manufactor. Or i miss understanding to "KM/L" values, if somebody can tell me what values means?

edit: Couple new ideas goes my head, example anyone connect graphic display to mpguino (enough cpu power?), outside temperatures, open doors(easy draw graphic display), How that "long" consumption saved in arduino memory? If i drive home to work and car is stopped aboud 8hours and i go back home. Can mpguino remember my old (morning home-work) travelling and continue "long" consumption calculatin or reset mpguino "long" consumption always than cars stops over (7min?)? (example Toyota, Honda, and i think many more cars do)

stargazerf3a 02-14-2013 07:54 AM

Very nice version !!! :thumbup:

I have a question is this version (0.81) suitable for a 16Mhz Crystal ?
And is it possible to see big instant L/100Km ?

Thank you!!!


All times are GMT -4. The time now is 12:15 PM.

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