0% found this document useful (0 votes)
101 views8 pages

Stepper Motor Interfacing With ATMEGA32

The document outlines an experiment on interfacing a stepper motor with the ATMega32 microcontroller using C programming. It details the necessary equipment, theory behind stepper motors, and provides a code example for controlling the motor's rotation direction. The experiment emphasizes the importance of a driver module, such as the ULN2003, for adequate current supply and isolation of the microcontroller.

Uploaded by

ciwana5697
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views8 pages

Stepper Motor Interfacing With ATMEGA32

The document outlines an experiment on interfacing a stepper motor with the ATMega32 microcontroller using C programming. It details the necessary equipment, theory behind stepper motors, and provides a code example for controlling the motor's rotation direction. The experiment emphasizes the importance of a driver module, such as the ULN2003, for adequate current supply and isolation of the microcontroller.

Uploaded by

ciwana5697
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Experiment-10

Aim: Hands-on experimentation of interfacing stepper motor with ATMega32 programming


in C .

Objectives: After successfully completion of this experiment students will be able to,
● Use C language for ATMega32 microcontroller programming on AVRStudio.
● Experiment with Stepper motor interfacing with ATMega32 on ATMega32 AVR
Development Board.

Equipment required:
● Windows7 or later based host computer
● ATMega32 Development board
● USBasp Programmer
● Jumper Wires
● Stepper Motor

Software required:

● AVR Studio7 installation setup


● USBasp driver installation setup

Theory:

Basics of Stepper Motor


Stepper Motor
Stepper Motors are DC brushless motors which can rotate from 00 to 3600 in steps. Stepper
motor uses electronic signals to rotate the motor in steps and each signal rotates the shaft in fixed
increment (one step). The rotation angel is controlled by applying certain sequence of signals.
Unlike Servo Motor, stepper motors can be driven by using GPIO pins of microcontroller rather
than PWM pins and can rotate in (+3600) and (-3600). The order of signals decides the
clockwise and counter clockwise direction of stepper motor. To control the speed of the motor,
we just need to change the rate of control signals applied. The stepper motors rotates in steps.
There are several modes of steps to operate Stepper Motor such as full step, half step and
microstep.

Enough of boring theory, let’s assume someone gives you a stepper motor say the famous 28-
BYJ48 and you are really curious to make it work. By this time you would have understood that
it is not possible to make these motors rotate by just powering them through a supply, so how
would you do it?
Okay, so unlike a normal DC motor this one has five wires of all fancy colors coming out of it
and why is it so? To understand this we should first know how a stepper which we already
discussed. First of all steppers motors do not rotate, they step and so they also known as step
motors. Meaning, they will move only one step at a time. These motors have a sequence of coils
present in them and these coils have to be energized in a particular fashion to make the motor
rotate. When each coil is being energized the motor takes a step and a sequence of energization
will make the motor take continuous steps, thus making it to rotate. Let us take a look at the coils
present inside the motor to know exactly know from where these wires come from.

As you can see the motor has unipolar 5-lead coil arrangement. There are four coils which
have to be energized in a particular sequence. The Red wires will be supplied with +5V and the
remaining four wires will be pulled to ground for triggering the respective coil. We use any
microcontroller to energize these coils in a particular sequence and make the motor perform the
required number of steps. Again there are many sequence you can use, normally a 4-step is used
and for more precise control an 8-step control can also be used. The sequence table for 4-step
control is shown below.

Why do we need Driver modules for Stepper Motors?

Most stepper motors will operate only with the help of a driver module. This is because the
controller module (Microcontroller/Digital circuit) will not be able to provide enough current
from its I/O pins for the motor to operate. So we will use an external module like ULN2003
module as stepper motor driver. There are a many types of driver module and the rating of one
will change based on the type of motor used. The primary principle for all driver modules will be
to source/sink enough current for the motor to operate.

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

CODE:
#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);
}
}

OUTPUT:
CONCLUSION:
In this experiment, we successfully interfaced a stepper motor with the ATMega32
microcontroller using the ULN2003 driver. We controlled the direction of rotation
(clockwise and anticlockwise) using both full-step and half-step sequences. This experiment
demonstrated how stepper motors operate by energizing coils in a specific pattern. It also
emphasized the importance of a driver module to supply sufficient current and isolate the
microcontroller. This kind of motor control is widely used in precision systems such as
CNC machines, 3D printers, and robotic actuators.
Experiment-12 Post Lab Exercise
Student Name: Viraj Vaghasiya
______________________________________________________________________
Enrollment No: 92301733027

_________________________________________________________________________

Answer the following questions:

1) What is the name of the Driver used in this experiment?

Answer: ULN2003

2) True or False. I can rotate the stepper motor

Answer: True

3) In stepper motor, what do we mean by full step sequence and half step sequence?
Answer:
 Full step: Energizes two coils at once for greater torque.
 Half step: Alternates between one and two coils for smoother and more precise
movement.

4) How many coils are present in the stepper motor?

Answer: Four coils

5) What kind of applications are there for using the stepper motor in the microcontroller
project?
Answer: Used in robotics, CNC machines, camera sliders, 3D printers, and other
automation systems requiring precise motion control.

You might also like