I Dragon Fire if it can help you, here is the complete code file for a similar application I made for my GPS repeater for my sailboat :
' Program to display returned value of a GPS on RB1
' LCD in 4-BIT mode PIC16F628 controller 4Mhz clock Fuse PWRT BODEN
'This version include: engine rpm,heading and speed,heading and range to WP
'
' 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
'Route sentence: $ECBWC,000000,5110.063,N,00236.403,E,276.4,T,277.6 ,M,3.15,N,02-NIEUWPOORT-BANK*34
@ DEVICE PIC16F628A,XT_OSC,WDT_OFF,PWRT_ON,MCLR_OFF,BOD_ON, LVP_OFF,PROTECT_OFF
DEFINE OSC 4
CMCON = 7
GPSin VAR PORTB.1
RPMin VAR PORTB.4 'input from rpm module optical with 2 marks on flyweel
TRISB.1=1 'define port B1 as input
TRISB.5=1 'define port B5 as input
TRISB.4=1 'define port B4 as input
TRISA.0=0 'define PORT A output for LCD DB4
TRISA.1=0 'define PORT A output for LCD DB5
TRISA.2=0 'define PORT A output for LCD DB6
TRISA.3=0 'define PORT A output for LCD DB7
TRISA.4=0 'define PORT A output for LCD RS
TRISB.3=0 'define PORT B output for LCD E
PORTA=0
PORTB=0
'Allocate Variables for GPS:
TimeOut CON 3000
baudGPS CON 24764 '16572 + 8192 (bit 13)
RPM VAR WORD 'motor revolutions
truecourse VAR WORD 'true course to WP
magcourse VAR WORD 'magnetic course to WP
dist VAR BYTE 'distance to WP units
distten VAR BYTE 'distance to WP tens
wpid VAR BYTE 'WP id nb
wp VAR BYTE[16] 'WP name
hh VAR BYTE 'hours
mm VAR BYTE 'minutes
j VAR BYTE 'day
m VAR BYTE 'month
a VAR BYTE 'year
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
fix VAR WORD 'GPS fix
'initialize variables
hh=0
mm=0
j=0
m=0
a=0
knots="0"
knotsten=0
course=0
latdeg=0
latmin=0
NS="N"
londeg=0
lonmin=0
EO="S"
truecourse=0
magcourse=0
dist="0"
distten=0
wpid=0
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
'read motor revolutions
Count RPMin,600,RPM
IF RPM<2Then
GoTo readgps
Else
RPM=RPM*50
LCDOut $FE, 1 'Clear Screen
LCDOut "ENGINE SPEED:"
LCDOut $fe,$c0
LCDOut #RPM," RPM"
Pause 2000
EndIF
readgps:
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
LCD:
'normal display if fix ok
LCDOut $FE, 1 'Clear Screen
LCDOut "SPEED :",knots,",",DEC2 knotsten,"KNT"
LCDOut $fe,$c0
LCDOut "HEADING:",DEC3 course,223,"TRUE"
Pause 3000
LCDOut $FE, 1 'Clear Screen
LCDOut DEC2 j,"-",DEC2 m,"-",DEC2 a," ",DEC2 hh,":",DEC2 mm
LCDOut $fe,$c0
LCDOut DEC2 latdeg,223,DEC2 latmin,39,NS," ",DEC2 londeg,223,DEC2 lonmin,39,EO
Pause 3000
'Get route informations from serial port
SerIn2 GPSin,baudGPS,Timeout,norte,[wait("$ECBWC"),wait(","),wait(","),DEC2 latdeg,DEC2 latmin,wait(","),NS,wait(","),DEC3 londeg,DEC2 lonmin,wait(","),EO,wait(","),DEC3 truecourse,wait(","),wait(","),DEC3 magcourse,wait(","),wait(","),DEC2 dist,wait("."),DEC2 distten,wait(","),wait(","),DEC2 wpid,wait("-"),STR wp\16\"*"]
'display route informations
LCDOut $FE, 1 'Clear Screen
LCDOut "WAYPOINT WP",DEC2 wpid,":"
LCDOut $fe,$c0
LCDOut STR wp
Pause 3000
LCDOut $FE, 1 'Clear Screen
LCDOut "POSITION WP",DEC2 wpid
LCDOut $fe,$c0
LCDOut DEC2 latdeg,223,DEC2 latmin,39,NS," ",DEC2 londeg,223,DEC2 lonmin,39,EO
Pause 3000
LCDOut $FE, 1 'Clear Screen
LCDOut "HEADING TO WP",DEC2 wpid
LCDOut $fe,$c0
LCDOut DEC3 truecourse,223,"TRUE",61,DEC3 magcourse,223,"MAG"
Pause 3000
LCDOut $FE, 1 'Clear Screen
LCDOut "DISTANCE TO WP",DEC2 wpid
LCDOut $fe,$c0
LCDOut DEC2 dist,",",DEC2 distten," NM"
Pause 2000
GoTo GPS
'display if no gps is present
Nogps:
Pause 1000
LCDOut $FE, 1 'Clear Screen
LCDOut " NO GPS"
LCDOut $fe,$c0
LCDOut " CHECK CABLES "
Pause 1000
GoTo GPS
'display if no gps fix
Nofix:
'display last valid from GPS
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 "LAT:",DEC2 latdeg,223,DEC2 latmin,39,NS
LCDOut $fe,$c0
LCDOut "LON:",DEC2 londeg,223,DEC2 lonmin,39,EO
Pause 2000
GoTo GPS
norte:
'display if no active route
Pause 1000
LCDOut $FE, 1 'Clear Screen
LCDOut "NO ACTIVE ROUTE"
Pause 1000
GoTo GPS
Bookmarks