dolphinlabs
...
Doplhin labs
News

PIC18F4520-DC Motor Interfacing


 

         Program Statement: Interfacing of DC motor with PIC184520

Connections: RC0=IN1, RC1=IN2, RC2=EN12

RD0=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 +12V supply of DC motor to +12V supply pin and GND of DC motor interface to GND pin of supply

4.      Connect IN1, IN2, EN12 pins of DC motor to RC0, RC1 and RC2 pins of microcontroller respectively.

5.      Connect OUT1 and OUT2 pins of DC motor interface to DC motor.

6.      Connect push button to RD0 pin of controller.

 

 

 

Program Code:

#include<P18F4520.h>

#define IN1 PORTCbits.RC0 //define RC0 as IN1

#define IN2 PORTCbits.RC1 //define RC1 as IN2

#define EN12 PORTCbits.RC2 //define RC2 as EN12

#define sw1 PORTDbits.RD0 //define RD0 as sw1

void delay(int);

void main()

{

TRISD=0x01; //make PORT RD0 as a input

TRISC=0x00; //make PORTC as a ouput

while(1)

{

if(sw1==0) //if sw1 is pressed

{

// motor moves clockwise

EN12=1;

IN1=0;

IN2=1;

delay(50);

}

else

{

//motor moves anti clockwise

EN12=1;

IN1=1;

IN2=0;

delay(50);

}

}

}

void delay(int x)

{

int i,j;

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

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

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Get SOCIAL







SAFE & SECURE SHOPPING

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