md-sohrab-alam / android-obd-reader

Android OBD-II Reader application that support standard PIDs Mode 01
78 stars 39 forks source link

Engine Displacement & Trip Fuel Usage calculations #9

Open YPITDataOmar opened 5 years ago

YPITDataOmar commented 5 years ago

Overall a nice job, but I noticed a couple of issues in trying to test against a couple of different vehicles.

  1. For test trips, my fuel usage was off. It seems like the engine displacement value was fixed to be 2 ... meaning a 2.0L engine. Testing against a larger 4.8L pickup truck showed results about 2.4x too small on fuel consumed. Included this more as an FYI for anyone using this data.... float engineDisp = 2; float maf = (imap / 60.0f) (85.0f / 100.0f) (engineDisp) * ((28.97f) / (8.314f));

  2. On newer Chevy pickup (2017-), if the ignition is turned to power, then OBD is reporting speed = 255 (but RPM = 0), so the TripRecord is having driving fuel consumption accumulate when no fuel is being used. Similar thing happens for Idle consumption if app continues to run while in the car but engine off (RPM & speed = 0). It seems to be using the last "currentMaf" value to continue calculating the totals. This also then impacts the driving & idling times and the distance travelled seems to also jump significantly when the engine is restarted.

md-sohrab-alam commented 4 years ago

@YPITDataOmar, Thanks for your feedback. Now I do not have Testing kit. If you find the solution, It would be great if you share.

YPITDataOmar commented 4 years ago

@md-sohrab-alam, I just used your code it to collect some data for a project. So I was comparing the code results to the known amount of fuel filled into the vehicle, and this flagged the discrepancy

For Item 1, I've also found that the 85.0f VE (volumetric efficiency) value doesn't work for turbo diesel engines that can have a value above 100%. Also, some newer trucks have variable-valve-timing, so only 1/2 the cylinders are used at idle which means a 4.8L engine acts more like a 2.4L one. I've tried to look at the OBD specs, but can't find anywhere that tells you the engine size or VE ... so not sure how to solve this. Just wanted to let others know who might use the code.

For Item 2, I think the issue is relying only on the Speed value and not using the RPM to determine if the engine is running. In my test, people would turn off the engine to make a quick visit, so there was a "dead time" in addition to driving and idle. As to the changes:

I think here there needs to have a check on whether RPM > 0, and if so then check whether the Speed > 0 to determine if idling or driving MAF. public void findIdleAndDrivingFuelConsumtion(float currentMaf) { float literPerSecond = 0; if (speed > 0) { mDrivingMaf += currentMaf; .... } else { mIdleMaf += currentMaf; ... } }

Trickier here as ... if RPM = 0 then engine not running, so do you consider that idling? private void calculateIdlingAndDrivingTime(int currentSpeed) { long currentTime = System.currentTimeMillis(); if ((speed == -1 || speed == 0) && currentSpeed == 0) { idlingDuration = currentTime - tripStartTime - drivingDuration; } drivingDuration = currentTime - tripStartTime - idlingDuration; }

I'm not sure on this one, but I think here, the "maf" value first needs to be reset to 0 each time before the if, so it doesn't carry over to the next data cycle?

private void calculateMaf() { if (mIntakePressure > 0 && mIntakeAirTemp > 0) { float rpm = Float.parseFloat(engineRpm); ... findInsFualConsumption(maf); } }

Hope that helps.