Driving a stepper motor with PIC and L293D

Status
Not open for further replies.

Wingmax

New Member
This is continuous from "Driving a stepper motor manually". This time we'll drive a bipolar stepper motor with P16F628 and L293D motor controller.

Please refer block diagram for connections:



The following are the codes, written for Hitec c compilar.
The program will make one complete revolution on a 7.5 degree/ step motor.
You can download "delay.c" and "delay.h" program from Hitec site, no need to write it your self.


#include <pic.h>
#include "delay.c"
#include "delay.h"

__CONFIG(WDTDIS & XT & UNPROTECT & LVPDIS);

#define XTAL 4000000 //crystal frequency- 4MHz

const char step[] = {5, 6, 10, 9}; //These are 4 basic steps. Stored in m

main()

{
int i, j;
TRISB = 0; //Set PORTB as output
for (j = 0; j<= 47; j++) //Repeat the four basic steps 48 times
{
for (i = 0; i <=3; i++) //The four basic steps
{
PORTB = step;
DelayMs(10);
}
}
while (1); //Stop here, do nothing.
}


Next we'll run a unipolar stepper motor with little modification...........
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…