PDA

View Full Version : Gps/glcd



karenhornby
- 1st April 2008, 05:13
Has anyone any ideas how to use a gps module and connect it to a GLCD?
What I'm hoping to do (somehow) is have the whole of the left hand side of the GLCD show the SPEED of the vehicle I'm travelling in (car) while the right hand side is split into 4 lines, 2 lines will only display one of maybe 3 words each depending on which input is active on the pic, while the other 2 lines will be a bargraph display displaying the level in the fuel tank.

Any ideas anyone? or would I be better off using a 2X16 or 4X 20 LCD display and just using LED's to display the speed decoded from the GPS unit?

skimask
- 1st April 2008, 13:38
Has anyone any ideas how to use a gps module and connect it to a GLCD?..........
Any ideas anyone? or would I be better off using a 2X16 or 4X 20 LCD display and just using LED's to display the speed decoded from the GPS unit?

http://www.picbasic.co.uk/forum/showthread.php?t=8135&highlight=nokia

DaveC3
- 1st April 2008, 16:18
What GLCD are you going to use? I have some code I used a few years ago to log GPS data to a eeprom and display the data on a character LCD. It would be easy to port that code to a GLCD. The code is a little sloppy but I think you can get the idea.



'************************************************* ***************
'* Name : hand held gps.BAS *
'* Author : Dave Cutliff *
'* Notice : Copyright (c) 2002 Use at your own risk *
'* : All Rights Reserved *
'* Date : 9/8/02 *
'* Version : 3.0 *
'* Notes : *
'* : *
'************************************************* ***************

'LCD Setup
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50

'************************************************* *********************

Cont CON %10100000
vol_addr CON 0
first_addr CON 2

CMCON = 7
'VRCON = 0

'************************************************* *********************
'Set up Serial port
SerPin VAR PORTA.2
SerPout VAR PORTA.3
GPSIN VAR PORTB.2
'************************************************* *********************
EECLR VAR WORD
A VAR BYTE
B VAR BYTE
G var byte
n VAR BYTE
C VAR WORD
D VAR BYTE
D1 VAR BYTE
E VAR BYTE
E1 VAR BYTE
Cse VAR BYTE(3) 'Whole number course (no decimal)
Spd VAR BYTE(3) 'Whole number speed in kts.(no decimal)
gdat VAR BYTE(60)
cnt VAR BYTE
volume VAR WORD
addr VAR WORD
LOGDAT VAR BYTE '(32)
OLD1 VAR BYTE
NEW1 VAR BYTE
Temp1 VAR BYTE
response VAR BYTE
Encodercnt VAR BYTE
N_ VAR OLD1.BIT4
O_ VAR NEW1.BIT5
INPUT PORTA.4 'ENCODER a
INPUT PORTA.5 'ENCODER b
INPUT PORTB.0 'ENCODER SWITCH
'status VAR BYTE 'GPS status, A = good data, V = bad data
NEW1 = PORTA & %00110000
OLD1 = NEW1
Encodercnt = 1
'************************************************* ********************
'LOG DATA VIA RB.0 INTERRUPT
INTCON =$90 'RB.0 INTERRPT NEG TRIGGER
OPTION_REG.6 = 0
GOTO START
'************************************************* ********************
DISABLE
log:
addr = (volume * 36) + 2 'append address
FOR A = 0 TO 35
I2CWRITE porta.1,porta.0,cont,addr,[gdat(A)] 'write GPS data
PAUSE 10
addr = ADDR + 1
NEXT A
VOLUME = VOLUME + 1
I2CWRITE porta.1,porta.0,cont,0,[VOLUME] 'write new address count
PAUSE 10
INTCON.1 = 0
RESUME
ENABLE

'************************************************* ***********************
Start:

cnt = 0
PAUSE 1000
LCDOUT $fe,1 'clear lcd
LCDOUT $fe,2 'home
LCDOUT $fe,$0c 'Curser off
I2CREAD PORTA.1,PORTA.0,CONT,0,[VOLUME] 'the eeprom reverses the upper
PAUSE 10 ' and lower bytes of the "volume"
D = VOLUME.BYTE1 ' word. These vars put the word
E = VOLUME.BYTE0 ' back in the correct order
D1 = E
E1 = D
VOLUME.BYTE1 = D1
VOLUME.BYTE0 = E1
LCDOUT "EPROM HAS ",HEX VOLUME," BYTES"
pause 1000
IF VOLUME = 0 THEN GET_DATA 'no saved data get data

IF PORTB.0 = 0 THEN GET_DATA 'bypass serial by pushing button
ON INTERRUPT GOTO log 'LOG DATA VIA RB.0 INTERRUPT
'************************************************* ***********************
has_data:

