AIS0. understanding AIS NMEA 0183: How it's coded
For my boat tracking system, I found out that using AIS format seems to be a good idea, at least I don't have to worry about how to present boat data, since there are already plenty things for do this on mobile phone or PC.
Here is what I read: http://catb.org/gpsd/AIVDM.html
Looking into AIS NMEA0183, it has much more application then I think. Such as MOB device, epir, aid to navigation device...etc, all are included. it use the first few char to indicate the function:
It can also be used between device on boat for message communication, AIVDO
The message is a series of data with "," as separator and end with a XOR check sum right after ! to the end of payload.
For example: a AVIDM sentence may look like this:
This is what it means:
AIS Datensatz: !AIVDM,1,1,,B,177KQJ5000G?tO`K>RA1wUbN0TKH,0*5C
Checksumme OK
Datenfeld: 177KQJ5000G?tO`K>RA1wUbN0TKH
Kanal: B
Message Type: 1
MMSI: 477553000
Nav. Status: 5 das ist: Moored
SOG:0.0
Longitude: 325 Grad 2.7949 Minuten
Latitude: 47 Grad 34.9700 Minuten
COG: 51.0
Heading: 181
And AIS message also take consideration of saving bytes,
1. one sentence is 82 char max.
2. every item is carefully arranged, occupied only necessary bits for data range.
3. the payload is coded with 6 bit ASCII, and the binary result still have to be ready able under 8 bits ASCII.
So, the trick is to change the 8 bits ASCII that we see:177KQJ5000G?tO`K>RA1wUbN0TKH
and translate them into binary by using 6 bits ASCII table. Then take according bits for certain data.
Here are the Char used by AIS and it's six bits binary.Note! there is no x,y,z nor X,Y,Z
To convert the Char we see(8 bits ASCII), subtract 48 from the ASCII character value; if the result is greater than 40 subtract another 8. (because in ASCII 88~95 are not used in AIS 6 bit table)
for example "w"=119
119-48=71, still greater than 40, 71-8=63, which resent 111111 in 6 bits.
Here is a web side easy to understand.
http://www.bosunsmate.org/news/article/258/Decoding-AIS-Data/
There is an example:
payload:
14eG;o@034o8sd<L9i:a;WF>062D
translate into 6bits binary:
000001 000100 101101 010111 011100 001010 010000 000000 000000 000000 110111 001000 110111 100001 101000 011100 011101 110010 011111 101011 110000 110101 010111 010000 000000 001000 011000 011011
here is the table for messge type 01:
So if we take the first 6 bits:000001 = 1, so the message type is 1
9 to 38 bits: 010010110101011101110000101001 = 316005417 this is the MMSI (here is binary to decimal, there is no issue for 6 bits or 8 bits)
navigation status39-42=0000=0
rate of turn:43-50=00000000=0
SOG 51-60 = 0000000000=0
position accuracy 61-61=1=1
long 10111 001000 110111 100001 10100
lat 0 011100 011101 110010 011111 10
COG 1011 110000 11 =3011 which means 301.1
true heading 0101 01011 =171
UTC in seconds 1 01000
To find out how to convert these bits into readable nr: http://catb.org/gpsd/AIVDM.html
I ran into some issues: there is only second in this format. there is no min and hour.
which means the receiver device need to have a gps or accurate clock for getting time.
some are signed nr, such as lon, lat, you have to calculate with some thing like this:
for example lon is 28 bits,
Here is what I read: http://catb.org/gpsd/AIVDM.html
Looking into AIS NMEA0183, it has much more application then I think. Such as MOB device, epir, aid to navigation device...etc, all are included. it use the first few char to indicate the function:
It can also be used between device on boat for message communication, AIVDO
The message is a series of data with "," as separator and end with a XOR check sum right after ! to the end of payload.
For example: a AVIDM sentence may look like this:
This is what it means:
AIS Datensatz: !AIVDM,1,1,,B,177KQJ5000G?tO`K>RA1wUbN0TKH,0*5C
Checksumme OK
Datenfeld: 177KQJ5000G?tO`K>RA1wUbN0TKH
Kanal: B
Message Type: 1
MMSI: 477553000
Nav. Status: 5 das ist: Moored
SOG:0.0
Longitude: 325 Grad 2.7949 Minuten
Latitude: 47 Grad 34.9700 Minuten
COG: 51.0
Heading: 181
And AIS message also take consideration of saving bytes,
1. one sentence is 82 char max.
2. every item is carefully arranged, occupied only necessary bits for data range.
3. the payload is coded with 6 bit ASCII, and the binary result still have to be ready able under 8 bits ASCII.
So, the trick is to change the 8 bits ASCII that we see:177KQJ5000G?tO`K>RA1wUbN0TKH
and translate them into binary by using 6 bits ASCII table. Then take according bits for certain data.
Here are the Char used by AIS and it's six bits binary.Note! there is no x,y,z nor X,Y,Z
To convert the Char we see(8 bits ASCII), subtract 48 from the ASCII character value; if the result is greater than 40 subtract another 8. (because in ASCII 88~95 are not used in AIS 6 bit table)
for example "w"=119
119-48=71, still greater than 40, 71-8=63, which resent 111111 in 6 bits.
Here is a web side easy to understand.
http://www.bosunsmate.org/news/article/258/Decoding-AIS-Data/
There is an example:
payload:
14eG;o@034o8sd<L9i:a;WF>062D
translate into 6bits binary:
000001 000100 101101 010111 011100 001010 010000 000000 000000 000000 110111 001000 110111 100001 101000 011100 011101 110010 011111 101011 110000 110101 010111 010000 000000 001000 011000 011011
here is the table for messge type 01:
Type 1, 2 and 3 messages share a common reporting structure for navigational information; we’ll call it the Common Navigation Block (CNB). This is the information most likely to be of interest for decoding software. Total of 168 bits, occupying one AIVDM sentence.
So if we take the first 6 bits:000001 = 1, so the message type is 1
9 to 38 bits: 010010110101011101110000101001 = 316005417 this is the MMSI (here is binary to decimal, there is no issue for 6 bits or 8 bits)
navigation status39-42=0000=0
rate of turn:43-50=00000000=0
SOG 51-60 = 0000000000=0
position accuracy 61-61=1=1
long 10111 001000 110111 100001 10100
lat 0 011100 011101 110010 011111 10
COG 1011 110000 11 =3011 which means 301.1
true heading 0101 01011 =171
UTC in seconds 1 01000
To find out how to convert these bits into readable nr: http://catb.org/gpsd/AIVDM.html
I ran into some issues: there is only second in this format. there is no min and hour.
which means the receiver device need to have a gps or accurate clock for getting time.
some are signed nr, such as lon, lat, you have to calculate with some thing like this:
if byte > 127: return (256-byte) * (-1) else: return byte
for example lon is 28 bits,
留言
張貼留言