Difference between revisions of "USB-teletype"

From HeepyWiki
Jump to navigation Jump to search
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
This is a compact USB to teletype current loop interface on a 1.6 by 1.4 inch pcb. It connects to a computer running Windows, Mac OSX, Linux, Android, or probably anything else via a USB Mini-B connector, and presents itself as a USB serial port, while the other end connects directly in series with a teletype loop. Data is relayed bidirectionally between the two. It does not provide loop current itself, so a loop power supply with fuse is needed if not already present. Download the [[Media:usbtty-instructions.pdf|instruction sheet]] or the windows INF file[http://github.com/epvuc/usb-tty].
+
'''[https://www.youtube.com/user/teletweety/videos?sort=dd&view=0&shelf_id=0 Action videos!]'''
 +
 
 +
This is a compact USB current loop serial adapter on a 1.6 by 1.4 inch pc board. It connects to a computer running Windows, Mac OSX, Linux, Android, or probably anything else via a USB Mini-B connector, and presents itself as a USB serial port, while the other end connects directly in series with a teletype loop (or pair of loops, if full duplex). Data is relayed bidirectionally between the two. It does not generate loop current itself, so a loop power supply with fuse is needed if not already present. Download the [[Media:usbtty-instructions.pdf|instruction sheet]] or the windows INF file[http://teletweety.com/usbtty_adapter.inf].
 +
 
 +
'''[http://teletweety.com/usbtty_adapter.html Trouble installing INF file on windows?]'''
  
 
[[File:loop-adapter3.jpg|450px]]
 
[[File:loop-adapter3.jpg|450px]]
Line 17: Line 21:
 
The circuit board is physically divided in half. The loop-interface side is 100% completely electrically isolated from the computer interface side. If operating the board without an enclosure, it is '''very important''' to insure that nothing conductive comes in contact with it that might bridge exposed contacts and potentially carry high loop voltage anywhere near your computer's USB interface. The loop side is protected against inductive spikes from selector magnets on the line, and should tolerate currents from <20mA to over 100mA. The loop current is sensed non-inductively by a 150 ohm, 2 watt resistor in series with the loop, which provides current to the input side of an opto-isolator. The output side is switched by another optical isolator with an on resistance around 34 ohms. Both input and output can be connected in any polarity. The device has separate connections for input and output, so it can be used in a full-duplex application with two separate loops, but for half duplex operation normally the two connector blocks would be jumpered in series. (they are also completely electrically isolated from each other.)
 
The circuit board is physically divided in half. The loop-interface side is 100% completely electrically isolated from the computer interface side. If operating the board without an enclosure, it is '''very important''' to insure that nothing conductive comes in contact with it that might bridge exposed contacts and potentially carry high loop voltage anywhere near your computer's USB interface. The loop side is protected against inductive spikes from selector magnets on the line, and should tolerate currents from <20mA to over 100mA. The loop current is sensed non-inductively by a 150 ohm, 2 watt resistor in series with the loop, which provides current to the input side of an opto-isolator. The output side is switched by another optical isolator with an on resistance around 34 ohms. Both input and output can be connected in any polarity. The device has separate connections for input and output, so it can be used in a full-duplex application with two separate loops, but for half duplex operation normally the two connector blocks would be jumpered in series. (they are also completely electrically isolated from each other.)
  
==Modification==
+
==Modification and firmware updates==
The controller is an Atmel atmega32u2 with a USB DFU-class bootloader installed via which the firmware can be updated or replaced.  The bootloader uses 4kb, leaving 28kb of flash free for application software. It is compatible with Atmel's "FLIP" software on most platforms, as well as linux "dfu-programmer" software. In addition, the atmega hardware ISP programming lines are brought out on the back side of the board on pogo-pin pads, allowing replacement of the bootloader, recovery from any kind of software corruption, or eliminating the bootloader entirely to gain flash space. Source code for the current firmware is freely available on github[http://github.com/epvuc/usb-tty].
+
The controller is an Atmel atmega32u2 with a USB DFU-class bootloader installed via which the firmware can be updated or replaced.  To activate the bootloader, briefly short the two bare pads on the board marked "RST" - the orange LED will go out, and the green LED will blink slowly. The host computer will see the USB serial device disappear and be replaced with one called "Atmel DFU". You can read and program the chip using Atmel's FLIP software[http://www.atmel.com/tools/FLIP.aspx] on most platforms, and the commandline tool "dfu-programmer" on Linux and Mac OSX. On windows you will also need a driver for it, which is provided in the FLIP download; all other OS's don't require any driver. To exit the bootloader, issue a DFU reset command or just power cycle the board.
 +
 
 +
The bootloader uses 4kB of flash, leaving 28kB free for application software. In addition to the USB bootloader, the hardware ISP programming lines are brought out on the back side of the board on labeled pogo-pin pads, allowing replacement of the bootloader, recovery from any kind of software corruption, or eliminating the bootloader entirely to gain flash space. Source code for the current firmware is freely available on github[http://github.com/epvuc/usb-tty]. If I make updates or changes to the firmware, I'll release them as intel-format hex files which can be flashed to the board using the DFU bootloader.
 +
 
 +
The firmware is written in C and built using GCC and avr-libc, and Dean Camera's LUFA USB support libraries[http://www.lufa-lib.org].
  
 
==To-Do List==
 
==To-Do List==
 
Firmware improvements being considered are:
 
Firmware improvements being considered are:
* transparent 7 or 8 bit passthrough mode for use with 33s and the like. (written, being tested)
+
* transparent 7 or 8 bit passthrough mode for use with 33s and the like. (done, included in shipped firmware)
 
* The ability, from the config command mode, to modify the ascii/baudot character translation table (done 4/2016)
 
* The ability, from the config command mode, to modify the ascii/baudot character translation table (done 4/2016)
 
* the ability to select from multiple stored translation tables (done)
 
* the ability to select from multiple stored translation tables (done)
* hand sending and receiving BREAK signals (done)
+
* handle sending and receiving BREAK signals (done)
* sending pre-recorded messages like RYRYRYRY and quick brown fox with short commands (not yet)
+
* automatically sending pre-recorded messages like RYRYRYRY and quick brown fox (present but experimental, included in shipped firmware)
* the ability to logically invert mark and sense for input and/or output. (not yet)
+
 
 +
==Known Bugs==
 +
* In Linux, if you press the button on the adapter board immediately after first connecting it to the host, but before opening it with a terminal program, it will hang and have to be disconnected and reconnected.
 +
* Most of the commands/options listed as "experimental" in the documentation lack thorough safety checks or bounds checking.
 +
* When put into firmware-update (DFU) mode, the loop is opened.  
 +
* <s>8-bit (ASR33, etc) mode is currently untested on real hardware.</s> It's been reported to work correctly on an ASR33.
 +
* If you have "showbreak" mode enabled, both actual line breaks and also null characters may be displayed as "[BREAK]"
  
 
==Schematic==
 
==Schematic==
 
[[File:loop-adapter1.png|800px]]
 
[[File:loop-adapter1.png|800px]]

Latest revision as of 01:27, 28 February 2017

Action videos!

This is a compact USB current loop serial adapter on a 1.6 by 1.4 inch pc board. It connects to a computer running Windows, Mac OSX, Linux, Android, or probably anything else via a USB Mini-B connector, and presents itself as a USB serial port, while the other end connects directly in series with a teletype loop (or pair of loops, if full duplex). Data is relayed bidirectionally between the two. It does not generate loop current itself, so a loop power supply with fuse is needed if not already present. Download the instruction sheet or the windows INF file[1].

Trouble installing INF file on windows?

Loop-adapter3.jpg Loop-adapter2.png

Software

Unlike most USB serial adapters, this one uses a general purpose microprocessor rather than a dedicated interface chip like FTDI, CP2102, etc. This allows features like onboard translation between ASCII and 5-level code, selectable auto-newline, unshift on space, and others. The yellow LED flashes in sync with data sent from the computer to the teletype loop, and the green LED flashes in response to data coming from the loop. The two LEDs are inverted in sense so that on a half duplex line one will show mark and one will show space.

On initial power-up, the interface's teletype side is set to 45.45 baud and will translate between teletype 5-level code (ITA-2, Baudot) and ASCII bidirectionally, so that from the point of view of the computer, it looks like a plain ASCII terminal. ASCII codes sent to the interface which have no teletype code equivalent are ignored and not forwarded. The interface keeps track of LTRS/FIGS shift and sends the appropriate shifts as necessary. On power up it assumes LTRS until it discovers otherwise. If unshift-on-space is enabled, it will switch to LTRS mode if it sees a space character on the loop side. It can also be switched into non-translating mode, in which it simply passes through the lower 5 bits of all characters sent from the computer, and vice-versa, so that it can be used with computer software which expects to do this translation itself (i.e., BaudotRSS, HeavyMetal, etc.) In operation, the yellow LED flashes in sync with data sent from the computer to the teletype loop, and the green LED flashes in response to data coming from the loop.

Pressing the SW1 button on the interface board switches the device into command mode, in which it ignores input from the teletype loop, keeps the output marking, and presents a command-line interface via USB to the computer. "help" shows available options and how to change them. Changes may be made on the fly and can remain temporary or be saved to permanent storage with the "save" command. If saved settings are present in permanent storage, they will be loaded and used automatically on power up. This way the device can be treated as transparent unless intentionally put into config mode.

The loop side character timing and framing are synthesized completely in software, so entirely arbitrary baud rates can be specified, up to the limits of the optical interfaces (about 1000 baud). Be careful of setting absurdly low baud rates. Common rates are recognized and precalculated timing used, but other arbitrary rates will get best-effort calculated timing which should be sufficient. Baud rate settings are taken only from the configuration command line, and rate changes sent the "normal" way from the computer are ignored, since typical teletype data rates are not supported via that method.

Electrical

The circuit board is physically divided in half. The loop-interface side is 100% completely electrically isolated from the computer interface side. If operating the board without an enclosure, it is very important to insure that nothing conductive comes in contact with it that might bridge exposed contacts and potentially carry high loop voltage anywhere near your computer's USB interface. The loop side is protected against inductive spikes from selector magnets on the line, and should tolerate currents from <20mA to over 100mA. The loop current is sensed non-inductively by a 150 ohm, 2 watt resistor in series with the loop, which provides current to the input side of an opto-isolator. The output side is switched by another optical isolator with an on resistance around 34 ohms. Both input and output can be connected in any polarity. The device has separate connections for input and output, so it can be used in a full-duplex application with two separate loops, but for half duplex operation normally the two connector blocks would be jumpered in series. (they are also completely electrically isolated from each other.)

Modification and firmware updates

The controller is an Atmel atmega32u2 with a USB DFU-class bootloader installed via which the firmware can be updated or replaced. To activate the bootloader, briefly short the two bare pads on the board marked "RST" - the orange LED will go out, and the green LED will blink slowly. The host computer will see the USB serial device disappear and be replaced with one called "Atmel DFU". You can read and program the chip using Atmel's FLIP software[2] on most platforms, and the commandline tool "dfu-programmer" on Linux and Mac OSX. On windows you will also need a driver for it, which is provided in the FLIP download; all other OS's don't require any driver. To exit the bootloader, issue a DFU reset command or just power cycle the board.

The bootloader uses 4kB of flash, leaving 28kB free for application software. In addition to the USB bootloader, the hardware ISP programming lines are brought out on the back side of the board on labeled pogo-pin pads, allowing replacement of the bootloader, recovery from any kind of software corruption, or eliminating the bootloader entirely to gain flash space. Source code for the current firmware is freely available on github[3]. If I make updates or changes to the firmware, I'll release them as intel-format hex files which can be flashed to the board using the DFU bootloader.

The firmware is written in C and built using GCC and avr-libc, and Dean Camera's LUFA USB support libraries[4].

To-Do List

Firmware improvements being considered are:

  • transparent 7 or 8 bit passthrough mode for use with 33s and the like. (done, included in shipped firmware)
  • The ability, from the config command mode, to modify the ascii/baudot character translation table (done 4/2016)
  • the ability to select from multiple stored translation tables (done)
  • handle sending and receiving BREAK signals (done)
  • automatically sending pre-recorded messages like RYRYRYRY and quick brown fox (present but experimental, included in shipped firmware)

Known Bugs

  • In Linux, if you press the button on the adapter board immediately after first connecting it to the host, but before opening it with a terminal program, it will hang and have to be disconnected and reconnected.
  • Most of the commands/options listed as "experimental" in the documentation lack thorough safety checks or bounds checking.
  • When put into firmware-update (DFU) mode, the loop is opened.
  • 8-bit (ASR33, etc) mode is currently untested on real hardware. It's been reported to work correctly on an ASR33.
  • If you have "showbreak" mode enabled, both actual line breaks and also null characters may be displayed as "[BREAK]"

Schematic

Loop-adapter1.png