LCDOUT $fe,1 'clear lcd
LCDOUT $fe,2 'home
PAUSE 250
SEROUT2 SerPout,188,["1 Clear EEProm", 10, 13] 'send PC instructions
SEROUT2 SerPout,188,["2 Append data", 10, 13]
SEROUT2 SerPout,188,["3 Read data log", 10, 13]
SERIN2 serpin,188,[DEC1 response] ' PC response
if response < 1 or response > 3 then has_data
branchL response,[NOP,Clear_EEProm,get_data,Read_EE] 'process response
GOTO has_data
'************************************************* ***********************
get_data:
'ENABLE 'SEROUT2 SerPout,188,["1 "]
gosub CHK_ENCODER1
OLD1 = NEW1
if portb.0 = 0 then gosub log 'if the switch is pressed log data
'serin2 SERPIN,188,2000,no_data,[wait("$GPGGA,"),str gdat\35\"*"] 'FOR TESTING W/O GPS CONNECTED
serin2 GPSIN,188,2000,no_data,[wait("$GPGGA,"),str gdat\60\"*"] ' FOR RUNNING WITH GPS CONNECTED
'serout2 serpout,188,["$GPRMC," ,gdat(0),gdat (1),gdat(2),gdat (3),gdat(4),gdat(5),_
'gdat(6),gdat(7),",A,",gdat(8),gdat(9),gdat(10),gdat(11),gdat(12),gdat(1 3),_
'gdat(14),gdat(15),gdat(16),gdat(17),gdat(18),gdat (19),gdat(20),gdat(21),gdat(22),gdat(23),_
'gdat(24),gdat(25),gdat(26),gdat(27),gdat(28),gdat (29),gdat(30)]
'SEROUT2 SERPOUT, 188,[13,10]
gosub GPSOUT
GOTO good_fix
'************************************************* ***********************
bad_fix:
LCDOUT $fe,1 'clear lcd
LCDOUT $fe,2 'home
LCDOUT " Bad Data "
GOTO get_data
'************************************************* ***********************
good_fix:
branchL Encodercnt,[NOP,latout,tout,Sat_dat] 'process encoder changes
GOTO get_data
'************************************************* ***********************
NOP: 'PLACE HOLDER
GOTO get_data
'************************************************* ***********************
no_data:
LCDOUT $fe,1
LCDOUT $fe,2
LCDOUT " No Data "
cnt = 0
GOTO get_data

'************************************************* ***********************
Sat_dat: 'Number of sats received and quality
LCDOUT $fe,1
LCDOUT $fe,2
LCDOUT "Recp Quality ",gdat(32)
LCDOUT $fe,$C0
LCDOUT "Sat's received ",gdat(34)
PAUSE 500
GOTO get_data
'************************************************* ***********************
tout: ' Time
LCDOUT $fe,1
LCDOUT $fe,2
cnt = cnt + 1
LCDOUT " ",gdat(0),gdat (1), ":",gdat(2),gdat (3), ":",gdat(4),gdat(5)
GOTO get_data
'************************************************* ***********************
latout: 'lat and long data
LCDOUT $fe,1
LCDOUT $fe,2
cnt = cnt + 1
LCDOUT " ",gdat(9),gdat(10),%11011111,gdat (11),_
gdat(12),gdat(13),gdat(14),gdat(15),gdat(16), " ",gdat(18)
LCDOUT $fe,$C0
LCDOUT gdat(20),gdat(21),gdat(22),%11011111,gdat(23),gdat (24),gdat(25),_
gdat(26),gdat(27),gdat(28)," ",gdat(30)
PAUSE 500
GOTO get_data
'**********Write to EEprom******************************************** **
Clear_EEProm:

LCDOUT "CLEARING EE"
FOR EECLR = 0 TO VOLUME * 37 'sets range to clear
I2CWRITE porta.1,porta.0,cont,EECLR,[$0] 'write zeros
PAUSE 10
NEXT EECLR
VOLUME = 0
I2CWRITE porta.1,porta.0,cont,0,[VOLUME] 'write volume zero
PAUSE 10
SEROUT2 SerPout,188,["VOLUME ", HEX volume,10,13]
LCDOUT "VOLUME", HEX VOLUME
PAUSE 1000
LCDOUT $fe,1
'NEXT A
GOTO get_data

'************************************************* ***********************
GPSOUT:
serout2 serpout,188,["$GPGGA," ]
for G = 0 to 60
serout2 serpout,188,[gdat(G)]
next G
'SEROUT2 SERPOUT, 188,[",A,"]
'for G = 8 to 30
'serout2 serpout,188,[gdat(G)]
'next G
SEROUT2 SERPOUT, 188,[13,10]
return

'***********Read EEProm******************************************** *****
Read_EE:
B = 0 'line counter
FOR C = 2 TO VOLUME * 36 'address range
ADDR = C
I2CREAD PORTA.1,PORTA.0,CONT,ADDR,[LOGDAT]
PAUSE 10
SEROUT2 SERPOUT, 188,[LOGDAT]
B = B + 1
IF B = 36 THEN GOSUB END_LINE 'put carrage return and line feed
NEXT C
GOTO GET_DATA
'************************************************* ***********************
END_LINE:
SEROUT2 SERPOUT, 188,[13,10] 'put carrage retun and line feed at end of line
B=0
RETURN

'************************************************* ***********************
CHK_ENCODER1:
NEW1 = PORTA & %00110000 'read porta
If NEW1 = OLD1 Then RETURN 'if no change return
Temp1 = N_ ^ O_ 'XOR bits to determine direction
If Temp1 = 1 Then GoTo Inc1 ' if 1 then incroment
Encodercnt = Encodercnt - 1 'decroment counter
if Encodercnt < 1 then Encodercnt = 3 'max count = 3 change to add pages
RETURN

Inc1:
Encodercnt = Encodercnt + 1 'incoment counter
if Encodercnt = 4 then Encodercnt = 1 'set min number
RETURN


end