Menu

Intro

Theory

Circuit

Code
title
Introduction

This page will (hopefully) show you the very basics of getting an AVR microcontroller to control a unipolar stepper motor.

A stepper motor is not like a normal motor. It has 6 (or 5) wires as opposed to just 2 for starters. It requires each wire to be activated in a specific sequence to make it rotate.

For a great introduction and detailed explaination of stepper motors see http://electronics.box.sk/newsread.php?newsid=100

Basically the operation is that you supply power, 5 volts or so in my case, to both red wires and then "stepping" throught the other 4 wires in turn connecting them to ground. This way the individual magnets in the motor are energised as the circuit is completed with the connection to ground, in sequence.

In this example I'm using an AVR microcontroller to control the timing of the sequences. I'm using a Mega32 running in this control board: http://www.futurlec.com/ATMegaControlBoard.shtml

Of course a microcontroller should not be sinking the current flowing through any form of motor, hence I'm using a transistor in each circuit to handle the current (only up to 800 mA each but more than the 200 mA the AVR can handle)

It is always a good idea to separate the power supplies for the microcontroller and the motor as well. This way, when the motor pulls a large amount of current to energise a coil etc, the voltage supply for the uC won't be affected. Otherwise, the instantaneous draw on the power supply might mean the supply voltage will drop momentarily, but for long enough to reset the uC and upset everything.


Circuit

This circuit has to be one of the very simplest ones.

It merely allows the transistor to act as a switch. The operation of the switch is controlled by the microcontroller.