PDA

View Full Version : V8 Scan - Calculated Pids



Tre-Cool
December 14th, 2016, 04:52 AM
Can we get an official break down or explanation on creating calculated pids for V8 or let me know if your happy with my explanation?

I've created a few Ben's tonight so i can start playing with the AEM CAN Wideband so thought i'd let everyone else know what i did.

1) Just like adding calculated pids for V7.5, get your self a good text editor. I recommend Notepad++
2) Browse to your My Documents\EFILive\V8\Config folder and open up the UserCalculatedPids.ini file
3) Copy in the sample data below


Sample Pids for AEM Can Wideband:

[Groups]
WO2CAN=Wide Band O2 Sensors - Canbus

[WO2CAN]
CANBEN_1="Base Efficiency Numerator 1 - Canbus",factor,3
CANBEN_2="Base Efficiency Numerator 2 - Canbus",factor,3
CANBEN_1_E40="Base Efficiency Numerator 1 E40 - Canbus",factor,3
CANBEN_2_E40="Base Efficiency Numerator 2 E40 - Canbus",factor,3

[WO2CAN.BEN_1]
0=|-- WO2CAN.BEN_1
1=|return pid("WO2S11")/pid("EQ_RAT")

[WO2CAN.BEN_2]
0=|-- WO2CAN.BEN_2
1=|return pid("WO2S12")/pid("EQ_RAT")

[WO2CAN.BEN_1_E40]
0=|-- WO2CAN.BEN_1
1=|return pid("WO2S11")*pid("EQ_RAT")

[WO2CAN.BEN_2_E40]
0=|-- WO2CAN.BEN_2
1=|return pid("WO2S12")*pid("EQ_RAT")

My understanding of the pid break downs is it's all similar to the old way doing things, except now you set them up via groups.

For each group, you have your old "PRN" or Description information, but you also set the formatting info here.

CANBEN_1="Base Efficiency Numerator 1 - Canbus",factor,3

In the old V7.5 format it would look like this:
CALC.Lambda-WO2BENS F110 CLC-00-115 factor "W02-Ben" "BEN from External Lambda"

Now the math or calculating part is defined for each one of those in the next break down:
[WO2CAN.BEN_1]
0=|-- WO2CAN.BEN_1
1=|return pid("WO2S11")/pid("EQ_RAT")

Obviously the first line in brackets is the header for your pid as such will be listed in your master group.

The next few lines I'm guessing tell the scanner what to do with the data. I'm not sure why the first 0 line is required, but it seems obvious what the 1 line does.

That's our "work" part where all the magic happens. we are telling it to use the data from the W02S11 pid & then divide or multiple by another pid etc, Just like we would set up in the old V7.5 slot definition area.
factor 0.5 1.5 .3 "{EXT.WO2LAM1}/{SAE.LAMBDA}"

Now looking at the above and some of the efilive defined pids, I'm actually thinking it might be possible to setup/define something like below to have all the CAN wb's.

[WO2CAN.BEN_1]
0=|-- WO2CAN.BEN_1
1=|return pid("WO2S11,WO2S12,WO2S21,WO2S22")/pid("EQ_RAT")

20553

EFi Guys?

joecar
December 14th, 2016, 12:54 PM
+1 on Notepad++.

joecar
December 14th, 2016, 12:57 PM
Yes, that is my understanding...


but the following won't define BEN's for all your widebands... it selects whichever of the mentioned pids is available, and from it it calculates this particular BEN.


[WO2CAN.BEN_1]
0=|-- WO2CAN.BEN_1
1=|return pid("WO2S11,WO2S12,WO2S21,WO2S22")/pid("EQ_RAT")




I'm not sure, but see my corrections (based on your definitions above) below:
( and further corrections to correct my omission )


[WO2CAN]
CANBEN_1="Base Efficiency Numerator 1 - Canbus",factor,3
CANBEN_2="Base Efficiency Numerator 2 - Canbus",factor,3
CANBEN_1_E40="Base Efficiency Numerator 1 E40 - Canbus",factor,3
CANBEN_2_E40="Base Efficiency Numerator 2 E40 - Canbus",factor,3

[WO2CAN.CANBEN_1]
0=|-- WO2CAN.CANBEN_1
1=|return pid("WO2S11")/pid("EQ_RAT")

[WO2CAN.CANBEN_2]
0=|-- WO2CAN.CANBEN_2
1=|return pid("WO2S12")/pid("EQ_RAT")

