vk4tec
Senior Member
Joined: 24/03/2012 Location: AustraliaPosts: 239 |
Posted: 09:06pm 14 Dec 2012 |
Copy link to clipboard |
Print this post |
|
Pretty easy
01. GARMIN GPS18 5 Hz - be carefull its 5 volts !
02. A little RS232 to TTL converter off ebay
03. The GPS gets 5 volts from the IDC connector.
04. The GPS TTL is connected to COM1 on the IDC connector
05. The GPS is 19200 N 8 1
06. I have connected TX RX VCC and GND on the GPS
07. On startup I can send the GPS $PGRMO commands to set the NMEA data
08. Once a minute the daily file is closed and re-opened.
09. 16 GB Class 10 MicroSD card
Please look on the IDC pin layouts I have posted before.
Running MMBasic 4.03B
Here is some code for you
[code]
Rem --------------------------------------
Rem GPS 5 Hz Logger GARMIN GPS18 5 Hz
Rem 16 GB class 10 MicroSD card
rem Saves to card once a min to a daily file
Rem Andrew Rich VK4TEC Dec 2012
Rem --------------------------------------
max =20
Dim arg$(max)
' Open the com port on the IDC connector 19200,n,8,1
Open "COM1:19200,5024" As #1
' Initialisation commands for GPS
Pause 500
Print #1,"$PGRMO,GPRMC,2"
Pause 500
Print #1,"$PGRMO,GPGGA,1"
Pause 500
Print #1,"$PGRMO,GPRMC,1"
Pause 500
Print #1,"$PGRMO,GPGSV,1"
Pause 500
Print #1,"$PGRMO,GPGSA,1"
Pause 500
' Get an intial filename from GPRMC
file2$ = ""
Do
nmea_sentence
If arg$(0) = "GPRMC" Then
file2$ = Mid$(arg$(9),1,6) + ".LOG"
EndIf
Loop Until file2$ <> ""
' Open the file ready to write to it
Open file2$ For append As #3
' Main Loop
Do
' Assign a time to check against
old$ = tchk$
' Get the NMEA data
nmea_sentence
' Get the checksum at the end of the NMEA
y$ = Input$(1, #1)
msg$ = msg$ + y$
y$ = Input$(1, #1)
msg$ = msg$ + y$
' $GPRMC routines
' Get the date and time ( need to check for date roll over )
' Set the filename daily
If arg$(0) = "GPRMC" Then
tod$ = Mid$(arg$(9),1,2) + "/" + Mid$(arg$(9),3,2) + "/" + Mid$(arg$(9),5,2)
tod$ = tod$ + " " + Mid$(arg$(1),1,2) + ":" + Mid$(arg$(1),3,2)
file2$ = Mid$(arg$(9),1,6) + ".LOG"
tchk$ = Mid$(arg$(1),1,4)
' Once a minute close and append the file
' Also check if a new day has started and update file
If tchk$ <> old$ Then
Close #3
Open file2$ For append As #3
Print Mid$(arg$(1),1,4) + " Min change - Savefile is " + file2$
EndIf
GoTo savefile
EndIf
' Save to the SD card each minute the program will check if there needs to be a new filename or not.
' Each minute the file is closed off and re-opened
savefile:
Print #3, MSG$
Loop
Rem -- SUBS --
Sub nmea_sentenc
Do
msg$ ="$" ' subroutine start
Do While Input$(1, #1) <> "$" : Loop ' wait for the start
For i = 0 To max
arg$(i) = "" ' clear ready for data
Do ' loops until a specific exit
x$ = Input$(1, #1)
msg$ = msg$ + x$ ' get the character
If x$ = "," Then Exit ' new data field, increment i
If x$ = "*" Then Return ' we have all the data so return
arg$(i) = arg$(i) + x$
Loop
Next i ' move to the next data field
Loop
End Sub
Edited by vk4tec 2012-12-16 Andrew Rich VK4TEC
www.tech-software.net |