THE COMPUTER AND THE INTERFACE

One of the advantages of CCD cameras is that they are designed to operate with a computer. Not only the CCD is very sensitive and has very good photometric qualities, but the computer allows the CCD to be better used (i.e. the computer reveals all the information contained in the image).

The computer used with the Audine camera is the PC. It is the standard of today. This choice guarantees a certain perenniality and facilitates data exchanges. An average PC is sufficient to control Audine (Pentium 200 MHz for example). The quantity of RAM must be 32 Mb minimum and the HD memory must be of a few GB. An CD-Rom writer is a very good investment for filing purposes. You can install a PC close to the telescope for controlling Audine (and the telescope) and you can connect this unit to your computer via an Ethernet network, whatever the type and the mark of your computer (i.e. Macintosh).

A PC capable of controlling Audine costs less than 5000 FF, a network adapter with a cable costs 200 or 300 FF maximum. The AUDACE software facilitates this data-processing architecture.

The type of interface used by the camera is essential. There are two possibilities: either installing a specific interface board, or using one of the input/output ports of the PC. The first solution makes it possible to optimize the operation of the camera, for example in term of speed or if you use a long connecting cable between the PC and the camera. Unfortunately the first solution is complex, is more expensive, and you cannot use a portable computer. However the Audine camera is designed to be controlled by a desktop computer or a laptop computer, via an external interface... There are many external interfaces. For example, the PCMCIA standard is a current and powerful interface for laptops but this standard is not easy to use. It is the same problem with parallel interfaces such as SCSI or the IEE488-GPIB bus.

The RS232 interface is interesting. Unfortunately the RS232 interface uses a very slow serial communication protocol. The maximum frequency is often 19200 bits/second. With this rate, since only one image digitized in 12 bits weighs approximately 5.9 million of bits, the transfer time is 5 minutes! Progress in the serial transmission now allows speeds of transfer of several megabits per second. These interfaces are RS422, Ethernet, IEEE 1394 (or FireWire, an interface specialized for the transmission of video images)... Among these interfaces, the USB is interesting because it can become a preferred means for communication between the computer and devices such as keyboard, scanner, modem, digital camera, printer... With a transfer rate of 12 Mbits/second, you can also use the USB for the hifi audio or MPEG-2 video signals. You can connect up to 127 devices to the same interface!

Unfortunately, all these interfaces require the use of specialized microprocessor chips. The development can thus be delicate. In fact, the only interface currently very simple to use, and also sufficiently effective, is the parallel interface (also called Centronics interface). At the beginning, the parallel interface was to control printers. It is a 25-points female connector (DB25 connector standard) located at the back of the PC. The parallel interface has other uses now: communication between computers, bulk storage, scanner and process control. The communication protocol is extremely flexible because it can be managed by software. However, the speed of transfer is not very high. A basic Centronics interface can communicate with words of 8 bits from the computer towards the external world, but only 5 bits are usable from the external world towards the computer. However, this limit is not valid any more because the parallel port was improved (IEEE 1284 standard). For example, the EPP mode (Enhanced Parallel Port) allows a bidirectional transfer on 8 bits, for the input and the output, with a frequency up to 2 MHz per word of 8 bits. The EPP mode can be used through the programming of registers or by modifying the computer start-up program. The ECP mode (for Extended Capabilities Port) is another possibility. The ECP mode allows even higher performance through the use of a DMA channel (Direct Memory Access) and a data compression procedure.

The EPP and ECP modes of the parallel interface greatly improve the Centronics standard. However, their development is sometimes delicate, in particular for a good synchronization between the entering and outgoing data flows. These interfaces are not completely universal and there is a problem of compatibility with old or very low end hardware. Also, the reading rate of a camera does not change much because the clocks controlling the reading of the CCD are directly generated from the computer. We thus decided to use the initial parallel interface for a maximum reliability. Data processing evolves very quickly. It is possible that the Centronics interface disappears from our PC to be replaced by the USB. But solutions ensuring conversion from USB towards parallel port will continue to exist for a long time.
 

GENERATING THE CHRONOGRAM

The chronogram is the graphic transcription of the signals sent to the CCD to transfer the electric charges at the end of the exposure time. These periodic signals are called clocks. They often have two levels: a high level and a low level. The chronogram is also used to control operations such as analog/digital conversion or the dialogue with the computer via its interface.

The chronogram can be complex: Audine needs at least 8 clocks. The quality of the chronogram is thus very significant for the coordination of the operations. Synchronization will be made by a software running on the control computer. This purely software approach to produce the chronogram is very flexible. To change the mode of operation of the camera, you just have to write some lines of code. To generate clocks in a software way, the only true problem is that the reading time of the CCD directly depends on the running speed of the program.

Here is the code to generate a clock:

FOR I=1 TO 1000
   OUT 767,255
   OUT 767,0
NEXT

This code produces 1000 successions of 1 and 0, which appear simultaneously on the 8 lines of data of the parallel port. If you examine this signal with an oscilloscope, it appears that:

PROGRAMMING THE PARALLEL PORT

The connector of the parallel port is DB25 female with 17 active lines and 8 ground lines. The active lines are divided into 3 groups:

When the parallel port is used to control a printer, the 8 data lines transmit the character code to be printed. The status lines are used to synchronize the printer with the PC (handshaking) and they inform the PC on the status of the printer (more paper, printer on standby, material error...). Finally, the control lines are used for controlling and synchronizing the printer from the PC towards printer.