[WO2CAN.CANBEN_1_E40]
0=|-- WO2CAN.CANBEN_1_40
1=|return pid("WO2S11")*pid("EQ_RAT")

[WO2CAN.CANBEN_2_E40]
0=|-- WO2CAN.CANBEN_2_E40
1=|return pid("WO2S12")*pid("EQ_RAT")



Too bad about the E40 EQR being inverted.

joecar
December 14th, 2016, 01:29 PM
I'm trying to do this:

Combining my AEM CAN pid into my serial pid would be this:



[Groups]
WO2SER=Wide Band O2 Sensors (Serial Comms)
WO2CAN=Wide Band O2 Sensors (CAN bus)

[WO2SER]
WO2BEN="Base Efficiency Numerator (Serial Comms)(Dynamically Leanest)",factor,3

[WO2CAN]
WO2BEN="Base Efficiency Numerator (CAN bus)(Dynamically Leanest)",factor,3

[WO2SER.WO2BEN]
0=|-- WO2SER.WO2BEN
1=|return iff(pid("WO2LAM1")>pid("WO2LAM2"),pid("WO2LAM1"),pid("WO2LAM2"))*pid("EQIVRATIO")

[WO2CAN.WO2BEN]
0=|-- WO2CAN.WO2BEN
1=|return iff(pid("WO2S11")>pid("WO2S21"),pid("WO2S11"),pid("WO2S21"))/pid("LAMBDA")


I need the iff() to be defined.

joecar
December 14th, 2016, 01:40 PM
I ended up defining my own iff(), but I'm wanting iff() to be a function not a calc pid...



0=|-- CALC.IFF
1=|function iff(x,y,z)
2=| if (x) then
3=| return y
4=| else
5=| return z
6=| end
7=|end

joecar
December 14th, 2016, 02:10 PM
I understand that EQ_RAT is LAMBDA or 1/LAMBDA.

joecar
December 14th, 2016, 02:13 PM
Paul, also see this:


20554

Tre-Cool
December 14th, 2016, 02:53 PM
Yes, that is my understanding...


but the following won't define BEN's for all your widebands... it selects whichever of the mentioned pids is available, and from it it calculates this particular BEN.




I'm not sure, but see my corrections (based on your definitions above) below:



Too bad about the E40 EQR being inverted.

Yeah the inversion thing for e40 is easy to fix on the pid, If only we could sweet talk the guys into fixing the editor scales to match all the other ls1/e38 scales. (i.e transpose the axis around).

I'll test out the canbus AEM further on the weekend as i just did a quick and dirty wire up of the guage to see if i could get it working. Biggest change is getting used to the V8 scanner. I still havent worked out how to set the data parameter in the maps yet either. I set the axis, but don't see anything obvious about what data it's using.

joecar
December 14th, 2016, 03:01 PM
Yeah, V8 scantool is a major change in way of thinking vs V7 scantool.


Even tho we log the AEM via CAN bus using FSV2, we should still be able to view the log in V7 scantool, is that not true...?


lol, looking at my corrections, I see I omitted something.

Tre-Cool
December 14th, 2016, 03:05 PM
I haven't been able to open any v8 logs in 7.

V7 also wont allow you to log 2 different controllers either I believe. So to use the AEM, we have to use the V8 scanner or setup BBX.

joecar
December 15th, 2016, 08:34 AM
Paul, also see post #139 in this thread: AEM-X-Series-OBDII-Wideband-UEGO-AFR-Sensor-Controller-Gauge (https://forum.efilive.com/showthread.php?26689-AEM-X-Series-OBDII-Wideband-UEGO-AFR-Sensor-Controller-Gauge&p=235237&viewfull=1#post235237)

Ninety8C5
December 15th, 2016, 09:26 AM
I don't know if this is what you are trying to accomplish, but I just built this in V8. :unsure:

If not totally disregard.

joecar
December 15th, 2016, 02:04 PM
I don't know if this is what you are trying to accomplish, but I just built this in V8. :unsure:

If not totally disregard.Yes, it is what I want (see mine attached), but I wanted to avoid using an if-then/if-else, I wanted Paul to include a builtin iff() function or operator

(hmmm, operator would be nicer than a function)

:)


20560

Blacky
December 15th, 2016, 02:21 PM
Can we get an official break down or explanation on creating calculated pids for V8 or let me know if your happy with my explanation?

