Shop OBEX P1 Docs P2 Docs Learn Events
BS2p and GPS PMB-248 help — Parallax Forums

BS2p and GPS PMB-248 help

BKaneBKane Posts: 9
edited 2010-05-23 17:31 in BASIC Stamp
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

Comments

  • BKaneBKane Posts: 9
    edited 2010-04-30 00:06
    I got this position problem figured out. Now I'm just wondering about this code. Can someone look through this code and tell me if this should work. I'm just trying to find speed and convert it into mph
  • BKaneBKane Posts: 9
    edited 2010-04-30 00:20
    At rest this is what I am getting:
    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.
  • TobiasTobias Posts: 95
    edited 2010-05-23 15:05
    Why am I getting like 40, sometimes 23 mph when I just have the thing sitting on my window sill?

    Thanks, Toby
  • FranklinFranklin Posts: 4,747
    edited 2010-05-23 17:31
    Looks to me that there is only one digit, a comma, and a second digit in the speed over ground string. I may be looking at the wrong spec but that is what I see.
    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
Sign In or Register to comment.