Tuesday, December 4, 2012

Drive up to 3 stepper motors on Atmega using "stepper02" library 01

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



Stepper02 is an AVR Atmega stepper motor library that can drive up to 3 motors having different direction, type and speed with a precision of 256us per step @8Mhz.
To drive a motors connect an ic driver between atmega pin and motor.
Setup parameters is stored in stepper02.h files.



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

17 comments:

  1. So with this library Do I have individual control over motors or all the motors will be running synchronously ?
    Can you please help , I want to make 3 or 4 axis bipolar stepper driver. I m using L293D to achieve this.

    ReplyDelete
    Replies
    1. motors can run independently
      setup ports for the motors in file stepper02.h, then use the same functions used in example file to move the motors.
      if you need more motors, you can try this library: http://davidegironi.blogspot.it/2012/12/drive-up-to-12-stepper-motors-on-atmega.html

      Delete
  2. Hi, Could you please indicate driver and IC model you used to driver stepper motors?
    I tried with L298 but it was not driving motors. I tried again with L293D and it drove motors but in an odd way and was not smooth at all. I am using Atmega32a and 42BYGHM809 WANTAI bipolar stepper motors.

    ReplyDelete
    Replies
    1. Hello, the one I'm using in this sample is a ULN2003A. You can find these cheap motors + driver on ebay or aliexpress.

      Delete
    2. I'm also using atmega32, L298N and Bipolar stepper motors, did you find a library file for stepper moters? can you give it to me? if you do it is really helpful to me...please

      Delete
    3. Hello Kavindu, please do not multi/post the same question.

      Delete
  3. Hello David Ser,
    i want to drive 6 stepper motor using AVR Atmega series controller.is there any library for that.
    please let me know sir,
    Thank You, your tutorials always help me..

    ReplyDelete
    Replies
    1. Hello, you can try using this one: http://davidegironi.blogspot.it/2012/12/drive-up-to-12-stepper-motors-on-atmega.html

      Delete
  4. Hello Davide ... Do u have any idea about using ATmega328 with L298 to drive a bipolar stepper motor .... If please send me schematic ...thanks

    ReplyDelete
    Replies
    1. Hello, you can use this project, you just havwe to change the TIMER0 register setup. I suggest you to use PWM to drive motor if you need something more accurate, you can find my library here: http://davidegironi.blogspot.it/2013/11/driving-dc-motor-using-software-pwm.html but there are a few availbale. Here you can find a simple L298 schematics http://davidegironi.blogspot.it/2013/03/controlling-dc-motor-speed-and_6.html, you basically just need to connect the output PIN from your micro to the IC. Note: a scope can help you here investigating the PWM output signal of your micro.

      Delete
  5. Hi
    How did you manage to provide PWM from normal pins. And how is speed of the Stepper controlled? Are you using ICR1 register to change the frequency for controlling speed.

    ReplyDelete
    Replies
    1. Hello. Not on this project, normal pin PWM emission was in another driver.

      Delete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Mr. davide,
    I'm using atmega32, L298N and two Bipolar stepper motors, is there a library file for stepper moters? can you give it to me? if you do it is really helpful to me...please

    ReplyDelete
    Replies
    1. Hello Kavindu are just full bridge driver, you can use thi library.

      Delete
  8. Hi, could i use Drv8825(as stepper driver) to save pins in atmega32?

    ReplyDelete
    Replies
    1. Hello Dashit, yes. You can take a look here if you want to view my implementation: http://davidegironi.blogspot.com/2015/03/drive-stepper-motor-with-acceleration.html

      Delete