bs2 gps lcd
brod
Posts: 16
Hi all
I am new to coding and need a little help with this.
Parts used
BOE BS2 PMB-648 2 x 16 LCD
Basically the code works i.e. I can get a fix and the results are correct, but if I move position the lcd does not refresh the data.
' {$STAMP BS2}
' {$PBASIC 2.5}
LatDeg VAR Byte
LatMin VAR Byte
LatMinD VAR Word
LatSign VAR Byte
LatDir VAR Byte
LonDeg VAR Byte
LonMin VAR Byte
LonMinD VAR Word
LonSign VAR Byte
LonDir VAR Byte
wVal VAR Word
'
[ Constants ]
LcdBLon CON 17 ' backlight on
'Baud rates (non-inverted):
n4800 CON 188
n19200 CON 32
'
lcd start up
SEROUT 0, n19200, [22, 12] 'initalize lcd
SEROUT 0, n19200, [LcdBLon] 'turn on lcd backlight
Main:
DO
'Get GPSRMC statement from pin 15
SERIN 15, n4800, [WAIT("RMC,"),SKIP 13,
DEC2 LatDeg, DEC LatMin, SKIP 1, DEC LatMinD, SKIP 1, LatSign,
DEC3 LonDeg, DEC LonMin, SKIP 1, DEC LonMinD, SKIP 1, LonSign]
'lcd information
wVal = (LatMin * 1000 / 6) + (LatMinD / 60) 'convert to min/seconds
SEROUT 0, n19200, [REP "-"\ LatDir, DEC LatDeg, ".", DEC4 wVal, " S ", 13]
wVal = (LonMin * 1000 / 6) + (LonMinD / 60) 'convert to min/seconds
SEROUT 0, n19200, [REP "-"\ LonDir, DEC LonDeg, ".", DEC4 wVal, " W ",128]
GOSUB AddSign
PAUSE 500
LOOP
AddSign:
IF LatSign = "S" THEN
LatDir = 1
ELSE
LatDir = 0
ENDIF
IF LonSign = "W" THEN
LonDir = 1
ELSE
LonDir = 0
ENDIF
RETURN
Thanks
Brod
I am new to coding and need a little help with this.
Parts used
BOE BS2 PMB-648 2 x 16 LCD
Basically the code works i.e. I can get a fix and the results are correct, but if I move position the lcd does not refresh the data.
' {$STAMP BS2}
' {$PBASIC 2.5}
LatDeg VAR Byte
LatMin VAR Byte
LatMinD VAR Word
LatSign VAR Byte
LatDir VAR Byte
LonDeg VAR Byte
LonMin VAR Byte
LonMinD VAR Word
LonSign VAR Byte
LonDir VAR Byte
wVal VAR Word
'
[ Constants ]
LcdBLon CON 17 ' backlight on
'Baud rates (non-inverted):
n4800 CON 188
n19200 CON 32
'
lcd start up
SEROUT 0, n19200, [22, 12] 'initalize lcd
SEROUT 0, n19200, [LcdBLon] 'turn on lcd backlight
Main:
DO
'Get GPSRMC statement from pin 15
SERIN 15, n4800, [WAIT("RMC,"),SKIP 13,
DEC2 LatDeg, DEC LatMin, SKIP 1, DEC LatMinD, SKIP 1, LatSign,
DEC3 LonDeg, DEC LonMin, SKIP 1, DEC LonMinD, SKIP 1, LonSign]
'lcd information
wVal = (LatMin * 1000 / 6) + (LatMinD / 60) 'convert to min/seconds
SEROUT 0, n19200, [REP "-"\ LatDir, DEC LatDeg, ".", DEC4 wVal, " S ", 13]
wVal = (LonMin * 1000 / 6) + (LonMinD / 60) 'convert to min/seconds
SEROUT 0, n19200, [REP "-"\ LonDir, DEC LonDeg, ".", DEC4 wVal, " W ",128]
GOSUB AddSign
PAUSE 500
LOOP
AddSign:
IF LatSign = "S" THEN
LatDir = 1
ELSE
LatDir = 0
ENDIF
IF LonSign = "W" THEN
LonDir = 1
ELSE
LonDir = 0
ENDIF
RETURN
Thanks
Brod
Comments
You need to walk down the road or something.
It's not going to pin-point your position in the front room.
I am getting a solid red light on the GPS so I took it for granted I was getting a solid fix.
I am also taking the readings out doors and no matter how far I walk the LCD does not change, but if I switch off and back on the data refreshes.
As I said earlier very new to coding.
Thanks again
May The Force be with you.
ran your code and without a fix you get seconds counting up and V,s.
When fixed seconds counting up and A,s (fixed confirmed)
When running my code it definitely does not refresh from the gps, if I press the reset button on the BOE lcd flashes but displays the same reading, but if you turn off the BOE and back on again the readings change to the correct ones.
Its as if it gets a lock and does not bother looking for an update.
I don't know what the objective of the kickstart code you've posted is.
REP makes it REPeat dashes LatDir or LonDir number of times? :zombie: Whatever.
Let's try ditching that part.
Maybe change the "wval =" lines.. and see how that goes.
The "-"\REP LatDir command just displays zero or one "-" signs for the direction, but the GOSUB was in the wong place.
Not sure why you changed the 13 to $10,$13. The 13 (CR) is supposed to move the cursor to the next line, but I would use 192 instead to exactly place it on the 2nd line. The 128 in the second SEROUT places the cursor back home, $02 is compose character 2.
I usually place the cursor positioning commands at the beginning of the SEROUT, not the end, to ensure the cursor is at the right spot before sending data. I suspect data may be written off-screen.
Adding a few DEBUGs before and after the SERIN would help:
and then possibly showing the data with a DEBUG too.
Sapphire I have added the Debug commands but as my PC is indoors I cant get a GPS fix.
On monday i will bring my laptop home from work and try it on that outdoors, so I can observe the Debug results.
Should be 10, 13 ($0A, $0C $0D): Line Feed (same position, next line) and Form Feed Carriage Return (to left-most of current line)
$02 (or 2) is Home Cursor (upper left corner, contents unaffected)
PE - $0C to $0D, FF to CR. Out in the sun too long, today. 10, 13 are right though (what's the matter with me?) :zombie:
I didn't think there was much sun where you are!
Still no joy, put Debug in as suggested by Sapphire and got the same results as I did with the Lcd.
Its just not refreshing the data from the gps.
The Debug comand is refreshing but not the data from the gps. ie "Got Gps data".
Have I missed some code that would make it look for new data at each loop?
This is starting to annoy me now, it must be something simple that I am missing.
Its strange that even if you press the reset button on the BOE it still doesn't update until you turn off and back on again.
-Phil
See Reply #13
Not sure what I am supposed to enter from your post #13 sorry bit thick
SEROUT 0, n19200, [DEC LatDeg, ".", DEC4 wVal, [COLOR="#0000CD"]10, 13[/COLOR]]
wVal = (LonMin * 1000 / 6) + (LonMinD / 60) 'convert to min/seconds
SEROUT 0, n19200, [DEC LonDeg, ".", DEC4 wVal, [COLOR="#0000CD"]2[/COLOR]]
I messed up those numbers last time, but I made the corrections.
So, include the numbers at the end, as above.
'Sorry, I missed your HOME recommendation. I'll go now ...
-Phil
I have modified my code like this,
wVal = (LatMin * 1000 / 6) + (LatMinD / 60) 'convert to min/seconds
SEROUT 0, n9600, [REP"-"\ LatDir, DEC LatDeg, ".", DEC4 wVal, " S ",13]
wVal = (LonMin * 1000 / 6) + (LonMinD / 60) 'convert to min/seconds
SEROUT 0, n9600,128, [REP"-"\ LonDir, DEC LonDeg, ".", DEC4 wVal, " W ",12]
This makes the LCD refresh at every loop[ but the data stiil doesn't change.
You kept the REP"-" stuff that I'd omitted.
I can't win.
Thanks
What LCD are you using, by the way?
Where's a link to this 'kickstart'?
OK here we go, according to the LCD info 12 clears the screen and returns cursor to the home position.
The LCD I m using is the Parallax,
Item code
27977.
Kickstart link, Example KickStart Circuits & Code
Parallax lcd docs, Parallax Serial LCD Docs v3.0
Ran the new code and got this,
Line 0 = 00234.55?46 a 51
Line 1 = 00234.55?47 a 51
Seconds count up and V changes to A when gps fix, ? = strange character.
None of the other data changes with position change.
Thanks again
SEROUT 0, n19200, [$0C,STR secs_10\1,STR secs_01\1," ",STR status\1," ",STR lat\7,$0D,STR lon\9]
$0C - erase screen and home cursor, pause 5msec per docs
str secs_10/1, str secs_01\1 - prints seconds
print a space
str status\1 - print status char
print a space
str lat\7 - print ddmm.mmm of latitude
$0D - go to next line and full left
str lon\9 - print dddmm.mmm of longitude
The GPS kickstart that you've posted has:
SEROUT 0, n19200, [22, 12, $19, $00] 'initalize lcd
I note that it too uses a "12" ($0C), but it is not followed by a 5msec pause that the documentation calls out as necessary
(See its Page 8 of 11), eyebrows raised