read seriel COM data from GPS into excel VBAmacro

ingvarlinden

New Member
Joined
Dec 18, 2013
Messages
5
hello. i need som assistans in solving this. Ive tried a coupel of ideas from the web but not succeeded.

Im about to get gps-koordinates into my excel--applikation. My Gps BU353 is installed through USB, and works well with the application sent together with the GPS GPSinfo. There I can see the NMEA signals rolling and also the coordinates that i want to catch. But how can i get hold of them? I think i can solve decoding the data when I can read it - but thats the trouble.

Do your have any VBA-code so i can test and perhaps get it to work with your help? I'm not a advanced programmer in VBA buti fight.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Does the GPSinfo app have an option to save to disk? If so you could then import this data into excel unless it needs to be live data as it's running.
 
Upvote 0
Does the GPSinfo app have an option to save to disk? If so you could then import this data into excel unless it needs to be live data as it's running.

No there is no save to file option. I copy in from the teqnical page that came along with the product - if its of any significance for the troublesolvation...

it goes:
GPS Protocol Default: NMEA 0183 (Secondary: SiRF binary)
GPS Output Data
SiRF binary >> position, velocity, altitude, status and control
NMEA 0183 MEA0183 V2.2 protocol, and supports
command: GGA, GSA, GSV, RMC, VTG, GLL v2.2 (VTG
and GLL are optional)
GPS transfer rate Software command setting (Default : 4800,n,8,1 for NMEA )

thanks for answering/ Ingvar
 
Upvote 0
HI. thanks. Ive tried that one. Two problems appeared. 1 the subroutine sleep in sleep 200 isnt defined so i had to remove that line and 2. the content of the record always = emptyrecord, just fillled with "boxes" and did react the same way either i had my GPS attached or not. So it seem it didnt hook on the signals - so to speak. I checked and changed to the correkt comnr COM15 whitch the GPS itself had configured and uses. /Ingvar
 
Upvote 0
Here is the code from the linked thread http://www.mrexcel.com/forum/excel-questions/488335-receive-data-com-port.html#post2410919:
Code:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Receive_COM5()
    
    Dim COM5file As Integer
    Dim timeout As Date
    Dim record As String * 11, emptyRecord As String * 11
    Dim recLen As Integer
    Dim inputByte As Integer
    
    recLen = Len(record)
        
    'Open COM5 port with baud rate 2400, No parity, 8 data bits and 1 stop bit
    
    COM5file = FreeFile
    Open "COM5:2400,N,8,1" For Random As #COM5file Len = recLen
    
    'Monitor port for 30 seconds
    
    timeout = Now + TimeValue("00:00:30")
    
    Debug.Print "Started"
    
    While Now < timeout
        Get #COM5file, , record
        
        If record <> emptyRecord Then
        
            Debug.Print Now; "<" & record & ">"
            
            'Display each byte
            
            For i = 1 To recLen
                inputByte = Asc(Mid(record, i, 1))
                If inputByte = 0 Then
                    'No character in this position
                ElseIf inputByte >= 32 And inputByte <= 126 Then
                    'Printable character
                    Debug.Print "<" & inputByte & "> "; Chr(inputByte)
                Else
                    'Non-printable character
                    Debug.Print "<" & inputByte & ">"
                End If
            Next
        End If
        
        DoEvents
        Sleep 200
    Wend
    
    Close #COM5file
    Debug.Print "Finished"

End Sub
As noted in the comment, the code is specifically for the COM5 port with baud rate 2400, No parity, 8 data bits and 1 stop bit, as defined in this line:
Code:
    Open "COM5:2400,N,8,1" For Random As #COM5file Len = recLen
GPS transfer rate Software command setting (Default : 4800,n,8,1 for NMEA )
I checked and changed to the correkt comnr COM15 whitch the GPS itself had configured and uses.

Therefore try changing the above line to:
Code:
    Open "COM15:4800,N,8,1" For Random As #COM5file Len = recLen
If the code still doesn't receive any data from your device then try using Windows HyperTerminal as a test program to receive the data.
 
Upvote 0
hi thanks. I've already changed the baudrate to 4800 so it isn't that problem.... ok I'll try to figure out how WhyperTerminal works... / IL
 
Upvote 0

Forum statistics

Threads
1,223,277
Messages
6,171,148
Members
452,382
Latest member
RonChand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top