Hi there,
I'm trying to build an OBD simulator based on some example code I have. It's all working ok, but I'm trying to add one more PID simulator and I'm struggling to see how its built.
As an example, the RPM PID for engine speed as listed here: OBD-II PIDs - Wikipedia is decoded on the reader end like this:
(256A+B)/4
and the simulator code I have generates the message to be read by that formula as:
case ENGINE_RPM: // ((A*256)+B)/4 [RPM]
can_MsgTx.buf[0] = 0x01;
can_MsgTx.buf[2] = ENGINE_RPM;
can_MsgTx.buf[3] = (ecu.engine_rpm & 0xff00) >> 8;
can_MsgTx.buf[4] = ecu.engine_rpm & 0x00ff;
Can0.write(can_MsgTx);
break;
So buffer 3 is A, buffer 4 is B.
so now I would like to make a simulator for engine fuel flow. The reader formula for this PID is very similar:
(256A+B)/20
I don't understand how the RPM one has been built though, so I'm unable to modify it for this PID. Does anyone understand how the RPM message is generated to be able to adapt the message buffers for the fuel flow PID type?
Thanks!
Nick