Applications Note
This note describes the operation of the ST-4 from a remote control standpoint. First of all some general points of interest about the camera are:
* The ST-4 camera consists of a 192 (h) by 165 (v) element CCD, with readout electronics, an 8 bit A/D converter, and a microcomputer with image storage buffers for two images (light and dark frames). Although the CCD has more horizontal elements than vertical elements, the size of each pixel is such that the overall CCD array has an aspect ratio of 1:1.
* The ST-4 can be run stand-alone as a star tracker, controlling the relays associated with the telescope drive to keep a star positioned at a fixed position in the CCD array.
* The ST-4 can be controlled remotely over a three-wire serial interface (Transmit Data, Receive Data and Ground) at various baud rates. Upon power-up the camera starts at 9600 baud and can be switched remotely to higher or lower baud rates. In our software we commonly use 57.6K baud, but 19.2K, 9600 and 1200 are also supported for installations with longer runs between the ST-4 and the computer. To communicate with the camera you need 8 bits of data, even parity, and 1 stop bit.
* Instructions are sent to the camera and data is received from the camera in packets, with each packet containing a checksum. Instructions sent to the ST-4 are acknowledged by the ST-4 in different ways depending on the type of instruction sent.
* Each packet contains a single checksum byte at the end to allow detection of corrupted packets. The checksum byte is the sum of all the byte values in the packet, excluding the checksum itself. Since it is a single byte, the checksum wraps around to 0 at 256. For users computing the checksum you would want to use an unsigned char type or the least significant byte of an unsigned int.
* The majority of the remote control of the camera is achieved by setting bits or writing bytes to memory inside the ST-4. The ST-4 then interprets those bits and bytes and acts accordingly.
* Image data and image data alone sent from the ST-4 to the remote computer can be compressed if the remote computer enables data compression in the ST-4. The image data is sent as compressed data only if the compressed data is shorter than the uncompressed data would be.
* The ST-4 has a special half-frame mode where an image in the lower half of the CCD (83 lines) can be transferred to the top half at a high speed (avoiding streaking due to integrating while reading out) and then those 83 lines are digitized as a half-frame image.
With these items in mind, below is a description of the instructions you can send to the camera. There are only three instructions the camera can understand:
Use this command to write data to the ST-4's memory locations (discussed below) to start commands, set options, etc.
Byte Value Meaning 1 01 Command for Write Memory 2 N Number of bytes that follow, excluding the checksum 3 0/1 0 = External ram, 1 = Internal ram 4 LSAD Starting address, least significant byte 5 MSAD Starting address, most significant byte 6 DATA Data to write to ram . . . . . . . . . 5+N-3 DATA Last data byte 6+N-3 CS Single byte checksum of all bytes, including command
Response
ACK ($06) if valid and accepted or nothing if dead
Use this command to download rows of image data from the ST-4 after an image has been acquired. Note that two variables discussed below (50 & 51) determine which pixels in the row are sent down and the data can be compressed or uncompressed based upon the setting of bit 1 in the Mode flag.
Byte Value Meaning 1 64-228 Command to send line = 64 + Line# (0 - 164) 2 CS Single byte checksum
Response
Byte Value Meaning 1 64-228 Command acknowledgement 2 N Number of data bytes following 3 DATA First data byte. . . 2nd data byte . . 2+N DATA Last data byte 3+N CS Checksum of entire packet
Use this command to read non-image data from the ST-4's memory. Note that data read from RAM is never compressed.
Byte Value Meaning 1 02 Read ram command 2 N Number of bytes to read 3 0/1 0 = External, 1 = Internal 4 LSAD Address of RAM, Least significant byte 5 MSAD Address of RAM, Most significant byte 6 CS Checksum of entire packet
Response
Byte Value Meaning 1 02 Command acknowledgement byte 2 N Number of data bytes that follow 3 DATA Data from ram, never compressed . . . . . . 2+N DATA Last data byte 3+N CS Checksum
With these three commands you can control the camera remotely by writing bytes into internal memory locations in the ST-4. The table below shows the internal addresses that are important and the meanings of each byte and bit.
The Internal RAM locations shown below are used to control the operation of the ST-4. The locations are shown in Decimal.
Codes are hexadecimal as follows:
Set of bits as follows:
Set of bits as follows:
These two locations are the exposure time in 1/100ths of a seconnd. Location 48 is the LS byte and location 49 is the MS byte.
Pixel to start on in sending lines of image data to the host. Valid range is 0 thru 191.
Number of bytes per line to send to the host when downloading images. Valid range is 1 thru 192.
This value is to be subtracted from the image data when the ST-4 is instructed to do a dark frame subtraction (defaults to 0).
Default = 255, Lower to have boost. For example a Boost of 4 uses 256/4 = 64 over the baseline value (location 54).
Default = 0, this is the same as the baseline.
Starts at 1, current version is 4.
Set this to change the data communications baud rate. 255 (256-1) for 56K baud, 253 (256-3) for 19.2K baud, 250 (256-6) for 9600 baud, etc. When programmed to change baud rates, the ST-4 will send the ACK at old rate before switching. Also if the ST-4 doesn't get a valid request from the host to read from memory within 1 second after changing baud rates, the ST-4 will switch back down to the default of 9600 baud.
Not used remotely.
This byte is set to 0 at power up. Writing a 1 through 255 to this byte causes the ST-4 to execute a command defined by that instruction byte. When the camera is finished with that command it writes a 0 to this location. The following commands are implemented in the version 3 and later ROMs:
Maximum image pixel value (0 through 255).
X coordinate of maximum image pixel (0 through 191).
Y coordinate of maximum image pixel (0 through 164).
There is a lot of detail in the previous two sections and please don't feel bad if you don't understand it. Just give us a call and we'll discuss it. Onward to the description of the image compression algorithm.
* Image data and image data alone is compressed, and then only if the ST-4 is told to do so (b1 of byte 46 is set), and the compressed data is actually shorter than the uncompressed data.
* The image compression is based on the difference between a pixels value and the value of the previous pixel.
* A compressed line of data can be detected by the fact that the 2nd byte in the received data packet (data length) is less than the requested number of pixels (setting of byte 51).
* A compressed line of data consists of a byte corresponding to the value of the first pixel (which also establishes a baseline), followed by a sequence of nibbles packed into bytes.
* In digesting nibbles, you first look at the low nibble, then the high nibble in a byte.
* If a pixel is within +7 or -7 of the baseline then the pixel is sent as a difference nibble (+7 = 0111, -7 = 1001), and a new baseline is established at the value of that pixel.
* If a pixel is not within +7 or -7 of the baseline, then the pixel is sent as three nibbles. The first nibble is a -8 (1000) which is a special value, and the next two nibbles are the pixel's value, with the 2nd nibble being the pixels ls nibble and the third nibble being the pixels ms nibble. Finally a new baseline is established at the pixel's value.
As an example the pixel sequence 4, 5, 7, 5, 25, ... would get sent as the byte 04 followed by the nibble sequence +1, +2, -2, -8, 5, 2 (byte sequence 04 21 -8-2 25 ...).
An example of what's required to take a full image is as follows:
* The desired exposure time in 100ths of a second is written to internal memory locations 48 and 49 in the camera.
* The mode flag (location 46) is set to 11100010 (Full frame, light array, start exposure, enable compression).
* You then read location 46 until both b5 and b4 are 0. * You then set location 50 to 0 (start at pixel 0), and location 51 to 192 (192 pixels per line).
* You then ask the camera to send lines 0 through 164 by requesting each of those lines individually and sequentially.
Revised: September 23, 1998 01:44:09 PM.
Copyright © 1998 Santa Barbara Instrument Group, Inc. All rights reserved.
Please report any problems with this page directly to the Webmaster