File Exchange

image thumbnail

AIS Decoder

version 1.0.0.1 (1.97 MB) by Mike Donovan
This submission provides an app and the source code to decode AIS transmissions using the RTL-SDR.

33 Downloads

Updated 14 Dec 2016

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Commercial and recreational marine vessels use a communications standard called Automatic Identification System (AIS) to report their ID, position, course, speed, destination and other relevant data to coastal base stations, aids to navigation, search and rescue aircraft and other vessels. This information can be received by many Software Defined Radio platforms, including the low-cost RTL-SDR. MATLAB can be used to demodulate and decode these captured signals and extract the information fields from the AIS messages. This app has been used to decode transmissions from ships in New York City, Boston Harbor and San Francisco Bay at a distance of up to 8 miles.
The source code for the AIS Receiver and an AIS Transmitter are provided. Capture logs and raw data files are also provided.
See the included file AIS_Decoder_Instructions.pdf for more information on how to use the app and source code.

Comments and Ratings (9)

Very handy! Thanks!

Bill Sneed

Installed AIS Decoder and the RTL Add-on on ML R2019a. Decoder through errors and never worked.
More importantly for me, it completely trashed a working version of SDR#.
User beware.

MSTK

A convertStringToBits function would be appreciated - in order to allow decoding of messages that are in an ASCII format.

Mike Donovan

Hi MTMCELRO - I've used this example with R2015b and it works fine. I have never tested with R2015a but believe that the example will work with any MATLAB version that supports the RTL-SDR. These demos don't use many new MATLAB features so I think older versions should work.

If you are getting errors with an R2015 MATLAB let me know and I'll try to troubleshoot.

Thanks, Mike

MTMCELRO

Mike,
Is there anyway to get around only having MatlabR2015a and not 2016?
Thanks,
Mike

Mike Donovan

Hi Oliver - This MATLAB AIS Decoder captures AIS messages off the air and decodes them, while the message you provided is how an AIS receiver sends the decoded data to a base station over a LAN connection (I believe). So this MATLAB AIS decoder is not what you are looking for, but I think the code at this site might help: http://arundale.com/docs/ais/ais_decoder.html. Good luck! MikeD

Oliver

Hi Mike,

first of all thanks for your swift reply! I am by no means an AIS/Matlab expert, so any input is greatly appreciated. The AIS information contained in the data base (db) file looks as follows (can simply be saved as txt file):

!ABVDM,1,1,4,B,11OGQ0032G112=@O@b<4@SJ:082V,0*3A

From this I would like to extract Lon, Lat, Timestamp, vessel dimension etc...

Mike Donovan

Hi Oliver - I'm not sure what the .db file format is. This program decodes the raw hex characters for AIS message types 1,2,3,4,5,18,19 and 21. For message type 1, if your hex characters are: 045795448820000DCFAD7A95A22280A5FFAA098327B30A
then you can decode the message and see that the MMSI is 367350050, the Longitude is -122.4043 and the Latitude is 37.807. You can use the script aisDecodeMsg1.m to do this decoding. Hope that helps, MikeD

Oliver

I have AIS data provided to me in the ITU-R M. 1371-3 format in a .db file. Can this code be used to extract e.g. MMSI No and location of the vessels for each time stamp?

Updates

1.0.0.1

Added a Decoder version for R2015B and capture files for NYC.

1.0.0.1

Updated license

1.0.0.0

Made a small correction to the instruction file

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux