LEGO Interface A

This post is part 1 of 4 of  LEGO Interface A

Nowadays computers are everywhere. And you can connect almost anything to a computer thanks to USB – truly a Universal Serial Bus.

But in 1986 computers were not so omnipresent. Computers were expensive and difficult to connect. Apple had the SCSI bus, IBM had ISA bus and simpler systems like the ZX Spectrum had… something. You could expect to connect maybe a modem or a printer but pretty much everything else would need a custom interface card.

So in 1986 LEGO announced the Dacta Technic Interface A (1093 or 9750) and for the first time people could use LEGO Technic motors and sensors with a computer.

Interface A was meant to be connected to the printer port of the computer. This was a clever move – at that time, the only de facto standards  were the serial port (RS232) and the parallel printer port (Centronics). By choosing the printer port several systems could use the Interface A: the IBM PC, the Apple II, the Acorn BBC Micro, the Commodore C64 and the MSX (some would still require a custom adapter).

So, historically speaking, the Interface A was the grand-grand-father of the current LEGO MINDSTORMS, WeDo and BOOST products.

I was 15 by that time. I had a Sinclair ZX Spectrum 128 and was learning Basic and decided to be an Engineer. In Portugal LEGO Technic was rare and expensive and I never heard about Interface A until a few years ago.

At university I tried to make my own Spectrum interface to use some motors but gave up and made a Centronics interface to use with my PC. I was afraid to damage my pretty expensive computer so I spent weeks designing it and used optocouplers to isolate the computer from the external electronics I wanted to use. I didn’t have LEGO motors so I used walkman motors glued to LEGO plates and used rubber bands instead of gears and even made a small 3 DOF LEGO robotic arm with the bricks I had from the only Technic set I ever had before my dark age, the 8074 – Universal Set with Flex System:

So without knowing, I was designing my own Interface A Plus 🙂

My own Interface

So after my LEGO dark age I was back to robotics and LEGO and finally found out the Interface A. Interesting but useless, I don’t have a printer port anymore on any of my computers and I was not interested in making an Arduino adapter just for that.

But recently I had been experimenting FTDI devices with linux and MINDSTORMS EV3. One of the uses of the FTDI 232 familly allows bitbanging each of the pins to create a custom GPIO interface. There even are python libraries for that purpose… so I wondered if I could use an FTDI adapter with the old  Interface A? If it worked, I could use the same adapter with my laptop, my Raspberry Pi’s and of course my EV3.

Short answer: Yes I can!

 

Ressurecting the LEGO Interface A

This post is part 2 of 4 of  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.

Some findings with Interface A

This post is part 3 of 4 of  LEGO Interface A

Controlling motor or lamps is easy, just change the state of a bit and the output changes accordingly. I made a simple cable adapter to use 9V devices so I can use more recent motors, even Power Functions 1.0 motors and LED’s. The PF Medium Motor works fine, just a bit more slow because maximum voltage is around 4.5V instead of 9V.

Read sensors is not so simple. When idle they are always high. When I shorted them the green LED blinks very quickly and then returns to high again.

I have an optosensor and it changes when passing a yellow brick at front (according to the user guides, the optosensor seems to react better to yellow) and it also changes when passing my hand between it and a light source or when pointing a ligth source directly to it. But it doesn’t “keep” that state, after a second or two it returns to high.

So I thing the sensor inputs react only to change, perhaps through a capacitor.

Using the same cable adapter I can use the RCX touch sensors with the Interface A

879 Touch Sensor

It works but it seems to only detect releases, not presses.

So for the inputs to be usefull we might have to take in account more than just the current state. And perhaps a counter also helps.

LEGO Interface A – the Python Turtle

This post is part 4 of 4 of  LEGO Interface A

In 1987 LEGO released several Activity Cards with examples to be used with the Interface A. One particular Activity Card, the 9700b8, proposed a robotic turtle that could be used to draw lines like the Logo Turtle (in fact, Interface A was used used with a LEGO variant of the Logo language) or even a lne follower!

I don’t have the exactly parts to build a 9700b8 robotic turtle but  have enough TECHNIC bricks already available at that time so created my own robotic turtle… the Python Turtle 🙂

I think Dr. Seymour Papert would like this turtle.

Source available here.