SERIAL COMMUNICATION WITH THE Z88 SERIAL PORT Pin 7 is the Signal Ground, GND. All other signals are relative to this pin. Pin 2 is used for Transmitted Data, TxD. When the Z88 is on, it carries a negative voltage. When sending, it puts out positive voltage signals. Pin 3 is used for Received Data, RxD. Pin 5 is called Clear To Send, CTS. If the Z88 is trying to send, nothing is sent unless a positive voltage is received on this pin. Pin 4 is called Request To Send, RTS. When the Z88 is turned on this pin carries a positive voltage. If the Z88 receives data without being able to process the data, or it is received faster then can be processed, the receive buffer will start to fill. When it becomes more then half full, pin 4 will shift to a negative voltage. When data has been processed so the receive buffer becomes less then a quarter full, it will shift back to a positive voltage. Pin 8 is called Data Carrier Detect, DCD. Received data is not valid unless a positive voltage is received on this pin. Pin 9 is called Data Terminal Ready, DTR. When the Z88 is on it carries a positive voltage (switched +5V at 1 milliamp). Also a moment every other minute when the Z88 is off. Pin 1 carries a positive voltage (unswitched +5V at 10 microamps) at all times power is avilable (Also when the Z88 is off). Should not be used. Pin 6 is not used. CONNECTING TWO Z88S. Pins 7 on both Z88s should be connected to make a common base to compare other pins voltages to. Pin 2 on the sending Z88 should be connected to pin 3 on the receiving one. What's more needed is a positive voltage on pin 5 on the sending Z88 to be able to send. The receiving Z88s' pin 4 is the most suitable source because it stops the sending Z88 by going to a negative voltage when the receive buffer begins to fill. Now data can be sent but it is not received as valid until a positive voltage is received on pin 8 on the receiving Z88. The signal can be taken from pin 9 on the sending Z88 or from its' own pin 9 to save a lead in the cable. The cable is then connected, 7-7, 2-3, 5-4, 9-8. To be able to send in the opposite direction, add the connections 3-2, 4-5 and 8-9. Again, 8 could be connected to 9 in the same cable end to save two leads in the cable. HARDWARE HANDSHAKING. The interaction between pin 4 and 5 is called hardware handshaking. This is always active on the Z88. SOFTWARE HANDSHAKING. The Z88, some printers, some MNP modems and some other computers depending on communication programs can use Xon/Xoff software handshaking. The sending Z88 starts with sending one Xon character before data is sent. The receiving Z88 sends an Xoff character if the receive buffer becomes more then half full. The sending Z88 stops sending when a received Xoff character has been processed. If there already are characters in the sending Z88s receive buffer, there may be a delay. If the receive buffer becomes 7/8 full an Xoff character is sent for every received character. When data has been processed so the receive buffer becomes less then half full, an Xon character is sent. When the sending Z88 receives the Xon character, it resumes sending. When using Xon/Xoff it is possible to manage with only 3 leads in the cable. Connect 7-7, 2-3, 3-2. Connect pin 5 and 8 to pin 9 in the same plug in both ends. Set Transmit and Receive baudrate to 9600, Parity to None and Xon/Xoff to Yes in the Panel settings on both Z88s. SENDING TO A NOT READY Z88 Pin 4 is positive when the Z88 is turned on. That means data can be received even if you are not in, for instance Terminal. 96 bytes will be received before pin 4 shifts to a negative voltage and the datasender can be stopped. If you then enter []V Terminal, or []X Imp-Export, R)eceive file and specify a filename, or []B BASIC and OPENIN a channel to :COM, the following bytes will be received correctly but the 96 bytes are lost. SENDING THE BITS Pin 2 carries a negative voltage except when sending data by putting out positive voltage signals. Data is sent as codes between 0 and 255. DATABITS. A number in this range can be thougth of as consisting of 0 or 1 komponent worth 1, + 0 or 1 komponent worth 2, + 0 or 1 komponent worth 4, etc. to 0 or 1 of the eighth komponent worth 128. The biggest number that can be represented is then if we have 1 of each of the 8 komponents wich are called bits. That means 1+2+4+8+16+32+64+128 = 255. The smallest is 0+0+0+0+0+0+0+0 = 0 and any number in between can be represented by combining the appropriate bits. The 'A' character has the code 65 = 1+0+0+0+0+0+64+0. It is sent by holding pin 2 at a negative voltage for 1 timeunit for the 1, at a positive voltage for 5 timeunits for the zeroes, at a negative voltage for 1 timeunit for the 64 and at a positive voltage for 1 timeunit for the last zero. The 8 timeunits have the voltages -+++++-+. BAUDRATE. One bit is sent in one timeunit. Transmission speed is measured in baud = bits/second. At 9600 baud one timeunit is then 1/9600 second = 0.000104 seconds. STARTBIT. As mentioned earlier, pin 2 is negative when not sending. The 'A' characters' first bit was 1 = negative voltage. For the receiver to know when a character with the first bit = 1 begins, every character is preceeded by 1 timeunit at a positive voltage, the start bit. The startbit and the 8 databits have the voltages +-+++++-+. STOPBITS. The last databit for sending 'A' was positive. The startbit is also positive. In order for the receiver to know when the startbit of the next character begins, there must be a pause when the voltage is negative. The receiver may also need some time to be ready for the next character. On the sending Z88 the pause is 2 timeunits. It puts out 2 stopbits. On receiving the Z88 needs a pause of 1 timeunit. It needs one stopbit. The pause can be any length if at least 1 timeunit. The startbit, 8 databits for 'A' and 2 stopbits then have the voltages +-+++++-+--. PARITY. The parity options Even and Odd are a way of error recognition. Only 7 databits are used. Using Odd parity to send the 'A' character, code 65 = 1+0+0+0+0+0+64, the number of set databits is 2 which is not odd, then the eighth bit, the parity bit is set to make the number of set bits among the data and parity bits odd. The startbit, 7 databits, 1 paritybit and 2 stopbits then have the voltages +-+++++----. If the parity was Even, the number of set bits would already be even and the parity bit would not be set (=0) and the voltages would be +-+++++-+--. The receiver can then check for corruption by checking if the number of set bits is odd or even. The option Mark means that the parity bit is always set, and Space means that it is never set. When receiving the Z88 does not check if the parity is correct. If receiving odd or even parity , the parity bit is taken as the eighth databit so every character that has the parity bit set has 128 added to the code. Most characters with codes over 126 are shown as a black square on the screen. On sending, the correct parity is output by the Z88. Corrected odd parity number of stopbits error discovered by Marc Van der Wal 27th June 2004 Dennis Gröning Ranglebyn Berget SE-661 94 Säffle Sweden