Robban
02-03-2007, 04: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
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