Pages

Saturday, December 8, 2012

Drive multiple (up to 12) stepper motors on Atmega using 74hc595 and "stepper04multi" library 01

A stepper motor is a brushless DC electric motor that divides a full rotation into a number of equal steps.



Stepper04multi is an AVR Atmega stepper motor library.
Stepper04multi can run multiple stepper motor (up to 12) having different direction, type and speed with a precision of 256us per step @8Mhz.
Setup parameters is stored in stepper04multi.h files.
Stepper04multi use 74hc595 ics to expands the number of micro ports.



This libray drives many stepper motors, to drive motors, every step is computed during timer interrupt. If you are running many tasks on the micro, your should check that motor step happens at a correct speed. If not, you have to increase the micro frequency, or reduce the number to motors to run. As example, on Atmega8 less than 3 motors runs without timing problem at 1Mhz.
Setup parameters is stored in stepper04multi.h files.

Pictures and video shows only two motors connected, cause i've only 2, but up to 12 can be connected, i've checked output pin using a logical analyzer, and results are fine.
The picture below refers to one motor output, during the sample motor velocity was 1280us, as you see the step is 1.250ms = 1250us, which is close to the requested velocity.


This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz (fuse LF: 0xE4, HF: 0xD9)


Code

Notes
  • read risk disclaimer
  • excuse my bad english

6 comments:

  1. both studio 5 and 6 develop library directory errors:
    "no such file or directory" after adding them in a folder in solution explorer.
    probable solution for this please.

    ReplyDelete
    Replies
    1. You can use Eclipse with AVR plugin and avrgcc as compiler. If that's not your way. I suppose you have to include also files in Atmel Studio, and "tell" the studio which files needs to be compiled. Unlucly i do not use the Atmel Studio.

      Delete
  2. Hi,

    Do you have a sample code where you have implemented more than 2 stepper motor using Atmega.

    ReplyDelete
    Replies
    1. Hello, you can take a look at the sample file provided in the download above, in the blog post description.

      Delete
  3. I'm programming with a atmega 88, and im getting this error " 'TIMSK' undeclared (first use in this function)
    make: *** [stepper02/stepper02.o] Error 1"
    do you have any idea what i did wrong?

    ReplyDelete
    Replies
    1. Hello, You are probably compiling on a ATmega without TIMSK register.

      Delete