Ocean Optics SAD500 Communications and Control User Manual
Page 15

15
Technical Note 1: SAD500 Data Compression
Transmission of spectral data over the serial port is a relatively slow process. Even at 115,200 baud, the
transmission of a complete 2048 point spectrum takes around 400 msec. The SAD500 implements a data
compression routine that minimizes the amount of data that needs to be transferred over the RS-232
connection. Using the “G” command (Compressed Mode) and passing it a parameter of 1 enables the data
compression. Every scan transmitted by the SAD500 will then be compressed. The compression algorithm
is as follows:
1. The first pixel (a 16-bit unsigned integer) is always transmitted uncompressed.
2. The next byte is compared to 0x80.
•
If the byte is equal to 0x80, the next two bytes are taken as the pixel value (16-bit unsigned integer).
•
If the byte is not equal to 0x80, the value of this byte is taken as the difference in intensity from
the previous pixel. This difference is interpreted as an 8-bit signed integer.
3. Repeat step 2 until all pixels have been read.
Using this data compression algorithm greatly increases the data transfer speed of the SAD500. The table
below shows the data transfer speed, in milliseconds, for various light sources and baud rates. Keep in mind
that these rates are for demonstration purposes only, and the speed of your computer may impact the data
transfer rates.
Comp 115 kb
% faster
57.6 kb
% faster
38.4 kb
% faster
19.2 kb
% faster
9.6 kb
% faster
on
290
32.9%
426
45.2%
624
46.7%
1148
47.5%
2247
48.8%
dark
off
432
778
1170
2188
4391
on
290
32.9%
429
44.9%
624
46.6%
1141
49.6%
2192
50.1%
LS-1
off
432
779
1169
2266
4390
on
303
29.9%
465
40.2%
679
41.9%
1238
43.5%
2424
44.8%
HG-1
off
432
777
1169
2193
4391
The following shows a section of a spectral line source spectrum and the results of the data compression
algorithm.
Pixel Value
Value
Difference
Transmitted Bytes
185
0
0x80 0x00 0xB9
2151
1966
0x80 0x08 0x67
836
-1315
0x80 0x03 0x44
453
-383
0x80 0x01 0xC5
210
-243
0x80 0x00 0xD2
118
-92
0xA4
90
-28
0xE4
89
-1
0xFF
87
-2
0xFE
89
2
0x02
86
-3
0xFD
88
2
0x02
98
10
0x0A
121
23
0x17
383
262
0x80 0x01 0x7F
1162
779
0x80 0x04 0x8A
634
-528
0x80 0x02 0x7A
356
-278
0x80 0x01 0x64
211
-145
0x80 0x00 0xD3
132
-79
0xB1