The need for a dialogue between the PC and the printer implies that certain lines of the interface are used as inputs and other lines are used as outputs. The output lines (as seen from the PC) are used to control the camera (generation of the chronogram). The input lines make it possible to receive the digitized pixels. The 5 input lines are somewhat limited for a data on 16 bits coming from the camera. The technique to force the passage consists in making a multiplexing. An electronic circuit divides the 16 bits into 4 groups of 4 bits (a group of 4 bits is called a nibble). They are then presented successively on four input lines of the printing port. The control software of the camera assembles the 4 nibbles to recreate the original word on 16 bits (operation called demultiplexing).

The binary level on the data lines and the control lines depends on the status of the corresponding bits in two special memory registers of the PC. At the input, another specific register sees the status of these bits modified according to the signal applied to the 5 status lines. In fact, the printer port is managed by 3 registers of 8 bits located at contiguous addresses in the memory of the PC. Normally, the memory address of the first register, called basic address, is 378h (or 888 in decimal). The two other registers are then at the addresses 379h and 37Ah (889 and 890 in decimal). However, if a PC has several printer ports (LPT1, LPT2, LPT3), the basic address changes according to the number of the port. Normally, the addresses of the various printer ports should be as follows:
 

Port
Data register
Status register
Control register
LPT1
3BCh
3BDh
3BEh
LPT2
378h
379h
37Ah
LPT3
278h
279h
27Ah
 

In fact, the basic address of LPT1 is very often 378h. This information briefly appears on the screen when the computer boots.

For the 3 registers, here is the allocation of the bits and the corresponding number of DB25 connector pins:
 

DATA REGISTER
BIT
SIGNAL 
PIN
D7
Data 7
9 (s)
D6
Data 6
8 (s)
D5
Data 5
7 (s)
D4
Data 4
6 (s)
D3
Data 3
5 (s)
D2
Data 2
4 (s)
D1
Data 1
3 (s)
D0
Data 0
2 (s)
 
STATUS REGISTER
BIT
SIGNAL
PIN
D7
Busy
11 (e)
D6
ACK*
10 (e)
D5
PE
12 (e)
D4
Select
13 (e)
D3
Error*
15 (e)
D2
IRQ*
/
D1
Reserved
/
D0
Reserved
/
 
CONTROL REGISTER
BIT
SIGNAL
PIN
D7
Reserved
/
D6
Reserved
/
D5
Direction
/
D4
IRQ Enable
/
D3
Select_In*
17 (s)
D2
INIT
16 (s)
D1
Auto Feed*
14 (s)
D0
Strobe*
1 (s)
 

Pins 18 thru 25 are connected to the ground.

The letter E or S located beside the pin number indicates if the line operates as input or output.

A symbol * after a name of signal means that the line is of the reverse-logic type. To get state 1 on a pin of this category, it is necessary to program the corresponding bit in the register to 0. The principle is different in input because it is the printer which gives the type of logic. However it is important to note that the signal Busy (bit 7 of the status register) is wired in reverse logic: if you set pin 11 of the connector to the low level, bit 7 will be to the high level.

 
Numbering of the pins of the printer port on the female side.

When the parallel port is used to control a printer, here is the meaning of the main signals: Select_In (Select Input) tells to the printer that it is selected, INIT makes it possible to initialize the printer, Auto Feed controls paper feeding, Strobe changes to the low level when a character is sent, PE (Paper Empty) tells the PC that the printer has no more paper, ACK (Acknowledge) indicates that the printer has actually received the character sent, Busy indicates that the printer is not ready to receive a character, Select indicates that the printer is on line, Error warns that a printing error has occurred (if this signal is at 0l). Note that the bits related to the processes of interruption are not used in Audine (they have no direct correspondence on the connector).

To write in one of the output registers you must use an instruction such as OUTP (in C language) or OUT (in BASIC). Here is an example in C which writes the bit configuration 10011101 in the data register:

#define DATA 0x0378
#define STATUS DATA+1
#define CONTROL DATA+2

int value=0x9D;   // 1001101
outp(DATA, value);

In BASIC you write:

OUT 888,157

If you want to transmit data through the control register, only the 4 least significant bits are important. If you want that pin 17 (Select signal In) takes status 1, that pin 16 (signal INIT) takes status 0, that pin 14 (signal Auto Feed) takes status 0 and that pin 1 (Strobe signal) takes status 1, you have to write the following code:

Value=0x09;     // 1001
outp(CONTROL, value);

That does not work because the Select In, Auto Feed and Strobe signals are in reverse logic (bits 0, 1 and 3). You obtain the bit configuration 0010 instead of 1001. To have a correct result you must invert the bits in negative logic, when writing in the register, by using " exclusive or " with the binary pattern 1011 (0x0B):

outp(CONTROL, value ^ 0x0B);

In BASIC you must write for example:

OUT 890, (9 XOR 11)

For a reading operation, it is necessary to read the status of the 5 most significant bits in the status register. It is necessary to invert the status of bit 7 (Busy signal) after the reading of the register to avoid problems (remember that this bit is inverted by the hardware). The instructions to be used are INP in C and out in BASIC. Example:

unsigned int inp_value ;
inp_value = inp(STATUS) ^ 0x80) >> 3;

Note the " exclusive or "with 0x80 (1000000) to invert the status of bit 7, then the 3 shifts towards the right so that the 5 most significant bits become the 5 least significant bits.

In BASIC, the program must be written:

V = (INP(889) XOR 128) / 8
 
For more information about the parallel port, please refer to the following addresses:

http://www.doc.ic.ac.uk/~ih/doc/par/
http://www.senet.com.au/~cpeacock/