Stepper Motors are unlike standard electrical motors, in that they offer fine-grained control over rotation angle by dividing 360° rotation into a number of "steps". The motor's centre rod is affixed to a magnetic gear, which is surrounded by a number of electomagnets. These electromagnets are energised in phase, causing the rod to rotate. Wikipedia has a good article on the workings of a stepper motor.
This interface allows stepping instructions (such as "rotate 3 steps clockwise") to be sent to the motor from the GNU/Linux command line using the computer's parallel interface.
The components required for this project can be bought cheaply from electronics retailers such as CPC, Farnell or Maplin.
BitsBox is a brilliant UK-based electronics shop with a great range of components; speedy, cheap delivery and they accept Paypal.
My new favorite!
Data output pins 2 through 5 of the computer's parallel port are connected to the input lines of the SN7407 hex buffer chip. As the input lines of the 7407 are taken high by the parallel interface, the corresponding outputs are supplied with current from the 5V supply.
Four TIP122 transistors are driven by the outputs of the 7404. As the transistor's base is energised, a 5V pulse is fed to the connected phase of the stepper motor. Each transistor has a 3.3kΩ pull-up resistor.
I've included five LEDs, one for power and one connected to the collector of each TIP122. These were originally 100% novelty but proved very useful for debugging both motor phase-order and software.
Construction & Mounting
The prototype of the stepper control interface has been built onto veroboard. Despite various jokes being made about the quality of my construction, (I work in an office full of electronics engineers) I'm pleased with the performance of the board.
The next job will be to package the unit in a casing which protects the circuits and is easily mounted on my Magnetic Loop aerial. At present, I'm looking at plastic enclosures so as not to interfere will loop resonance.
There are several ways to drive this parallel interface from GNU/Linux but by far the easiest method is to use Linux's support for userspace parallel port drivers.
The first step is to ensure your kernel has correct parameters set for userspace parallel port access:
Device Drivers --->
<M> Parallel port support --->
<M> PC-style hardware
Character Devices --->
<M> Support for user-space parallel port device drivers
I elected to build these options as modules but compiling direct into the kernel should work fine too.
My Motor Control Utility is provided for download as C source code. Provided your Linux distribution includes a C compiler, building the application should be trivial. Compile the code with the simple command:
gcc -Wall -O2 -o stepper ./stepper.c
Valid syntax for the newly-compiled stepper application is viewed with the -h option:
bash#: $ ./stepper -h
Usage: stepper [options] [byte-value, ...]
-h, --help show this help and exit
-p, --port select parallel port device
-l, --loop-delay set loop delay time [us].
-c, --loop-count repeat the sequence times (-1 = unlimited).
-F, --full-step use sequence to drive a stepper motor with full steps.
-H, --half-step use sequence to drive a stepper motor with half steps.
-R, --reverse stepper motor turns in reverse direction.
-i, --interactive interactive fine-tune mode.
-r, --reset-on-exit reset the data lines on exiting the program.
-d, --debug print debugging information.
Use of the -r option is recommended. Without it, the motor is left on "hold-step" and can become hot after a period of time.
When run with the -i option, stepper will listen for key presses from the user. Keys F, R, G & D are used to move the motor in fine steps.
bash#: $ ./stepper -i
Interactive Fine-Tuning Mode.
WARNING - Prolonged use of this mode may heat up your motor!
F --> Half-Step Clockwise.
R --> Half-Step Anti-Clockwise.
G --> Full-Step Clockwise
D --> Full-Step Anti-Clokwise
Press CTRL-D to exit.
bash#: $ ./stepper -F
Rotate one full-step cycle clockwise.
bash#: $ ./stepper -c3 -H -R
Rotate three half-step cycles anti-clockwise.
bash#: $ ./stepper -p /dev/parport1 -r -F
Rotate one full-step cycle clockwise. Use parallel port /dev/parport1 and release the parallel port when finished.