Quote:
Originally Posted by dcb
I don't know what liberties you are taking with the schematic or the code [...] please and don't be surprised that making random changes to the code or circuit can break things.
|
I'm starting from scratch on both counts. I've borrowed a few hardware design elements, but the code is all new as far as the MPGuino project is concerned.
Unlike the MPGuino, I'm using one interrupt input for the injector signal with the interrupt being called when the signal changes (rising or falling edge). The interrupt code then checks whether the pin is high (just hit a rising edge) or low (just hit a falling edge) and executes the appropriate chunk of code to start or complete the pulse width measurement (adding the measurement to the total dispensed if completing), and/or calculate the period of the pulse cycle. Those two bits of data let you calculate total fuel dispensed, engine speed and duty cycle of the injectors (instantaneous flow rate).
The second interrupt input is dedicated to the VSS and only triggers on rising edges. It's code is a good bit simpler, calculating the time period since the last rising edge (used for instantaneous speed) and incrementing the VSS pulse count.
My latest code, now calculating trip and instantaneous MPG:
http://dl.dropbox.com/u/9882625/MPGshield_0.2.pde
[edit]scratch that. trip MPG is just sitting at zero. :/
probably some stupid programming bug.[/edit]
[edit2]fixed.[/edit2]