Tokunrcr.Vol. 29. pp. 626 to 628. 1982 Printed in Great Britain. All rights reserved
A SERIAL
0039-9140/82/070626-03SO3.00/0 Copyright 0 1982 Pergamon Press Ltd
ASCII KEYBOARD-PRINTER
D. F. MARINO and J. D. INGLE. JR. Department of Chemistry, Oregon State University. Corvallis, OR 97331, U.S.A. (Received
26
October
1981. Accepfed
13 January
1982)
construction of a simple keyboard-printer is described. It is intended for use with single-hoard microcomputers such as the KIM and SYM which have a 20-mA loop ASCII interface.
Summary-The
It is now common to interface microcomputers with many types of instruments. Many inexpensive &bit single-board microcomputers (SBC) can be purchased for less than $300. Most SBCs do not have a printer, video display, or full alphanumeric keyboard but usually provide ASCII serial interface hardware and software. The hexadecimal keyboard and display on many SBCs is adequate only for entry and display of machine language codes. To use assembler-editors or higher level languages such as BASIC, a full ASCII keyboard and display unit is required for initial programming and for interaction of the operator with the experiment. However, if many SBCs are used as stand-alone units with various instruments in a laboratory, as in ours, the cost of purchasing a separate commercial teletype or CRT terminal plus printer combination for each SBC becomes prohibitive. These commercial units are 2-10 times the cost of the SBC. This paper is concerned with the construction of a keyboard-printer which costs about $300 in parts. It is constructed with commercially available sub-units and requires the construction of only one small interface board. A printer was chosen for the display unit instead of a video display, because it is less expensive and because hardcopy is desired in most experiments. The keyboard-printer was constructed specifically for the KIM (MOS Technology, Norristown, PA) and SYM (Synertek Systems Corp., Santa Clara, CA) SBCs used in our laboratory, but it can be used with any SBC with a standard ASCII serial interface. The keyboard-printer has no local copy capability, however, and the printer responds only to characters from the keyboard that are echoed by the serial interface of the SBC or to characters generated directly by the SBC. The keyboard-printer was constructed with a commercially available keyboard and electrostatic printer [George Risk (George Risk Industries, Kimball, NE) model 753 ASCII encoded keyboard kit ($50) Panasonic (Panasonic Company, Secaucus, NJ) model EUYlOEOllL line printer ($85) and a Panasonic model EUYPUD7OOlL parallel ASCII decoder/ printer driver board ($115)]. The printer uses 60-mm wide electrostatic paper, and either 16 or 32 charac626
ters per line may be selected (other models provide longer line length). The printing speed is two lines/set and the decoder board has a one-line memory buffer. Both the commercial keyboard and printer are designed to work with parallel TTL level ASCII data, The KIM TTY (teletype) line, however, delivers 20-mA current-loop serial ASCII. The UART (universal asynchronous receiver and transmitter) board shown in Fig. 1 was constructed to transform the parallel ASCII from the keyboard into serial ASCII, and the serial ASCII from the KIM into parallel ASCII for the printer. The UART circuit (Fig. 1) operates as follows. When a key is struck on the keyboard, it triggers IC2 to deliver a 15-psec logic 0 pulse to pin 23 of ICI, after which, on the positive edge the 7-bit parallel ASCII character is strobed into ICI. The 555 timer (IC3) then shifts these character data out of ICI at pin 25, along with the two stop bits provided by the UART at 1.7 kHz (106 baud). IC8, T2, and T3 then transform these TTL level data with optical isolation into 20-mA current-loop data for the KIM TTY interface. Serial ASCII from the KIM TTY interface enters IC9 and T4 in 20-mA current-loop form and is translated into TTL level serial ASCII. It then enters pin 20 of ICl and is shifted into the second half of ICl at 1.7 kHz. When the 7 bits of the ASCII character are received, ICl (pin 19tthrough Tl-delivers a logic 0 level STROBE signal to the printer interface. The interface senses the STROBE level, latches the ASCII character data into a buffer, and sends out a logic 0 acknowledge (ACK) pulse which resets the STROBE level. The UART will continue to process further ASCII characters even if an ACK pulse is not received, in which case the STROBE line remains low. During the print cycle, ACK pulses are not generated and the ASCII character data from ICl are not accepted by the printer interface. In some cases, pins 612 of ICI could be directly connected to the ASCII parallel port of a printer interface. However, the particular printer interface board chosen uses &bit negative true parallel ASCII logic and translates ASCII codes with the MSD (most significant digit or HEX representation of ASCII bits
SHORT
TO
621
COMMUNlCATlONS
KEYBOARD
TO
k
KIM TTY INTERFACE
TO PRI-NTER INTERFACE BOARD
Fig. 1. UART keyboard/printer interface. ICl, AY5013A UART; IC2, 74121 one-shot; 1C3, 555 timer; IC4, 7404 hex inverter; IC5, IC7, 7400 NAND gate (2 gates for IC7); IC6, 7420 NAND gate: IC8, IC9, TIlll opto isolator; Tl-T4,2N3904: Rl, 2.2 kQ; R2, 39 kfJ; R3, 27 kR; R4, R5, R8, 10 kf2; R6, 220 R; R7, 100 n; R9, 270 kQ: Cl, 0.01 PF ceramic; C2, 0.02 PF ceramic; C3, 0.01 /.IF tantalum: CNl, 30-pin edge-connector on UART interface board. 5-8) equal to 0 as a CR-LF and with the MSF equal to 1, 6-9, E, and F, into a SPACE. Thus upper-case letters, numbers, and symbols are unaffected (the MSD equals 2-5). However, lower-case letters (bits 6 and 7 high or MSD = 6 or 7) and control characters (bits 6 and 7 low or MSD = 0 or 1) with bit 5 high are printed as a SPACE and with bit 5 low are translated as a CR-LF (PRINT). Therefore IC4 inverts the ASCII data bits from the UART for logic compatibility, while IC5, IC6 and IC7 act as decoding circuitry to transform certain ASCII control codes into spaces (NULL and LF in particular), and all ASCII letters into upper case. This decoding logic works in the following manner (an ASCII code chart is helpful in understanding the following). The lower case letter problem is solved by “NANDing” ASCII bits 6 and ‘i. If ASCII bit 7 is high, the character just received by the UART is a letter, and the output of IC4a is low, forcing the output of IC5 high regardless of the status of ASCII bit 6. Hence, ASCII bit 6 (output of ICS) which goes to the printer interface is high, and ASCII bit 6 is translated by the printer as being low even if it is high, so a lower-case letter (ASCII bits 7 and 6 high) will be printed as an upper-case letter (ASCII bits 7 and 6. high and low respectively). The control characters are decoded by “NANDing” bits 7,6,5 and i so that a CR-LF or PRINT occurs only once at the end of a line rather than after certain control characters which the KIM transmits after a line. If a control code with bit 5 low is transmitted to the UART, bits 5, 6 and 7 will be low, forcing three inputs of IC6 high. If ASCII bit 1 is high, the fourth
input of IC6 will be low, causing its output to be high, and bit 8 to the printer will remain high, resulting in a CR-LF. This is the case for all odd ASCII control codes (such as CR). Any control code with bit 5 low reaching the UART with bit 1 low, however, causes the output of IC6 to go low, causing bit 8 to the printer to go low, and resulting in a SPACE being printed. ASCII control codes with bit 1 low include NULL and LF. Control characters with bit 5 high will also cause a SPACE to be printed although none of these is transmitted by the KIM. Thus the decoding prevents certain control characters from causing a CR-LF when not desired. The KIM transmits each line of data as DATA, CR, LF and then outputs six NULLS. A CR will cause the printer to print the data line in the buffer. The LF and six NULLS (translated into seven SPACES by the UART), which are also transmitted, will not be accepted by the printer while the printer is printing. Inclusion of seven spaces (translated LF and NULLS) in this KIM data transmission allows the printer enough time to finish printing before any real data from the next line arrive, privided that the transmission rate is < 110 baud, preventing the loss of some of these data. The UART interface board, along with the keyboard, the Panasonic printer interface unit, and a line printer were encased in an aluminium box along with a dedicated power supply delivering + 5 V at 800 mA, - 12 V at 400 mA, and -24 V at 1.5 A (circuit diagram available from the authors). Both +5 V and - 12 V are used by the keyboard, UART board, and printer interface board, and the printer interface board also requires -24 V.
628
SHORT COMMUNICATIONS
Although this keyboard-printer was designed for use with a KIM, it can be used with other microcomputers, in some cases with modification. Other keyboard-printer units have been interfaced to SYMs by using the SYM 1IO-baud TTY lines. The KIM synchronizes to any baud rate while the SYM TTY interface is constructed to accept only exactly I IO baud. For keyboard-printer units interfaced to SYMs, R2 in Fig. I was replaced by a IO-turn 50 kR pot to allow fine tuning of the frequency or IC3 was replaced by a baud-rate generator (MCI441 1) and a 1.8432-MHz crystal. The circuitry connected to pins 25 and 20 of ICI in Fig. I can be replaced by standard circuitry for TTL to RS232 interconversion for microcomputers that use RS232.
The UART board has been used with other printers and keyboards. Keyboard-printer units have been constructed with capacitive touch-switch keyboards, including ones made by Tasa (Santa Clara, CA) and RCA (model VP-601) (Lancaster, PA) which are similar in cost to the George Risk keyboard. More expensive printers such as the Axiom EX80l (Glendale, CA) have been used in place of the Panasonic printer and interface card. For this particular unit. IC4-IC7 and TI in Fig. I are eliminated and direct connection is made to ICI. Acknowledgemmr-We appreciate partial support of this work by the National Science Foundation (Grants CHE-761671 I and CHE-7921293).