Page 1 of 2 12 LastLast
Results 1 to 10 of 32

Thread: V8 Scan - Calculated Pids

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Joe (Moderator) joecar's Avatar
    Join Date
    Apr 2003
    Posts
    28,400

    Default

    Paul, also see post #139 in this thread: AEM-X-Series-OBDII-Wideband-UEGO-AFR-Sensor-Controller-Gauge

  2. #2
    Lifetime Member Ninety8C5's Avatar
    Join Date
    Sep 2003
    Posts
    446

    Default

    I don't know if this is what you are trying to accomplish, but I just built this in V8.

    If not totally disregard.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	EFILive Calc PID.jpg 
Views:	567 
Size:	51.2 KB 
ID:	20558  

  3. #3
    Joe (Moderator) joecar's Avatar
    Join Date
    Apr 2003
    Posts
    28,400

    Default

    Quote Originally Posted by Ninety8C5 View Post
    I don't know if this is what you are trying to accomplish, but I just built this in V8.

    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)




    Click image for larger version. 

Name:	Function Editor~000013.png 
Views:	646 
Size:	43.9 KB 
ID:	20560
    Last edited by joecar; December 15th, 2016 at 02:15 PM.

  4. #4
    EFILive Developer Site Admin Blacky's Avatar
    Join Date
    Mar 2003
    Posts
    9,606

    Default

    Quote Originally Posted by joecar View Post
    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...nary-operator/ (although there's issues with nil values).

    I think it would look something like this:
    Code:
    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:

    Code:
    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
    Before asking for help, please read this.

  5. #5
    Joe (Moderator) joecar's Avatar
    Join Date
    Apr 2003
    Posts
    28,400

    Default

    Quote Originally Posted by Blacky View Post
    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...nary-operator/ (although there's issues with nil values).

    I think it would look something like this:
    Code:
    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:

    Code:
    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
    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:
    [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"),p id("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")

  6. #6
    EFILive Developer Site Admin Blacky's Avatar
    Join Date
    Mar 2003
    Posts
    9,606

    Default

    Quote Originally Posted by joecar View Post
    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
    Before asking for help, please read this.

  7. #7
    Joe (Moderator) joecar's Avatar
    Join Date
    Apr 2003
    Posts
    28,400

    Default

    Quote Originally Posted by Blacky View Post
    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
    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++.



    Click image for larger version. 

Name:	EFILive Scan Tool~000017.png 
Views:	875 
Size:	129.6 KB 
ID:	20568
    Last edited by joecar; December 15th, 2016 at 03:19 PM.

  8. #8
    Joe (Moderator) joecar's Avatar
    Join Date
    Apr 2003
    Posts
    28,400

    Default

    Paul, how do you comment (as in commenting out)...?

  9. #9
    EFILive Developer Site Admin Blacky's Avatar
    Join Date
    Mar 2003
    Posts
    9,606

    Default

    Quote Originally Posted by joecar View Post
    Paul, how do you comment (as in commenting out)...?
    Click image for larger version. 

Name:	lua_comments.png 
Views:	633 
Size:	54.5 KB 
ID:	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
    Before asking for help, please read this.

  10. #10
    Joe (Moderator) joecar's Avatar
    Join Date
    Apr 2003
    Posts
    28,400

    Default

    Quote Originally Posted by Blacky View Post

    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
    Paul, thanks.

Page 1 of 2 12 LastLast

Similar Threads

  1. Calculated pids
    By x MadMAX DIESEL in forum Black Box Logging
    Replies: 37
    Last Post: June 22nd, 2018, 09:26 AM
  2. Calculated PIDS?
    By beav in forum Diesel
    Replies: 0
    Last Post: December 3rd, 2013, 04:19 AM
  3. Calculated pids not displayed on V2
    By ttls1 in forum Black Box Logging
    Replies: 3
    Last Post: October 7th, 2013, 08:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •