06/17/08
Reverted back to double vsspulsespermile, seemed more reliable that way.
Added BIG NUMBERS (sorry, not a priority, I know).
Updated freeMemory function to not use malloc.
Did a bunch of ram optimizations:
Sketch size: 7990
Free Mem: 642 !
%CPU 52
Re orgd the displays to be more consistent with the original plan:
Instant/Current (instant mpg and speed , current mpg and distance)
Instant/Tank
BIG Instant;
BIG Current
BIG Tank
Current
Tank
Instant raw Data
Current raw Data
Tank raw Data
CPU Monitor
post 1 updated, tagged as v0.62
06/11/08
Fixed the runaway problem!!! (yay).
Added debug flag for serial logging.
put version # on opening screen (v0.60 currently).
Toned down the values in the brightness array.
Code in
post 1[/url] updated
Developer note: On my breadboard model, I am now powering the LCD pin 2 from arduino pin 15, this allows the LCD to properly re-initialize between resets and makes development life much easier. Do Not try and power the backlight from an arduino pin or you will be shopping for a new atmega168.
06/07/08 More bench testing results:
I think I have the glitches out of the microseconds logic. It has been running for 635 minutes now with the signal generator.
Other quirks:
at some point during the long test, the trip mph dropped to 8.5mph instead of 20mph, probably overflowing, instant is fine. Another "if" statement in mph() might buy us some more range, or a generic routine for computing that which retains maximum resolution would be nice.
MPG figures are stable after 630 minutes, but there remains a discrepancy between instant and the trips. Instant is saying 41.67, the trips are saying ~56.74, and last I checked the raw data for both was right in both their actual values (signal input x time) and their displayed values based on the raw data and the vehicle parameters?!?
Have not seen the fuel consumption runaway on the bench. Will update saturn guino with latest version.
Did some experimenting with the eprom library, will try and get a user input screen together for the fuel and distance parameters (it is taking a while to bake in my head).
06/06/08 Built signal generator from spare atmega168 using arduino code, detected and fixed glitch in microseconds() function as a result. Will be able to do more thorough bench testing now. code updated in post 1, will put signal generator in seperate thread. "Key off" hack won't work in all vehicles, will be removing it.
05/21/08 Fixed mph off by half, and mph overflow display when engine not running. Added tank time to cpu display. Code updated.
05/20/08 Hacked in some "the key is off" detection by utilizing the fact that the injector "seems" like it's been open for a long time with the key off "1.5 seconds". LCD turns of after about 20 seconds. Trips don't take a huge MPG hit when you turn off the ignition now. Could be better, but the concept is solid (would like to avoid ANY impact to consumption, and the "current" trip should reset on startup). Code updated.
05/20/08 added CPU Monitor screen (cpu utilization and bytes free), running simulation gives below reading, in car should have higher CPU%:
CPU%: 024.75
FREE MEM: 158.00
Might need to push some stuff into flash memory.
edit: took a test drive, the max cpu % was less than 25 and free mem stayed at 158 (as expected). So the interrupt handlers are pretty tight, and we can entertain upping the refresh rate to .5 seconds.
05/19/08 Added the updated mpg function, instant mpg is looking a whole lot better. Still issues with trip. Added 999999 display if there are no injPulses but there are vssPulses. Noticed that when I play with the injector kill switch while EOC (it interrupts the FI fuse), the MPG reading goes to single digits... hmm... Might have to recommend ignition kill switches or something. Code updated.
05/18/08 Stumbled on some vss info, my saturn is 5000 pulses/mile. If I set vssPulsesPerMile to 10000 then I have a pretty accurate speedo on the guino(counting 2 times too many pulses for some reason).
05/18/08 getting real close here, added scaling logic to mph function. mpg function looks good on the trips once they have some data (in simulation mode) but instant still needs a little work. trips are accumulating and displaying miles and gallons reasonably well too (again in simulation mode). code updated.
05/18/08 cleaned up the size of the code a bit (under 6k for now, 5996 bytes), added 3 new screens (formatted output for the trips). Got an ok looking mph display (from main screen, press right button, wait for the instant screen to draw, then press right + left to start the simulation). I think the display strategy will be to have simple ifs/elses in the trip functions (mpg,miles,gallons,mph,etc) to do the math based on pre-defined ranges to prevent overflows/underflows. Also mph is klunky on instant, we are dividing by the number of vss pulses but might want to time the pulses for low vss pulse counts (longer time between pulses=slower), instant accuracy will suffer till that is done.
05/15/08 calling the hardware good, I'm not planning on messing with it anymore for version one. Added a
parts list and cleaned up
post 1. Raw instant looks good, but the rest needs work yet.
05/14/08 Tried the zener trick on the vss signal, it works!! (getting about 25 tics/second at 10mph). Schematic and code updated. I want to see about replacing the 2n3906 with a 2n3904 (can get rid of one more resistor) before calling the interface board good enough.
05/13/08 found a useable VSS signal (was speedometer "output"), probing with the piezo indicates that it is a ground switch. Might need to redo the vss circuit for the saturn. there are probably going to be a few varieties of vss signal to sort out.
05/13/08 added a bunch of installation pictures to post #1 , no working vss signal yet however. I don't hear anything on the vss lead with the piezo so I think I need to try another wire.
05/13/08 Bypassed the ecu injector lead and got a solid signal straight from the injector wire. VSS still needs work (I don't think my cheesey clip is making a good purchase on the conductor). Switched in a zener on the injector lead and the fuel monitoring started working much better (I must have messed up the transistor). Added a couple screens for debugging and button commands, described in post #1, including tank and current resets and brightness control.
05/08/08 Couple of code tweaks and a test run in the car (97 saturn s2) was promising. The miles reading is in the ballpark, but the gallons was at least an order of magnitude off. Also everything was in whole numbers, will need to include floating point routines or device an integer based strategy.
05/07/08 removed 10k resistor from vss circuit and turned on internal pullup resistor.
05/06/08 update: I Took Coyotes suggestion and used two arduino pins for the injector. With one interrupt watching for rising and one watching for falling, the hardware handles the state management.
Added the button interrupt logic since I needed a vss interrupt handler, and moved the vss pin to pin 14 (all the pins for the buttons and the vss are read with one call to PINC).
Updated vss and injector hookup locations in the wiring diagram and the code. Changed brightness resistor to 100 ohms.
05/06/08 update: Updated wiring diagram, changed the 2.2k to 2.7k resistors (it's what I had laying around), and changed the 100k connected to pin 9 (brightness) to 430 ohm and got brightness control (can easily go down to 200 ohm for a brighter display). Put all the extra components on a small project board. So now it is just a matter of seeing if the other circuits and the code work.
05/05/08 update: Updated wiring diagram to include CPU control of the LED backlight via a transistor (completely untested). Also indicated ground path and voltage source and added optional (for now) buttons. The 7805 can handle 15 volts, so I'm just going straight to the car battery, will cut a power plug off an old wall wart or something to connect to the 'duino.
05/04/08 update: Added wiring diagram
05/04/08 update: the LCD code is behaving much more reliably now. Added vehicle interface picture.
05/02/08 update:
just fyi, the serial port version of freeduino is on sale for $14.49 at nkc
http://www.nkcelectronics.com/arduin...omplete-k.html
*not for legacy free homes
grab a $9.99 LCD while you are there
http://www.nkcelectronics.com/16x2-l...backli162.html
and another $8 worth of stuff from the shack or mouser or digikey and we are right about at $35.