Software method generates 5 bit Baudot codes
This idea describes a technique for generating 5 bit Baudot codes (also known as the CCITT International Telegraph Alphabet No 2) using a small computer's own serial (asynchronous) interface; no additional hardware is required. The BBC BASIC program listed here (Fig. 1) can be easily adapted for use with other machines.
In asynchronous transmission data are sent one character at a time with variable gaps between characters (Figs. 2a and 2b) during a gap (the 'idle' time) the serial output line remains in the 'mark' state; ie, set to a '1'; to signal the start of the transmission of a character a 'start' bit (a '0') is sent in the bit interval before the data bits. In the bit intervals immediately following the data bits a '1' is sent lasting for either 1, 1.5 or 2 bit periods to indicate the end of that character's transmission. The number of stop bits is an indication of the minimum interval between the last data bit and the start bit of the next character. Data bits are transmitted starting with the LSB; (after the MSB and before the first stop bit a parity bit may be sent but in this application the parity generation must be disabled and no parity sent).
The Baudot code is used in the transmission of Telex and Radio Teletype; the code uses only five data bits and has a character set limited to upper case letters, numerals, some punctuation and special codes. The total number of characters is extended from the 32 possible combinations by using two "shift" codes (31 = 'shift to letters', 27 = 'shift to figures'); these are non-printing and extend the character set to 50 (plus two control codes). Thus each 5 bit code can represent two possible characters; which character a code corresponds to is determined by which shift character was most recently transmitted. Line feed, carriage return, space and the shift codes themselves are exceptions and are common to both the figure and letter character sets.
The serial interface of computers can be programmed to produce either 7 or 8 bit codes but rarely is it possible to select only 5 bits. Comparison of 8 bit and 5 bit formats in Figs. 2a and 2b shows that by forcing the three MSBs of the 8 bit code to the idle (1) state the word can be made to resemble a 5 bit one.
The program generates an 8 bit code (array variable S%( . )) from the 5 bit code (P%( . )) (program lines: 600-760) according to the equation:
S%( . ) = P% ( . ) + 224 ( where 0 P
31 )
ie, the 8 bit serial output has the last three (most significant) bits set to '1'.
When the program is started the code-conversion table is displayed on the screen: the first column is the ASCII code, the second the 5 bit Baudot code, the third the character itself and the fourth the 8 bit Baudot code. Zero entries in column two indicate that there is no corresponding Baudot code for that character and that it will be coded as 224 (which is an undefined Baudot code).
Once a key is pressed the corresponding 8 bit code is found (lines 500-590) and is sent to the serial interface. If necessary an appropriate shift character is sent first. Special characters such as CR and BEL are dealt with separately by lines 220-350. Since the Baudot alphabet is limited to upper case letters any lower case codes are first converted to upper case ones by lines 770-810.
L Mayes, Rochdale, Lancs
Figures 2a & 2b: 8 bit and 5 bit serial formats
![]()
It is a reasonably simple exercise to incorporate 'UNSHIFT ON SPACE' into the software so that a FIGURE SHIFT is automatically sent after every space when the most recent SHIFT from the keyboard was a FIGURE one.
Last updated: 15 November 2001; © Lawrence Mayes, 1993 & 2001