Stepper

(last updated: 11/06/02)

Purpose: Provides a platform for evaluating stepper motors.

Overview

Stepper motors are used to adjust valves, drive printer platens, and turn lead screws in positioning tables. The Stepper project is a simple system which allows one to learn more about stepper motors, and it provides an easy test station for all those stepper motors that are lying in your electronics "junk" box. The system is presented in the following diagram:

The Atmel AVR microcontroller is running the firmware in the avr_io project (provides control of the AVR's I/O ports). The motor driver circuit is based on the Allegro 3966 and is set up almost exactly like the "Typical Application" circuit given in the 3966's data sheet. The PC runs a java program that sends commands to the avr_io. The user is presented with the following:

By clicking the CW button, the motor starts turning. Click the CW button again to turn off the motor. Use the CCW to make the motor turn in the opposite direction. The actual direction of CW and CCW depend on how the stepper motor is connected to the driver and whether your looking at the front or back of the motor. The slider is used to vary the motor speed.

Note: This page does not explain the theory behind stepper motors. There are plenty of web sites that do this already.

Specifications

1. Uses the avr_io.

2. Cause a two-phase bipolar stepper motor to turn clockwise and counterclockwise.

3. Support bipolar stepper motors which require <=500mA of drive current for each winding.

4. A java program provides a GUI interface.

5. To cause the stepper motor to turn, click either the CW or CCW button. The non-selected button becomes disabled. Reselect the same button to turn the motor off.

6. A slider adjusts the speed of the motor. When the pointer is at the far left, the motor turns at its maximum speed (this speed is determined by how fast the port control commands are being sent to the avr_io through the serial port, and it is also affected by the angular resolution of the stepper motor). When the pointer is at the far right, the stepper runs at its slowest speed. The motor drive procedure has four steps and between each of these steps, the execution thread is delayed. The amount of delay is determined by the slider position. The value of the slider can be between 0 and 100. This slider value is divided by 4 to reduce the resolution to 0-25. This value is subtracted from 25 to match to orientation of the slider so that when the pointer is on the left, the value of 25 is obtained. When the pointer is on the right, then the value of 0 is obtained. This value is then used as the thread delay value, in milliseconds. The psuedocode is given as follows:

When slider value changes:

speed adjust = 25 – (slider value / 4)

Main thread:

while( exit == false )

if motor direction is CW

Set phase1/phase2: +/+

delay( speed adjust ms )

Set phase1/phase2: +/-

delay( speed adjust ms )

Set phase1/phase2: -/-

delay( speed adjust ms )

Set phase1/phase2: -/+

delay( speed adjust ms )

else if motor direction is CCW

Set phase1/phase2: -/-

delay( speed adjust ms )

Set phase1/phase2: +/-

delay( speed adjust ms )

Set phase1/phase2: +/+

delay( speed adjust ms )

Set phase1/phase2: -/+

delay( speed adjust ms )

else disable the motor driver

7.Hardcoded comm port: COM1 (other parameters hardcoded to 19200,8,N,1 as per the avr_io's requirements).

8. Development: Jbuilder6, Java 1.4 sdk, Java Communications API, Stepper project files (Stepper.java, GUI.java, AVR.java)

9. Errors detected by the avr_io are not checked

My Setup

:

- PC running JBuilder6 with the Stepper project

- STK200 development board with AT90S8515 running the avr_io firmware

- Motor driver circuit board (constructed on a perfboard), based on the Allegro 3966.

- Motor: 15BA-H041-02P, +24V, 0.085A, 220ohm windings, 2 phase

The logic supply for the motor driver chip is taken from the STK200. The stepper motor requires 24V, and this is provided by a power supply that is not shown in this picture. The STK200 is the yellow board at the top. A 10-wire ribbon cable connects the STK200 PortA port to the motor driver circuit board. The stepper motor is the silver shiny object located to the left of the motor driver circuit (the large black dot is the motor shaft with a magnet coupler).

Download (see Attachments)

Stepper - project files/source code, JBuilder6 + Communications API + Java 1.4 SDK

Stepper_hardware_connection_diagram.jpg - Hardware connection diagram.

Links

avr_io

Terms of Use

Home

Copyright Steven R. Nickels, 2008. All rights reserved.