Shop OBEX P1 Docs P2 Docs Learn Events
Problem in connection with GPS OEM (using BS2) — Parallax Forums

Problem in connection with GPS OEM (using BS2)

akmarifakmarif Posts: 1
edited 2006-07-24 08:39 in BASIC Stamp
we have been trying to develop an AVLS system using a BS2 mcu and an Axiom Sandpiper II, OEM GPS module.

we have tried the GPS module with its default software[noparse][[/noparse]conductor] and we always get the correct position displayed on the screen.

we have been trying to use the BS2 SERIN command to extraxt NMEA data from the GPS module. we are aware of the fact that BS2 has only 24 bytes of RAM where as the GPRMC string has 65 chracters in it. we also tried the GPGLL string.[noparse][[/noparse]please see the full code below to understand the variable names]

SERIN 8, 16572,[noparse][[/noparse]WAIT ("$GPGLL"),SKIP 1,DEC lat1,SKIP 1,DEC lat2,comma,latd,comma,DEC lon1,comma,DEC lon2,comma,lond]

with our code we were able to extract the correct position only 30% times on average. we have been trying different codes with SERIN to get a steady stream of correct position data. the same GPS module workds fine with the default software. so we guess there is nothing wrong with the GPS OEM. we have tried to change the baud rate and get the NMEA string. but every effort has failed. I am sure that there is something wrong in the way we are trying to read and parse the GPGLL and GPRMC strings.I am providing the full code.

====================================================

' {$STAMP BS2}
' {$PBASIC 2.5}

lat1 VAR Word
lat2 VAR Word
latd VAR Byte
lon1 VAR Word
lon2 VAR Word
lond VAR Byte

comma VAR Byte

SERIN 8, 16572,[noparse][[/noparse]WAIT ("$GPGLL"),SKIP 1,DEC lat1,SKIP 1,DEC lat2,comma,latd,comma,DEC lon1,comma,DEC lon2,comma,lond]
DEBUG "testX"
DEBUG DEC ? lat1
DEBUG "*"
DEBUG DEC ? lat2
DEBUG "*"
DEBUG· ? latd
DEBUG "*"
DEBUG DEC ? lon1
DEBUG "*"
DEBUG DEC· ? lon2
DEBUG "*"
DEBUG· ? lond
DEBUG "ok"

END

*****************

please provide me some suggestions as to what is going wrong.

appreciate your help

