Current Loop Interface #2

USB-Powered 20mA Current Loop Interface

Introduction   Description   Settings   Project Status   Downloads

Introduction

cli2-rev-1-pcb-622-480

This board is useful for connecting a computer to a current-loop peripheral.

It was primarily designed for connecting a current-day PC to a Model 33 Teletype without the need for any external power supply. Simply connect the PC to the board via a USB cable, and connect the Teletype’s 20mA current loop cable directly to the board. It also has RS232 inputs (and built in baud rate conversion functionality) if you would prefer to connect via the PC’s RS232 port. This will however require the use of an external 5V or 12V power supply (a wall wart will be sufficient).

This board can also be easily adapted for other uses. For example:

  • The drive current can be increased from 20mA to 60mA, by changing a few component values
  • It can be used to connect a vintage computer (via its RS232 port) to terminals or printers via 20mA current loop
  • It can be used to connect a current-day PC to the current loop interface of a vintage computer (provided the vintage computer’s current loop circuitry can be switched to “passive” mode)

This board is intended to be the “active” end of the current loop. It is important to know that when connecting two devices via current loop, one (and only one!) device should be configured as “active” and the other device should always be configured as “passive”. The active device will generate the loop voltage, and regulate or limit the loop current. Typically the active device is not opto-isolated from the device it forms part of. The passive device does not inject any voltage or current into the loop. Typically the passive device isolates the current loop from the other circuitry within the device. Often this is done using opto-couplers. Because my board is not fitted with any opto-couplers, it is not designed to operate as the passive end of a current loop connection. Please see my “Current Loop Board 1” project if you are looking for a circuit for the passive end of the current loop.

Description

The main parts of the circuitry are:

  • On-board switch mode power supply. This provides power for the current loops and for the board’s own circuitry. A potentiometer is provided to adjust the current loop voltage within the range of 14V to 28V. Depending on the jumper settings used, the power supply takes its input from the USB port or from an external supply (5V to 12V, AC or DC). If using an external supply, a 5VDC 1A or 12VDC 500mA plug pack is recommended.
  • Analogue circuitry to drive the transmit-data, receive-data and reader-enable current loops. Current is regulated in the loops at approximately 20mA by way of current-sensing circuitry. So there is no need to change any current limiting resistors if you vary the loop voltage.
  • Indicator LEDs for power and to show activity on the TX and RX current loops.
  • A “Type B” USB connector, to connect the board to a PC.
  • A DB9F connector, which will connect directly to a PC’s 9-pin serial port using a straight-through cable. It will also connect directly to a USB-to-DB9 RS232 adapter.
  • A DB25M connector, for general purpose RS232 use. You can use this to connect to other RS232 devices. It has jumpers to configure it as a DTE or DCE device, to help simplify the RS232 cabling requirements.
  • A PIC microcontroller that performs the tasks of bridging between the PC side (USB or RS232) and the current loop.

The PIC microcontroller provides the following functionality (however – functionality relating to 5-bit Teletypes will be removed soon, to simplify the settings menu)

  • Teletype-side byte length (5-bit, 8-bit)
  • PC-side data format (ITA2/USTTY, printable ASCII, full 7-bit ASCII, binary)
  • Teletype baud rate (45.4, 50, 75, 91.67, 100, 110, 132, 300, 600, 1200, 2400, 4800, 9600)
  • Handling of bit D7 from Teletype (strip from keyboard, strip from all, no strip)
  • Data sent to PC via USB port (no, yes)
  • Data sent to PC via RS232 port (no, yes)
  • Newline character from PC (CR, LF, CR+LF)
  • Newline sequence to Teletype (CR, LF, CR+LF, CR+LF+LS+LS)
  • Fast Teletype LFs at left margin (no, yes)
  • Teletype 5-bit character set (ITA2, USTTY)
  • Teletype unshifts on CR (no, yes)
  • Teletype unshifts on SPACE (no, yes)
  • Teletype characters per line (30 to 250)
  • Column counter reset trigger (CR, LF)
  • Teletype action at right margin (keep printing, CR, LF, CR+LF, Discard-silently, Discard-bell)
  • Convert TABs to SPACEs (no, yes)
  • Tab stop interval (2 to 16)
  • RS232 baud rate (110, 300, 600, 1200, 2400, 4800, 9600)
  • RS232 mode (off, Mirror USB I/O, Emulate tape reader/punch, Hex dump)
  • RS232 CTS timeout in mSec (0, 1, 2, 5, 10, 20, 50, 100, 200, 250)

