Parallax GPS Receiver


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2006
    Posts
    31

    Default Parallax GPS Receiver

    Hi,

    I've read in the August/October 2008 issue, page 76, the GPS Receiver based from the Parallax GPS. I am fascinated with this project hoping to successfully build one. Parallax has a sample BS2 code for the GPS. I'm using PIC16F628A running at 10MHz xtal.

    My problem is how to migrate the BS2 code to PICBasic Pro
    Is there somebody who has a "basic" PICBasic code that enables PIC16F628A display the $GPRMC data on the LCD using Parallax GPS?


    http://www.parallax.com/Store/Microc...%2cProductName

    The code is found in "GPS Reciever Manual v1.1 (.pdf)"

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    I looked over the code just briefly. It has been a really really long time since I used a basic stamp. In my opinion, I would consider using the more powerful PIC16f628a without the basic stamp like commands. I do something a little different with a gps application, but most people use a command like:

    Code:
    gpsdata         VAR BYTE[70]  'define a 70 character string gpsdata
    
    HSerin 200, Main, [WAIT("$GPRMC"),STR gpsdata\MAXDATA\13] 'wait 200ms for GPRMC
    Then you can look at each character of the string as gpsdata[x], gpsdata[0] will be the comma directly after GPRMC Saving it as a string is the way to go, the uart makes this pretty easy.


    here is an example of pulling the latitude high numbers out of the sentence
    Code:
    IF gpsdata[13] = "A" Then  'tells you if valid data A= valid V=invalid
     lathome_hi = ((gpsdata[15] - 48) *10)+((gpsdata[16] - 48)) 'first two digits
     more code here.....
    ENDIF
    You will notice that I am subtracting 48, this is because I am changing an asci number to a decimal number for some math functions. You wouldnt need to do that if you are just printing to an lcd. But if you wanted to use the data for a project, you would need to convert to decimal. I don't know if you have already purchased it or not, but sparkfun.com has some too.

    http://www.sparkfun.com/commerce/pro...oducts_id=8975 but with this one you have to worry about 3.3 volt to 5 volt conversion.
    Last edited by ScaleRobotics; - 11th February 2009 at 07:57.

  3. #3
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

  4. #4
    Join Date
    Jan 2006
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    thank very much scalerobotics, i'm not yet to this hardware UART thing. But the solution that you gave was a great help.

    I consulted parallax's forum and the guy pointed out the i'm having problems with the baud rate.

    Here's what i've sent to him.-----------------------------------------------------------------
    We constructed the controller circuit last week. We followed what was written in the sample code
    http://www.parallax.com/Portals/0/Do...ManualV1.1.pdf

    Upon testing the GPS receiver behaved the way it was described in the GPSManual. We modified the code based on our needs and we ended up having a message on the LCD some sort of "No Valid Data" or "No Response".

    We are using PIC16F628A running at 10MHz crystal. We have peripherals such as RS-485 chip & a 4-liner LCD. We are using PICBasic Pro.

    I've read also in the ELEKTOR magazine August/October 2008 issue, page 76, the GPS Receiver based from the Parallax GPS. The sad thing about it is that it is coded in C.

    http://www.elektor.com/magazines/200...r.531567.lynkx

    The sample code of Parallax is not working with our setup. Is there anybody who has a "basic" PICBasic code that enables PIC16F628A display the $GPRMC data on the LCD?

    Here's my sample code in PICBasic version:
    @ DEVICE PIC16F628A, HS_OSC '10MHz Oscillator
    @ DEVICE PIC16F628A, MCLR_OFF '
    @ DEVICE PIC16F628A, WDT_ON 'Watchdog Timer
    @ DEVICE PIC16F628A, PWRT_ON 'Power-On Timer
    @ DEVICE PIC16F628A, BOD_ON 'Brown-Out Detect
    @ DEVICE PIC16F628A, LVP_OFF 'Low-Voltage Programming
    @ DEVICE PIC16F628A, CPD_OFF 'Data Memory Code Protect
    @ DEVICE PIC16F628A, PROTECT_OFF 'Program Code Protection

    define OSC 10

    DEFINE LCD_DREG PORTB 'Set LCD Data port
    DEFINE LCD_DBIT 4 'Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTA 'Set LCD Register Select port
    DEFINE LCD_RSBIT 1 'Set LCD Register Select bit
    DEFINE LCD_EREG PORTA 'Set LCD Enable port
    DEFINE LCD_EBIT 0 'Set LCD Enable bit
    DEFINE LCD_BITS 4 'Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 4 'Set number of lines on LCD
    'DEFINE LCD_COMMANDUS 4000 'Set command delay time in us
    'DEFINE LCD_DATAUS 100 'Set data delay time in us

    Symbol SIO = PortA.3 'Pin 2 of PICMicro connects to GPS Module SIO pin
    TrisA = 0
    TrisB = 0
    CMCON = 7
    ' -----[ Constants ]-------------------------------------------------------
    T4800 CON 188
    Open CON $8000
    Baud CON Open | T4800 ' Open mode to allow daisy chaining
    TimeOut CON 6000
    MoveTo CON 2 ' DEBUG positioning command
    ClrRt CON 11 ' clear line right of cursor
    FieldLen CON 22 ' length of debug text
    EST CON -5 ' Eastern Standard Time
    CST CON -6 ' Central Standard Time
    MST CON -7 ' Mountain Standard Time
    PST CON -8 ' Pacific Standard Time
    EDT CON -4 ' Eastern Daylight Time
    CDT CON -5 ' Central Daylight Time
    MDT CON -6 ' Mountain Daylight Time
    PDT CON -7 ' Pacific Daylight Time
    UTCfix CON PST ' for San Diego, California
    DegSym CON 176 ' degrees symbol for report
    MinSym CON 39 ' minutes symbol
    SecSym CON 34 ' seconds symbol
    DLY con 500
    ' GPS Module Commands
    GetInfo CON $00
    GetValid CON $01
    GetSats CON $02
    GetTime CON $03
    GetDate CON $04
    GetLat CON $05
    GetLong CON $06
    GetAlt CON $07
    GetSpeed CON $08
    GetHead CON $09
    ' -----[ Variables ]-------------------------------------------------------
    char VAR Byte
    workVal VAR Word ' for numeric conversions
    eeAddr VAR workVal ' pointer to EE data
    ver_hw VAR Byte
    ver_fw VAR Byte
    valid VAR Byte ' signal valid? 0 = not valid, 1 = valid
    sats VAR Byte ' number of satellites used in positioning calculations
    tmHrs VAR Byte ' time fields
    tmMins VAR Byte
    tmSecs VAR Byte
    day VAR Byte ' day of month, 1-31
    month VAR Byte ' month, 1-12
    year VAR Byte ' year, 00-99
    degrees VAR Byte ' latitude/longitude degrees
    minutes VAR Byte ' latitude/longitude minutes
    minutesD VAR Word ' latitude/longitude decimal minutes
    dir VAR Byte ' direction (latitude: 0 = N, 1 = S, longitude: 0 = E, 1 = W)
    heading VAR Word ' heading in 0.1 degrees
    alt VAR Word ' altitude in 0.1 meters
    speed VAR Word ' speed in 0.1 knots
    ' -----[ EEPROM Data ]-----------------------------------------------------
    NotValid DATA "NV", 0
    IsValid DATA "V ", 0
    DaysInMon DATA 31,28,31,30,31,30,31,31,30,31,30,31
    MonNames DATA "JAN",0,"FEB",0,"MAR",0,"APR",0,"MAY",0,"JUN", 0
    DATA "JUL",0,"AUG",0,"SEP",0,"OCT",0,"NOV",0,"DEC", 0
    ' -----[ Initialization ]--------------------------------------------------
    Initialize:
    PortA = 0
    PortB = 0
    PAUSE 250 ' let DEBUG open
    lcdout $FE,$02,"<<GPS Receiver>>"
    LCDOUT $FE,$C0,"SATs: Signal: "

    Main:
    GOSUB Get_Valid
    GOSUB Get_Sats
    GOSUB Get_TimeDate
    GOTO Main

    Get_Valid:
    SEROUT2 Sio,Baud,["!GPS",GetValid]
    SERIN2 Sio,Baud,TimeOut,No_Response,[valid]
    if Valid = 0 then
    lcdout $FE,$CE,"NV"
    else
    lcdout $FE,$CE," V"
    endif
    RETURN
    ' ----------------------------------------------------
    Get_Sats:
    SEROUT2 Sio,Baud,["!GPS",GetSats]
    SERIN2 Sio,Baud,TimeOut,No_Response,[sats]
    lcdout $FE,$C5,dec Sats
    RETURN
    ' ----------------------------------------------------
    Get_TimeDate:
    SEROUT2 Sio,Baud,["!GPS",GetTime]
    SERIN2 Sio,Baud,TimeOut,No_Response,[tmHrs,tmMins,tmSecs]
    SEROUT2 Sio,Baud,["!GPS",GetDate]
    SERIN2 Sio,Baud,TimeOut,No_Response,[day,month,year]
    GOSUB Correct_Local_Time_Date
    lcdout $FE,$90,DEC2 tmHrs, ":", DEC2 tmMins, ":", DEC2 tmSecs
    LCDout $FE,$D0,DEC2 day,"-",DEC2 Month,", 20",DEC2 Year
    RETURN

    No_Response:
    lcdout $FE,$CE,"NR"
    PAUSE 1000
    GOTO Main
    ' ----------------------------------------------------
    Signal_Not_Valid:
    LCDOUT $FE,$90," "
    lcdout $FE,$D0," "
    GOTO Main
    ' ----------------------------------------------------
    ' adjust date for local position
    Correct_Local_Time_Date:
    workVal = tmHrs + UTCfix
    IF (workVal < 24) THEN Adjust_Time
    workVal = UTCfix
    BRANCH workVal.BIT15,[Location_Leads,Location_Lags]
    Location_Leads:
    day = day + 1
    eeAddr = DaysInMon * (month - 1)
    READ eeAddr, char
    IF (day <= char) THEN Adjust_Time
    month = month + 1
    day = 1
    IF (month < 13) THEN Adjust_Time
    month = 1
    year = year + 1 // 100
    GOTO Adjust_Time
    Location_Lags:
    day = day - 1
    IF (day > 0) THEN Adjust_Time
    month = month - 1
    IF (month > 0) THEN Adjust_Time
    month = 1
    eeAddr = DaysInMon * (month - 1)
    READ eeAddr, day
    year = year + 99 // 100
    Adjust_Time:
    tmHrs = tmHrs + (24 + UTCfix) // 24
    RETURN
    ' ----------------------------------------------------
    ' Print Zero-terminated string stored in EEPROM
    ' -- eeAddr - starting character of string
    Print_Z_String:
    READ eeAddr, char ' get char from EE
    IF (char = 0) THEN Print_Z_String_Done ' if zero, we're done
    eeAddr = eeAddr + 1 ' point to the next one
    GOTO Print_Z_String
    Print_Z_String_Done:
    RETURN

    -------------------------------------------------------------------------

    He answered

    Okay, the issue is with how you are having the PIC communicate with the GPS. I've never worked with the PIC line before (or the various compilers), but I assume that you cannot just cut and paste the sample code that parallax provides for the BS2. The BS2 uses a PIC, but it's been transformed into something else. Anyway, it's probably a problem with the baud rate in the serout statements. I'd look in the manual for your PIC compiler and figure out what baud is needed.

    The key bit of text in the datasheet for the GPS that you want to look at is the last line of 'Mode Selection' where it talks about the communication protocol. Figure out how to do that with the PIC, and that may solve your problem.

  5. #5
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    I would use the code written for the same chip in post #6. Just change osc to 10, if that is what you are using, and either wire your lcd the same way, or edit those too.

    http://www.picbasic.co.uk/forum/show...18&postcount=6

    Looks like he was printing other things to lcd, but you can easily use his examples.

    It looks like the parallax gps accepts input, and can output specific data, but I would just use its standard NMEA output. This will output at 4800 baud NMEA, like almost all gps's on the market.

Similar Threads

  1. Replies: 0
    Last Post: - 17th June 2009, 03:55
  2. Replies: 4
    Last Post: - 15th May 2008, 09:43
  3. PIC16F877 with GPS receiver
    By rocketqueen in forum GPS
    Replies: 10
    Last Post: - 15th November 2006, 21:56
  4. interfacing gps receiver with 16f877a
    By sakhyvava in forum GPS
    Replies: 1
    Last Post: - 27th September 2006, 09:13
  5. GPS Receiver
    By lester in forum Adverts
    Replies: 2
    Last Post: - 22nd February 2006, 12:47

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts