PDA

View Full Version : OBD-2 visual basic program to Pbasic



Robban
02-03-2007, 05:13 AM
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

allanlane5
02-03-2007, 05:59 AM
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.

bassmaster
02-03-2007, 10:39 AM
the prop may be esier to code though, and you will not run out of ram for that app.

Robban
02-03-2007, 03:47 PM
the prop?

Bruce Bates
02-03-2007, 05:57 PM
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 -->