EcoModder.com

EcoModder.com (https://ecomodder.com/forum/)
-   OpenGauge / MPGuino FE computer (https://ecomodder.com/forum/opengauge-mpguino-fe-computer.html)
-   -   Enhancements to MPGuino code -- bargraph display, etc. (https://ecomodder.com/forum/showthread.php/enhancements-mpguino-code-bargraph-display-etc-8695.html)

skelly 06-08-2009 07:37 PM

Enhancements to MPGuino code -- bargraph display, etc.
 
I have been playing with the MPGuino code, and I've made a number of usability enhancements:
  • Enhanced large font -- see Code Hacks Wiki page
  • Store tank data in EEPROM -- never again lose your tank info if the MPGuino blanks out for some reason. The tank data is written to EEPROM when the unit goes to sleep.
  • Turn off LCD as well as backlight on sleep -- probably does not save any power or anything, but I just like having the display off when I'm not in the car.
  • Fuel cut indication on all screens -- get a visual indication that "fuel cut" is happening while you are driving in any display mode. If I am in the bargraph display or the "Big Current" display mode, I like to know if fuel cut is happening. I am just writing a lower-case "c" on the screen when the car is in motion and no injector pulses have been measured. (I've also implemented the fuel cut indication as an animated 'spinner'.)
  • Distance To Empty (DTE) big number display -- I have this working right now, but it is based on your tank economy. This means that when you reset the tank economy this value can flop around a bit and I personally don't like it. Needs some improvement.
  • Prius-like economy histogram (bar graph). Get a new bar representing fuel economy every two minutes. The oldest bar is all the way to the left. Here is a photo:

    http://lh6.ggpht.com/_ERCBSb5GqMU/Sh...0/IMGP6866.JPG
    The "C" value on the top is the "Current" economy and the "P" value on the bottom is the "Periodic" (two minute) value.

Other things I am thinking about:
  • Multiple vehicles, stored in EEPROM, and selected by the user (i.e. if you want to use the MPGuino in more than one car, and keep the configuration for both vehicles)
  • Selectable units for our smarter neighbors who use the metric system. :)
  • Bar graph display of tank history -- each time you reset the tank, add a new bar, and store this history in the eeprom. (intention would be to use this history for the DTE display too)
  • Visual warning (overwrite any display) when low DTE.
  • "eco" indication -- some kind of indication that your driving style is optimal for fuel economy. Maybe a special display pops up during acceleration from zero, that helps you keep your fuel consumption during acceleration in check. (thinking out loud)
  • User-configurable cost/gallon, and corresponding Current and Tank "cost" of fuel used. My brain in general responds better to dollar signs than it does to a fuel economy readout. Someone on the forum suggested something like this too.

Okay, the above is all fine and dandy. Now the bad news. The bargraph display will not fit into the existing ATMEGA 128 or 168. I bought a 328 (about $5), which has plenty of room, and I'm using it with Arduino-0015. More on the bad news side -- this represents a departure from the official project, which has moved away from the Arduino framework and is moving toward straight gcc. This raises the bar of entry for most casual hackers, who probably don't want to install gcc and take the time to get the project compiling.

The good news: I've made all of the features above available at compile-time, so you can turn on or off various features above until you run out of room. I will be tough, however, to get the bargraph display without upgrading to the ATMEGA328 (about $5).

All of that said, I have talked with dcb about these things, and in general I am making changes for my own benefit, and with zero regard for selling 'prebuilt' units with any sort of guarantee. I do, however, think that the changes I've made make the code more maintainable, and in most cases will reduce RAM and executable requirements.

I am not trying to be disruptive of the project. On the contrary, I'm trying to (and I am, in fact) help add value to the project. This is what I see as the *point* of open source. Open source has no guarantees. Use at your own risk. But also, the beauty of it all -- feel free to crack open the cover and poke around.

I offer up the above as an 'alternative' firmware based on version 0.75. It will not be in lock-step with dcb's changes. Obviously this work is all free of charge and the changes are donated back to the community.

I will figure out a way to post the source(s) if anyone is interested in such changes/features.

dcb 06-08-2009 08:55 PM

It's good stuff, it just hasn't made it to the top of my list yet (and we hit the wall in arduino).

I think you would do well to just make a "Skellys arduino based mpguino mods" wiki page with the code embedded in it to cut and paste into arduino. I can add a pointer to it from the top of the pde file in googlecode for the adventurous sorts. And of course a pointer from the code hacks page.

Also, you might want to incorporate the changes for .75, some fundamental accuracy fixes in there, and of course keep an eye on the mpguino update thread if you are going to try to keep it current. This way I know there is a well tested version published on the main site, but there is a path forward the adventurers. I just can't personally help them much these days, and they are good at getting into trouble :)

Thanks,
Dave.

P.S.: the prebuilt does not come with any guarantees either, but I do try extra hard to make sure it works :) My reputation is worth something to me.

McTimson 06-08-2009 10:45 PM

I'm very interested in your code - the bar graph doesn't look too useful to me, as I'm pretty much always watching the screen anyway, so I at least have a general idea of how I've been doing. But, the storing of tank data, fuel cut indication, and DTE look very useful.

I think putting the code up on the wiki would be great, with some sort of disclaimer that adding all the extra code will take up more space, and may not fit on different Atmega chips.

skelly 06-09-2009 08:28 AM

Quote:

Originally Posted by dcb (Post 108756)
Also, you might want to incorporate the changes for .75, some fundamental accuracy fixes in there, and of course keep an eye on ...

Oops, yes, I did start with 0.75 and I've just updated my post to reflect that.

Let's think about the best way to store the source, as I've broken it into multiple source files:

Code:

"lcd.h"
"lcd.pde"
"mathfuncs.pde"
"mpguino.h"
"mpguino.pde"
"mpguino_conf.h"

I can use a wiki to post some photos of what to expect, and describe the feature or whatever, but I think it will be a PITA to store source there.

dcb 06-09-2009 08:44 AM

Quote:

Originally Posted by skelly (Post 108819)
I've broken it into multiple source files

Well that is an issue you created, don't know what to tell you, and don't want to make a huge debate about it either. It was one file when you found it though so that it was easy to load it into arduino (just cut and paste ONE thing, no download and navigating filesystem stuff). So there is plenty of precedent for not fragmenting it. There are PITAs in all directions.

SVOboy 06-09-2009 11:29 AM

Looks like good stuff! I wish I was more near to my car to play around. Looking forward to what you do and how it is when I get home. Maybe when I get my second mpguino up I will compare side by side :P

CoClimber 06-10-2009 10:58 AM

More changes
 
I like the ideas for your mods. I'm actually thinking of other mods for my personal needs. I'm working on data logging capabilities so that I can analyze data on my PC. I'm installing an I2C eeprom on my IDuino board to store the data.

I realize this is blasphemy here but I also autocross my car (Honda Del Sol) so I also want to log my lap times so this will serve double duty. The last reason I want to log speed, etc. is for when my son borrows the car so that I can make sure he isn't getting stupid with it.

Doug

dcb 06-10-2009 11:33 AM

for the last one, not that I'm offering to write it, or that there is space for it, but you *could*, without using a separate computer:

1. initialize the guino with the odometer reading
2. have it track max speed (store it and odo in eprom)
3. have it reset max speed/update odo with password (up to 10 digit number for password would be easy)

So you can track max speed (or some sort of average) confidently, or your kid will figure out how to hack it, it's all good :)

CoClimber 06-10-2009 01:43 PM

Good ideas. I'm not worried about my kid hacking it. I don't even plan to tell him that it logs. :)
The next trick will be to get the CD down below .35...

arlo 07-21-2009 02:12 AM

skelly,
Where have you posted this code? I really wanted to check out distance to empty. I made a function for it, but it takes up too much memory and won't fit.
Thanks

skelly 07-21-2009 11:19 PM

Quote:

Originally Posted by arlo (Post 116834)
skelly,
Where have you posted this code? I really wanted to check out distance to empty. I made a function for it, but it takes up too much memory and won't fit.
Thanks

Hi arlo,

I have not figured out a place to put the code yet. Any ideas?

I did not try

Here is essentially the code for DTE. You will need to add a #define somewhere:
Code:

#define DTE_CFG                    1  /* 0=Off 1=On        */
My call to "doDisplayBigDTE" here:

Code:

pFunc displayFuncs[] ={
  doDisplayCustom,
  doDisplayInstantCurrent,
  doDisplayInstantTank,
  doDisplayBigInstant,
  doDisplayBigCurrent,
  doDisplayBigTank,
  doDisplayCurrentTripData,
  doDisplayTankTripData,
  doDisplayEOCIdleData,
  doDisplaySystemInfo,
#if (BARGRAPH_DISPLAY_CFG == 1)
  doDisplayBigPeriodic,
  doDisplayBarGraph,
#endif
#if (DTE_CFG == 1)
  doDisplayBigDTE,
#endif
};

Also you need to add a label to it:
Code:

  displayFuncNames[x++]=  PSTR("Custom  ");
  displayFuncNames[x++]=  PSTR("Instant/Current ");
  displayFuncNames[x++]=  PSTR("Instant/Tank ");
  displayFuncNames[x++]=  PSTR("BIG Instant ");
  displayFuncNames[x++]=  PSTR("BIG Current ");
  displayFuncNames[x++]=  PSTR("BIG Tank ");
  displayFuncNames[x++]=  PSTR("Current ");
  displayFuncNames[x++]=  PSTR("Tank ");
  displayFuncNames[x++]=  PSTR("EOC mi/Idle gal ");
  displayFuncNames[x++]=  PSTR("CPU Monitor ");
#if (BARGRAPH_DISPLAY_CFG == 1)
  displayFuncNames[x++]=  PSTR("BIG Periodic ");
  displayFuncNames[x++]=  PSTR("Bargraph ");
#endif
#if (DTE_CFG == 1)
  displayFuncNames[x++]=  PSTR("BIG DTE ");
#endif


And here is the function. The 'safety factor' there is if you want to subtract a gallon or so to ensure that even when DTE says zero, you still maybe have a gallon left.

Code:

#if (DTE_CFG == 1)
void doDisplayBigDTE(void) {
  unsigned long dte;
  signed long gals_remaining;
  /* TODO: user configurable safety factor see minus zero below */
  gals_remaining = (parms[tankSizeIdx] - tank.gallons()) - 0;
  gals_remaining = MAX(gals_remaining, 0);
  dte = gals_remaining * (tank.mpg()/100);
  dte /= 10; /* divide by 10 here to avoid precision loss */
  /* dividing a signed long by 10 for some reason adds 100 bytes to program size?
    * otherwise I would've divided gals by 10 earlier! */
  bigNum(dte, "DIST", "TO E");
}

You need this supporting macro "MAX":

Code:

#define MAX(value2, value1)\
    (((value1)>=(value2)) ? (value1) : (value2))


cjm 07-22-2009 12:22 AM

Not sure if this is the right thread to ask this question, but I haven't seen a more appropriate place. I'm interested in logging data to a PC so that long trips can be profiled and routes analyzed. PC logging would be helpful in coast down tests too. Would adding a serial output to the MPGuino require substantial coding? or is it just a matter of finding someone who is familiar with these sorts of electronics to add that physical interface? Do you know of anyone who's done this or is working on it? Thanks.

skelly 07-22-2009 09:37 AM

Quote:

Would adding a serial output to the MPGuino require substantial coding? or is it just a matter of finding someone who is familiar with these sorts of electronics to add that physical interface?
I have the 'spiffie' hardware that has a USB plug on it. dcb's code (at least version 0.75) already has a serial output enabled and active. If you plug the USB into your PC, the PC recognizes it as a serial port, and you should see economy, speed, etc. being spit out.

Does the prebuilt unit have a USB plug on it? If so, and you are running at least version 0.75 of the MPGuino software, what you are asking for is already there.

cjm 07-22-2009 10:04 AM

Thanks for the response, skelly. I have not yet purchased the prebuilt unit -- just shopping right now. If it has the USB plug you describe, my shopping will be done. I can't really tell from the picture on the web site. Can anyone here confirm that there is a USB plug on the prebuilt? Thanks.

dcb 07-25-2009 10:39 AM

Nope, the usb was an addition on the spiffed kit (arduino legacy), was never part of the original mpguino except when built from an arduino or clone, though the data is still being transmitted on pin 3 of the cpu for the adventurous sorts (wire in a max232 or bluetooth or ft232rl, or just do straight uart to a large display or ???).

Fhajad 07-26-2009 01:12 PM

So pretty much all you did was just swap out the chip and put in a higher capacity one? Did you have to reflash it at all or na?

hu_man 07-27-2009 10:50 AM

Skelly you are onto something here. I am planning a 328 upgrade to make room for more programming. I would also like to see your code as I have some ideas of my own and I like your gals to empty idea a lot. I can not trust my fuel gauge so I am always filling up to soon. This would help. I do use the gal used but a direct screen would be nice.
Thanks for your post
Hugh

JohnNeiferd 08-04-2009 08:46 PM

A few features I think would be cool are 1) and rpm feature based on injector pulses per minute (as already suggested by someone else). And 2) a 1/4 mile time set up so a screen would display a timer that starts when the vehicle speed increases from 0, and stops when the odometer reaches 0.25. It would also display the speed you were at when the timer stopped. You're 1/4 mile time and top speed could be used to get a rough estimate of horsepower from calculators online. It'd be interesting to see how our fuel economy mods change the horsepower output of the engine.

skelly 08-05-2009 10:04 PM

Quote:

Originally Posted by Fhajad (Post 117768)
So pretty much all you did was just swap out the chip and put in a higher capacity one? Did you have to reflash it at all or na?

I got the higher capacity chip, the 328, from Adafruit with their 'customized' bootloader.

Arduino-bootloader speedy 2x upgrade chip (Atmega328) - $6.00 : Adafruit Industries, Unique & fun DIY electronics and kits

You just plug it in, and then I use the Arduino-015 platform to reflash it.

orange4boy 09-13-2009 06:42 PM

Are there any issues with using the earlier versions of arduino?
Can you just flash the chip with the older versions of the code like .75

Quote:

If you plug the USB into your PC, the PC recognizes it as a serial port, and you should see economy, speed, etc. being spit out.
Where / on which program would I see the data on a mac?

skelly 09-13-2009 08:23 PM

Quote:

Originally Posted by orange4boy (Post 127584)
Are there any issues with using the earlier versions of arduino?
Can you just flash the chip with the older versions of the code like .75
Where / on which program would I see the data on a mac?

Should be no issues going back to 0.75.

If you plug the MPGuino into your computer, and then fire up the Ardunio IDE, you should see the data appear in the debug window there.

njakts 05-20-2010 01:44 PM

