GPS Clock
TickTockTony
Posts: 12
Hello All
I have a Basic Stamp 2 and am using it along with a Garmin 18xLVC GPS to make a clock.
I am trying to input the GPGGA sentence into the stamp chip to strip off Hr Min sec
Below is the sentence I capture in Hyperterminal so the correct data is coming out of the GPS. the time here is 21:39:59
$GPGGA,213949,3339.5437,N,11733.7918,W,1,06,2.2,405.7,M,-34.4,M,,*75
$GPGGA,213950,3339.5437,N,11733.7919,W,1,06,2.2,405.7,M,-34.4,M,,*7C
$GPGGA,213951,3339.5437,N,11733.7918,W,1,06,2.2,405.8,M,-34.4,M,,*73
$GPGGA,213952,3339.5436,N,11733.7919,W,1,05,2.8,405.8,M,-34.4,M,,*79
$GPGGA,213953,3339.5436,N,11733.7919,W,1,06,2.2,405.8,M,-34.4,M,,*71
$GPGGA,213954,3339.5436,N,11733.7919,W,1,06,2.2,405.8,M,-34.4,M,,*76
$GPGGA,213955,3339.5436,N,11733.7918,W,1,05,2.8,405.9,M,-34.4,M,,*7E
$GPGGA,213956,3339.5435,N,11733.7918,W,1,05,2.8,405.9,M,-34.4,M,,*7E
$GPGGA,213957,3339.5435,N,11733.7918,W,1,05,2.8,405.9,M,-34.4,M,,*7F
$GPGGA,213958,3339.5434,N,11733.7918,W,1,05,2.8,405.9,M,-34.4,M,,*71
$GPGGA,213959,3339.5433,N,11733.7917,W,1,06,2.2,406.0,M,-34.4,M,,*7B
Problem is I can NOT capture this in my stamp2. I have looked at the demo codes used for the stamp2p and the Parallax GPS and have used elements of these to greater a code that works for me.
below is the code I am using.
Question is am I flogging a dead hoarse and need to go purchase the Stamp2p, or should I
persist?
GPS to stamp via input pin #8 and baud rate 4800 8b noP 1 stop flow hardware
Thanks in advance for your time
TickTockTony
Orange County, CA
' {$STAMP BS2}
' {$PBASIC 2.5}
sec VAR Word
cnt3 VAR Word
cnt3 = 0
sec = 0
tmHrs VAR Byte ' time fields
tmMins VAR Byte
tmSecs VAR Byte
Baud CON Open | 4800 ' Open mode to allow daisy chaining
Open CON $8000
T4800 CON 188
garmin:
'DEBUG ? "eaiting for pulse"
IF (IN4 = 1) THEN
sec = sec + 1
'SERIN 8, 4800, [tmHrs]
SERIN 8, Baud, [tmHrs, tmMins, tmSecs]
DEBUG DEC2 tmHrs, ":", DEC2 tmMins, ":", DEC2 tmSecs, CR
GOTO clock
ELSE
GOTO garmin
ENDIF
'move the clock hands
clock:
'DEBUG ? " move clock hands"
IF (IN4 =1) THEN
GOTO clock
ELSE
IF (cnt3 = 0) THEN
HIGH 12
LOW 11
cnt3 = cnt3 + 1
ELSE
LOW 12
HIGH 11
cnt3 = 0
ENDIF
ENDIF
PAUSE 200
GOTO garmin
I have a Basic Stamp 2 and am using it along with a Garmin 18xLVC GPS to make a clock.
I am trying to input the GPGGA sentence into the stamp chip to strip off Hr Min sec
Below is the sentence I capture in Hyperterminal so the correct data is coming out of the GPS. the time here is 21:39:59
$GPGGA,213949,3339.5437,N,11733.7918,W,1,06,2.2,405.7,M,-34.4,M,,*75
$GPGGA,213950,3339.5437,N,11733.7919,W,1,06,2.2,405.7,M,-34.4,M,,*7C
$GPGGA,213951,3339.5437,N,11733.7918,W,1,06,2.2,405.8,M,-34.4,M,,*73
$GPGGA,213952,3339.5436,N,11733.7919,W,1,05,2.8,405.8,M,-34.4,M,,*79
$GPGGA,213953,3339.5436,N,11733.7919,W,1,06,2.2,405.8,M,-34.4,M,,*71
$GPGGA,213954,3339.5436,N,11733.7919,W,1,06,2.2,405.8,M,-34.4,M,,*76
$GPGGA,213955,3339.5436,N,11733.7918,W,1,05,2.8,405.9,M,-34.4,M,,*7E
$GPGGA,213956,3339.5435,N,11733.7918,W,1,05,2.8,405.9,M,-34.4,M,,*7E
$GPGGA,213957,3339.5435,N,11733.7918,W,1,05,2.8,405.9,M,-34.4,M,,*7F
$GPGGA,213958,3339.5434,N,11733.7918,W,1,05,2.8,405.9,M,-34.4,M,,*71
$GPGGA,213959,3339.5433,N,11733.7917,W,1,06,2.2,406.0,M,-34.4,M,,*7B
Problem is I can NOT capture this in my stamp2. I have looked at the demo codes used for the stamp2p and the Parallax GPS and have used elements of these to greater a code that works for me.
below is the code I am using.
Question is am I flogging a dead hoarse and need to go purchase the Stamp2p, or should I
persist?
GPS to stamp via input pin #8 and baud rate 4800 8b noP 1 stop flow hardware
Thanks in advance for your time
TickTockTony
Orange County, CA
' {$STAMP BS2}
' {$PBASIC 2.5}
sec VAR Word
cnt3 VAR Word
cnt3 = 0
sec = 0
tmHrs VAR Byte ' time fields
tmMins VAR Byte
tmSecs VAR Byte
Baud CON Open | 4800 ' Open mode to allow daisy chaining
Open CON $8000
T4800 CON 188
garmin:
'DEBUG ? "eaiting for pulse"
IF (IN4 = 1) THEN
sec = sec + 1
'SERIN 8, 4800, [tmHrs]
SERIN 8, Baud, [tmHrs, tmMins, tmSecs]
DEBUG DEC2 tmHrs, ":", DEC2 tmMins, ":", DEC2 tmSecs, CR
GOTO clock
ELSE
GOTO garmin
ENDIF
'move the clock hands
clock:
'DEBUG ? " move clock hands"
IF (IN4 =1) THEN
GOTO clock
ELSE
IF (cnt3 = 0) THEN
HIGH 12
LOW 11
cnt3 = cnt3 + 1
ELSE
LOW 12
HIGH 11
cnt3 = 0
ENDIF
ENDIF
PAUSE 200
GOTO garmin
Comments
I'm not seeing where you test for $GP in the string.
-Phil
I tried the wait and DEC2 statments with no luck. with wait statment the programs halts at the wait. With no wait and the DEC2 parameter the progran loops 5 times slower than it shouls and data is still incorect.
garmin:
'SERIN 8, 4800, [tmHrs, tmMins, tmSecs]
'SERIN 8, 4800, [DEC2 tmHrs, DEC2 tmMins, DEC2 tmSecs]
SERIN 8, 4800, [WAIT("GPGGA,"), DEC2 tmHrs, DEC2 tmMins, DEC2 tmSecs]
DEBUG DEC2 tmHrs, ":", DEC2 tmMins, ":", DEC2 tmSecs, CR
GOTO garmin
-Phil
Books shows several examples where the baude rate is directley entered .
Initaly I had my program looking just like the demo example, see below.
It does not help.
' {$STAMP BS2}
' {$PBASIC 2.5}
sec VAR Word
cnt3 VAR Word
cnt3 = 0
sec = 0
tmHrs VAR Byte ' time fields
tmMins VAR Byte
tmSecs VAR Byte
T4800 CON 188
Open CON $8000
Baud CON Open | T4800 ' Open mode to allow daisy chaining
garmin:
'SERIN 8, Baud, [tmHrs, tmMins, tmSecs]
'SERIN 8, Baud, [DEC2 tmHrs, DEC2 tmMins, DEC2 tmSecs]
SERIN 8, Baud, [WAIT("GPGGA,"), DEC2 tmHrs, DEC2 tmMins, DEC2 tmSecs]
DEBUG DEC2 tmHrs, ":", DEC2 tmMins, ":", DEC2 tmSecs, CR
GOTO garmin
Tony
SERIN does not have an OPEN mode modifier. That's only for SEROUT. Try it without the $8000.
-Phil
-Phil
I think the Garmin is an RS-232 True output, so the Stamp's baudmode should be an Inverted (id est "TTL inverted").
-Phil
I have a Garmin 18xLVC. I have 22K ohn resistor in serise with the pin 2 in data. I find the code will not assembel if I use a N4800 for the baud rate statment.
Garmin replied and said the 18X does not go lower than 4800. That explanes wht the menue selection of 2400 does not work.
Any and all comments welsome, as I have to get this working.
Thanks for your time
Tony
-Phil
The code below gives the correct hrs but incorect value for min and sec. I know this because the debug display shows 19:06:06 and changed to 20:06:06 when UTC time changed the Hrs
Based in this information the baud rate and wait statment must be OK.
' {$STAMP BS2}
' {$PBASIC 2.5}
sec VAR Word
cnt3 VAR Word
cnt3 = 0
sec = 0
tmHrs VAR Byte ' time fields
tmMins VAR Byte
tmSecs VAR Byte
tmHrs = 0
tmMins = 0
tmSecs = 0
Baud CON 16572
garmin:
SERIN 8, Baud, [WAIT("GPGGA,"), DEC2 tmHrs, DEC2 tmMins, DEC2 tmSecs]
DEBUG DEC2 tmHrs, ":", DEC2 tmMins, ":", DEC2 tmSecs, CR
GOTO garmin
1. Change all the DEC2s to HEX2. We can worry about converting to decimal later.
2. Read the time as a 6-byte string:
-Phil
Tony
I had a syntax error in the latest PBASIC code I posted -- now corrected. ('Too used to Spin syntax these days.) By "no luck" did you mean that the program didn't compile, or that it didn't output the right results?
-Phil
I use/have used the STR'ing successfully with a BS2. Though it's with a different sentence, the principle is the same --
SERIN 9,188,[WAIT("GLL,"),STR PA\2,STR PM\2,SKIP 1,STR PD\3,SKIP 2,STR NS\1,SKIP 1,STR MA\3,STR MM\2,SKIP 1,STR MD\3,SKIP 2,STR EW\1,SKIP 1,STR [COLOR="red"]TM\6[/COLOR],SKIP 5,STR AV\1]
TM\6 is the hours, minutes, seconds
The SKIPs are the commas (CSV).
I use baudmode = 188 because I always use a MAX232.
Yes, I would've thought the BS2 could keep up with the STR stuff at 4800 baud. On-the-fly DEC conversions? Maybe not so much. I hope Tony didn't run off and buy a BS2p just because my example code didn't compile.
-Phil
Sorry to be brief I had and appointment.
Original code debug output
03:06:03
03:06:05
03:06:03
03:06:03
The 03 hour is correct and will incroment when it should. The min and seconde do not make sence. Is it is not min 06 and it will never increment no matter how long you leave it.
Replacing Dec2 with Hex2
03:06:0B
03:06:0B
03:06:0B
Again hour is correct and inrements and min and sec do not make sence.
changing the time to a string value got did not compile. however i plaied aroud with string and work values and could not get the correct output.
No phill i am not getting a Stamp2p cos the code did not compile. i ordered it yeaterday cos like this system and need a second processor and the GPS demo code was for a 2P.
Thanks for your help
regards Tony
Please Attach your code, uncompiling or otherwise.
You mention the syntax error "now corected" Where can I find the corected version?
The code in the post has a compalation error "expected end of lind "
at the "\" in Time(2)\2
Tony
Push the "Go Advanced" button and then scroll down a bit and push the "Manage Attachments" button and Attach your code.
I've made another correction to the code. In addition to the obvious syntax error, PBASIC exhibited a restriction that I didn't know existed. 'Sorry for the misdirection.
-Phil
The ending problem was to implement Pauls modifies string code.
Tony
(Now to get that subject title"unsolved" changed to "Solved"; Phil will be over the Moon I'm sure.)
-Phil
I grab the $GPGLL data, format it and send it to
a 4x20 serial LCD.
It's been chugging along, 24/7, for >5 years.
-Phil