Ressurecting the LEGO Interface A

By modern criteria, the Interface A is quite simple: it has 2 inputs that accept TTL levels and 6 power outputs able to turn ON or OFF 6 ‘devices’ like motors or lamps. These 6 output can be used independently or in pairs. A motor connected to a single output just turns ON or OFF so it rotates always in the same direction but when connected to a pair of outputs it can rotate in both directions. I think (but I’m not sure) that this is implemented through an H-bridge – if true, motors can also stop in two ways (Break and Coast).

There are a few web resources with excellent information about the LEGO Interface A:

So the Interface A uses 6 pins from the Data port of the Parallel Printer Interface (D0..D5) for Output and 2 pins from the Status port (Paper Empy and Select) for Input. Two other pins from the Control port (STROBE and AUTO FEED) are used to get the +5 Volt that power the optocouplers that assure electric isolation between the computer circuits and the external world circuits – these are also powered by a 7.5V AC transformer with at least 11 Watt (VA), not easy to find but we can use a good 12V power adapter with at least 1A output (preferably 15V/2A) because there is an internal rectifier bridge [that reduces average voltage to half].

A note about the power adapter: my first attempts were with a cheap linear “universal” wall adapter, just 300 mA output, at 12V. It worked but when issuing commands to motors, every time the motor stopped I saw both Input green LEDs blinking. With a decent switched wall adapter, 2000 mA, also at 12V, never happened again.

Before using the FTDI adapter I manually tested my Interface A, using a 4.5V battery to power the optocouplers (just need to connect one of the two Control pins, they are internally shorted; same for Ground pins). Some jumper wires directly attached to the 20-pin IDC connector and I was controlling a 4.5V Technic motor:

Manually testing the Interface A

Only issue was finding pin 1: it is the top pin from right. I made a mistake and started with the top pin from left and it started to smell bad – amazingly, it didn’t destroy my Interface A.

So these are the pins (based on the table available at L Gauge)

Pin Function
1 VCC: +5V
2
3 VCC: +5V
4
5 Ground
6 Output Bit 0
7 Ground
8 Output Bit 1
9 Ground
10 Output Bit 2
11 Ground
12 Output Bit 3
13 Ground
14 Output Bit 4
15 Ground
16 Output Bit 5
17 Ground
18 Input Bit 6
19 Ground
20 Input Bit 7

Don’t need to use all pins – pin 1 and 3 (VCC) are internally connected, as all Ground pins – if we keep wires short between the FTDI adapter and the Interface A, we don’t need so many Ground wires (on a long flat cable they help minimizing noise). I used just 10 (VCC, GND and 8xI/O).

Now I need to connect these pins to an USB FTDI adapter with enough pins, like the Sparkfun Breakout Board for FT232RL USB to Serial.

Most of the information needed I got from this post: FT232: FTDI’s Bit Bang using Python (Parallel Port Replaced !!)

I used the 8 pins available in Bitbang mode:

Output 0               TXD
Output 1               RXD
Output 2               RTS#
Output 3               CTS#
Output 4               DTR#
Output 5               DSR#
Input 6                DCD#
Input 7                RI#

To use these pins we just need to configure the bitbang port to use the 2 most significant bits as inputs and the 6 least significant bits as outputs.

The +5 Volt to power the optocouplers is also available as VCC.

So these are the pins I use:

FTDI adapter for Interface A

(and, of course, at least one GND pin)

I decided to use pylibftdi. On my Ubuntu 17.04 I just needed

sudo apt-get install libftdi1-dev
sudo pip3 install pylibftdi

To use it I need to know the serial number of my FTDI. That’s available from dmesg:

[ 253.177269] usb 1-6.2: new full-speed USB device number 10 using xhci_hcd
[ 253.272003] usb 1-6.2: New USB device found, idVendor=0403, idProduct=6001
[ 253.272012] usb 1-6.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 253.272017] usb 1-6.2: Product: FT232R USB UART
[ 253.272022] usb 1-6.2: Manufacturer: FTDI
[ 253.272027] usb 1-6.2: SerialNumber: A105BPBO
[ 253.317758] usbcore: registered new interface driver ftdi_sio
[ 253.317781] usbserial: USB Serial support registered for FTDI USB Serial Device
[ 253.317912] ftdi_sio 1-6.2:1.0: FTDI USB Serial Device converter detected
[ 253.317949] usb 1-6.2: Detected FT232RL
[ 253.319094] usb 1-6.2: FTDI USB Serial Device converter now attached to ttyUSB3

Or we can use the ‘pylibftdi.examples.list_devices’ provided with the library:

sudo python3 -m pylibftdi.examples.list_devices
FTDI:FT232R USB UART:A105BPBO

(pylibftdi requires root privileges unless we write an udev rule for our device)

So I’m writing a python script that uses the computer keyboard to control the individual output ports 0..5 or the pair ports A..C and constantly polls the state of the input ports 6 and 7.

Series Navigation<< LEGO Interface ASome findings with Interface A >>