GPS Receiver
Hi,
My students bought last year·1 GPS Receiver from Parallax last year for their·institutional project.· It is·a project some kind of "PASSPORT" to their Graduation.·
We constructed the controller circuit last week.· We followed what·was written in the sample code
··http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/GPSManualV1.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/2008/july-047-august/gps-receiver.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?
The leader of the group emailed parallax and they responded negatively.· What we need is only technical support on how to adapt this device (GPS Receiver) to PIC Microcontrollers.· We are not competitors, we are end-user/customer.· I admit that there are no parallax stores/branches in our locality or even here in the Philippines but making this project up and running is also a plus factor to Parallax 'coz universities around (students, professionals, etc) )might be·asking for the details of what my students are coming up with.
We spent $240+ for acquisition of this·device and then here's what we got.· I believe that the microcontroller that we are using or the type of compiler that we are using is NOT AN·ISSUE here.· The issue is about putting what we bought/invested into action. ·Parallax might not·know that we are indirectly marketing their product based on results.·
We shall be having this MALL EXHIBIT this February 21 in one of the biggest malls in our city and this project is the forefront of all projects.· We are also giving credits to companies who helped us (including parallax...hopefully)
Anyway here's our modified code for·PICBasic it doesn't work.· It only displays "SATs: 5··Signal:NV". which means no valid data. I really would like to ask help for those who tried this.
@ 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
'
[noparse][[/noparse] 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
'
[noparse][[/noparse] 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
'
[noparse][[/noparse] 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
'
[noparse][[/noparse] 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,[noparse][[/noparse]"!GPS",GetValid]
· SERIN2· Sio,Baud,TimeOut,No_Response,[noparse][[/noparse]valid]
· if Valid = 0 then
···· lcdout $FE,$CE,"NV"
· else
···· lcdout $FE,$CE," V"
· endif
· RETURN
'
Get_Sats:
· SEROUT2 Sio,Baud,[noparse][[/noparse]"!GPS",GetSats]
· SERIN2 Sio,Baud,TimeOut,No_Response,[noparse][[/noparse]sats]
· lcdout $FE,$C5,dec Sats
· RETURN
'
Get_TimeDate:
· SEROUT2 Sio,Baud,[noparse][[/noparse]"!GPS",GetTime]
· SERIN2 Sio,Baud,TimeOut,No_Response,[noparse][[/noparse]tmHrs,tmMins,tmSecs]
· SEROUT2 Sio,Baud,[noparse][[/noparse]"!GPS",GetDate]
· SERIN2 Sio,Baud,TimeOut,No_Response,[noparse][[/noparse]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································· ' add UTC offset
· IF (workVal < 24) THEN Adjust_Time······················· ' midnight crossed?
· workVal = UTCfix········································· ' yes, so adjust date
· BRANCH workVal.BIT15,[noparse][[/noparse]Location_Leads,Location_Lags]
Location_Leads:············································ ' east of Greenwich
· day = day + 1············································ ' no, move to next day
· eeAddr = DaysInMon * (month - 1)························· ' get days in month
· READ eeAddr, char
· IF (day <= char) THEN Adjust_Time························ ' in same month?
· month = month + 1········································ ' no, move to next month
· day = 1·················································· ' first day
· IF (month < 13) THEN Adjust_Time························· ' in same year?
· month = 1················································ ' no, set to January
· year = year + 1 // 100··································· ' add one to year
· GOTO Adjust_Time
Location_Lags:············································· ' west of Greenwich
· day = day - 1············································ ' adjust day
· IF (day > 0) THEN Adjust_Time···························· ' same month?
· month = month - 1
· IF (month > 0) THEN Adjust_Time·························· ' same year?
· month = 1················································ ' no, set to January
· eeAddr = DaysInMon * (month - 1)
· READ eeAddr, day········································· ' get new day
· year = year + 99 // 100·································· ' set to previous year
Adjust_Time:
· tmHrs = tmHrs + (24 + UTCfix) // 24······················ ' localize hours
· 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
Post Edited (emavil) : 2/11/2009 8:05:44 AM GMT
My students bought last year·1 GPS Receiver from Parallax last year for their·institutional project.· It is·a project some kind of "PASSPORT" to their Graduation.·
We constructed the controller circuit last week.· We followed what·was written in the sample code
··http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/GPSManualV1.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/2008/july-047-august/gps-receiver.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?
The leader of the group emailed parallax and they responded negatively.· What we need is only technical support on how to adapt this device (GPS Receiver) to PIC Microcontrollers.· We are not competitors, we are end-user/customer.· I admit that there are no parallax stores/branches in our locality or even here in the Philippines but making this project up and running is also a plus factor to Parallax 'coz universities around (students, professionals, etc) )might be·asking for the details of what my students are coming up with.
We spent $240+ for acquisition of this·device and then here's what we got.· I believe that the microcontroller that we are using or the type of compiler that we are using is NOT AN·ISSUE here.· The issue is about putting what we bought/invested into action. ·Parallax might not·know that we are indirectly marketing their product based on results.·
We shall be having this MALL EXHIBIT this February 21 in one of the biggest malls in our city and this project is the forefront of all projects.· We are also giving credits to companies who helped us (including parallax...hopefully)
Anyway here's our modified code for·PICBasic it doesn't work.· It only displays "SATs: 5··Signal:NV". which means no valid data. I really would like to ask help for those who tried this.
@ 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
'
[noparse][[/noparse] 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
'
[noparse][[/noparse] 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
'
[noparse][[/noparse] 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
'
[noparse][[/noparse] 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,[noparse][[/noparse]"!GPS",GetValid]
· SERIN2· Sio,Baud,TimeOut,No_Response,[noparse][[/noparse]valid]
· if Valid = 0 then
···· lcdout $FE,$CE,"NV"
· else
···· lcdout $FE,$CE," V"
· endif
· RETURN
'
Get_Sats:
· SEROUT2 Sio,Baud,[noparse][[/noparse]"!GPS",GetSats]
· SERIN2 Sio,Baud,TimeOut,No_Response,[noparse][[/noparse]sats]
· lcdout $FE,$C5,dec Sats
· RETURN
'
Get_TimeDate:
· SEROUT2 Sio,Baud,[noparse][[/noparse]"!GPS",GetTime]
· SERIN2 Sio,Baud,TimeOut,No_Response,[noparse][[/noparse]tmHrs,tmMins,tmSecs]
· SEROUT2 Sio,Baud,[noparse][[/noparse]"!GPS",GetDate]
· SERIN2 Sio,Baud,TimeOut,No_Response,[noparse][[/noparse]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································· ' add UTC offset
· IF (workVal < 24) THEN Adjust_Time······················· ' midnight crossed?
· workVal = UTCfix········································· ' yes, so adjust date
· BRANCH workVal.BIT15,[noparse][[/noparse]Location_Leads,Location_Lags]
Location_Leads:············································ ' east of Greenwich
· day = day + 1············································ ' no, move to next day
· eeAddr = DaysInMon * (month - 1)························· ' get days in month
· READ eeAddr, char
· IF (day <= char) THEN Adjust_Time························ ' in same month?
· month = month + 1········································ ' no, move to next month
· day = 1·················································· ' first day
· IF (month < 13) THEN Adjust_Time························· ' in same year?
· month = 1················································ ' no, set to January
· year = year + 1 // 100··································· ' add one to year
· GOTO Adjust_Time
Location_Lags:············································· ' west of Greenwich
· day = day - 1············································ ' adjust day
· IF (day > 0) THEN Adjust_Time···························· ' same month?
· month = month - 1
· IF (month > 0) THEN Adjust_Time·························· ' same year?
· month = 1················································ ' no, set to January
· eeAddr = DaysInMon * (month - 1)
· READ eeAddr, day········································· ' get new day
· year = year + 99 // 100·································· ' set to previous year
Adjust_Time:
· tmHrs = tmHrs + (24 + UTCfix) // 24······················ ' localize hours
· 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
Post Edited (emavil) : 2/11/2009 8:05:44 AM GMT
Comments
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.
BTW, is the mall an indoor mall? As one might expect, the GPS wouldn't work in there regardless of what code you have.
Post Edited (SRLM) : 2/11/2009 6:11:56 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Craig Eid
www.TriadRD.com
Thank you very much for replying.· We design the project to cater both indoor and outdoor applications.· As you can see we managed to interface RS485 device from MAXIM for long distance communication.· Our plan is to wire the controller remotely, install it outside the mall for better signal reception.· A huge display panel inside the mall will request data from the GPS controller and the controller will respond based on the data requested.· The panel will serve·as the master clock·for all timer devices.·
We are planning to deploy·the project outside our campus in an area where it is visible to all and this project·is responsible for update all digital clocks inside or each classroom.
Yeah, I agree with you. The problem might be·in the baud rate.· Once we solve the communication problem, I'm sure that everything is straight forward. We just can't figure out how to come up with·the right·baud (what is T4800 in PICBasic).· Are we allowed to use crystals like 4MHz, 8MHz? What will happen to the baud rate? Will it be the same?· Is 4800 baud in 4MHz the same with 4800baud in 8MHz,·how about in 10MHz?
Post Edited (emavil) : 2/11/2009 8:07:19 AM GMT
When you post in the Pic forums, then be sure to put the information that I pointed out from the GPS datasheet. I'd assume that there is a table somewhere to figure out what constant to use for the various PIC setups.
As a side note, you may want to look up the READ and WRITE commands for you compiler. They're directly part of the stamp environment, so I'm not sure that you would have support for them.