BS2p and GPS PMB-248 help
BKane
Posts: 9
I am trying to calculate the speed of a vehicle using the gps module. I want to take this information and send it to the BS2p module which will output this information. I have used the gps earlier and got my position correctly. But when I just tried to use it, I am getting a completely different position than before. I was just trying to find the position to see if the gps was working correctly. But here is the code I am using to calculate speed:
' {$STAMP BS2p}
' {$PBASIC 2.5}
'By George Lejnine and parts by Randy Price
'Program to read in GPS coordinates from the NMEA 0183 GPRMC statement
'Many parts have been removed such as time and course direction, for simplicity. They can easily be added.
GPS PIN 15
tens VAR Byte
tens_conv VAR Word
digits VAR Byte
digits_conv VAR Word
tenth VAR Byte
tenth_conv VAR Word
knots VAR Word
speed1 VAR Word
speed2 VAR Word
mph VAR Word
mph_conv VAR Word
'Baud rates:
n4800 CON 16884
main:
'The number after SERIN is the Pin to which the Green wire is connected, in our case 15
SERIN GPS, n4800 ,noGPS1,[noparse][[/noparse]WAIT("RMC,"),SKIP 34, DEC1 tens, DEC1 digits, SKIP 1, DEC1 tenth]
GOSUB speed
GOSUB output1
GOTO main
'******************************************* OUTPUT ROUTINE *******************************************
speed:
tens_conv=tens*115
digits_conv=(digits*115)/10
tenth_conv=(tenth*115)/100
mph = tens_conv + digits_conv + tenth_conv + 5 'tenths of knots
mph_conv= mph/10
'using 6 instead of 60 takes care of the tenths of knots
'necessary to read GPS in integer form.
RETURN
output1:
DEBUG DEC tens, DEC digits, ".", DEC tenth, " knots",CR
DEBUG "Vehicle Speed:", DEC mph_conv , " MPH", CR
PAUSE 250
RETURN
'************************************** GPS Not Detected Routine ***************************************
nogps1:
DEBUG "no gps",CR
GOTO MAIN
The gps is getting the speed in knots so we are trying to convert it into mph. I don't think the gps is recognizing the string I am trying to get. When I tried it out I was just getting 0
' {$STAMP BS2p}
' {$PBASIC 2.5}
'By George Lejnine and parts by Randy Price
'Program to read in GPS coordinates from the NMEA 0183 GPRMC statement
'Many parts have been removed such as time and course direction, for simplicity. They can easily be added.
GPS PIN 15
tens VAR Byte
tens_conv VAR Word
digits VAR Byte
digits_conv VAR Word
tenth VAR Byte
tenth_conv VAR Word
knots VAR Word
speed1 VAR Word
speed2 VAR Word
mph VAR Word
mph_conv VAR Word
'Baud rates:
n4800 CON 16884
main:
'The number after SERIN is the Pin to which the Green wire is connected, in our case 15
SERIN GPS, n4800 ,noGPS1,[noparse][[/noparse]WAIT("RMC,"),SKIP 34, DEC1 tens, DEC1 digits, SKIP 1, DEC1 tenth]
GOSUB speed
GOSUB output1
GOTO main
'******************************************* OUTPUT ROUTINE *******************************************
speed:
tens_conv=tens*115
digits_conv=(digits*115)/10
tenth_conv=(tenth*115)/100
mph = tens_conv + digits_conv + tenth_conv + 5 'tenths of knots
mph_conv= mph/10
'using 6 instead of 60 takes care of the tenths of knots
'necessary to read GPS in integer form.
RETURN
output1:
DEBUG DEC tens, DEC digits, ".", DEC tenth, " knots",CR
DEBUG "Vehicle Speed:", DEC mph_conv , " MPH", CR
PAUSE 250
RETURN
'************************************** GPS Not Detected Routine ***************************************
nogps1:
DEBUG "no gps",CR
GOTO MAIN
The gps is getting the speed in knots so we are trying to convert it into mph. I don't think the gps is recognizing the string I am trying to get. When I tried it out I was just getting 0
Comments
00.0 knots
Vehicle Speed:0 MPH
00.0 knots
Vehicle Speed:0 MPH
When I shake the gps a little this is what i get:
00.0 knots
Vehicle Speed:0 MPH
00.6 knots
Vehicle Speed:1 MPH
00.7 knots
Vehicle Speed:1 MPH
I'm not too sure if this is an accurate test. But I am going to take it on the road soon to test it.
Thanks, Toby
www.tronico.fi/OH6NT/docs/NMEA0183.pdf Page 14
Then this one shows 3 digits a period and then a digit. Who is correct? you will have to look at the data from your unit. also you might take the whole number part as a single variable.
vancouver-webpages.com/peter/nmeafaq.txt
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Post Edited (Franklin) : 5/23/2010 5:37:51 PM GMT