The PIC also has some built-in test messages that can be printed on the Teletype (whether or not a PC is connected). To access this feature, press the “Select” button 1, 2 or 3 times in quick succession. The PIC will then transmit the corresponding test message to the Teletype via the current loop interface.

Settings

The PIC chip stores a number of user-changeable settings that affect the functionality of the board, as described above.

To view and change the settings:

  • Connect a PC (or terminal) to the board via RS232 (at 9600 baud) or USB.
  • Use a terminal program on the PC to communicate with the board. TeraTerm or PuTTY work well.
  • Press the “settings” button on the board. The settings menu will display on your PC.
  • Use the arrow keys on your PC’s keyboard to view and change the settings. Press “X” when done.

The settings will be documented more fully when the firmware has been completed. Some settings are a little complicated, but most can be understood from the options/values provided in the settings menu itself.

Here is a screen shot showing the settings menu, though note this is still undergoing change (most of the changes will be to simplify the settings menu):

Current Loop Driver, Version 0.15, Unreleased

       Current loop word length:            8 data bits
       PC-side data format:                 Full ASCII (7-bit)
       Teletype baud rate:                  110
       Handling of D7 from Teletype:        Strip D7 only for keyboard data
       Data sent to PC via USB port:        Only keyboard data
       Data sent to PC via RS232 port:      Only keyboard data
       Newline character from PC:           CR
       Newline sequence to Teletype:        CR
       Fast Teletype LFs at left margin:    NO
       Teletype 5-bit char. set:            USTTY
       Teletype unshift on CR:              NO
       Teletype unshift on SPACE:           NO
       Teletype chars per line:             66
       Column counter resets on:            CR
       Teletype action at right margin:     Keep printing
       Convert TABs to SPACEs:              YES
       Tab stop interval:                   4
       RS232 baud rate:                     9600
       RS232 mode:                          Mirror USB I/O
       RS232 CTS timeout (msec):            ??????
       File transfer protocol:              XMODEM

Press X to exit when done

Project Status

Note: The firmware still needs some significant improvements.  I am currently (November 2017) actively working on it.

12 November 2017

I am half-way through the process of significantly revising (simplifying) the user interface.

Recent modifications include:

  • Adding 3 front-panel rotary switches to control the key functional selections. These control the format of data passing through the USB and RS232 interfaces (OFF, Hex-Dump, Unfiltered, Filtered) and how the Reader Enable output works (OFF, ON, CTS Level Triggered, CTS Edge Triggered)
  • Added A/D code to read and process the data from the 3 front-panel rotary switches (each switch uses just one analog input to the PIC)
  • Removed the 5-Bit/8-Bit option from the settings menu. Instead, this is now specified at compile time
  • Fixed a bug in the code so that this program can now be loaded (and upgraded) using the HID bootloader. This means that a PIC programmer won’t be needed to upgrade the firmware in the field

6 May 2015

PIC firmware is rough but mostly operable. Most (not all) of the functionality listed above has been implemented. The firmware needs work in 4 main areas:

  • Remove all options relates to 5-bit Teletypes, in order to simplify the settings menu. A dedicated 5-bit board will be put together in the future.
  • Implement code to initialise the settings. Presently the settings have to be initialised manually. Operation is unpredictable until the settings have been initialised.
  • Implement watchdog timer.
  • Implement functionality that will allow user code on a PC to control reader-enable on the ASR33 paper tape reader.

Further testing is also needed to refine firmware and hardware.

This page was last updated on 19 May 2016.

Downloads

Schematic and PCB Layout (KiCAD files)

Schematic (PDF)

PIC source code (user.c) [as at 27-DEC-2014]