Torque

Forums

Forums

Guest  

Show or hide header
Welcome Guest, posting in this forum require registration.




Torque » Torque OBD ECU Scanner » Torque Discussion / Ideas » PID math summary

Pages: [1]
Author Topic: PID math summary
kitchw8436
Member
Posts: 4
Post PID math summary
on: November 4, 2012 (GMT)

Does anyone have a good summary of the functions and operators available to manipulate PID data? Would be great to have this info summarized in the wiki. Short of that, please post what you know about functions and operators. Here’s what I’ve gleaned so far

Operators
* — multiply, example 256*A
/ — Divide, example A/10
+ — Add, example 256*A+B
– — Subtract, example B-10
() — precedence operator, example (256*A+B)*0.1
{A:b} — returns the bth bit of the byte A. Least significant bit is 0, example A = 00001010b = 09h, {A:0} = 0; {A:1} = 1

Funtions
SIGNED(A) returns decimal value of A assuming highest bit is a sign bit
ABS(A) returns absolute value of A

piemmm
Administrator
Posts: 6082
Post Re: PID math summary
on: November 5, 2012 (GMT)

(I’ll shift all this to the wiki at some point)

[XX] – where XX is the ID of the OBD2 sensor – ie: [0d] (speed) or [ff1001] (GPS speed). ID’s can be found using the TorqueScan plugin which lists all known sensors and their IDs

VAL{sensor name} – The same as above, but used with the actual sensor name (make sure this matches exactly) – useful for dynamically assigned IDs (some PID plugins). Sensor names are their untranslated name.

Virtual PIDs
———–
You can make your own ‘Virtual’ PID that combines one or more normal PIDs using the above methods

For this there are 2 distinct modes. One that calculates the PID each ‘loop’ of running through the sensors, and one where you can get it to calculate at the time the sensor is read.

Method a – calculating at any point, each ‘loop’. The [id] will be dynamically generated so you can reference this PID using the VAL{name} function from another PID

PID: [leave blank]
Name: GPS vs OBD speed difference
Equation: ABS([0d] – [ff1001])
Unit: km/h

[0d] is OBD2 speed, [ff1001] is GPS speed. Units for these PIDs default to km/h so keep the units to match.

Method b – calculating when the speed PID is read

PID:010d
Name: GPS vs OBD speed difference
Equation: ABS(A – [ff1001])
Unit: km/h

‘A’ is the byte reply for the 01’0d’ PID request. You could equally use [0d] instead.

frodus
Member
Posts: 518
Post Re: PID math summary
on: November 5, 2012 (GMT)

Bill, This is Travis from the Elithion site

I posted this as well:
http://torque-bhp.com/forums/?wpforumaction=viewtopic&t=2803.0

Thanks for the response Piemmm… really needs to get updated in the wiki.

Can you open it up so those of us that want to can update it?

kitchw8436
Member
Posts: 4
Post Re: PID math summary
on: November 6, 2012 (GMT)

Travis, I’m really glad you posted this. I didn’t know you were Frodus and was going to email your own post back to you!

So square braces [] indicate a hex value?

piemmm
Administrator
Posts: 6082
Post Re: PID math summary
on: November 6, 2012 (GMT)

yep – [] indicates the PID id in hex (use the TorqueScan plugin to get the IDs as it shows them when browsing the list of sensors)

diesl
Member
Posts: 25
Post Re: PID math summary
on: October 3, 2015 (GMT)

Using ‘(‘ instead of ‘{‘ in the VAL{customPIDname} not only does not work, but also leads to misleading error messages.

2012 VW JSW TDI w/ DSG

EVrail
Member
Posts: 1
Post Re: PID math summary
on: October 25, 2016 (GMT)

Hi,
This equation worked once, maybe twice but now the PID function is flagged as an error and the gauge doesn’t work.
Is there a different way to get this to work?

I tried to post the equation, but apparently its not happening. Whats the point for the toolbar if I can’t post using code?

I tried to post it as a picture, didn’t work

Waste of my time

Pages: [1]
WP-Forum by: Fredrik Fahlstad, Version: 2.4
Page loaded in: 0.166 seconds.

  Follow me on twitter