Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] help requested......code for bipolar stepper motor implementation.

2005-02-06 by Dave VanHorn

First, what electronics are you using to drive the stepper?
You'll need some sort of stepper chip to handle the current, unless you use 
open collector drivers, and a unipolar stepper.

With bipolar, you may need as little as two output bits on the AVR.

You need to drive them in quadrature, according to an acceleration and 
deceleration table, which means you'll need a timer involved to tell you 
when to make your next step.

The simplest way is to write a table into rom containing the acceleration 
time values that you'll load into your timer.

Then, assuming you're not moving already, you pick your direction, output 
the bits, and output the timer value to the timer.
When the timer int happens, you change to the next stepper state, and load 
the next accel value into the timer.

You keep doing this till you're halfway "there", then decelerate along the 
same table, so that when you arrive at the destination you're on step 0 
again.

This is not necessarily the fastest approach, but it's simple.

During moving, if you hit the end of the accel table, then you just stay at 
that max speed, until you're N steps from your destination, where N is the 
length of the accel table.

When you arrive, then if there's no load fighting you, you can turn off the 
motor current.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.