Shop OBEX P1 Docs P2 Docs Learn Events
OBD-2 visual basic program to Pbasic — Parallax Forums

OBD-2 visual basic program to Pbasic

RobbanRobban Posts: 124
edited 2007-02-03 09:57 in BASIC Stamp
Hi
Found this program on the net and now i wonder if it is possible to convert it to Pbasic?
It´s a program that reads speed and rpm from a car computer (OBD-2)


'RPM code 010C
Private Sub cmdRPM_Click()
MyStrg = ""
MSComm1.Output = "010C" & vbCr
··· MyStrg = MSComm1.Input
··· Text1.Text = MyStrg
··· Temp = Mid(MyStrg, 15, 3)
··· If InStr(1, Temp, ">") <> 0 Then
··· 'If Mid(MyStrg, 15, 3) = ">" Then
··· B1 = Mid(MyStrg, 7, 2)
··· B2 = Mid(MyStrg, 10, 2)
···
··· B3 = ("&H" & B1) 'Convert to Hex
··· B4 = ("&H" & B2)
··· RPM = (((B3 * 256) + B4) / 4)
··· RPM = Format(RPM, "0")
··· lblRPM.Caption = RPM & " RPM" 'Output RPM
··· Else
··· 'Do nothing
··· End If
End Sub


Private Sub cmdSpeed_Click()
'Speed Code
MyStrg = ""
MSComm1.Output = "010D" & vbCr
MyStrg = MSComm1.Input
··· Text1.Text = MyStrg
··· Temp = Mid(MyStrg, 12, 3)
··· If InStr(1, Temp, ">") <> 0 Then
··· 'If Mid(MyStrg, 12, 1) = ">" Then
··· B1 = Mid(MyStrg, 7, 2)
'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"
Else
'Do nothing
End If
End Sub

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2007-02-02 21:59
    At first, I was going to say no, a BS2 can't do what VB does.

    At second look, it appears you're getting a few serial bytes from the OBD computer, then parsing them into something that can be displayed. And yes, the BS2 can easily do the few bytes you're looking for.
  • bassmasterbassmaster Posts: 181
    edited 2007-02-03 02:39
    the prop may be esier to code though, and you will not run out of ram for that app.
  • RobbanRobban Posts: 124
    edited 2007-02-03 07:47
    the prop?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-02-03 09:57
    Robban -

    Confusing for sure, since there is both a Prop-1 board:
    http://www.efx-tek.com/topics/prop-1.html

    and the new Propeller chip - both products which come or came from Parallax development resources. This is the Propeller chip which I suspect is what he's speaking about:
    http://www.parallax.com/propeller/index.asp

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
Sign In or Register to comment.