AIS3.Encoding payload of AIS

Idea is to use GPS information, to send out a AIS message.there are several items need to be built up:


  1. messge type: plan to use type 1 for position report
    1. which makes 6 bits 0b000001
  2. repeat indicator: 0
    1. which makes 2 bits 0b00
  3. MMSI: 543543543
    1. whcih maks 30 bits: 0b100000011001011101000011110111
  4. Navigation status: 8 , under way sailing
    1. which makes 4 bits: 0b1000
  5. rate of turn: 128, not available
    1. which makes 8 bits:0b01000000
  6. SOG: 8.8kt
    1. 8.8knt=88(unit at 0.1kt), which makes 0b0001011000
  7. position accuracy: 0( GNSS >10m) or 1 (DGPS<10m)
    1. which makes 0b0
  8. Longitude 
    1.   -149.329461 is presneted with unit = 1/0000min in 28bits, -149.329461degree*60000=-89597676.6, round to -89597677 
    2. 89597677 in 28 bit=0b 0101 0101 0111 0010 0110 1110 1101
    3. flip bits:1010 1010 1000 1101 1001 0001 0010
    4. add 1=  1010101010001101100100010011 , this is -89597677 in 28 bits binary
  9. Latitude
    1. -17.732161 degrees in unit of 1/10000 min=-10,639,296.6 round to -10639296
    2. 10639296 in 27 bits= 0b 000 1010 0010 0101 0111 1100 0000
    3. flip bit: 0b111 0101 1101 1010 1000 0011 1111
    4. add 1=  0b111010111011010100001000000
  10. COG
    1. 123.4 degree, in unit of 0.1 degree=1234
    2. 1234 in 12 bits=0b0100 1101 0010
  11. True heading 0 to 359 degrees, 511 = not available.
    1. 511 in 9 bits=0b111111111
  12. time stamp seconds
    1. 30 second
    2. 30 in 6bits=0b011110
For bit 143~167 no to use. so there is 25 bits I took the last 25 bits from previous example

0b0 000000 001000 011000 011011 

Which make the whole payload=
000001001000000110010111010000111101111000010000000001011000010101010100011011001000100111110101110110101000010000000100 1101 00101111111110111100000000001000011000011011 

Now, how to convert it into 6 bits??

well, I decided to use the most stupid one, one by one.....

Here I made a bit map to help me understand the correct mapping:

0type5
0
14
23
32
41
50
6repeat5
1
74
8MMSI 293
9282
10271
11260
12255
2
13244
14233
15222
16211
17200
18195
3
19184
20173
21162
22151
23140
24135
4
25124
26113
27102
2891
2980
3075
5
3164
3253
3342
3431
3520
3615
6
3704
38status3
392
401
410
42turn 75
7
4364
4453
4542
4631
4720
4815
8
4904
50SOG 93
5182
5271
5360
5455
9
5544
5633
5722
5811
5900
60accuracy5
10
61Lon 274
62263
63252
64241
65230
66225
11
67214
68203
69192
70181
71170
72165
12
73154
74143
75132
76121
77110
78105
13
7994
8083
8172
8261
8350
8445
14
8534
8623
8712
8801
89lat 260
90255
15
91244
92233
93222
94211
95200
96195
16
97184
98173
99162
100151
101140
102135
17
103124
104113
105102
10691
10780
10875
18
10964
11053
11142
11231
11320
11415
19
11504
116Course 113
117102
11891
11980
12075
20
12164
12253
12342
12431
12520
12615
21
12704
128Heading 83
12972
13061
13150
13245
22
13334
13423
13512
13601
137second 50
13845
23
13934
14023
14112
14201
143Maneuver 10
14405
24
145spare 24
14613
14702
148raim 01
149sync state 10
15005
25
151slot time-out 24
15213
15302
154hours         41
15530
15625
26
15714
15803
159minutes      62
16051
16140
16235
27
16324
16413
16502
16611
16700

when :
sync state=0, UTC direct
When slot timeout = 1 - Then the sub message is UTC hour and minute
Hour (0-23) should be coded in bits 13 to 9

Minute (0-59) should be coded in bit 8 to 2


Here is the git
https://github.com/Ldsrc2008/AIS-encode-arduino

留言

這個網誌中的熱門文章

Heltec ESP32+OLED+Lora, hardware testing

micro SD card for ESP32, on lolin32 with OLED and heltec 32 lora oled

Install Network Time Protocol(NTP) on BeagleBone with Angstrom linux and set local time zone