PDA

View Full Version : Exressions question?



67SS509
November 10th, 2009, 01:52 PM
When entering your expression in the calc.pid which is correct....

"({EXT.AD1}*2.5)+8.75"
or
"{EXT.AD1}*2.5+8.75"

or does it matter?

This is for a FJO wideband with a .5v-4.5v analog output= 10-20AFR

joecar
November 10th, 2009, 03:11 PM
The operator * has higher precedence than the operator + so both expressions are the same.

See the scantool user manual, page 92.

mr.prick
November 10th, 2009, 03:39 PM
It should have the brackets. IMO
Some of the WBO2 PIDs are missing them.

calc_pids will have improper data
if the equation is not strung together properly.

joecar
November 10th, 2009, 06:09 PM
Show me an example of "a*b + c" that does not mean "(a*b) + c"...? ;)

mr.prick
November 11th, 2009, 02:55 AM
Show me an example of "a*b + c" that does not mean "(a*b) + c"...? ;)

"({SAE.LONGFT1}+{SAE.LONGFT2})/2"
"({SAE.LONGFT1}+{SAE.LONGFT2}/2)"
6591

How about "(a+b)/c"? ;)
It might not make a difference with "a*b+c" but (a+b)/c" does. :doh2:
IMO it's better to get into the habit of using them.
A PID like this:
"({SAE.MAP.kPa})-value({SAE.MAP.kPa},frame()-1)"
would not work without brackets.
I'm no fan of syntax errors :throw:
Some of the predefined WBO2 PIDs have them and some don't. :confused:

joecar
November 11th, 2009, 03:40 AM
...
A PID like this:
"({SAE.MAP.kPa})-value({SAE.MAP.kPa},frame()-1)"
would not work without brackets.

This works (the one and only bracket pair removed):
"{SAE.MAP.kPa}-value({SAE.MAP.kPa},frame()-1)"

value() and frame() are functions and so ( ) are in their syntax.

mr.prick
November 11th, 2009, 04:17 AM
This works (the one and only bracket pair removed):
"{SAE.MAP.kPa}-value({SAE.MAP.kPa},frame()-1)"
value() and frame() are functions and so ( ) are in their syntax.

Not syntax but improper data, as far as this PID is concerned.
I tried a few different combos with this one until I got it to work right. :doh2:
It originally was this:
"Value({TP},frame()-1)-{TP}"
(I got it from Paul) :hihi:

The syntax error reference is not relevant here,
just pointing out that it's annoying when it happens.
Just because it "works" doesn't mean it will be right.
:cheers:

Like I said some of the predefined WBO2 PIDs have them and some do not,
even though the expressions are the same.
Example:
Wide Band AFR 1 - LC-1 {CALC.AFR_LC11}
Expression:
AFR = ({EXT.AD1}*3)+7.35

Wide Band AFR 2 - NGK AFX {CALC.AFR_NGK2}
Expression:
AFR = {EXT.AD2}*1.4+9
is VALID

I showed (a+b)/c can result in differing data but (a*b)+c may not.
Whether or not this results in the data being wrong/right
you will need to try both ways to see.
My 2¢

joecar
November 11th, 2009, 04:24 AM
Not syntax but improper data, as far as this PID is concerned.
I tried a few different combos with this one until I got it to work right. :doh2:
It originally was this:
"Value({TP},frame()-1)-{TP}"
(I got it from Paul) :hihi:
...
Hmmmm... What was going wrong...? Which {TP} occurance was giving the wrong value, the first or the last...?

If {X} gives a wrong value that is corrected by ({X}) then that is a bug.

Can you post a log file and a calc_pids.txt for me to look at.

That expression is finding the delta in TP from the previous frame to the current frame, right...?

joecar
November 11th, 2009, 04:35 AM
...
Like I said some of the predefined WBO2 PIDs have them and some do not,
even though the expressions are the same.
Example:
Wide Band AFR 1 - LC-1 {CALC.AFR_LC11}
Expression:
AFR = ({EXT.AD1}*3)+7.35

Wide Band AFR 2 - NGK AFX {CALC.AFR_NGK2}
Expression:
AFR = {EXT.AD2}*1.4+9
is VALID
Both of those work correctly.


I showed (a+b)/c can result in differing data but (a*b)+c may not.
a*b+c takes advantage of default precedence, whereas (a+b)/c requires parentheses.


Whether or not this results in the data being wrong/right
you will need to try both ways to see.
My 2¢I value your 2¢... I'm trying to see this for myself, I'll run a few experiments, I just need to know how to duplicate this and what to look for.

I work with programming languages and compilers everyday, and when the default precedence is not honoured then this is a MAJOR show stopper.

Oh, please do assume smilies in all my posts... :) ...I'm pretty easy to discuss things with.

joecar
November 11th, 2009, 04:38 AM
This works (the one and only bracket pair removed):
"{SAE.MAP.kPa}-value({SAE.MAP.kPa},frame()-1)"

value() and frame() are functions and so ( ) are in their syntax.


Not syntax but improper data, as far as this PID is concerned.

It originally was this:
"Value({TP},frame()-1)-{TP}"
(I got it from Paul) :hihi:

...value() needs ( ) since that's how it groups its parameter list...

frame() same thing, the parameter list is empty.

mr.prick
November 11th, 2009, 04:59 AM
The bracket themselves don't not make the difference in this PID in particular,
the whole equation is wrong.

Also notice how the wrong_load pid needed to be spelled
under description in the calc_pid.txt to be proper in the description row in the PIDs tab.
That is another issue tho. :hihi:

P.S.
The PIDs here 6592 show the current frame#,
and the difference in TPS% from the previous frame to the next.
Example:
frame #1 TPS% is 10%, frame #2 TPS% is 50%
delta_load will be 40%
Values will be negative with TPS% decreasing.
I use this both for filtering, enjoy. :secret:

joecar
November 11th, 2009, 07:58 AM
Ok, problem #1: you need to add 2 blank lines at the end of your calc_pid.txt file.

I'm still looking...

mr.prick
November 11th, 2009, 09:30 AM
Ok, problem #1: you need to add 2 blank lines at the end of your calc_pid.txt file.

I'm still looking...

Thanks Joe.
Adding more space at the bottom fixed the spelling issue. :cheers:
I didn't know that was needed.

On a side note,
I have been trying to make a time() PID but it always starts off with a highly positive number.
I want it to start from 0.

joecar
November 11th, 2009, 10:03 AM
Try "time(frame()) - time(0)" or "time() - time(0)".

i.e. subtract the timestamp of frame 0 from the timestamp of the current frame...

this will be in milliseconds, so divide by 1000 to get seconds.

joecar
November 11th, 2009, 10:05 AM
Thanks Joe.
Adding more space at the bottom fixed the spelling issue. :cheers:
I didn't know that was needed.
...Lol, I think it may be a bug, and the newlines hide it...:hihi:

mr.prick
November 11th, 2009, 10:14 AM
Thanks again Joe
" time() - time(0)"
This worked,
brackets and all. :laugh:

joecar
November 11th, 2009, 10:55 AM
lol.