0% found this document useful (0 votes)
236 views

Stepper Motor Interfacing With AVR Atmega16/32

This document discusses interfacing a stepper motor with an AVR ATmega32 microcontroller. It provides the following key points: 1) A stepper motor rotates in discrete steps by applying a sequence of control signals. Microcontrollers can generate these signals to control the motor's rotation. 2) This project interfaces a 6-wire unipolar stepper motor to an ATmega32 using a ULN2003 driver chip. The motor is rotated clockwise and counterclockwise using half-step and full-step sequences. 3) The code example programs the ATmega32 to rotate the motor 360 degrees clockwise using half steps, then 360 degrees counterclockwise using full steps, repeating indefinitely

Uploaded by

ayu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
236 views

Stepper Motor Interfacing With AVR Atmega16/32

This document discusses interfacing a stepper motor with an AVR ATmega32 microcontroller. It provides the following key points: 1) A stepper motor rotates in discrete steps by applying a sequence of control signals. Microcontrollers can generate these signals to control the motor's rotation. 2) This project interfaces a 6-wire unipolar stepper motor to an ATmega32 using a ULN2003 driver chip. The motor is rotated clockwise and counterclockwise using half-step and full-step sequences. 3) The code example programs the ATmega32 to rotate the motor 360 degrees clockwise using half steps, then 360 degrees counterclockwise using full steps, repeating indefinitely

Uploaded by

ayu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Stepper Motor Interfacing with AVR Atmega16/32

Introduction

Stepper Motor

Stepper motor is a brushless DC motor that divides the full rotation angle of 360° into number of
equal steps.

 The motor is rotated by applying certain sequence of control signals. The speed of rotation
can be changed by changing the rate at which the control signals are applied.
 Various stepper motors with different step angles and torque ratings are available in the
market.
 Microcontroller can be used to apply different control signals to the motor to make it rotate
according to the need of application.

For more information about Stepper Motor and how to use it, refer the topic Stepper Motor in the
sensors and modules section.
Interfacing of Stepper Motor with AVR ATmega32

Interfacing Stepper Motor With ATmega 32

 Here we are going to interface 6 wires Unipolar Stepper Motor with ATmega32
controller.
 Only four wires are required to control stepper motor.
 Two common wires of stepper motor connected to 5V supply.
 ULN2003 driver is used to drive stepper motor.
 Note that to know winding coil and their centre tap leads measure resistance in between
leads. From centre leads we will get half resistance value of that winding.

Example
Let’s program AVR ATmega32 to rotate stepper motor 360° clockwise by half step sequence and
360° anticlockwise by full step sequence.

Program

/*
* ATmega32 Stepper Motor Control
* http://www.electronicwings.com
*
*/

#define F_CPU 8000000UL /* Define CPU Frequency 8MHz */


#include <avr/io.h> /* Include AVR std. library file */
#include <util/delay.h> /* Include delay header file */

int main(void)
{
int period;
DDRD = 0x0F; /* Make PORTD lower pins as output */
period = 100; /* Set period in between two steps */
while (1)
{
/* Rotate Stepper Motor clockwise with Half step sequence */
for(int i=0;i<12;i++)
{
PORTD = 0x09;
_delay_ms(period);
PORTD = 0x08;
_delay_ms(period);
PORTD = 0x0C;
_delay_ms(period);
PORTD = 0x04;
_delay_ms(period);
PORTD = 0x06;
_delay_ms(period);
PORTD = 0x02;
_delay_ms(period);
PORTD = 0x03;
_delay_ms(period);
PORTD = 0x01;
_delay_ms(period);
}
PORTD = 0x09; /* Last step to initial position */
_delay_ms(period);
_delay_ms(1000);

/* Rotate Stepper Motor Anticlockwise with Full step sequence */


for(int i=0;i<12;i++)
{
PORTD = 0x09;
_delay_ms(period);
PORTD = 0x03;
_delay_ms(period);
PORTD = 0x06;
_delay_ms(period);
PORTD = 0x0C;
_delay_ms(period);
}
PORTD = 0x09;
_delay_ms(period);
_delay_ms(1000);
}
}

You might also like