ok, thanks for the help... it appears that im gonna need to learn a lot more before i can get this to work... i dont understand most of the stuff you just said so im gonna have to learn all that stuff....
thanks
ok, thanks for the help... it appears that im gonna need to learn a lot more before i can get this to work... i dont understand most of the stuff you just said so im gonna have to learn all that stuff....
thanks
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
thanks for the reply.. i understand that a lot more than i did before... my lcd is currently not working, and i dont know why, so as soon as i get it fixed, or i get another, i will retry writing the code using your example...
thanks
danny
OK, i think ive got the basics of how to do this... im sorry if it seems like im asking you all to write the code for me, but im not... im just one of those people that figure the best way to learn is from examples.. i have tried changing leinske's code to make it display with a serial lcd, and what data it displays... i got it to work, except for displaying the course... thanks for that, i learnt a lot from it.... i just learned that my gps does output GPAPB sentences (only outputs it if there is a route active), and so i changed the code for it... i just want to display waypoint name and distance and direction for some geocaching stuff i am working on... when i try to compile, it says that there is an error. it says "expected ]"... i know its probably a stupid mistake somewhere, but i cant find it.... im using a 16f88 at 10mhz, with an epic programmer... the gps is a sporttrak map.... thanks for all the help...
@ DEVICE HS_OSC
DEFINE OSC 10
cmcon = 7
TRISA = %00000000
'variables
'-------------------------------------------------------------
lcd VAR PORTA.3
gpsin VAR PORTB.0
GPAPB_IN VAR BYTE
TimeOut CON 3000
baudGPS CON 24764 '16572 + 8192 (bit 13)
blink VAR BYTE 'SNR warning
warning VAR BYTE 'cycle warning
xtrack VAR WORD 'crosstrack error
lrcorrect VAR WORD 'steer right or left to correct
xtrackunits VAR BYTE 'cross track error units n or k
arrivalcircle VAR WORD 'arrival alarm circular
arrivalperp VAR WORD ' arrival alarm perpendicular
magbear VAR WORD 'origin to dest 'magnetic bearing
dest VAR WORD 'destination ID
bear VAR WORD 'position to dest
head VAR WORD 'heading to steer
'initialize variables
'setup serial lcd
'-------------------------------------------------------------
Pause 5000
SerOut2 lcd, 32,[254,"X"] 'clear screen
Pause 100
'main program
'-------------------------------------------------------------
GPS: 'read GPS
SerIn2 GPSin,baudGPS,Timeout,Nogps,[wait("$GPAPB"), wait(","), blink, wait(","), warning, wait(","), DEC2 xtrack, wait(","), lrcorrect, wait(","), xtrackunits, wait(","), arrivalcirlce, wait(","), arrivalperp, wait(","), DEC3 magbear, wait(",$,"), mag, wait(","), dest, wait(","), DEC3 bear, wait(","), DEC3 head]
SerOut2 lcd, 32,[254,"G",4,1]
SerOut2 lcd, 32,[#lrcorrect," "]
SerOut2 lcd, 32,[254,"G",1,2]
SerOut2 lcd, 32,[#magbearing," "]
SerOut2 lcd, 32,[254,"G",4,2]
SerOut2 lcd, 32,[#mag," "]
SerOut2 lcd, 32,[254,"G",1,3]
SerOut2 lcd, 32,[#dest," "]
SerOut2 lcd, 32,[254,"G",4,3]
SerOut2 lcd, 32,[#magbear," "]
SerOut2 lcd, 32,[254,"G",1,1]
SerOut2 lcd, 32,[#maghead," "]
Pause 500
GoTo gps
Nogps:
Pause 100
SerOut2 lcd, 32,[254,"X"]
SerOut2 lcd, 32,[254,"G",5,2]
SerOut2 lcd, 32,[" NO GPS"]
Pause 100
GoTo GPS
Bookmarks