| |
'***************************************************************************
'***************************************************************************
'Description: This example application demonstrates use of the DS-GPM
Global 'positioning system using the BX-24 microcontroller and an ISLCD220
IIC/Serial 'LCD.
'
'Compiler Version 2.1 Beta 1
'Created: 22/01/03 Revision 1.00
'Written by: TRControl Solutions (Jamie Finnan)
'
'TR31
'***************************************************************************
'***************************************************************************
dim icom3(1 to 50) as byte 'inwards buffer
dim ocom3(1 to 50) as byte 'outwards buffer
dim data (1 to 50) as byte 'incoming data store
dim data2 (1 to 50) as byte 'incoming data store
dim data3 (1 to 50) as byte 'incoming data store
'***************************************************************************
Public sub main()
do
call setup_LCD 'Setup the LCD screen
call welcome 'Send the initialising screen to the LCD
Call CloseCom(3, icom3, ocom3) 'Close the serial coms to the LCD
Call ClearQueue(icom3) 'Clear the data queues
Call ClearQueue(ocom3) 'Clear the data queues
call setup_GPM 'Setup the GPS
call Read_GPM 'Read registers from the GPS
Call CloseCom(3, icom3, ocom3) 'Close the serial coms to the GPS
Call ClearQueue(icom3) 'Clear the data queues
Call ClearQueue(ocom3) 'Clear the data queues
call setup_LCD 'Setup the LCD again ready for coms
call LCD_Output 'Output Data to the LCD screen
Call CloseCom(3, icom3, ocom3) 'Close the serial coms to the LCD
Call ClearQueue(icom3) 'Clear the data queues
Call ClearQueue(ocom3) 'Clear the data queues
delay (2.0) '2.0 second delay
loop 'loop the program
end sub
'***************************************************************************
Public sub welcome()
call putqueuestr(ocom3,chr(254) & chr(1)) 'clear the screen
delay (0.5) '0.5 second delay
call putqueuestr(ocom3,chr(254) & chr(128)) 'Command byte sent
call putqueuestr(ocom3,"Global Positioning") 'send first line
to LCDcall putqueuestr(ocom3,chr(254) & chr(192)) 'command byte
call putqueuestr(ocom3, "using the BX-24") 'send line 2
delay (0.5) '0.5 second delay
end sub
'***************************************************************************
Public sub setup_GPM()
call openqueue(icom3,50) 'create input queue
call openqueue(ocom3,50) 'create output queue
call definecom3 (16,17,bx1000_1000) 'define coms port on pin16 &
17
call opencom(3,9600,icom3,ocom3) 'initiate coms port3
end sub
'***************************************************************************
Public sub setup_LCD()
call openqueue(icom3,50) 'create input queue
call openqueue(ocom3,50) 'create output queue
call definecom3 (0,5,bx1000_1000) 'define coms port on pin 0 and 17
call opencom(3,9600,icom3,ocom3) 'initialise coms port3
end sub
'***************************************************************************
Public Sub LCD_Output()
call putqueuestr(ocom3,chr(254) & chr(1)) 'clear the screen
delay (1.0) '1.0 second delay
call putqueuestr(ocom3,chr(254) & chr(128)) 'Command byte sent
call putqueuestr(ocom3,"GPS Quality is ") 'send line 1
if data3(20) = 0 then 'If then else statement to see quality of GPS
call putqueuestr(ocom3, "Bad") 'unit.
call putqueuestr(ocom3,chr(254) & chr(192)) 'command byte
call putqueuestr(ocom3, "There is no signal")
elseif data3(20) = 1 then
call putqueuestr(ocom3, "Good")
call putqueuestr(ocom3,chr(254) & chr(192)) 'command byte
call putqueuestr(ocom3, "There is a signal")
else
call putqueuestr(ocom3,chr(254) & chr(192)) 'command byte
call putqueuestr(ocom3, "No Reading")
end if
Delay (3.0) '3 second delay
'***************************************************************************
call putqueuestr(ocom3,chr(254) & chr(1)) 'clear the screen
delay (1.0) '1 second delay
call putqueuestr(ocom3,chr(254) & chr(128)) 'Command byte sent
call putqueuestr(ocom3,"Time is " & CStr(data(3))&
CStr(data(4)) & ":" & _ CStr(data(5)) & CStr(data(6))
& ":" & CStr(data(7))& CStr(data(8)))
call putqueuestr(ocom3,chr(254) & chr(192)) 'command byte
call putqueuestr(ocom3, "Date is " & CStr(data(9))&
CStr(data(10)) & "/" & _ CStr(data(11)) & CStr(data(12))
& "/" & CStr(data(13)) & CStr(data(14)) &
_ CStr(data(15)) & CStr(data(16)))
Delay (3.0) '3 second delay
'***************************************************************************
call putqueuestr(ocom3,chr(254) & chr(1)) 'clear the screen
delay (1.0) '1.0 second delay
call putqueuestr(ocom3,chr(254) & chr(128)) 'Command byte sent
call putqueuestr(ocom3,"The headings are") 'send line 1
call putqueuestr(ocom3,chr(254) & chr(192)) 'command byte
call putqueuestr(ocom3, "True North =" & CStr(data2(3))&
CStr(data2(4))& _ CStr(data2(5)) & "." & CStr(data2(6))
& "deg" ) 'send line 2
Delay (3.0) '3 second delay
'***************************************************************************
call putqueuestr(ocom3,chr(254) & chr(1)) 'clear the screen
delay (1.0) '1.0 second delay
call putqueuestr(ocom3,chr(254) & chr(128)) 'Command byte sent
call putqueuestr(ocom3,"Mag North =" & CStr(data2(7))&
CStr(data2(8))& _ CStr(data2(9)) &"." & CStr(data2(10))
& "deg") 'send line 1
call putqueuestr(ocom3,chr(254) & chr(192)) 'command byte
call putqueuestr(ocom3, "The speed =" & CStr(data2(11))
& CStr(data2(12)) & _ CStr(data2(13)) & "." &
CStr(data2(14))& "Km/h") 'send line 2
Delay (3.0) '3 second delay
'***************************************************************************
call putqueuestr(ocom3,chr(254) & chr(1)) 'clear the screen
delay (1.0) '1.0 second delay
call putqueuestr(ocom3,chr(254) & chr(128)) 'Command byte sent
call putqueuestr(ocom3,"Position & Altitude") 'send line
1
call putqueuestr(ocom3,chr(254) & chr(192)) 'command byte
call putqueuestr(ocom3, "Lat = " & CStr(data3(3)) &
CStr(data3(4)) & ":" & _ CStr(data3(5)) & CStr(data3(6))&
":" & CStr(data3(7)) & CStr(data3(8)) & _ CStr(data3(9))
& CStr(data3(10)))
Delay (3.0) '3 second delay
'***************************************************************************
call putqueuestr(ocom3,chr(254) & chr(1)) 'clear the screen
delay (1.0) '1.0 second delay
call putqueuestr(ocom3,chr(254) & chr(128)) 'Command byte sent
call putqueuestr(ocom3,"Lon = " & CStr(data3(11)) &
CStr(data3(12)) & _ CStr(data3(13)) & ":" & CStr(data3(14))
& CStr(data3(15))& ":" & CStr(data3(16)) _ &
CStr(data3(17)) & CStr(data3(18)) & CStr(data3(19))) 'send line
1
call putqueuestr(ocom3,chr(254) & chr(192)) 'command byte
call putqueuestr(ocom3,"Alt = " & CStr(data3(26)) &
CStr(data3(27)) & _ CStr(data3(28)) & CStr(data3(29)) &
"m") 'send line 2
Delay (3.0) '3 second delay
'***************************************************************************
call putqueuestr(ocom3,chr(254) & chr(1)) 'clear the screen
delay (1.0) '1.0 second delay
call putqueuestr(ocom3,chr(254) & chr(128)) 'Command byte sent
call putqueuestr(ocom3,"There are " & CStr(data3(21))
& CStr(data3(22)))
call putqueuestr(ocom3,chr(254) & chr(192)) 'command byte
call putqueuestr(ocom3,"Satellites in use") 'send line 2
Delay (3.0) '3 second delay
end sub '***************************************************************************
Public sub Read_GPM()
'Read the registers relating to Time and Date
call putqueuestr(ocom3, "[" & Chr(209) & Chr(128)
& "]" & "]")
'command characters with two terminators
delay (0.6) '0.6 second delay
call getqueue(icom3,data,17) 'receive 17 bytes from the GPS
delay (0.6) '0.6 second delay
sleep (20)
'Read the registers relating to Heading and speed
call putqueuestr(ocom3, "[" & Chr(209) & Chr(130)
& "]" & "]")
'command characters with two terminators
delay (0.6) '0.6 second delay
call getqueue(icom3,data2,16) 'receive 16 bytes from the GPS
Delay (0.6) '0.6 Second delay
sleep (20)
'Read the registers related to Position and Altitude
call putqueuestr(ocom3, "[" & Chr(209) & Chr(129)
& "]" & "]")
'command characters with two terminators
delay (0.6) '0.6 second delay
call getqueue(icom3,data3,29) 'receive 29 bytes from the GPS
Delay (0.6) '0.6 second delay
sleep (20)
end sub
'***************************************************************************
'***************************************************************************
|