![]() |
DC Motor |
This tutorial will describe, how to interface a DC motor with a Microcontroller and in this tutorial, I will use pic18f2550 microcontroller. Generally, to control a DC motor we need voltage 12v with 300mA current. Basically a microcontroller works on 5v and can't provide the current follow to operate a DC motor.As we know a motor can produce back emf, we need other technique to operate .The solution will be a H-Bridge circuit or L293D ic.
![]() |
H-Bridge Circuit |
![]() |
L293D |
![]() |
DC Motor Rotation Controlling |
Now Create a new project in Proteus. If you are a beginner, just follow the instructions.
Proteus Circuit:
![]() |
How to Create a New Project in Proteus 8_Step1 |
![]() |
How to Create a New Project in Proteus 8_Step2 |
![]() |
How to Create a New Project in Proteus 8_Step3 |
![]() |
How to Pick parts from Proteus library |
![]() |
How to find Power ,Ground etc |
![]() |
Interface DC Motor with pic Microcontroller |
MikroC Project :
![]() |
Create a project in mikroC_Step_1 |
![]() |
Create a project in mikroC_Step_2 |
![]() |
Create a project in mikroC_Step_3 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void main() {
CMCON = 0x07; // To turn off comparators
ADCON1 = 0x0F;
Trisc=0x00;
delay_ms(1000);
while(1){
/////// Step1: Rotate Motor Clockwise
PORTC.F0=1;
PORTC.F1=0;
delay_ms(4000); //delay for 4 sec
/////// Step2: Stop the Motor
PORTC.F0=0;
PORTC.F1=0;
delay_ms(4000); //delay for 4 sec
/////// Step3: Rotate Motor Anti-Clockwise
PORTC.F0=0;
PORTC.F1=1;
delay_ms(4000); //waiting for 4 sec
/////// Step4: Again Stop The Motor
PORTC.F0=1;
PORTC.F1=1;
delay_ms(4000); //delay for 4 sec
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Now run the program and save the hex file on your computer .
![]() |
Run project in mikroC |
![]() |
Load hex to microcontroller |
![]() |
Run Proteus Project |
Result :
![]() |
DC motor in Clockwise direction |
![]() |
DC motor in Anti-Clockwise directionDownload Proteus File & Hex fileJust Click on '' SKIP ADD '' and You will get the download linkThank You! |
LINK CAIDO :(
ReplyDeleteLink was updated.
DeleteVery nice blog...
ReplyDeleteGreat information provided. We also provide PIC Microcontroller Training in Noida. I appreciate your work.
Thank you.
Delete