TTY machines send and receive audio signals (usually over the phone line) which are encoded and decoded as text. They feature a small typing keyboard, display, phone handset acoustic coupling modem, and often a small printer or printer port.
TTY machines typically use a 5-bit character encoding protocol based on Baudot code that was developed in 1870 for telegraph transmission of the Roman alphabet, numbers, and symbols.
The chirping you'll hear when typing a letter on a TTY machine are 1400Hz and 1800Hz tones being shifted in 5-bit sets to represent the full character, number and symbol set. You can see the frequencies of the letter
A visualized here -- we'll take a closer look at the specific meaning below.
The protocol is defined in this specification document. Here are some relevant selections:
A.1 Mode of operation
5-bit operational mode
The 5-bit mode is defined in ANSI TIA/EIA-825 (2000), A Frequency Shift Keyed Modem for use on the Public Switched Telephone Network.
The communication channel is half-duplex with no channel turnaround. Carrier is transmitted 150 ms before the first character is transmitted. The receiver shall be disabled for 300 ms when a character is transmitted to mitigate false detection of echoes (in non-V.18 devices, the carrier may remain for up to 1 s after the last character to provide this same function).
The modulation is frequency shift-keyed modulation (i.e. no carrier is present when a character is not being transmitted) using 1400 Hz (±5%) for a binary 1 and 1800 Hz (±5%) for a binary 0. A bit duration of either 20 or 22.00 ± 0.40 ms is used providing either a nominal data signalling rate of 50 or 45.45 bits/s respectively.
Looking at our captured audio from the letter
A, here's what we see:
- A bit is 20ms in duration
- The lower frequency 1400Hz tone is used both as the carrier tone and to represent a binary
- The higher frequency 1800Hz tone is used to represent binary
A(see full chart below) has a binary 5-bit encoding of
- 5-bit character codes are sent with in order of least signifigant bit (so "right-to-left"), which means the
Abits are transmitted as
- The start bit is a binary 0 sent for 1 bit time, while the stop bit is a binary 1 sent for at least 1.5 bit time
Put all of that together and we get this:
carrier (for 150ms) + 0 + 11000 + 1 (for 40ms)
Play the file below to hear the A audio looped five times.
One other important feature of the TTY 5-bit code is the implementation of character sets. With 5 bits we can only encode 32 characters, however there are two mode character codes reserved (sort of like a shift or control key) for switching the decoder between "letters" and "figures".
When the LTRS mode character (
11111) is sent, all characters that follow are decoded as their alphabet letter version. When the FIGS mode character (11011) is send, all characters that follow are decoded as their numerical or symbol variant.
01101would decode as F
01101would decode as !
The mode character should be sent right before any shift to the other mode, or every 72 characters even if you are staying in one mode.
You'll notice these mode swaps when typing on a TTY machine because some keystrokes will suddenly sound twice as long as the mode character is sent right before the letter or figure character.
Now, lets implement this in CircuitPython to send tones over a speaker and into the TTY system.