Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instant MPG sometimes reverts to fuel flow. #30

Open
FlashStopFall opened this issue Nov 21, 2024 · 1 comment
Open

Instant MPG sometimes reverts to fuel flow. #30

FlashStopFall opened this issue Nov 21, 2024 · 1 comment

Comments

@FlashStopFall
Copy link

FlashStopFall commented Nov 21, 2024

Instant MPG seemingly randomly reports fuel flow (g/h for my settings) instead of MPG. Affects every screen as well as serial output. It seems to be working correctly about 20% of the time, and showing fuel flow the other 80%. It usually starts working, and then stops working after coming to a stop. Sometimes though it doesn't start in a working condition, and sometimes it will come back after driving (usually after coming to a halt).

From what I can tell, fuel economy is calculated in prgmFuelEcon() in functions.h.

static const uint8_t prgmFuelEcon[] PROGMEM = {
	instrLdRegTripVarIndexed, 0x02, rvVSSpulseIdx,		// fetch the accumulated number of VSS pulses counted
	instrMul2byMain, mpCyclesPerVolumeIdx,				// multiply by cycles per unit volume to get the denominator for fuel economy
	instrLdReg, 0x21,									// save denominator for later
	instrLdRegTripVarIndexed, 0x02, rvInjCycleIdx,		// fetch the accumulated fuel injector open cycle measurement
	instrMul2byEEPROM, pPulsesPerDistanceIdx,			// multiply by the pulses per unit distance factor to get the numerator for fuel economy
	instrBranchIfFuelOverDist, 6,						// if MPGuino is in metric mode, skip ahead
	instrSwapReg, 0x21,									// swap the numerator and denominator terms around
	instrMul2byConst, idxDecimalPoint,					// put in the decimal point constant used for output formatting (for mi/gal or km/L)
	instrSkip, 2,										// go skip ahead

//fecont1:
	instrMul2byConst, idxMetricFE,						// put in the output formatting decimal point constant, multiplied by 100 (for L/100km or gal/100mi)

//fecont2:
	instrDiv2by1,										// divide the numerator by the denominator
	instrAdjustQuotient,								// bump up quotient by adjustment term (0 if remainder/divisor < 0.5, 1 if remainder/divisor >= 0.5)
	instrDone											// exit to caller
};

So it seems like it calculates (amount of fuel/amount of distance) and then swaps the numerator and denominator to get (distance/fuel). (I'm using U.S. settings). So if I'm only getting (amount of fuel) reported instead of (distance/fuel), it seems like the code must be first calculating (fuel/distance), somehow loosing (distance) (or setting it = 1?) and then not swapping the numerator and denominator before returning the value.

I'll start looking here.

@FlashStopFall
Copy link
Author

Interesting. I found that I can put the car in park/neutral and wait 5-10 seconds, and it will correctly show instant mpg after that every time. Then when I come to stop again, and the screen goes to the "park" screen (no vehicle movement) if I don't shift to park/neutral, it will continue to read the g/h rate which replaces mpg on the "park" screen. I wonder if there is a fuel rate threshold for stopping/restarting the instant mpg reading? Because that's the only thing really noticeably different from idling in gear (idle in gear at 0.78-0.88g/h, idle in neutral 0.47-0.68g/h).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant