Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 34

Thread: Yet Another OBDII VB6 Class

  1. #21
    Low Bitrate Erorus's Avatar
    Join Date
    Feb 2005
    Location
    NEPA
    Posts
    100
    I wrote this class back in the day.. Basically, once you create mscomm1 and timer1 you'll never need to touch those controls. When you use
    dim withevents elm as clselm323
    then you should see "elm" as a control in the code window with its own events. Those events fire whenever things happen with that class. So you don't have to handle mscomm1_oncomm at all.

    Let's say that your elm323 is on com2.

    strReturn$ = elm.openELM(mscomm1, 2, timer1)
    if strReturn$ = "" then
    msgbox "opened successfully"
    else
    msgbox "open error: " & strReturn$
    end if



    private sub elm_statusmessage(byval strMessage as string)
    debug.print strMessage
    end sub

    private sub elm_OBDReturn(ByVal bMode As Byte, ByVal bPID As Byte, ByVal strData As String, ByVal lngData As Long)
    msgbox "OBD Returned mode " & cstr(cint(bMode)) & ", pid " & cstr(cint(bPID)) & ": " & cstr(lngdata)
    end sub

  2. #22
    Newbie
    Join Date
    Jul 2007
    Posts
    3
    You might want to convert tSpeed from kph to mph

    Quote Originally Posted by Erorus View Post
    PHP Code:
    Function GetMPG(tMAF As Variant
       
    tSpeed As VarianttLTFuelTrim As Variant) As Variant ... 
    The problem I have with this is the air flow sensor is very optimistic, and you probably run richer than this formula indicates. It says I average around 60-90MPG when cruising on the hwy and up to 200+ MPG when coasting. However, it does change when you have the pedal down, etc. I forget where I stole this code from.
    Quote Originally Posted by stevieg View Post
    It looks like my botched attempt at MPG conversion I think.

    I didn't think it was accurate as it could be either, and haven't actually used it in real-life.

    Any idea what could be done using the OBD to get a more accurate measure?

  3. #23
    Newbie
    Join Date
    Jun 2003
    Posts
    23
    First of all thanks Erorus for nice class. I was able to implement OBD read VB program in few hours.

    http://www.mp3car.com/vbulletin/engi...-maf-obd2.html

    I tried using the MPG calculation in above thread and it seems to be pretty accurate. Many constants are similar to what is shown in this thread but this thread seems to be missing pound to gallon conversion and seems to be off by 10x as well. I see that the fuel trim is used here. I'll try to apply that. Looks like it may give you better estimate for your car rather than looking for ideal values.

    The equation I am using is

    14.7 g of air / 1 g of gas * 6.17 lb / 1 gal * 454 g / 1 lb * VSS Km / 1 h * 1 Mi / 1.609344 Km * 1s / MAF (100g from OBD) * 100g * 1 h / 3600 s * (0.7812 * (LTFT - 128) + 1)

    Which will be

    710.7 * VSS / MAF * (0.7812 * (LTFT - 128) + 1)

    When cruising I get about 20 MPG and when I press the clutch I get like 105MPG which kinda makes sense.... =P When I calculate MPG when I fuel my car I get about 23MPG so I think this is pretty close.

    Erorus, do you know if there is a way to read the OBD data in burst fashion? Or is this the limitation of ELM chip? I tried to tune the time to read the data from OBD but reading those three data takes at least 2.5 s. I kind of want to be able to read all three at the same time to increase the accuracy. In 2.5 second many things can change.
    Is there a way to read back the data more quickly?

    If not I guess running average or something similar can be implemented I suppose.. =)

    Regards

  4. #24
    Newbie
    Join Date
    Jun 2003
    Posts
    23
    Actually instead of 0.7812 it should be -0.007812. I forgot this was in percentage and also positive value means on LTFT means using more fuel.

    Regards

  5. #25
    Newbie
    Join Date
    Jun 2003
    Posts
    23
    I found my error regarding data ready time. I've set the timer interval before openELM function so default must have been assigned. I was able to set it to 200ms without getting any errors. However it would still be nice if we can read the data at the same time though. Is this possible?

    Regards,

  6. #26
    Newbie
    Join Date
    May 2007
    Posts
    36
    Wouldn't it be easier to just use injector duty-cycle, engine RPM, and speed to derive this data?

  7. #27
    Newbie
    Join Date
    May 2007
    Posts
    36
    I know nothing about PHP and I also know very little about what is avalible from the OBD2 interface, but here goes:

  8. #28
    Newbie
    Join Date
    May 2007
    Posts
    36
    Quote Originally Posted by Erorus View Post
    PHP Code:
    Function GetMPG(tIDC As VarianttSpeed As Variant) As Variant

    ''tIDC is injector duty cycle

    ''tSpeed is vehicle speed in MPHTo convert from what the OBD returnsvalue=OBDData 0.621371192

    ''tVFF is volume fuel flow.
        
        If 
    IsNull(tIDC) Or IsNull(tSpeedThen
            GetMPG 
    Null
            
    Exit Function
        
    End If

        
    Dim tMPG As String
        Dim tVFF 
    As String

        
    '' Do VFF (gallons/minute)

        
    tVFF tIDC 250 0.000264172051 
        
        
    '' Do Speed in miles/min

        tSpeed 
    tSpeed/60

        
    '' Calculate MPG
        tMPG 
    = (tSpeed tVFF) * tLTFuelTrim

        GetMPG 
    FormatNumber(tMPG1TrueFalseFalse)

    End Function 
    This is with 250cc/min injectors. Would something like this work?

  9. #29
    Newbie
    Join Date
    May 2008
    Posts
    1
    Yes i always wanted to make one of these. But i dont know how im not that smart of a person. But i love to learn ... You people know any good places to find codes for this stuff.

  10. #30
    Newbie
    Join Date
    Apr 2008
    Posts
    4
    what is the bMode used in send_to_obd? also, what form should i be sending the PIDs as? something like "SAE.RPM" or the hex value 0C ?

    and example send_to command would be helpful as well

Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Able to get voltage from OBDII?
    By aoLhaTer in forum Engine Management, OBD-II, Engine Diagnostics, etc.
    Replies: 10
    Last Post: 07-18-2007, 10:26 PM
  2. FS: OBDII diagnostic interface
    By deskcom in forum Classified Archive
    Replies: 0
    Last Post: 12-10-2004, 12:24 AM
  3. @ Leddy OBDII
    By gyro in forum NeoCar Media Center
    Replies: 4
    Last Post: 12-08-2004, 07:43 PM
  4. Pick my Programing class for me!
    By Sonicxtacy02 in forum Off Topic
    Replies: 14
    Last Post: 11-23-2004, 09:59 PM
  5. 1994 Saab 900 & OBDII
    By Shark in forum General Hardware Discussion
    Replies: 2
    Last Post: 11-03-2003, 09:58 AM

Bookmarks

Posting Permissions

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