HI! I know its been a while, but where can i find a full code for MPGuino? With full, I mean, all code hacks, this tank memory thing, distance to emty etc etc... i am not very advanced with programming so my code hacking is quite unsuccessful :(

can someone post a fully modified code? or send me e-mail to burritto AT inbox DOT lv

very much appreciated ;)

Bix 03-09-2011 06:11 AM

Even though its now 2 years late, but does anyone have the code for this? The bar graph and saving to eprom sounds interesting.

mcmancuso 03-29-2011 03:38 PM

I and others are working on implementing this into the new firmware, check the release 2 workspace thread

skelly 07-26-2013 12:02 AM

I've been gone for a while. I sold my Mazda Protege5 a couple of years ago and bought a 2010 Corolla. The Corolla already had a fuel economy readout so the MPGuino was rolling around in my glovebox for a couple of years.

I just bought a '06 Wrangler and I resurrected the MPGuino a couple of days ago. It is installed and working like a champ.

I've posted all of the code changes from this original thread to github:

https://github.com/skelliam/mpguino_fork

So what is going on with MPGuino, is dcb still around and active with it?

One thing I learned after installing the MPGuino is how to get into fuel cut mode. In my Mazda Protege5 with manual trans it was quite easy, and you could hear and feel when it was happening. Jumping to the Corolla, it was also really *really* easy to get into fuel cut mode, even during cruise control if you were going SLIGHTLY downhill you could feel fuel cut happening.

My Wrangler, not so much. I had it for about a week before installing the MPGuino and I had definitely the suspicion that it was not entering fuel cut mode at all. After installing the MPGuino I could confirm that suspicion -- but also I learned that it *WILL* enter fuel cut mode but only under very extreme conditions, like very high engine rpm off throttle. In 5th or 6th gear, coasting, it simply won't enter.

Anyhoo, enough rambling, fork and hack away on my github repo if you are so inclined. Sorry it has been so long.

aharvey 08-11-2013 09:13 PM

I think you still have the brightness settings in debug mode on github. The brightness array doesn't have 0 as the first element. Other than that, I was able to load it up, and I'll see how it works tomorrow. Good work, and thanks!

skelly 08-12-2013 10:41 PM

Quote:

Originally Posted by aharvey (Post 384687)
I think you still have the brightness settings in debug mode on github. The brightness array doesn't have 0 as the first element. Other than that, I was able to load it up, and I'll see how it works tomorrow. Good work, and thanks!

Hm... It never has had zero as the first element. I checked the repo and even back to the first change I made in April '09... I'm assuming you can't get the backlight to turn off after flashing this...?


All times are GMT -4. The time now is 04:07 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