Announcement

Collapse
No announcement yet.

VB Code for Dan Harrison's OBDScan

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • VB Code for Dan Harrison's OBDScan

    If anyone else has Dan Harrison's OBDScan tool here's some Visual Basic code to you started developing your own front end. Also check out the programmers guide (API) http://www.ghg.net/dharrison/OBDScanAPI.PDF


    Code:
    Option Explicit
    Dim B1, B2, B3, B4, Speed, RPM, CLoad, AFlow, TP, CTemp, ITime, AIT, MPres As Double
    Dim MyStrg, MyPos As String
    Dim OpenWindows
    'RPM code
    Private Sub cmdRPM_Click()
    Comm1.InBufferCount = 0
    Do
    OpenWindows = DoEvents()
    Loop Until Comm1.Input = "S"
    Comm1.Output = "010C07"
    Do
    OpenWindows = DoEvents()
    Loop Until Comm1.InBufferCount >= 15
    Text1.Text = Comm1.Input
    'set
    MyStrg = Text1.Text
    'Identify position of V in string
    MyPos = InStr(1, MyStrg, "V", 1)
    'Select first hexidecimal byte in reply
    Text1.SelStart = MyPos + 10
    Text1.SelLength = 2
    B1 = Text1.SelText
    'Select second hexidecimal byte in reply
    Text1.SelStart = MyPos + 12
    Text1.SelLength = 2
    B2 = Text1.SelText
    
    B3 = ("&H" & B1)
    B4 = ("&H" & B2)
    
    RPM = (((B3 * 256) + B4) / 4)
    RPM = Format(RPM, "0")
    'display it
    lblRPM.Caption = RPM & " RPM"
    End Sub
    'AIT code
    Private Sub cmdAirPressure_Click()
        Comm1.InBufferCount = 0
        Do
            OpenWindows = DoEvents()
        Loop Until Comm1.Input = "S"
        
        Comm1.Output = "010B06"
        
        Do
            OpenWindows = DoEvents()
        Loop Until Comm1.InBufferCount >= 13
        
        Text1.Text = Comm1.Input
        MyStrg = Text1.Text
        'Identify position of V in string
        MyPos = InStr(1, MyStrg, "V", 1)
        'Select first hexidecimal byte in reply
        Text1.SelStart = MyPos + 10
        Text1.SelLength = 2
        B1 = Text1.SelText
        'Convert slection into decimal
        B3 = ("&H" & B1)
        'calulate it
        MPres = (B3 * 0.29613)
        MPres = Format(MPres, "0.0")
        'display it
        lblAPres.Caption = MPres
    End Sub
    Private Sub cmdSpeed_Click()
    'Speed Code
    Comm1.InBufferCount = 0
    Do
    OpenWindows = DoEvents()
    Loop Until Comm1.Input = "S"
    Comm1.Output = "010D06"
    Do
    OpenWindows = DoEvents()
    Loop Until Comm1.InBufferCount >= 13
    Text1.Text = Comm1.Input
    'set MyStrng to contain reply from scanner
    MyStrg = Text1.Text
    'Identify position of V in string
    MyPos = InStr(1, MyStrg, "V", 1)
    'Select first hexidecimal byte in reply
    Text1.SelStart = MyPos + 10
    Text1.SelLength = 2
    B1 = Text1.SelText
    'convert selection into decimal
    B3 = ("&H" & B1)
    'Do calculation for speed
    Speed = (B3 * 0.6215)
    Speed = Format(Speed, "0.0")
    'display it!
    lblSpeed.Caption = Speed & " MPH"
    End Sub
    Private Sub cmdAIT_Click()
    Comm1.InBufferCount = 0
    Do
    OpenWindows = DoEvents()
    Loop Until Comm1.Input = "S"
    Comm1.Output = "010F06"
    Do
    OpenWindows = DoEvents()
    Loop Until Comm1.InBufferCount >= 13
    Text1.Text = Comm1.Input
    MyStrg = Text1.Text
    'Identify position of V in string
    MyPos = InStr(1, MyStrg, "V", 1)
    'Select first hexidecimal byte in reply
    Text1.SelStart = MyPos + 10
    Text1.SelLength = 2
    B1 = Text1.SelText
    'Convert slection into decimal
    B3 = ("&H" & B1)
    'calulate it
    AIT = (B3 - 40) * 1.8 + 32
    AIT = Format(AIT, "0.0")
    'display it!
    lblAIT.Caption = AIT & " F"
    End Sub
    Private Sub cmdClose_Click()
    If Comm1.PortOpen = False Then
    MsgBox "Port already closed"
    Else
    Comm1.PortOpen = False
    End If
    End Sub
    Private Sub cmdCoolent_Click()
    Comm1.InBufferCount = 0
    Do
    OpenWindows = DoEvents()
    Loop Until Comm1.Input = "S"
    Comm1.Output = "010506"
    Do
    OpenWindows = DoEvents()
    Loop Until Comm1.InBufferCount >= 13
    Text1.Text = Comm1.Input
    MyStrg = Text1.Text
    'Identify position of V in string
    MyPos = InStr(1, MyStrg, "V", 1)
    'Select first hexidecimal byte in reply
    Text1.SelStart = MyPos + 10
    Text1.SelLength = 2
    B1 = Text1.SelText
    'Convert slection into decimal
    B3 = ("&H" & B1)
    'calulate it
    CTemp = ((B3 - 40) * 1.8 + 32)
    CTemp = Format(CTemp, "0")
    'display it!
    lblCoolent.Caption = CTemp & " F"
    End Sub
    Private Sub cmdCLoad_Click()
    Comm1.InBufferCount = 0
    Do
    OpenWindows = DoEvents()
    Loop Until Comm1.Input = "S"
    Comm1.Output = "010406"
    Do
    OpenWindows = DoEvents()
    Loop Until Comm1.InBufferCount >= 13
    Text1.Text = Comm1.Input
    MyStrg = Text1.Text
    'Identify position of V in string
    MyPos = InStr(1, MyStrg, "V", 1)
    'Select first hexidecimal byte in reply
    Text1.SelStart = MyPos + 10
    Text1.SelLength = 2
    B1 = Text1.SelText
    'Convert slection into decimal
    B3 = ("&H" & B1)
    'calulate it
    CLoad = ((B3 / 255) * 100)
    CLoad = Format(CLoad, "0")
    'display it!
    lblengineLoad.Caption = CLoad & " %"
    End Sub
    Private Sub cmdOpen_Click()
    If Comm1.PortOpen = True Then
    MsgBox "Port already Open"
    Else
    Comm1.PortOpen = True
    End If
    End Sub
    Private Sub cmdTP_Click()
    Comm1.InBufferCount = 0
    Do
    OpenWindows = DoEvents()
    Loop Until Comm1.Input = "S"
    Comm1.Output = "011106"
    Do
    OpenWindows = DoEvents()
    Loop Until Comm1.InBufferCount >= 13
    Text1.Text = Comm1.Input
    MyStrg = Text1.Text
    'Identify position of V in string
    MyPos = InStr(1, MyStrg, "V", 1)
    'Select first hexidecimal byte in reply
    Text1.SelStart = MyPos + 10
    Text1.SelLength = 2
    B1 = Text1.SelText
    'Convert slection into decimal
    B3 = ("&H" & B1)
    'calulate it
    TP = (B3 / 256) * 100
    TP = Format(TP, "0")
    'output
    lblTP.Caption = TP & " %"
    End Sub

  • #2
    I am looking for a tool that I can make my own front end to. I am considering buying his tool and was wondering if it was any good? Does he support it well? Also could you send me, or post the whole .vbp with the forms please. Not that good with cars, i know my cavalier uses VPW do you have any recomendations as to which one I should get?

    OBDScan-VPW $110.00
    OBDScan-VPW-PWM $125.00

    - OR -

    OBDScanUSB - Universal Package with native USB interface - includes all you need except the computer, for Windows 98,ME,2000 and XP USB interface.
    ISO-9141,VPW,PWM, KWP2000
    ----------USB Tool Only ---------------
    NOTE: Ford Extended Data software will
    be available Jan. '04 with USB support $160.00

    that one. I will share the interface once I make it, I just need to know what connecter will be best. Thanks in advance.
    CarComputer Status: New Car & Broken (Motherboard Fried)
    Owen JH | My Linux Blog | The Tech Fellows

    Comment


    • #3
      wow, that is $$
      I have this one http://www.scantool.net/software.htm
      But the software blows. Was wondering if I could use this API for Scantool? Wishful thinking I'm sure.

      Comment


      • #4
        They recommend I buy the one that supports all 3 protocols $140, would be nice.
        CarComputer Status: New Car & Broken (Motherboard Fried)
        Owen JH | My Linux Blog | The Tech Fellows

        Comment


        • #5
          2k1civic.com, try software from odb2crazy.com (http://www.obd2crazy.com/software.html) it has VB OCX so in theory you could build up a VB program around it.
          Let me know because I would like to buy from scantool.net
          -NicGalla-
          custom-made aluminum case | MK2.8+ PSU | EPIA 800 | 256 Mb DDR | 120 Gb 7.2k WD | Wireless Chieftec mouse & keyb | Trust USB Keypad & USB webcam | Majestic TFT 7" 16:9 | WinXP & ME2 | connected to factory head-unit in a PT Cruiser 2.0L

          Comment


          • #6
            http://www.obddiagnostics.com/ supports all 3 protocols and only costs $88. I have it, and it works great.
            Chrysler 300 - Fabricating
            http://hallert.net/

            Comment


            • #7
              so are there any freeware tools out that let you get 0-60, 1/4mile times?

              Comment


              • #8
                I doubt it. Even the paid software seems to suck. I have yet to see an OBD-II program that didn't have a horrible interface.

                Comment


                • #9
                  anyone know how to use this vb code? ive looked at it but it seems to be missing alot of information. is there anyone out there that has a working vb code or any source code that can successfully connect to the obd2 port using an elm interface? Im not looking for a program, only the source code.

                  Comment

                  Working...
                  X