Ocean Optics SAD500 Communications and Control User Manual
Page 18
18
Technical Note 3: SAD500 Checksum Calculation
For all uncompressed pixel modes, the checksum is simply the unsigned 16-bit sum (ignoring overflows) of
all transmitted spectral points. For example, if the following 10 pixels are transferred, the calculation of the
checksum would be as follows:
Pixel Number
Data (decimal)
Data (hex)
0
15
0x000F
1
23
0x0017
2
46
0x002E
3
98
0x0062
4
231
0x00E7
5
509
0x01FD
6
1023
0x03FF
7
2432
0x0980
8
3245
0x0CAD
9
1984
0x07C0
Checksum value: 0x2586
When using a data compression mode, the checksum becomes a bit more complicated. A compressed pixel
is treated as a 16-bit unsigned integer, with the most significant byte set to 0. Using the same data set used
in Technical Note 1, the following shows a section of a spectral line source spectrum and the results of the
data compression algorithm.
Data Value
Value
Difference
Transmitted Bytes
Value added to
Checksum
185
0
0x80 0x00 0xB9
0x0139
2151
1966
0x80 0x08 0x67
0x08E7
836
-1315
0x80 0x03 0x44
0x03C4
453
-383
0x80 0x01 0xC5
0x0245
210
-243
0x80 0x00 0xD2
0x0152
118
-92
0xA4
0x00A4
90
-28
0xE4
0x00E4
89
-1
0xFF
0x00FF
87
-2
0xFE
0x00FE
89
2
0x02
0x0002
86
-3
0xFD
0x00FD
88
2
0x02
0x0002
98
10
0x0A
0x000A
121
23
0x17
0x0017
383
262
0x80 0x01 0x7F
0x01FF
1162
779
0x80 0x04 0x8A
0x050A
634
-528
0x80 0x02 0x7A
0x02FA
356
-278
0x80 0x01 0x64
0x01E4
211
-145
0x80 0x00 0xD3
0x0153
132
-79
0xB1
0x00B1
88
-44
0xD4
0x00D4
83
-5
0xFB
0x00FB
86
3
0x03
0x0003
82
-4
0xFC
0x00FC
91
9
0x09
0x0009
92
1
0x01
0x0001
81
-11
0xF5
0x00F5
80
-1
0xFF
0x00FF
84
4
0x04
0x0004