Torque

Forums

Forums

Guest  

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




Torque » Torque OBD ECU Scanner » Torque Discussion / Ideas » Comprehensive list of PID operators and functions

Pages: 1 [2] 3 4 5 6
Author Topic: Comprehensive list of PID operators and functions
Berni
Member
Posts: 1
Post Re: Comprehensive list of PID operators and functions
on: May 23, 2016 (GMT)

I have made up two custom PID. One was done to change the tank volume from % to Litre. Works excellent.

With the other one I have a problem.

It is meant to show me the cost per trip. Therefore I took the value of “trip distance” and the value of “cost per km” and multiplied it. The result this PID is showing me is plain nonsense. Where did I make the mistake.

[ff1204] value trip distance.
[ff125c] value cost per km

Turned into

[ff1204]*[ff125c] which is showing me nonsense.

Please help.

Regards, Berni

406dany
Member
Posts: 11
Post Re: Comprehensive list of PID operators and functions
on: June 21, 2016 (GMT)

I have see that you probablely add new function (sin,tan,cos) in the futur
i have a problem with my no-standard obd protocol:
it send some values in decimal (no float)
but torque read it as hexadecimal and display it in decimal

the convert function “decimal to hexadecimal” and “hexadecimal to decimal”
like: DEC(A) , HEX(A) will be usefull…

rgds

OldGit
Member
Posts: 5
Post Re: Comprehensive list of PID operators and functions
on: June 23, 2016 (GMT)

Can someone help me with a custom pid for a on/off display for DPF regeneration .

cintakc
Member
Posts: 1661
Post Re: Comprehensive list of PID operators and functions
on: June 24, 2016 (GMT)

The author of the program wishes
once you have started to add some formulas, I propose to add a function of storing and reading intermediate results in one or two byte cell, which is necessary to calculate with the various types of fuel costs by using external PIDs
it is only for the current session start Torquay and perhaps to store data after the close of the program

Capp777
Member
Posts: 2993
Post Re: Comprehensive list of PID operators and functions
on: June 24, 2016 (GMT)

Quote from admin on June 24, 2016
Hi!

R0 is the ‘raw’ variable (includes part of the response before the A,B,C start). The ABC variables start from the actual data after headers, lengths, ID bytes (etc, etc) are sent depending on the protocol used

But as far as the Nx variables go:

N0 is the same as A
N1 is the same as B
(etc)
for the variable naming thing – it’s basically a replacement for the A,B,C stuff – this is mainly due to the way the parser works. The A,B,C variables will continue to work and I have no plan to stop them being used, though if you get strange results, try with N0, N1, (etc) variables instead

End Quote.

FYI

F-150Torqued
Member
Posts: 437
Post Re: Comprehensive list of PID operators and functions
on: July 7, 2016 (GMT)

@cintakc

I just read your post above….
——————–

Quote from cintakc on June 24, 2016
The author of the program wishes
once you have started to add some formulas, I propose to add a function of storing and reading intermediate results in one or two byte cell, which is necessary to calculate with the various types of fuel costs by using external PIDs
it is only for the current session start Torquay and perhaps to store data after the close of the program

——————–

……. AND IF I understand correctly – you can already create a “memory variable” for storing intermediate results using a custom PID entry with the PID field totally blank – and the LONG NAME becomes your variable name. You can use it in formulas of other PIDs by placing braces, { } around your variable name. It works great for current session, just is not persistent after you quit torque.

You can see more information as provided by @Capp777 and how I am using it in this thread:

https://torque-bhp.com/forums/?wpforumaction=viewtopic&t=6110.0

Hope this helps.

—————

54371019

PS: What I would like to see implemented, and could get TONS of power and value out of is the implementation of “BOOLEAN LOGIC” in formulas. To be able to multiply, divide, add or subtract by the Boolean result of logical test results (equal to, Not equal to, greater than, less than, and equal to).

cintakc
Member
Posts: 1661
Post Re: Comprehensive list of PID operators and functions
on: July 7, 2016 (GMT)

Thank you,
that I read your topic, but it does not solve the problem of storing intermediate data after turning off the program and start it again, the previous session data will not be saved

Capp777
Member
Posts: 2993
Post Re: Comprehensive list of PID operators and functions
on: July 7, 2016 (GMT)

Changes in 1.8.94 (23 June)
======================

* Added equation functions:
SIN(…)
TAN(…)
COS(…)
RANDOM() (returns random value between 0 and 1)
SQRT(…)

From Changelog.

Edit:

Frodus,

If you add these to your first post I will
remove this post.

andreas214
Member
Posts: 8
Post PID expression syntax
on: August 25, 2016 (GMT)

I still seem to lack some understanding of the syntax of the PID expression string. I tried:

Drehm,Drehm,63,256*A+B,0,200,Nm,7E2
U/min,U/min,0C,(256*A+B)/4,0,9000,U/min,7E2
Power,Power,63,(256*A+B)*VAL(“U/min”)/1000,0,200,kW,7E2

