dolphinlabs
...
Doplhin labs
News

PIC18F4520-Stepper motor Interfacing


 

         Program statement: Interfacing of stepper motor with PIC18F4520 controller

Connections: PORT RC0-RC3 = Stepper motor pins using ULN interface.

PORT RB1 = push button

Hardware connections for PIC184520 Board:

1.      Give supply to the Board with the help of adapter.

2.      Connect +5V pin of PIC controller to +5v supply and GND pin of controller to GND pin of supply.

3.      Connect push button to RB1 pin. If it is pressed motor moves clockwise, otherwise motor will move anticlockwise.

4.      Connect RC0-RC3 pins of controller to IN1-IN4 pins of stepper motor interface block.

5.      Connect OUT1-OUT4 pins of controller stepper motor.

6.      Connect 12V pin of stepper motor interface block to +12v supply pin and GND pin of stepper motor interface to GND pin of supply.

 

 

 

 

 

Program Code:

 

#include<P18F4520.h>

#define SW PORTBbits.RB1 //define pin RB1 as SW

void delay(int ms);

void main()

{

TRISC=0x00; //make PORTC as output port

TRISBbits.TRISB1=1; //make pin RB1 as input

while(1)

{

if(SW==0) //if switch is pressed

{

PORTC=0x66; //rotate clockwise

delay(55);

PORTC=0x33;

delay(55);

PORTC=0x99;

delay(55);

PORTC=0xcc;

delay(55);

}

else if(SW==1) //if switch is nit pressed

{

PORTC=0x66; //rotate anticlockwise

delay(55);

PORTC=0xcc;

delay(55);

PORTC=0x99;

delay(55);

PORTC=0x33;

delay(55);

}

}

}

void delay(int k)

{

int i,j;

for(i=0;i<255;i++)

for(j=0;j<k;j++);

}

 

 

 

 


Get SOCIAL







SAFE & SECURE SHOPPING

visa card master card maestro card
Maverick IT Industries Pvt. Ltd.