Comments

  • Robert@HCCRobert@HCC Posts: 80
    edited 2006-07-22 10:00
    These are some of the subs we use for our Trimble LassenIQ OEM GPS unit , and seem to get good results with. Perhaps you can find something useful here.

    Alohas



    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    ' ==============================================================================
    '
    '   File...... CanSat_Sensor_Interface.BS2
    '   Purpose... Combined Sensor Data Interface Program
    '   E-mail.... ifitsscrewedupdontcallme@cansathawaii.com
    '   Date...... 11/22/2005
    '
    ' ==============================================================================
    '
    '
    ' ------------------------------------------------------------------------------
    ' Program Description
    ' ------------------------------------------------------------------------------
    '
    ' This program aquires data from a Memsic 2125 Accelerometer, DS1620 Temp sensor,
    ' a modified version of Shaun William's Altimeter/Pressure sensor, and a
    ' Trimble LassenIQ GPS module. It also includes a DS1302 RTC to provide a date/time stamp
    ' for the sensor data. The data is first logged to a Microchip 25LC640
    ' EPPROM. The program then transmits the data via AeroComm 4790 transceiver to a
    ' ground-based computer for display in the debug window, or hyperterminal.
    ' I also added a user-initiated remote program start function that checks
    ' for an authorized user via password before starting the program.
    
    
    ----------------------------------------------------------------------------------------------------------------------------
    
    'RF Constants
    
    Baud48         CON    188                                               ' Baud rate of 4800 for BS2
                                                                            ' Baud rate kept at 4800 to
                                                                            ' compliment GPS module NMEA
                                                                            ' transmit default baud rate
                                                                            ' of 4800
    
    'Data transmit/receive I/O Definitions
    
    TxD            CON     16
    Rxd            CON     14
    
    'Terminal screen controls/formatting
    '
    
    MoveTo          CON    2                                                 ' for terminal screen control
    DegSym          CON    186                                               ' degrees symbol for terminal
    MinSym          CON    39                                                ' Minutes symbol for GPS
    
    
    WordData        VAR    Word
    WordData1       VAR    Word                                              ' Temp Variables to store Word,Byte and Nib values
    WordData2       VAR    Word
    
    WriteWord       VAR    Word
    ByteData1       VAR    Byte
    ByteData2       VAR    Byte
    ByteData3       VAR    Byte
    ByteData4       VAR    Byte
    ByteData5       VAR    Byte
    ByteData6       VAR    Byte
    ByteData7       VAR    Byte
    NibData         VAR    Nib
    
    
    
    DO:
      GOSUB GetLatLong                                                     ' Capture and display GPS NMEA msg
      GOSUB GetSpeed                                                       ' and format data for display
    LOOP
    
    
    ' GPS subroutines
    '
                                                                                                           ' Read the GGA sentence from LassenIQ GPS -
    'GetLatLong:                                                                                     ' $GPGGA,hhmmss.ss,llll.lll,a,nnnnn.nnn,b,t,uu,
      SERIN  RxD,Baud48, [noparse][[/noparse]WAIT("GPGGA,"),SKIP 9,DEC WordData1,                            ' v.v,w.w,M,x.x,M,y.y,zzzz*hh <CR><LF>
      SKIP 6, ByteData1, DEC WordData2,SKIP 6, ByteData2,                                 ' - store Lat as WordData1, NS Coor as
      SKIP 2,DEC NibData]                                                                             ' ByteData1, store LON as WordData2,and EW Coor as
                                                                                                                    ' ByteData2. Store the satellites in use as NibData
    
      SEROUT  TxD, Baud48, [noparse][[/noparse]CRSRXY, 7, 10, DEC WordData1 DIG 3, DEC WordData1 DIG 2,DegSym, "  ",                                                ' Print Lat/Long
      DEC WordData1 DIG 1, DEC WordData1 DIG 0,MinSym, " ", ByteData1,CLREOL,
      CRSRXY, 7,11,DEC WordData2 DIG 4,  DEC WordData2 DIG 3, DEC WordData2 DIG 2,DegSym, " ",
      DEC WordData2 DIG 1, DEC WordData2 DIG 0,MinSym, "  ", ByteData2,CLREOL,CRSRXY,20,9,   ' Print Satellites in use
      DEC NibData, CLREOL]
    RETURN
    
    GetSpeed:
       SERIN RxD, Baud48, [noparse][[/noparse]WAIT("VTG,"), WAIT(","),                                              ' Read the VTG sentence from LassenIQ GPS -
       WAIT(","),WAIT(","),DEC WordData1]                                                        ' $GPVTG,x.x,T,x.x,M,x.x,N,x.x,K,i*hh<CR><LF>
       SEROUT Txd,Baud48, [noparse][[/noparse]CRSRXY, 7, 12,  DEC WordData1,CLREOL ]                       ' - store the SOG (Speed Over Ground) as WordData1
                                                                                                ' Print SOG
    RETURN
    

    Post Edited (Robert@HCC) : 7/22/2006 10:10:49 AM GMT
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-22 10:33
    Akmarif -

    See if the following alterations help. The unwanted commas may well·sort themselves out, I believe:

    SERIN 8, 16572,[noparse][[/noparse]WAIT ("$GPGLL"),SKIP 1,DEC lat1,SKIP 1,DEC lat2,latd,DEC lon1,DEC lon2,lond]

    If for some reason that doesn't get you going, then try this:

    SERIN 8, 16572,[noparse][[/noparse]WAIT ("$GPGLL"),SKIP 1,DEC lat1,SKIP 1,DEC lat2,SKIP 1,latd,SKIP 1,DEC lon1,SKIP 1,DEC lon2,SKIP 1,lond]

    What I have tried to do in each case is to reduce or minimize·the amount of PBASIC processing overhead. In the first case, we're trading the speed of checking for unwanted characters in a DEC field (which PBASIC will ignore innately) for actually fetching and moving data into storage (a longer process); which characters we really don't want to begin with. In the second case we're avoiding the unwanted character check, and the fetch/move by using another·set of SKIPs·which basically advance a buffer pointer, which takes little time at all.

    Regards,

    Bruce Bates
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-07-22 11:15
    I use the GLL (time and position) string in my constantly-running GPS, using the attached program.

    [noparse][[/noparse] I'm a "magic number" guy, not with the Elements of PBASIC Style sort. ]
  • StuartttttStuarttttt Posts: 45
    edited 2006-07-22 13:06
    Akmarif,
    perhaps also try a slimmed down version as below.
    I use this with a Jupiter OEM module.
    Basically it doesn't mind if its $GPRMC or $GPGLL or any of the other NMEA Data messages as its only looking for the
    correct degrees/mins in a string then only graps the 4 seconds.

    ****Obviously change the degs/mins to suit your exact location****

    ' {$STAMP BS2}
    Latt VAR Byte(5)
    Long VAR Byte(5)
    Latt(4)=0
    Long(4)=0
    Main:
    DEBUG HOME
    DEBUG "Lattitude(secs)"," ", "Longitude(secs)",CR
    SERIN 0,188,[noparse][[/noparse]WAIT ("5241."),STR Latt\4]
    SERIN 0,188,[noparse][[/noparse]WAIT ("00112."),STR Long\4]
    DEBUG " ",STR Latt," ", STR Long,CR
    PAUSE 800
    GOTO Main
  • shakilshakil Posts: 5
    edited 2006-07-23 07:19
    Hi Stuart,

    I am also engaged in a similar project.
    If I specify the lat/long for a specific location can I use my device for roaming around?
    as my GPS device shall be moving around my country ,I can not specify it to a specific lat or long.

    can you please suggest me a way, by which I can make a general program that will work in any location.

    I will ofcourse try the other solutions provided in this thread.

    thank you all.

    shakil
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-07-23 13:12
    I suppose that I should clarify that the program I uploaded
    previously was/is designed for use with a 4x20 LCD, but it
    will work anywhere.· The only thing that it WAITs for is
    'GLL' and·then it's off to the races.
  • StuartttttStuarttttt Posts: 45
    edited 2006-07-24 08:39
    Shakil,
    I'm new to GPS as well. The minimum simple code I posted above was purely for testing of the thread originators (Akmarif) GPS
    as it was reported as being correct only 30% of the time. I'll be using the code (with refinements) below as the starting point for
    my project, which looks like its what you are trying to achieve.
    Good luck, let me know how you get on as its interesting to see how problems are resolved in a different manner.
    Stuart

    ' {$STAMP BS2}
    ' {$PORT COM1}

    deg1 VAR Byte : deg2 VAR Byte : minu1 VAR Byte : minu2 VAR Byte
    per1 VAR Byte : sec1 VAR Byte : sec2 VAR Byte : sec3 VAR Byte
    sec4 VAR Byte : deg3 VAR Byte : deg4 VAR Byte : deg5 VAR Byte
    minu3 VAR Byte : minu4 VAR Byte : per2 VAR Byte : sec5 VAR Byte
    sec6 VAR Byte : sec7 VAR Byte : sec8 VAR Byte

    ' RMC

    Main:
    DEBUG HOME
    SERIN 0,188,[noparse][[/noparse]WAIT("RMC,"),SKIP 9, deg1,deg2,minu1,minu2,per1,sec1,sec2,sec3,sec4,SKIP 3,deg3,deg4,deg5,minu3,minu4,per2,sec5,sec6,sec7,sec8]
    PAUSE 100
    DEBUG " Lattitude"," ","Longitude",CR
    DEBUG "GPRMC ", deg1,deg2, minu1,minu2,per1,sec1,sec2,sec3,sec4," ",deg3,deg4,deg5,minu3,minu4,per2,sec5,sec6,sec7,sec8,CR
    PAUSE 100
    GOTO Main
Sign In or Register to comment.