Słomkowski's technical musings

Playing with software, hardware and touching the sky with a paraglider and amateur radio as SP3OHM.

Linux PC-controlled model crane


A model crane with two stepper-motor axes and an electromagnet, driven from a PC parallel port. Comes with a text-mode controller written in C and a Tcl/Tk network client.

This article is very old, from 2006. It was originally published on my old website, flylab.ovh.org, now defunct. It’s unlikely to have much educational value. I’ve republished it mainly for sentimental reasons.

This is a model tower crane controlled by a Linux program through the LPT port. It was built when I was fourteen and disassembled shortly after — I stripped the stepper motors out of it and used them to build my first robot. Only a single photo of the crane survived.

The crane was initially supposed to have three axes of movement, but because I had only two motors and ran into mechanical difficulties, I built just two. They allow rotation around the crane’s own axis (direction) and raising and lowering the electromagnet (height). Both stepper motors were salvaged from 5.25″ floppy disk drives:

The other components are:

Part Notes
Male DB25 or Centronics connector
ULN2803 integrated circuit Darlington array driving the motor phases.
BD135 transistor Switches the electromagnet.
1N4148 diode Catches the back-EMF spike across the coil.
Coil for the electromagnet In my case, one taken from a 12 V relay.
Mechanical parts Pieces of wood, nails, glue, string, wires, a piece of perfboard etc.
Overview of the crane's mechanical layout.
Overview of the crane's mechanical layout.
↑ click to enlarge ↑

The motors and the electromagnet are powered from an external +12 V supply — the parallel port only provides the logic signals. The sequence to drive the stepper motors is generated by the computer, which controls the D0D7 pins of the LPT port, amplified by ULN2803 Darlington array. The electromagnet is controlled by STROBE pin, which drives a BD135 transistor. I used the coil from a 12 V automotive relay that used to switch the front headlights. The electromagnet has a 1N4148 diode across the coil to catch the back-EMF spikes.

Electrical schematic of the crane's controller.
Electrical schematic of the crane's controller.
↑ click to enlarge ↑

The circuit is simple enough to be assembled on a piece of perfboard.

The software is available as a compressed archive. It was written for Linux, leveraging sockets and I/O port access as described in the Linux I/O port programming mini-HOWTO. There is both a local and a networked version of the control software. The server and the local controller were written in C and require root privileges to run. The local controller is a terminal application. The control commands are:

Key Command
r Right
l Left
u Up
d Down
s Turn the motors off
h Lock the motors
f Toggle the electromagnet
e Exit

The network controller server listens on port 3490. The client was written in Tcl/Tk, so it can also run on other operating systems. It works in graphical mode: there are buttons for control, and on top of that you can use the arrow keys (direction) and ENTER (toggling the electromagnet):

Screenshot of the Tcl/Tk client.