garmin GPS serial hookup
I have a Garmin GPS set to text mode 2400 baud, trying to use Jon Williams code Easy_GPS.BS2.
The values I get are not correct and change.· Hooking GPS to RS232 on computer in terminal shows GPS lines coming ok.· I believe I am not connecting the GPS to the STAMP correctly.
I've tried ground pin five DB9 to STAMP ground.
Tried both pin 3 and pin 4, inverted, non, with 20k ohm·of resistance.
Can't get any accurate data coming out the debug.· Time, hour minute second stays around 00:07:07.. its giberish.
' =========================================================================
' {$PORT COM1}
'
'·· File...... Easy_GPS.BS2
'·· Purpose...
'·· Author.... Jon Williams
'·· E-mail.... jwilliams@parallax.com
'·· Started...
'·· Updated... 07 MAR 2004
'
'·· {$STAMP BS2}
'·· {$PBASIC 2.5}
'
' =========================================================================
'
[noparse][[/noparse] Program Description ]
'
' This program accepts text data from a Garmin GPS receiver using the
' Garmin text output at 2400 baud.· The advantage over NMEA 183 for this
' application is fixed field positions and widths which can be extracted
' using SERIN modifiers.
'······················ '
' String:
'
'····· @020202183142N3251129W09701159G008+00165E0000N0000D0001 <-- GPS
'······ |
'······ |······· 1········ 2········ 3········ 4········ 5
'······ 12345678901234567890123456789012345678901234567890123· <-- index
'
'····· @060408192405N3933843W10456696g020+01750E0000N0000U0002
'
'
'· 0·· @······· header
'· 1·· 020202·· UTC date (yr [noparse][[/noparse]2], mo, dy)
'· 7·· 183142·· UTC time (hr, mn, sc)
' 13·· N······· lat hemisphere
' 14·· 32······ lat degrees
' 16·· 51······ lat minutes
' 18·· 129····· lat frac minutes (1/1000)
' 21·· W······· long hemisphere
' 22·· 097····· long degrees
' 25·· 01······ long minutes
' 27·· 159····· long frac minutes (1/1000)
' 30·· G······· position status
' 31·· 008····· horizontal position error (meters)
' 34·· +······· altitude sign
' 35·· 00165··· altitude above/below sea level (meters)
' 40·· E······· E/W velocity direction
' 41·· 0000···· E/W velocity (meters per sec - tenths xxx.x)
' 45·· N······· N/S velocity direction
' 46·· 0000···· N/S E/W velocity (meters per sec - tenths xxx.x)
' 50·· D······· vertical velocity direction (Up / Down)
' 51·· 0001···· vertical velocity (meters per sec - hundredths xx.xx)
'
'
' For additional details see: http://www.garmin.com/support/text_out.html
'
[noparse][[/noparse] Revision History ]
'
[noparse][[/noparse] I/O Definitions ]
Rx············· PIN···· 0
'
[noparse][[/noparse] Constants ]
#SELECT $stamp
· #CASE BS2, BS2E, BS2PE
··· T1200······ CON···· 813
··· T2400······ CON···· 396
··· T4800······ CON···· 188
··· T9600······ CON···· 84
··· TimeOut···· CON···· 1500
· #CASE BS2SX, BS2P
··· T1200······ CON···· 2063
··· T2400······ CON···· 1021
··· T4800······ CON···· 500
··· T9600······ CON···· 240
··· TimeOut···· CON···· 3750
#ENDSELECT
Inverted······· CON···· $4000
Baud··········· CON···· T2400 + Inverted
EST············ CON···· 5······················ ' Eastern Standard Time
CST············ CON···· 6······················ ' Central
MST············ CON···· 7······················ ' Mountain
PST············ CON···· 8······················ ' Pacific
DST············ CON···· 0······················ ' daylight savings time
UtcAdj········· CON···· 24 - MST + DST········· ' adjust UTC for Dallas, TX
'
[noparse][[/noparse] Variables ]
hr············· VAR···· Byte··················· ' time fields
mn············· VAR···· Byte
sc············· VAR···· Byte
latHemi········ VAR···· Byte··················· ' hemisphere
latD··········· VAR···· Byte··················· ' degrees
latM··········· VAR···· Byte··················· ' minutes
latF··········· VAR···· Byte··················· ' fractional minutes
lonHemi········ VAR···· Byte
lonD··········· VAR···· Byte
lonM··········· VAR···· Byte
lonF··········· VAR···· Byte
altSign········ VAR···· Byte··················· ' "+" or "-"
alt············ VAR···· Word
ewDir·········· VAR···· Byte··················· ' "E" or "W"
ewVel·········· VAR···· Word··················· ' meters per second
nsDir·········· VAR···· Byte
nsVel·········· VAR···· Byte
'
[noparse][[/noparse] EEPROM Data ]
'
[noparse][[/noparse] Initialization ]
Setup:
· DEBUG CLS
'
[noparse][[/noparse] Program Code ]
Main:
·SERIN Rx, Baud, TimeOut, No_GPS,
····· [noparse][[/noparse]WAIT("@"), SKIP 6, DEC2 hr, DEC2 mn, DEC2 sc,
······ latHemi, DEC2 latD, DEC2 latM, DEC2 latF, SKIP 1,
······ lonHemi, DEC3 lonD, DEC2 lonM, DEC2 lonF, SKIP 1,
······ SKIP 4, altSign, DEC5 alt,
······ ewDir, DEC4 ewVel, nsDir, DEC4 nsVel]
· 'SERIN Rx, Baud, TimeOut, No_GPS,
·'······ [noparse][[/noparse]WAIT("@"), SKIP 6, S]
' The PAUSE instruction below shows how much time is
' available for processing captured GPS data
Test:
· PAUSE 750
Show_Time:
· 'hr = hr + UtcAdj // 24······················· ' localize time
· DEBUG HOME,
· DEC2 hr, ":", DEC2 mn, ":", DEC2 sc, " latHemi: ", latHemi, DEC2 latD, DEC2 latM, DEC2 latF
· GOTO Main
· END
'
[noparse][[/noparse] Subroutines ]
No_GPS:
· DEBUG CLS, "No GPS..."
· PAUSE 2000
· GOTO Setup
Post Edited (Dru) : 4/8/2006 9:36:54 PM GMT
The values I get are not correct and change.· Hooking GPS to RS232 on computer in terminal shows GPS lines coming ok.· I believe I am not connecting the GPS to the STAMP correctly.
I've tried ground pin five DB9 to STAMP ground.
Tried both pin 3 and pin 4, inverted, non, with 20k ohm·of resistance.
Can't get any accurate data coming out the debug.· Time, hour minute second stays around 00:07:07.. its giberish.
' =========================================================================
' {$PORT COM1}
'
'·· File...... Easy_GPS.BS2
'·· Purpose...
'·· Author.... Jon Williams
'·· E-mail.... jwilliams@parallax.com
'·· Started...
'·· Updated... 07 MAR 2004
'
'·· {$STAMP BS2}
'·· {$PBASIC 2.5}
'
' =========================================================================
'
[noparse][[/noparse] Program Description ]
'
' This program accepts text data from a Garmin GPS receiver using the
' Garmin text output at 2400 baud.· The advantage over NMEA 183 for this
' application is fixed field positions and widths which can be extracted
' using SERIN modifiers.
'······················ '
' String:
'
'····· @020202183142N3251129W09701159G008+00165E0000N0000D0001 <-- GPS
'······ |
'······ |······· 1········ 2········ 3········ 4········ 5
'······ 12345678901234567890123456789012345678901234567890123· <-- index
'
'····· @060408192405N3933843W10456696g020+01750E0000N0000U0002
'
'
'· 0·· @······· header
'· 1·· 020202·· UTC date (yr [noparse][[/noparse]2], mo, dy)
'· 7·· 183142·· UTC time (hr, mn, sc)
' 13·· N······· lat hemisphere
' 14·· 32······ lat degrees
' 16·· 51······ lat minutes
' 18·· 129····· lat frac minutes (1/1000)
' 21·· W······· long hemisphere
' 22·· 097····· long degrees
' 25·· 01······ long minutes
' 27·· 159····· long frac minutes (1/1000)
' 30·· G······· position status
' 31·· 008····· horizontal position error (meters)
' 34·· +······· altitude sign
' 35·· 00165··· altitude above/below sea level (meters)
' 40·· E······· E/W velocity direction
' 41·· 0000···· E/W velocity (meters per sec - tenths xxx.x)
' 45·· N······· N/S velocity direction
' 46·· 0000···· N/S E/W velocity (meters per sec - tenths xxx.x)
' 50·· D······· vertical velocity direction (Up / Down)
' 51·· 0001···· vertical velocity (meters per sec - hundredths xx.xx)
'
'
' For additional details see: http://www.garmin.com/support/text_out.html
'
[noparse][[/noparse] Revision History ]
'
[noparse][[/noparse] I/O Definitions ]
Rx············· PIN···· 0
'
[noparse][[/noparse] Constants ]
#SELECT $stamp
· #CASE BS2, BS2E, BS2PE
··· T1200······ CON···· 813
··· T2400······ CON···· 396
··· T4800······ CON···· 188
··· T9600······ CON···· 84
··· TimeOut···· CON···· 1500
· #CASE BS2SX, BS2P
··· T1200······ CON···· 2063
··· T2400······ CON···· 1021
··· T4800······ CON···· 500
··· T9600······ CON···· 240
··· TimeOut···· CON···· 3750
#ENDSELECT
Inverted······· CON···· $4000
Baud··········· CON···· T2400 + Inverted
EST············ CON···· 5······················ ' Eastern Standard Time
CST············ CON···· 6······················ ' Central
MST············ CON···· 7······················ ' Mountain
PST············ CON···· 8······················ ' Pacific
DST············ CON···· 0······················ ' daylight savings time
UtcAdj········· CON···· 24 - MST + DST········· ' adjust UTC for Dallas, TX
'
[noparse][[/noparse] Variables ]
hr············· VAR···· Byte··················· ' time fields
mn············· VAR···· Byte
sc············· VAR···· Byte
latHemi········ VAR···· Byte··················· ' hemisphere
latD··········· VAR···· Byte··················· ' degrees
latM··········· VAR···· Byte··················· ' minutes
latF··········· VAR···· Byte··················· ' fractional minutes
lonHemi········ VAR···· Byte
lonD··········· VAR···· Byte
lonM··········· VAR···· Byte
lonF··········· VAR···· Byte
altSign········ VAR···· Byte··················· ' "+" or "-"
alt············ VAR···· Word
ewDir·········· VAR···· Byte··················· ' "E" or "W"
ewVel·········· VAR···· Word··················· ' meters per second
nsDir·········· VAR···· Byte
nsVel·········· VAR···· Byte
'
[noparse][[/noparse] EEPROM Data ]
'
[noparse][[/noparse] Initialization ]
Setup:
· DEBUG CLS
'
[noparse][[/noparse] Program Code ]
Main:
·SERIN Rx, Baud, TimeOut, No_GPS,
····· [noparse][[/noparse]WAIT("@"), SKIP 6, DEC2 hr, DEC2 mn, DEC2 sc,
······ latHemi, DEC2 latD, DEC2 latM, DEC2 latF, SKIP 1,
······ lonHemi, DEC3 lonD, DEC2 lonM, DEC2 lonF, SKIP 1,
······ SKIP 4, altSign, DEC5 alt,
······ ewDir, DEC4 ewVel, nsDir, DEC4 nsVel]
· 'SERIN Rx, Baud, TimeOut, No_GPS,
·'······ [noparse][[/noparse]WAIT("@"), SKIP 6, S]
' The PAUSE instruction below shows how much time is
' available for processing captured GPS data
Test:
· PAUSE 750
Show_Time:
· 'hr = hr + UtcAdj // 24······················· ' localize time
· DEBUG HOME,
· DEC2 hr, ":", DEC2 mn, ":", DEC2 sc, " latHemi: ", latHemi, DEC2 latD, DEC2 latM, DEC2 latF
· GOTO Main
· END
'
[noparse][[/noparse] Subroutines ]
No_GPS:
· DEBUG CLS, "No GPS..."
· PAUSE 2000
· GOTO Setup
Post Edited (Dru) : 4/8/2006 9:36:54 PM GMT
Comments
[noparse][[/noparse] I/O Definitions ]
Rx PIN 0
Your Stamp is waiting to see data on Stamp Pin 0, not the DB9 programming connector. Or you can change the statement to the programming connector with
RX PIN 16
Secondly, you'll need to go into the Setup screen on your Garmin, Select Interface, Text Output and 2400 baud.
What do you mean by pin 3 and pin 4? Is this a stamp pin or the pin on the DB9 connector?
I always get it wrong, but you should be looking at pins 2 or 3 on the DB9 connector for your serial data.
If you have a voltmeter, you can put it on pin 2 or 3 and see the voltage fluctuate as the data flows....the pin that fluctuates is your TX pin (from the GPS) and should connect to your Receive pin on the stamp....unless you are using the programming port!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
I have set the Garmin GPS interface settings to text output at 2400 baud.
It seems it should be working. Not using the stamp, but hooking the GPS DB9 conn to the computer and watching in hyperterminal, the data lines are coming thru fine once a second.
I did try a multimeter over GPS serial pin 5 and 3 and I see about .5 volts fluctuating. Ah haaa... too small.
OK I just got it to work. Its Pin 2 on the GPS' serial connector, not pin 3!
Thanks for the replies.
I can't tell you how many times I get pin 2 and 3 backwards! The Tx Line will sit at -12volts (on a proper rs232 level system) when there is no data flowing on the pin....or when it's sitting idle.
Your voltmeter is a good way to see things on it....only a scope will letyou see the actual voltage levels as the fluctuate too fast for a voltmeter to indicate!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."