Page 1 of 1

OBD-II Precision

Posted: Mon Sep 25, 2017 12:13 am
by Leggo
Hello,
I am trying to get higher precision on some of the PIDs. For example, when reading PID_DISTANCE, is it possible to get a reading with decimal places or is it strictly integers?

I've noticed that the obd.read() command only accepts int values, and does not allow floats, doubles, or bytes.

Thanks for the help,
Anthony

Re: OBD-II Precision

Posted: Tue Sep 26, 2017 4:13 pm
by stanley
It's a 16-bit integer value in km. You can measure distance traveled by sampling OBD speed and time elapsed.

Re: OBD-II Precision

Posted: Fri Sep 29, 2017 12:42 pm
by Leggo
Thanks Stanley. I'm trying to think what would be an accurate way to measure this. I think I understand what you are saying.

So use the PID_SPEED function and the Arduino function millis(). Find the difference between each millis() read and multiply that by PID_SPEED. Does that sound right?

Thanks.

Re: OBD-II Precision

Posted: Sun Oct 01, 2017 10:14 pm
by stanley
Basically it is like:

distance = (v1 + v2) * (t2 - t1) / 2;

Re: OBD-II Precision

Posted: Tue Oct 03, 2017 12:08 pm
by Leggo
Perfect, that was along the lines of what I was thinking. Thanks Stanley!