Jump to content

EngineLink for OBDII in iOS


Noah Harbinger
 Share

Recommended Posts

I finally spent some time figuring out how to read signed-integer values in the EngineLink ODB-II reader app for the iPhone/iPad/iOS.

 

The values that come over the bus are 2s-compliment signed integers, but EngineLink uses the (open source but unmaintained) GCMathParser library for its formula evaluations. It doesn't have any concept for treating values as signed, and EngineLink doesn't seem to have the chops to modify it or to pre-process any (signed) evaluations. 

 

Someone (who? I can't find the post anymore!) somewhat recently posted a link to http://i-fix.us/Torque-Pro-Settings-for-Ford-Fusion-and-C-MAX-Energi.php, which provided a bunch of interesting PIDs I'd never seen before (specifically, the gen/motor torque and speed PIDs). That finally gave me the motivation to look at this some more. 

 

I played with different ways to use the mod function, which seemed the most relevant function they provide. 

 

Suppose u(x) is the equation for the unsigned value of the 16-bit 2s-compement signed x. Then, u(x)%2^15 - x yields a function whose value is -(2^15) where X < 0, and 0 where x > 0. With that, you can subtract that offset function from the unsigned value, and the result is equal to the signed value. 

 

That simplifies to Value = 2*(Unsigned%MaxSigned) - Unsigned. 

 

To clarify visually, in the chart below, red indicates the unsigned value of the signed integer X; blue the offset you add twice to X, and green the desired value. 

 

azaZBWE.jpg

 

 

That let me convert the formulas that use signed values to work in Enginelink, including the long-sought HV Battery Current. I have loaded these into EngineLink and taken some test drives, and the values all seem reasonable and seem to match my understanding of how the powersplit transmission works. (The min/max values seem to be off, though - I'll have to update those based on data I collect). 

ModeAndPID,Name,Min,Max,Unit,Formula,Header
22480B,Hv Current,-110,110,amps,(2*((A*256+B)%32768)-(A*256+B))/50,0
221e2c,Motor Speed,-10000,10000,RPM,(2*((A*256+B)%32768)-(A*256+B)),0
22481b,Motor Torque Command,-500,500,Nm,(2*((A*256+B)%32768)-(A*256+B))/10,0
22481c,Motor Torque from AC Source,-500,500,Nm,(2*((A*256+B)%32768)-(A*256+B))/10,0
224821,Generator Speed,-10000,10000,RPM,(2*((A*256+B)%32768)-(A*256+B)),0
224819,Generator Torque Command,-500,500,Nm,(2*((A*256+B)%32768)-(A*256+B))/10,0
22481a,Generator Torque from AC Source,-500,500,Nm,(2*((A*256+B)%32768)-(A*256+B))/10,0

If there's anyone else out there using EngineLink, I hope that's useful!

Edited by Noah Harbinger
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...