Interfacing Servo Motor With PIC Microcontroller - MPLAB XC8
Interfacing Servo Motor With PIC Microcontroller - MPLAB XC8
24
AUG
third wire is used to provide control signals to control exact angular position of the servo
motor. Its color varies for different manufactures such as YELLOW, BROWN, WHITE etc.
Servo Motor shaft can be moved to desired position by using Pulse Width Modulated (
http://www.electrosome.com/pwm-pulse-width-modulation/)
(PWM
http://electrosome.com/servo-motor-pic-mplab-xc8/
1/10
11/12/2014
Unlike DC Motors, reversing the power supply polarity does not reverse the rotation instead
of it may damage the control circuitry.
Servo Motors can be easily interfaced with PIC Microcontroller. Here for demonstration we
are using PIC 16F877A and VIGOR VS-10A servo motor. The required pulse width of this
servo motor ranges from 800S to 2200S and rotation angle is greater than or equal to
170. Its operating voltage range is 4.8V to 6V.
(http://electrosome.com/wp-content/uploads/2012/06/Servo-Angular-RotationPulse-Width-Modulation1.jpg)
http://electrosome.com/servo-motor-pic-mplab-xc8/
2/10
11/12/2014
Circuit Diagram
(http://electrosome.com)
(http://electrosome.com/cart/)
(http://electrosome.com/wp-content/uploads/2014/08/Interfacing-Servo-Motor-with-PICMicrocontroller.jpg)
Interfacing Servo Motor with PIC Microcontroller (http://electrosome.com/servo-motor-pic-microcontroller/)
Tip : Use separate power supplies for PIC and Servo Motor OR use proper filtering
capacitors otherwise ripples produced by the Servo Motor may affect the working of PIC.
3/10
11/12/2014
#pragma config
#pragma config
#pragma config
#pragma config
#pragma config
#pragma config
//END CONFIG
PWRTE = OFF
BOREN = ON
LVP = OFF
CPD = OFF
WRT = OFF
CP = OFF
4/10
11/12/2014
__delay_ms(2000);
servoRotate90(); //90 Degree
__delay_ms(2000);
servoRotate180(); //180 Degree
}while(1);
}
Hope you can understand the working of the above program. If you have any doubts just
comment below.
Download
You can download the entire project files here.
Servo Motor (http://electrosome.com/wp-content/uploads/2014/08/Servo-Motor.zip)
http://electrosome.com/servo-motor-pic-mplab-xc8/
5/10
11/12/2014
electroSome
Follow
+1
+ 470
CATE G O RI E S : MP L A B X C8 (HTTP : / / E L E CTRO S O ME . CO M/ CA TE G O RY / TUTO RI A L S / P I C-MI CRO CO NTRO L L E R/ MP L A B X C8 / ), P I C MI CRO CO NTRO L L E R (HTTP : / / E L E CTRO S O ME . CO M/ CA TE G O RY / TUTO RI A L S / P I C-MI CRO CO NTRO L L E R/ ),
TUTO RI A L S (HTTP : / / E L E CTRO S O ME . CO M/ CA TE G O RY / TUTO RI A L S / )
TAG S : MI CRO CO NTRO L L E R (HTTP : / / E L E CTRO S O ME . CO M/ TA G / MI CRO CO NTRO L L E R/ ), MP
B
L ALOVE
IT , SHARE IT
http://electrosome.com/servo-motor-pic-mplab-xc8/
6/10
11/12/2014
2 Comments
electroSome
Login
Share Favorite
Sort by Best
a month ago
MG996R
how can i drive this servo , pleasee ?? your code dont work with this one..
Reply Share
Ligo George
Mod
Reply Share
WHAT'S THIS?
ALSO ON ELECTROSOME
https://www.youtube.com/user/l...
Subscribe
Privacy
RECENT POSTS
USING PUSH BUTTON SWITCH WITH PIC MICROCONTROLLER CCS C
(HTTP://ELECTROSOME.COM/SWITCH-PIC-MICROCONTROLLER-CCS-C/)
7/10
11/12/2014
SUBSCRIBE
EMAIL
SUBMIT
http://electrosome.com/servo-motor-pic-mplab-xc8/
8/10
11/12/2014
RECENT COMMENTS
Even if you are using 0.47 ohm resistor... it actual value may [..]
Yes it can. .but the accuracy of A/D converter degrades as Vref [..]
http://electrosome.com/servo-motor-pic-mplab-xc8/
9/10
11/12/2014
Hi, I want to build a multiple timer with 16F877a, ds1307, and [..]
NEYAMAT (MAILTO:[email protected])
on Interfacing Relay with PIC Microcontroller (http://electrosome.com/interfacing-relay-with-picmicrocontroller/#comment-3311)
Hi, what if, for example, my Vref+ is 20mV and my Vref- [..]
http://electrosome.com/servo-motor-pic-mplab-xc8/
10/10