April 25, 2024, 10:32:39 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


AIS decoding example

Started by Egil, July 18, 2015, 06:34:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Egil

Fortunately I had a copy of EB installed when staying in Trondheim for three weeks, at a motel whith no wi-fi, when discoverring that the USB stick containing IWB and all my code was left at home.
So instead of being able to work on the map project between the hospital visits, I had to do something different to avoid going crazy. Since I had a description of the AIS system on my laptop, I started to work on some ideas I played with back in 2009.

The AIS system is used internationally by vessels to transmit their position, ID and other navigational data on VHF radio, so other traffic can be aware of them. The system is compulsary for all vessels carrying paying passengers, and for all cargo and fishing vessels exeeding 300 brutto tons. This is  regulated by UN resolutions, and administered by the ITU.
The data received by other vessels can be shown and plotted on "electronic" maps and radar screens (so called ARPA Radars).

The transmitted data use the NMEA 0183 protocol. This is a "de facto" protocol used mainly by the maritime industry. Wikipedia has a good description of this protocol:
https://en.wikipedia.org/wiki/NMEA_0183

A typical message coming from an AIS receiver looks like this:
!AIVDM,1,1,,A,13n8T400000SIwvT7C1I@K?H0UCT,0*6F

The example shows an ordinary position report, and is the very first line in the enclosed file aislog.log. Running the enclosed exe file reveals what the line means.
This is an example of a "dynamic report" ( Data continuously changing automaticly ).

Pressing any key will show the next line of the log file. In this case it shows two lines, as it is a two line transmission. Such transmissions are used mainly for transmitting "static reports" ( Data that seldom change, and must be manually changed by an operator ).

The two lines looks like this:
!AIVDM,2,1,6,A,53nEwL02>?8<hqHR2208E8LDr1=@5:222222221I9H>1?5m90@BlRDm2@CTmCQ88,0*2A
!AIVDM,2,2,6,A,8888880,2*22


AIS Message type descriptions are thoroughly explained on US Coast Guard's web pages:
http://www.navcen.uscg.gov/?pageName=AISMessages

The NMEA 0183 protocol are used mainly with serial communication, using RS-422 (EIA-422) at 4800 baud.
But many AIS receivers also deliver 38400 baud. For hobby applications with only one "listener", we can use a computer with an ordinary RA-232 serial port to receive the data, and that is exactly what I do here.

And though the systems using RS-422 are slowly changing to systems using Ethernet communications instead, the bit-stuffing methods described in this example will still be the same for ages. And is a good  example of what young coders will be up to if they decide to join the automation industry.

The enclosed source only have decoding routines for the four most common of the AIS message types (1,2,3 and 5), but the rest of the message types can be done the same way. It is really just a matter of counting bits...


Have Fun!

Egil

Support Amateur Radio  -  Have a ham  for dinner!