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

Wa0200

This document outlines an open-ended lab assignment to interface a stepper motor with an Atmega32 microcontroller. The objective is to apply concepts learned in the lab course to control the direction of a stepper motor. A MikroC Pro compiler and Proteus simulation software are required. The task is to write C code to make the stepper motor turn clockwise or anticlockwise depending on the state of a switch. Port pins are used to control the motor direction and speed. The code and circuit are to be tested on an MC-8600 trainer board and applications of stepper motors explained.

Uploaded by

Aroosa Bibi
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)
22 views8 pages

Wa0200

This document outlines an open-ended lab assignment to interface a stepper motor with an Atmega32 microcontroller. The objective is to apply concepts learned in the lab course to control the direction of a stepper motor. A MikroC Pro compiler and Proteus simulation software are required. The task is to write C code to make the stepper motor turn clockwise or anticlockwise depending on the state of a switch. Port pins are used to control the motor direction and speed. The code and circuit are to be tested on an MC-8600 trainer board and applications of stepper motors explained.

Uploaded by

Aroosa Bibi
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

Microprocessors and Microcontrollers

Stepper Motor Interface using Atmega32


Open Ended Lab
(2021-2025)

Objective
To use all the concepts learnt in lab course so far and apply to interface Stepper motor with Atmega32.

Requirements

● MC-8600 board (Stepper motor)

● MikroC Pro for AVR

● Proteus Professional

Lab Task
Using the concepts of AVRAtmega32, C programming and DC motor, interface a unipolar Stepper motor
with Atmega32.

● If SW=0, the stepper motor moves clockwise

● If SW=1, the stepper motor moves anticlockwise

Turn PD0 on for clockwise and PD1 on for anticlockwise direction. Verify your results using Proteus
simulation.

void main() {

DDRD &=~ (1<<0);

PORTD |= (1<<0);

DDRD &=~ (1<<1);

PORTD |= (1<<1);

DDRC = 0xFF;

while(1){

if((PIND&0x02)==0)

{
PORTC = 0x01;

Delay_ms(400);

PORTC = 0x02;

Delay_ms(400);

PORTC = 0x04;

Delay_ms(400);

PORTC = 0x08;

Delay_ms(400);

else{

PORTC = 0x08;

Delay_ms(400);

PORTC = 0x04;

Delay_ms(400);

PORTC = 0x02;

Delay_ms(400);

PORTC = 0x01;

Delay_ms(400);

}
sbit LCD_RS at PORTB0_bit;
sbit LCD_EN at PORTB1_bit;
sbit LCD_D4 at PORTB2_bit;
sbit LCD_D5 at PORTB3_bit;
sbit LCD_D6 at PORTB4_bit;
sbit LCD_D7 at PORTB5_bit;

sbit LCD_RS_Direction at DDB0_bit;


sbit LCD_EN_Direction at DDB1_bit;
sbit LCD_D4_Direction at DDB2_bit;
sbit LCD_D5_Direction at DDB3_bit;
sbit LCD_D6_Direction at DDB4_bit;
sbit LCD_D7_Direction at DDB5_bit;

void main() {
DDRD &=~ (1<<0);
PORTD |= (1<<0);
DDRD &=~ (1<<1);
PORTD |= (1<<1);
DDRC = 0xFF;
DDB1_bit=1; //this pin sets bit1 to the output
PORTB1_bit=0; //bit0 is reset to enable LCD. Must be declared.
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
while(1){
if((PIND&0x02)==0)
{
Lcd_Out(1,2,"ANTICLOCKWISE"); // Write text in first row
Lcd_Out(2,2,"DIRECTION"); // Write text in second row
PORTC = 0x08;
Delay_ms(400);
PORTC = 0x04;
Delay_ms(400);
PORTC = 0x02;
Delay_ms(400);
PORTC = 0x01;
Delay_ms(400);

}
else{

Lcd_Cmd(_LCD_CLEAR); // Clear display

Lcd_Out(1,2,"CLOCKWISE"); // Write text in first row


Lcd_Out(2,2,"DIRECTION"); // Write text in second row
PORTC = 0x01;
Delay_ms(400);
PORTC = 0x02;
Delay_ms(400);
PORTC = 0x04;
Delay_ms(400);
PORTC = 0x08;
Delay_ms(400);
}
}
}
Also run the designed logic on MC-8600 trainer board and verify the results.

Explain the working and applications of Stepper motor.

Note: Refer to Chapter 14 of your textbook to implement this lab.

You might also like