Drehm and U/min seemed to give me fair values, but Power does not. It seems that the “/1000” part is ignored, the numbers are too high at least by a factor of 1000. Do these operators need space characters around them?

What is about the PIDmode column? Can it be omitted in something like:

Power,Power,,VAL(“Drehm”)*VAL(“U/min”)/1000,0,200,kW,7E2

?
What is about the header column? Is it needed here, and for what? What values should be given (https://en.wikipedia.org/wiki/OBD-II_PIDs does not give them)? Can it be omitted, say:

Power,Power,,VAL(“Drehm”)*VAL(“U/min”)/1000,0,200,kW,

?
Also, what does the [] operator do? (In my case, returns zero):

Power,Power,,[0C]*[63]/1000,0,200,kW,

What is the purpose of this operator, as I can not supply the “(256*A+B)” which is actually part of the PID?

Also I am not clear about quotation. I have tested a csv which hat quotes around every field, like

“Actual Engine Torque”,”ActEngTorq”,”2149″,”(D * 256 + E) – 32768″,”0″,”150″,”Nm”,”7E0″

and it worked. How does this affect the argument of the VAL function? Writing
“VAL(“Drehm”)”
does not seem correct, what about
“VAL(\”Drehm\”)”
? Should I write these quotes also in the case, where not every field is enclosed by quotes, like:

VAL(\”Drehm\”)

? The problem is, it is difficult to test all this systematically as I have to drive the car to get a readout and if I don’t I don’t have an error message.

Capp777
Member
Posts: 2993
Post Re: Comprehensive list of PID operators and functions
on: August 25, 2016 (GMT)

Val{Long Name}

Use braces for Val and make sure your
long name matches exactly.

Val{Drehm}*Val{U/min}/1000

F-150Torqued
Member
Posts: 437
Post Re: Comprehensive list of PID operators and functions
on: August 26, 2016 (GMT)

@andreas214

I am no expert, but do have some small custom csv files set up for detailed diagnostics on particular systems on my 2004 Ford F150 5.4L 3 valve engine, such as the variable valve cam timing.

Without specific knowledge, I recommend leaving the header line – and I know it does NOT effect Torque. If nothing more its good for memory refresher when modifying or adding additional lines. It even places nice column headers on the first line when imported into Microsoft Excel.

The important thing is EACH field must be separated from the next by a comma. Thus, if you leave out Mode & PID you have to use two commas before beginning your formula. (Leaving out the MODE/PID in this manner will make your Long Name, for all practical purposes function like a public memory variable. As with all variables, like @Capp777 mentioned, spelling must be exact including upper/lower case, and be careful not to use one that has already been used – ie: possibly “Power”.)

Some software ignores quotes enclosing each field – and some require it. Torque does not seem to care, so the Quotes surrounding your formula seem to be just get ignored. But you DO need both MODE (ie: 22 or 21) in your Mode/PID field. ie: 220004 for engine load.

The operator [ xx ] is the instantaneous reading of the PID represented by xx – (WITHOUT Mode, just the raw PID, say: 04 for engine load or OD for vehicle speed, or 16CD for the PCM’s requested cam retard in the case of MY vehicle.)

As @Capp777 said – VAL requires braces enclosing the target PIDs LONG NAME – without any quotes.

Perhaps you can get some ideas from my actual csv file for my Variable Valve Timing diagnostics that follows in its entirety between the dashed lines. You will note that I use two variables (without Mode/PID) for running an accumulator of CAM ERR samples. On a smooth working VVT system, it bobbles above and below Zero degrees. Accumulating TOO high positive or negative indicates over advance or over retard condition respectively.

//// EDIT — Uh Oh — the special characters bit me. Edited to make a link to a JPG file instead.

BTW: Credits to Capp777 for telling me how to construct function memory variables as are used in the above example. Thanks again Capp777

Hope this helps sort it out a little more

——————

54371019

andreas214
Member
Posts: 8
Post Accumulated and stored variables in PID expression syntax
on: August 31, 2016 (GMT)

Thanks for the replies so far. It was mentioned in this forum, that simple variables can be defined – but no details were given.

My aim is to calculate the accumulated gas consumption as a display. What I have already have is the momentary gas consumption. What I would need is:

– a variable which stores the time of the last reading, which I would subtract from the actual time to get the time difference
– a variable for the accumulated gas consumption which would be updated as:
AccGas = AccGas + MomentaryGas * (ActualTime-LastTime)

Is that possible, and how is it done?

andreas214
Member
Posts: 8
Post Re: Comprehensive list of PID operators and functions
on: September 2, 2016 (GMT)

[XX] – returns the value of a PID, where XX is the ID of the OBD2 sensor. i.e. [0d] (speed) or [ff1001] (gps speed)
/div>

That seems resaonable to me. I wanted to test whether the ModeAndPID and header can be ommited in this case:

1 ICE Drehm,ICE Drehm,,[ff1225]*1.3558,0,200,Nm,
1 ICE Drehm1,ICE Drehm1,ff1225,[ff1225]*1.3558,0,200,Nm,Auto

The result is utterly confusing to me. The reading of “1 ICE Drehm” is higher by the factor 1.3558 than “1 ICE Drehm1”.

Is the expression “[ff1225]*1.3558” ignored in the second case?

Cheers

Capp777
Member
Posts: 2993
Post Re: Comprehensive list of PID operators and functions
on: October 2, 2016 (GMT)

Wiki equation page…

https://torque-bhp.com/wiki/Equations

Yuriy_SPb
Member
Posts: 8
Post Re: Comprehensive list of PID operators and functions
on: October 2, 2016 (GMT)

Hello!

Is it possible to introduce some function which uses results of previous PIDs to update PID command itself? That is change
some bytes in PID to bytes calculated from previous PIDs answers?

I think it would be interesting in many cases :-)

