FiDoStepper - a simple stepper motor driver

Summary: A surprisingly simple board that can drive three (unipolar/bipolar) stepper motors simultaneously. Microstepping, tool PWM control and communication over USB are implemented in ATMega8 firmware. Circuit schematics and firmware supplied.
Edit: After checking the low prices of StepStick and Arduino nano on Ebay, I decided to abandon making these boards and developing them further. I will instead try to make an easy-to follow guide how to make steppers work with the aforementioned pre-fabricated modules.

Introduction

Stepper motors are useful for various experiments, automation and robotics for their ability to rotate to a precise position and hold it. Two most common types are 5-wired unipolar, and 4-wired bipolar. The unipolar motor has one central conductor connected to four coils which should be energized sequentially; a simple solution is to connect the central conductor to positive source and switch the coils with four power transistors.

The bipolar motors are not this easy; they have two orthogonal independent coils only. The bipolar driving circuit must therefore be capable to drive the coils with reversing polarity. Such a circuit is capable of driving both types of motors, and it can be shown that it is more efficient than the simple solution with transistors above. Bipolar drivers are generally more complex, but in the following a novel and very simple approach will be shown.


Front and rear views of the motor driver built in a metal box; front side connects to a computer via USB and to a 5 V power source, rear side has three blue D-SUB connectors for motors, black one for a PWM-controlled tool and a simple switched power output.

The presented project consists of a board capable of driving three bipolar or unipolar stepper motors (i.e. 6 independent coils), with possible extension to add pulse-width-modulated (PWM) tool, I2C interface to other devices and detection of reaching an end position.

Another important feature is microstepping, enabling the motor to move within a fine position between two steps by pulse-width modulation of the signal into the coils.

The most important limitation of the board is that it has no current feedback; this generally leads to reduced torque when the motor is rotating, and higher energy consumption and heating when it holds still. For relatively slow operation, this is however not a big problem. Another limitation is that it only operates the motors at 4.5 - 5.5 V; the motors must be chosen accordingly so that they do not overheat yet keep sufficient torque.

Electrical part

H-bridge made of four transistors

The key feature enabling to squeeze the driver on a relatively small board is the following connection of four unipolar transistors, enabling to revert the polarity on one coil, or to turn it off. The gate of upper P-MOSFET and the gate of lower N-MOSFET are driven by a common digital signal; when this signal is 0 V, the upper transistor is open and the lower is closed. With signal of 5 V, the situation is opposite. Connecting the gates this way is certainly not a textbook approach; most importantly it presents risk of source short-circuit when the gate voltage traverses around 2.5 V. However, the switching time of the microcontroller is in order of tens of nanoseconds and no significant current peaks were observed with an oscilloscope.

Connecting one coil to such a pair of P/N mosfets on each side forms a H-bridge, enabling one to efficiently invert the voltage on the coil by sending 1/0 or 0/1 digital signals. The voltage on the coil can be turned off by sending 0/0 signal.

A suitable component is IRF7105, which houses a P-MOSFET and an N-MOSFET in one SO8 package, both capable of switching over 2.5 A. The MOSFET efficiency is so high that the transistors do not heat up under full load. To drive 6 coils, 12 packages are needed, which can be obtained for about 5 EUR.

Note that switching off any inductive load requires to handle the current continuing after the switch off. This is efficiently handled by built-in diodes in IRF7105, which de facto form a rectifier that recuperates the inductor energy back to a capacitor in power source. This not only prevents dangerous voltage spikes from forming, but also significantly improves efficiency.

schematic and board layout (GEDA gschem/pcb format)
printable PDF version thereof -- pending remake, write me a mail if interested

Connectors

The pinout in the "D-SUB 9" connectors adheres to the convention found in OWIS laboratory equipment. As a result, FiDoStepper can be directly connected e.g. to the motorized stages in our laboratory and drive them with micrometer precision.

Programs

Firmware

The board is controlled by ATMega8, running on 16 MHz. Due to limited number of PWM channels and missing USB interface in the chip, both microstepping and PWM routine as well as USB communication are implemented in software. The firmware uses Christian Starkjohann's V-USB library.

FiDoStepper firmware (2012-11-10)

The firmware can be compiled using avr-gcc and uploaded, e.g., using the usbasp programmer through the five programming pins on the board.

Computer software and communication protocol

Communication is based on short binary messages of several types. Using libusb and Python header files, I compiled a Python module that allows easy access to the device from Python scripts, which proves to be very convenient.

More description is to follow; so far please read the commented source codes below, or write me an e-mail if interested

library+example Python program for FiDoStepper (2012-12-06)

FiDoStepper is used as the electronic part of the FiDoCNC circuit board manufacturing robot.


© Filip Dominec | Last edited: 2015-01-18 | go to index➤