release
Release the GPS object
Syntax
Description
Examples
Read data from the GPS receiver connected to the host computer on a specific serial port.
Required Hardware
To run this example, you need:
UBlox Neo-6M GPS module
GPS antenna
USB to UART module
USB cable
Connecting wires
Hardware Connection
Connect the pins on the UBlox Neo-6M GPS module to the pins on your USB to UART module. The connections are:
VCC - +5V
RX - TXO
TX - RXI
GND - GND
Connect the GPS antenna to the GPS module. Connect the USB to UART module to the host computer with a USB cable. GPS Fix can be easily acquired in locations that have a clear view of the sky. Wait for the GPS module to acquire satellite signals (Fix). This can be verified by checking the Fix LED (D1) of your GPS module.
Create GPS Object
Create a gpsdev
object for the GPS receiver connected to a specific port. Specify the output format of the data as a timetable.
gps = gpsdev('COM4','OutputFormat',"timetable")
gps = gpsdev with properties: SerialPort: COM4 BaudRate: 9600 (bits/s) SamplesPerRead: 1 ReadMode: "latest" SamplesRead: 0 Show all properties all functions
Read the GPS Data
Read the GPS data and return them as a timetable.
[tt,overruns] = read(gps)
tt=1×5 timetable
Time LLA GroundSpeed Course DOPs GPSReceiverTime
________________________ _________________________ ___________ ______ ____________________ ________________________
22-Mar-2021 15:31:15.190 17.47 78.343 449.6 0.25619 NaN 9.31 1.48 9.19 22-Mar-2021 10:01:14.000
overruns = 0
Display number of samples read and the samples available in the host buffer.
gps.SamplesRead
ans = 1
gps.SamplesAvailable
ans = 0
Release the GPS object to configure the non tunable properties. The release function also clears the buffer and resets the SamplesRead
and SamplesAvailable
properties.
release(gps)
Specify the number of samples per read to 2. Read the GPS data.
gps.SamplesPerRead = 2; read(gps)
ans=2×5 timetable
Time LLA GroundSpeed Course DOPs GPSReceiverTime
________________________ _________________________ ___________ ______ ____________________ ________________________
22-Mar-2021 15:31:17.178 17.47 78.343 450 0.063791 NaN 9.32 1.48 9.2 22-Mar-2021 10:01:16.000
22-Mar-2021 15:31:17.178 17.47 78.343 450 0.063791 NaN 9.32 1.48 9.2 22-Mar-2021 10:01:16.000
Display number of samples read and the samples available in the host buffer.
gps.SamplesRead
ans = 1
gps.SamplesAvailable
ans = 0
Clean Up
When the connection is no longer needed, clear the associated object.
delete(gps);
clear gps;
Input Arguments
The GPS sensor, specified as a gpsdev
object.
Version History
Introduced in R2020b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)