I've created a few Ben's tonight so i can start playing with the AEM CAN Wideband so thought i'd let everyone else know what i did.

1) Just like adding calculated pids for V7.5, get your self a good text editor. I recommend Notepad++
2) Browse to your My Documents\EFILive\V8\Config folder and open up the UserCalculatedPids.ini file
3) Copy in the sample data below

EFi Guys?

You don't need to (nor should you) be editing that text file directly. You should use the built in calc PID editor for V8.

[F2: Scan]->[Config]:Calculate PIDs (hotkey Ctrl_K)

Regards
Paul

joecar
December 15th, 2016, 02:29 PM
Paul, how do you comment (as in commenting out)...?

joecar
December 15th, 2016, 02:31 PM
It's Pascal/Algol-like:

20562

Tre-Cool
December 15th, 2016, 02:35 PM
So did what i have for a single wideband be all i need to have for a functioning BEN factor to populate a map?

Until i connect to an ecu, i can't tell if it's actually going to populate a map. Seems you need to manually type in the data pid. How come we can't just select a pid like we can for the row/column tables?

Blacky
December 15th, 2016, 02:36 PM
Yes, it is what I want (see mine attached), but I wanted to avoid using an if-then/if-else, I wanted Paul to include a builtin iff() function or operator

The language is Lua, so whatever is available in that language is what you can use. I'm not able to modify the Lua language - sorry :(
https://www.lua.org/manual/5.2/#index

You could try this: http://hisham.hm/2011/05/04/luas-and-or-as-a-ternary-operator/ (although there's issues with nil values).

I think it would look something like this:

return pid("EQIVRATIO") * ((pid("WO2LAM1")>pid("WO2LAM2")) and pid("WO2LAM1") or pid("WO2LAM2"))

Or you could just write a function to do it, like this:


function iff(cond, a, b)
if cond then
return a
else
return b
end
end

return pid("EQIVRATIO") * iff(pid("WO2LAM1")>pid("WO2LAM2"),pid("WO2LAM1"),pid("WO2LAM2"))



Regards
Paul

joecar
December 15th, 2016, 02:42 PM
The language is Lua, so whatever is available in that language is what you can use. I'm not able to modify the Lua language - sorry :(
https://www.lua.org/manual/5.2/#index

You could try this: http://hisham.hm/2011/05/04/luas-and-or-as-a-ternary-operator/ (although there's issues with nil values).

I think it would look something like this:

return pid("EQIVRATIO") * ((pid("WO2LAM1")>pid("WO2LAM2")) and pid("WO2LAM1") or pid("WO2LAM2"))

Or you could just write a function to do it, like this:


function iff(cond, a, b)
if cond then
return a
else
return b
end
end

return pid("EQIVRATIO") * iff(pid("WO2LAM1")>pid("WO2LAM2"),pid("WO2LAM1"),pid("WO2LAM2"))

Regards
PaulThanks Paul...

that's what programming is about, working with what is available;


I ended up defining my own, the .ini looks like this now:


[Groups]
FUNCTION=Function definitions
WO2SER=Wide Band O2 Sensors (Serial-Comms)
WO2CAN=Wide Band O2 Sensors (CAN-bus)

[FUNCTION]
IFF=IFF,factor,0

[FUNCTION.IFF]
0=|-- FUNCTION.IFF
1=|function iff(x,y,z)
2=|if (x) then return y else return z end
3=|end

[WO2SER]
WO2BEN="Base Efficiency Numerator (Serial-Comms)(Dynamically-Leanest)",factor,3

[WO2SER.WO2BEN]
0=|-- WO2SER.WO2BEN
1=|return iff(pid("WO2LAM1")>pid("WO2LAM2"),pid("WO2LAM1"),pid("WO2LAM2"))*pid("EQIVRATIO")

[WO2CAN]
WO2BEN="Base Efficiency Numerator (CAN-bus)(Dynamically-Leanest)",factor,3

[WO2CAN.WO2BEN]
0=|-- WO2CAN.WO2BEN
1=|return iff(pid("WO2S11")>pid("WO2S21"),pid("WO2S11"),pid("WO2S21"))/pid("EQ_RAT")

Blacky
December 15th, 2016, 02:52 PM
Paul, how do you comment (as in commenting out)...?

20564

