![]() |
FalconFour's MPGuino mods
I think they deserve their own thread, although I think the bigger ones (like the ALDL one I plan once I get comfortable with Arduino coding) probably deserve their own thread...
Here's what I've been up to tonight, after getting my Arduino back from a friend ;) Current list of "gee, wouldn't that be nice to have?" features on my todo list: - Tank remaining gallons calculated by (tank size - tank gallons) * tank MPG (completed) - Editor for tank values in memory, for restoring from a power outage from values recorded prior to unplugging (e.g. to recover from the setup menu CPU% timing bug) (still planning that one, LCD manipulation is tough) - Smartass message/indicator for ultra low instant MPG, high instant MPH delta (flooring it) - Real-time clock based on cycles, computed from memory value of "current time", set using "tank" method above (implemented, but unable to set the time at the moment due to lack of editor, so it always starts at 12am) And more posts to follow for each mod, and the associated code. |
Tank MPG is the easiest. Right now, for testing, it starts with a fixed value of 17.9999999 MPG to test rounding functions (I wasn't quite sure how the code worked yet, but I'm getting the hang of it now), but that value is discarded as soon as tank MPG moves away from 0.00. It calculates against the configured (but currently unused) tank capacity setting.
It uses its own "screen" which I currently call "F4 edit" due to all the comments I made in the code indicating where I patched it ("// ** F4 edit: blah blah"). The screen has both RemMiles and Time (clock). Here's the code: Put this somewhere around the screen routines. I put mine after doDisplaySystemInfo. Code:
void doDisplayRem(void) { Code:
displayFuncNames[x++] = PSTR("Rem tank miles "); Code:
doDisplayRem, Code:
void doDisplayCustom() { As they say... enjoy! ;) |
1 Attachment(s)
And a fun one, if at least to see how far the MPGuino's interrupt-generated clock differs from reality (if "1.024 milliseconds, we will call that a millisecond for our purposes" is any indicator ;))... a clock.
It's not complete. The "values editor" has to first be created here in order to set the time on the clock. But it does count time, and it seems to be working, so I'll provide that here as a starting point, and to get some feedback (particularly on if there's anything I can do to clean up all the mBuff parameters)... First, a new function, char * clock(): Code:
char * clock() { Then, a way to display it. Basically just call LCD::print(clock()) anywhere. I added a new menu for it. Take the construct above and replace the blank line print with: Code:
LCD::print("Time: "); Attached is a photo of my work thus far :) |
Bleh, just found out that tank miles isn't working right either. For some reason it flips out once tank MPG != 0.00. I can't figure out how the math is done in this thing. For example, tank capacity is stored as an integer like "10500" by default, but when I throw "format()" at it, it comes out as 10.5, as it should. But values like VSS pulses/mile also come out from format() as "4.00". I can't figure out where the decimal is coming from... or going to. I created a small test function to cycle through every stored parameter during every update, and it gave me some fast-paced but useful insight, such as that I should remove the "/1000" on the tank capacity parameter. But now it explodes in my face after I try to use it.
Needless to say I'm a little confused as to how to handle variables in the MPGuino code. Any tips? :/ |
1 Attachment(s)
Updated both mods... tank remaining MPG now actually works (yay! d'oh), learned a little too late about the 64-bit, integer-based *1000 math that was used in MPGuino... so all the calculations were screwed up. All fixed now with sane math and a better understanding of how to follow MPGuino as it runs around the room...
Also updated clock to fix the bug I noticed as I was posting it. Still not functional; tomorrow I'll work on a menu that allows you to set the time. Already added a menu as in the photo. Will work on adding clock- and tank-setting menus tomorrow! BTW, here's as small as I could get the menu code: (sorry, haven't gotten around to commenting it - but check out that pos-pointer statement! Hint: press L/R to go to the 4 corners.) Code:
void setupGuino() { // setup menu |
Next up... Duck.
http://www.youtube.com/watch?v=01kLTKLSEXI Yes, all it is, is a duck. Just a duck. Add to LCD prototype (begins at "// LCD prototype" near the top): Code:
void initDuck(); Add the line "displayFuncNames[x++] = PSTR("Duck.");" to the menu selections (big block of displayFuncNames[x++]). Add the following function, I put it around all the other display functions (below doDisplaySystemInfo): Code:
void doDisplayDuck(void) { Finally, two LCD functions need to be added - initDuck and printDuck. In the LCD section near the middle, add: Code:
void LCD::initDuck() { |
LOL! I did some playing around too, here is conways game of life:
http://ecomodder.com/forum/showthrea...html#post39458 |
Feature suggestions:
How about "tank miles remaining" before tank is empty VSS pass through, (so I can change the VSS signal to the speedometer to read correct speed when changing tire sizes) So modify the input VSS, and output a "corrected" value to take into account changes Allowance for a bigger/better screen to see more information at once |
Miles remaining? I've got that now, and it's pretty much dead accurate, based on tank MPG, tank gallons used, and the configured tank size. Also got a working clock that's 100% completely and totally spot-on accurate 24 hours a day, 7 days a week... haven't reset the MPGuino in some 3... almost 4 weeks now, and it's still got the perfect time. Also made a huge number of modifications to the screens, to provide more intuitive flow of screens:
BIG MPG (instant) BIG MPH (instant) Instant Current Tank EOC/Idle CPU usage (current/peak; free mem) Remaining miles / clock Duck And the Instant/Current/Tank screens have been rearranged to provide more intuitive figures: MPG | MPH Gallons | Distance (on Instant screen, distance is replaced with current MPG for reference) Also added a menu that allows me to edit different parameters instead of just jumping in and locking me into editing all system parameters with no way out... when I press L+R buttons, I'm presented with a menu of "Params, Clock, Tank, Exit" (image above). Params launches the usual all-parameter edit screen, but selecting "XX" backs out of all editing back to the main screen. Clock allows me to enter the clock time in 24-hour format. Tank lets me edit the tank gallons and tank miles, in case of an accidental reset or power cycle, using figures I recorded previously (say I need to take the MPGuino inside to reprogram or something). It takes those figures in value*1000, then converts them into VSS pulses and injector S/MS that the MPGuino works with internally, based on the configured values. I think I've made waaaaay too many edits to this code now... lol. But... what do you mean by VSS pass through? You mean, reproduce a VSS signal on a signal pin to drive the speedometer? Hm... I don't really have a use for that, so I dunno if I could really develop and test that... :/ And a bigger screen? Not sure about that one either... if I get my hands on a bigger LCD I might play around with it, but the 16x2 LCD format comes in a wide variety of physical dimensions... doesn't help to put more info on the screen at once, but I think the instant/current/trip screen setup is already an information overload as it is while driving! ;) |
FalconFour, Wow! Thanks for that crazy quick response. :)
|
All times are GMT -4. The time now is 11:44 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com