Capp777
Member
Posts: 2993
Post Re: Comprehensive list of PID operators and functions
on: October 2, 2016 (GMT)

Quote from Yuriy_SPb on October 2, 2016
Hello!

Is it possible to introduce some function which uses results of previous PIDs to update PID command itself? That is change
some bytes in PID to bytes calculated from previous PIDs answers?

I think it would be interesting in many cases :-)

End Quote.

Maybe? The new RDLY and TDLY functions might work. Just
not sure what you are trying to do. An example would
help.

Yuriy_SPb
Member
Posts: 8
Post Re: Comprehensive list of PID operators and functions
on: October 2, 2016 (GMT)

I mean the possibility to change ModeAndPID part using some data from answer from previous request. Currently the length of PID can be more then 5 bytes. So the first 2 bytes may be constant and next bytes could be updated using bytes from answer to some previous PID.

albuquerquefx
Member
Posts: 10
Post Re: Comprehensive list of PID operators and functions
on: January 13, 2017 (GMT)

First time poster, very long time user.

I see you already support the SIGNED(value) function for 8-bit values, is there any possibility you might support a 32-bit signed value function as well?

Reason: There are two or three of us working on a Mode 23 raw memory block dump method for a very popular racing platform which, for now, shall go unnamed but is absent the wonderful Mode 23 capability. Turns out Torque Pro can be used to pull data in this way, but much of the data is 32-bit floats.

Given an OBD request of 23FFFF6DD80004 (using our proper header) I get a reply of 6341ABB732. The 63 is expected, this is a “good reply” acknowledgement. I want to drop the remaining data (in whatever way makes sense for your parser) into a SIGNED32(41ABB732) call and get back the float value of 21.4645.

The far larger use case for this is to pull back dozens of bytes at a time and use this single active PID as a reference value for dozens of virtual PIDs, which allows for _really_ fast logging out of a singular raw memory export (Mode 23) call.

I’m almost there! Can you help? :)

blown maloo
Member
Posts: 40
Post Re: Comprehensive list of PID operators and functions
on: January 14, 2017 (GMT)

Quote from Vasilich on April 5, 2014
The custom PID edit window mentions A<8 in its example string, and after testing it I confirm that Torque supports shift operators x<n and x>n in equations.

hi
i need help getting pro to work were do i post
thanks

Australia FNQ

Capp777
Member
Posts: 2993
Post Re: Comprehensive list of PID operators and functions
on: January 14, 2017 (GMT)

Quote from albuquerquefx on January 13, 2017
First time poster, very long time user.

I see you already support the SIGNED(value) function for 8-bit values, is there any possibility you might support a 32-bit signed value function as well?

Reason: There are two or three of us working on a Mode 23 raw memory block dump method for a very popular racing platform which, for now, shall go unnamed but is absent the wonderful Mode 23 capability. Turns out Torque Pro can be used to pull data in this way, but much of the data is 32-bit floats.

Given an OBD request of 23FFFF6DD80004 (using our proper header) I get a reply of 6341ABB732. The 63 is expected, this is a “good reply” acknowledgement. I want to drop the remaining data (in whatever way makes sense for your parser) into a SIGNED32(41ABB732) call and get back the float value of 21.4645.

The far larger use case for this is to pull back dozens of bytes at a time and use this single active PID as a reference value for dozens of virtual PIDs, which allows for _really_ fast logging out of a singular raw memory export (Mode 23) call.

I’m almost there! Can you help? :)

End Quote.

Examples:

((Signed(A)*256)+B)

((A*256)+B)-32768

((Signed(A) lt 24)+(B lt 16)+(C lt 8)+D)

The less than sign without spaces. (shift
mentioned in previous posts).

Note:

The byte response will be in integer
and will need to be properly scaled
to get proper values.

Are you sure its a signed equation? All
my calculations with your byte A data
result in a negative number.

Need a hex value greater than 80 for it
to result in a positive value…

((Signed(B)*256)+C)*(1/521.3724)

for example.

Torque is expecting a standard hex response.
Not a floating point number. Maybe Ian can
add a function for the conversion.

Edited.

Pages: 1 [2] 3 4 5 6
WP-Forum by: Fredrik Fahlstad, Version: 2.4
Page loaded in: 0.074 seconds.

  Follow me on twitter