Stepper Motor
Stepper Motor
Stepper Motor
ABSTRACT
The microcontroller based stepper motor control system controls the motor and any motor device
according to its requirement for any industrial application. At the heart of the circuit is the AT mega 32
microcontroller which controls all its functions. The stepper motor can move a precise angle; the motor’s
position can be controlled without any feedback mechanism. Microcontroller can be used to apply different
control signals to the motor to make it rotate according to the need of application. In this paper, we are going
to rotate a stepper motor by using an AT mega 32 microcontroller. AT mega 32 has been programmed in
order to rotate the stepper motor for various applications. The motor drive which acts as an interface between
the microcontroller and the stepper motor. The microcontroller board is applying the external voltage of
about 5V. From this it can be directly deliver the input to the stepper motor drive where it provides sufficient
current to the stepper motor which tends to rotate the stepper motor. By programming the stepper drive, we
can be able to control the speed of the stepper motor, direction of the stepper motor either in clockwise or
anticlockwise direction. Motor drive protects the stepper motor from damages so that the stepper motor drive
can be connected between the stepper motor and AT mega 32 microcontroller.
KEYWORDS
AT mega 32, Microcontroller, Stepper Motor, Preset, Virtual Terminal
1. INTRODUCTION
There are various AT mega microcontroller used for many applications. In this paper,
we are going to use AT mega 32 microcontroller. AT mega 32 microcontroller has different
numbers of analog and digital inputs. A specially provided USB cable which acts as an
interface between the microcontroller and the computer. From the USB cable, we upload the
program to the microcontroller. Based on the program done in the microcontroller, we can
use the microcontroller for various applications such as rotating and to control the speed of
the motor. The stepper motor is being connected with the digital input of the circuit. Reset
button is provided in the microcontroller board to reset the program and also to upload the
other program [1].
A stepper motor is a brushless, synchronous electronic motor that converts electrical
pulses into mechanical movement. Every revolution of the stepper motor is divided into a
discrete number of steps, and the motor must be sent a separate pulse for each step. The
stepper motor can only a precise angle, the motor’s position can be controlled without any
feedback mechanism. As the electrical pulses increases in frequency, the step movement
changes into continuous rotation, with the speed of rotation directly proportional to the
frequency of the pulses. Step motors are used every day in both industrial and commercial
applications because of their low cost, high reliability, high torque at low speeds and a
simple, rugged construction that operates in almost any environment [2].
Annual University Journal on Innovative Research and Products 2018
Stepper motor is a 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 [3].
2. IMPLEMENTATION OF THE DESIGN
This design is based on both hardware and software. For the design to be
implemented, we will be using an ATMega32 microcontroller, interface with some other
hardware components. The functional block diagram of the design is shown in Figure 2.1.
angle reduces to half. Stepper motor rotating in full mode takes 4 steps to complete a revolution, so
step angle can be calculated as:
#define baud9600
#define ubrr_value((F_CPU/(16UL*baud))-1)
int main(void)
{
DDRD |= 0xff; //Set the direction of TxD pin as output
DDRD &= ~(1<<0); //Set the direction of RxD pin as input
DDRB = 0xff; //Set the direction of Unipolar Stepper Motor
while(1)
{
usart_tx(12); //Clear Virtual Terminal Screen
int count=0;
usart_tx_string("Enter password to open Gate");
for i=0;i<strlen(pw);i++)
{
temp = usart_rx();
usart_tx(temp);
if(temp != pw[i])
{
count++;
}
if(temp==13)
break;
}
if((count==0)&&(i=strlen(pw)))
{
Annual University Journal on Innovative Research and Products 2018
usart_tx_string("\rGate is openning...");
motor (); //Open the Gate
}
else
{
usart_tx_string("\r Password is not correct");
}
usart_tx_string("\r If you want to quit please press 'q'...");
temp1=usart_rx();
if(temp1=='q')break;
}
usart_tx(12);
usart_tx_string("Project End...");
}
void usart_init()
{
//Baudrate:9600
UBRRH=(ubrr_value>>8);
UBRRL=ubrr_value;
//Enable Transmiter and Receiver
UCSRB|=(1<<TXEN)|(1<<RXEN);
//Character size:8bits
UCSRC|=(1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0);
}
void usart_tx(chardata)
{
while(!(UCSRA&(1<<UDRE)));
UDR=data;
}
void usart_tx_string(char*string)
{
while(*string)
{
usart_tx(*string++);
_delay_ms(50);
}
usart_tx('\r');
}
unsigned char usart_rx()
{
while(!(UCSRA&(1<<RXC)));
return UDR;
}
void motor()
{
PORTB=0x08;
_delay_ms(100);
PORTB=0x0C;
_delay_ms(100);
PORTB=0x04;
_delay_ms(100);
PORTB=0x06;
_delay_ms(100);
PORTB=0x02;
_delay_ms(100);
PORTB=0x03;
_delay_ms(100);
PORTB=0x01;
Annual University Journal on Innovative Research and Products 2018
_delay_ms(100);
PORTB=0x09;
}
Figure 3.2 Open the Stepper Motor (Gate) Using the Password
Annual University Journal on Innovative Research and Products 2018
Authors
Kyi Kyi Khaing completed her Ph.D
specialising in computer hardware
technology from the University of
Computer Studies, Yangon in 2007. She
works in Faculty of Computer System and
Technology (FCST) at Myanmar Institute
of Information Technology (MIIT),
Mandalay.
Photo