0% found this document useful (0 votes)
91 views2 pages

Stepper Motor Interfacing With PIC16F877A

This document discusses interfacing a stepper motor with a PIC16F877A microcontroller. It defines the ports and bits used to control the stepper motor. The main program loop sequentially sets the bits of PORTD to different values to rotate the stepper motor in steps. This causes the motor to rotate clockwise and counter-clockwise over time in half step increments controlled by a 500ms delay between each step.

Uploaded by

Eysha qureshi
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)
91 views2 pages

Stepper Motor Interfacing With PIC16F877A

This document discusses interfacing a stepper motor with a PIC16F877A microcontroller. It defines the ports and bits used to control the stepper motor. The main program loop sequentially sets the bits of PORTD to different values to rotate the stepper motor in steps. This causes the motor to rotate clockwise and counter-clockwise over time in half step increments controlled by a 500ms delay between each step.

Uploaded by

Eysha qureshi
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/ 2

Stepper Motor Interfacing with PIC16F877A

Code:

#include <16f877a.h>
#fuses XT,NOWDT
#use delay (clock=4000000)

#BYTE PORTD = 0x08


#BYTE PORTC = 0x07
#BYTE TRISD = 0x88
#BYTE TRISC = 0x87

#BIT X = PORTC.0
#BIT Y = PORTC.1

void main ()
{
TRISD=0x00;

while (1)
{

delay_ms(500);
PORTD=0b00000001;
delay_ms(500);
PORTD=0b00000011;
delay_ms(500);
PORTD=0b00000010;
delay_ms(500);
PORTD=0b00000110;
delay_ms(500);
PORTD=0b00000100;
delay_ms(500);
PORTD=0b00001100;
delay_ms(500);
PORTD=0b00001000;
delay_ms(500);
PORTD=0b00001001;
delay_ms(500);

}
}

You might also like