It seems like a pretty arbitrary and strange pair of tokens to use for block comments but it makes including/excluding blocks of code much easier:

--[[ I want to exclude the next two lines
a = b+c
d = e+f
--]]

---[[ I want to include the next two lines
a = b+c
d = e+f
--]]

Notice that by just adding another minus sign to the --[[ start comment token, it is no longer a valid start comment block, it is just a single line comment, so the two lines of code are now included again.
The end comment token is also ignored because it is now just a single line comment.

Regards
Paul

Blacky
December 15th, 2016, 02:57 PM
Thanks Paul...

that's what programming is about, working with what is available;


I ended up defining my own, the .ini looks like this now:

I have not tried this, but you should be able to create a group/pid that contains multiple functions. I.e. say a group called "Global" and a PID called "Functions" and then define multiple functions in that Global.Functions "pid definition". Then you could call any of those functions from any calculated PID function.

Regards
Paul

joecar
December 15th, 2016, 02:59 PM
It seems like a pretty arbitrary and strange pair of tokens to use for block comments but it makes including/excluding blocks of code much easier:

--[[ I want to exclude the next two lines
a = b+c
d = e+f
--]]

---[[ I want to include the next two lines
a = b+c
d = e+f
--]]

Notice that by just adding another minus sign to the --[[ start comment token, it is no longer a valid start comment block, it is just a single line comment, so the two lines of code are now included again.
The end comment token is also ignored because it is now just a single line comment.

Regards
PaulPaul, thanks.

joecar
December 15th, 2016, 03:02 PM
Paul,

I want to draw your attention to this:

20565


and also to this (from post #7 above):

20566

joecar
December 15th, 2016, 03:03 PM
Also, how do you log from two AEM 03-0334 units...?


20567

joecar
December 15th, 2016, 03:12 PM
I have not tried this, but you should be able to create a group/pid that contains multiple functions. I.e. say a group called "Global" and a PID called "Functions" and then define multiple functions in that Global.Functions "pid definition". Then you could call any of those functions from any calculated PID function.

Regards
PaulThe V8 calc pid editor won't let me spell out Global, it stops after 4 characters... I had to dive into the ini file with Notepad++.



20568

Blacky
December 15th, 2016, 03:27 PM
The V8 calc pid editor won't let me spell out Global, it stops after 4 characters... I had to dive into the ini file with Notepad++.

Ahh yes, I did that to try and keep the total Group.PID name length to a reasonable size for black box logging.
It should not be a problem for calculated PIDs, because calc PIDs are not logged/evaluated during black box logging.
I may look at allowing those group names for calculated PIDs to be longer than 4 characters.

Regards
Paul

Blacky
December 15th, 2016, 03:28 PM
Also, how do you log from two AEM 03-0334 units...?


20567


Right now you can't. It is limited to only 1
I'm not sure if/when EFILive will support dual AEMs.

Regards
Paul

joecar
December 15th, 2016, 03:44 PM
Right now you can't. It is limited to only 1
I'm not sure if/when EFILive will support dual AEMs.

Regards
PaulWe have been using dual widebands, I tune to the leanest bank dynamically (using iff() in the BEN pid to select the leanest wideband lambda)...

and since the AEM 03-0334 will have a high sample rate, dual wideband ability (ability to tune to leanest bank) would be a good feature to have.

joecar
December 15th, 2016, 04:06 PM
Paul,

I also see an AV:


20569

dr.mike
December 15th, 2016, 05:21 PM
Getting multi-channel lambda working with EFILive would be tricky. Somehow, both lambda channels would need to be reported by one gauge. So, one gauge would need to listen to the other, and, parrot its data. I guess I could rig up a test version that reports PIDs 0x24 and 0x25 from a single controller.

joecar
December 16th, 2016, 07:25 AM
Getting multi-channel lambda working with EFILive would be tricky. Somehow, both lambda channels would need to be reported by one gauge. So, one gauge would need to listen to the other, and, parrot its data. I guess I could rig up a test version that reports PIDs 0x24 and 0x25 from a single controller.dr.mike,

That would be great, thanks :cheers:

we can test it out at Martin's shop.

Tre-Cool
December 17th, 2016, 10:23 PM
See here (https://forum.efilive.com/showthread.php?27288-Known-Issues-With-Current-Public-Release&p=235311&viewfull=1#post235311) about an issue had trying to work with the ben. Could be just a logger issue.