Thanks evrerybody, i made my prototype for GPS reading and it works perfectly i give my code as somebody can use it for similar applications
Best regards,
Leinske
' Program to display returned value of a GPS on RB1
' LCD in 4-BIT mode PIC16F628 controller 4Mhz clock Fuse PWRT BODEN
'
' LCD should be connected as follows:
' LCD PIC
' DB4 PortA.0
' DB5 PortA.1
' DB6 PortA.2
' DB7 PortA.3
' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
' E PortB.3
' RW Ground
' Vdd 5 volts
' Vss Ground
' Vo 20K potentiometer (or ground)
' DB0-3 No connect
'GPS sentence: $GPRMC,192144.62,A,5041.6058,N,00412.6124,E,0.45,3 57.74,081205,,*0B
DEFINE OSC 4
CMCON = 7
GPSin VAR PORTB.1
SW VAR PORTB.5 'optional switch for Man Over Board keeps position on EEPROM when switched on
TRISB.1=1 'define port B1 as input
TRISB.5=1 'define port B5 as input
TRISA.0=0
TRISA.1=0
TRISA.2=0
TRISA.3=0
TRISA.4=0
TRISB.3=0
PORTA=0
PORTB=0
'Allocate Variables for GPS:
TimeOut CON 3000
baudGPS CON 24764 '16572 + 8192 (bit 13)
hh VAR BYTE 'hours
mm VAR BYTE 'minutes
knots VAR WORD 'speed in knots (units)
knotsten VAR BYTE 'speed in knots (tens)
course VAR WORD 'heading
latdeg VAR BYTE 'degrees latitude
latmin VAR BYTE 'minutes latitude
NS VAR BYTE 'north or south
londeg VAR BYTE 'degrees longitude
lonmin VAR BYTE 'minutes longitude
EO VAR BYTE 'east or west
j VAR BYTE 'day
m VAR BYTE 'month
a VAR BYTE 'year
fix VAR WORD 'GPS fix
LCDOut $FE, 1 'Clear Screen
LCDOut " POP CORN"
LCDOut $fe,$c0
LCDOut " WELCOME ABOARD"
Pause 2000
LCDOut $FE, 1 'Clear Screen
LCDOut " YOUR SKIPPER"
LCDOut $fe,$c0
LCDOut " ALAIN DE VOS"
Pause 2000
LCDOut $FE, 1 'Clear Screen
GPS: 'read GPS
IF SW=1 Then 'switch for man over board
GoTo mob
EndIF
SerIn2 GPSin,baudGPS,Timeout,Nogps,[wait("$GPRMC"),wait(","),DEC2 hh,DEC2 mm,wait(","),fix,wait(","),DEC2 latdeg,DEC2 latmin,wait(","),NS,wait(","),DEC3 londeg,DEC2 lonmin,wait(","),EO,wait(","),knots,wait("."),DEC2 knotsten,wait(","),DEC3 course,wait(","),DEC2 j,DEC2 m,DEC2 a]
IF fix="V" Then 'if no GPS fix
GoTo Nofix
EndIF
'write last valid into EEPROM
Write 0,hh
Write 1,mm
Write 2,latdeg
Write 3,latmin
Write 4,NS
Write 5,londeg
Write 6,lonmin
Write 7,EO
Write 8,j
Write 9,m
Write 10,a
GoTo LCD
LCD:
'normal display if fix ok
LCDOut $FE, 1 'Clear Screen
LCDOut "SPEED :",knots,".",DEC2 knotsten," KNT"
LCDOut $fe,$c0
LCDOut "HEADING:",DEC3 course," DEG"
Pause 3000
LCDOut $FE, 1 'Clear Screen
LCDOut "LAT:",DEC2 latdeg,",",DEC2 latmin," ",NS
LCDOut $fe,$c0
LCDOut "LON:",DEC2 londeg,",",DEC2 lonmin," ",EO
Pause 3000
GoTo GPS
'display if no gps is present
Nogps:
Pause 1000
LCDOut $FE, 1 'Clear Screen
LCDOut " NO GPS"
Pause 1000
GoTo GPS
'display if no gps fix
Nofix:
'read last valid from EEPROM
Read 0,hh
Read 1,mm
Read 2,latdeg
Read 3,latmin
Read 4,NS
Read 5,londeg
Read 6,lonmin
Read 7,EO
Read 8,j
Read 9,m
Read 10,a
Pause 1000
LCDOut $FE, 1 'Clear Screen
LCDOut " NO GPS FIX"
LCDOut $fe,$c0
LCDOut " LAST VALID"
Pause 2000
LCDOut $FE, 1 'Clear Screen
LCDOut "DATE: ",DEC2 j,"-",DEC2 m,"-",DEC2 a
LCDOut $fe,$c0
LCDOut "TIME: ",DEC2 hh,":",DEC2 mm
Pause 2000
LCDOut $FE, 1 'Clear Screen
LCDOut "LAT:",DEC2 latdeg,",",DEC2 latmin," ",NS
LCDOut $fe,$c0
LCDOut "LON:",DEC2 londeg,",",DEC2 lonmin," ",EO
Pause 2000
GoTo GPS
mob: 'man over board
Read 2,latdeg
Read 3,latmin
Read 4,NS
Read 5,londeg
Read 6,lonmin
Read 7,EO
Pause 1000
LCDOut $FE, 1 'Clear Screen
LCDOut " MAN OVER BOARD"
LCDOut $fe,$c0
LCDOut " POSITION"
Pause 2000
LCDOut $FE, 1 'Clear Screen
LCDOut "LAT:",DEC2 latdeg,",",DEC2 latmin," ",NS
LCDOut $fe,$c0
LCDOut "LON:",DEC2 londeg,",",DEC2 lonmin," ",EO
Pause 2000
GoTo GPS
Bookmarks