interfacing servo motor with pic microcontroller - mplab xc8
TRANSCRIPT
8/10/2019 Interfacing Servo Motor With PIC Microcontroller - MPLAB XC8
http://slidepdf.com/reader/full/interfacing-servo-motor-with-pic-microcontroller-mplab-xc8 1/10
11/12/2014 Interfacing Servo Motor with PIC Microcontroller - MPLAB XC8
http://electrosome.com/servo-motor-pic-mplab-xc8/
(http://electrosome.com/wp-
content/uploads/2012/06/Servo-Motor.gif)
Servo Motor (http://electrosome.com/servo-motor/)
24 AUG Interfacing Servo Motor with PIC Microcontroller – MPLABXC8BY LIGO GEORGE (HTTP:/ /ELECTROSOME.COM/AUTHOR/LIJOPPANS/) / 2 COMMENT S
(HTTP:/ /ELECTROSOME.COM/SERVO-MOTOR-PIC-MPLAB-XC8/#DISQUS_THREAD)
Servo Motor is an ordinary geared dc motor
equipped with closed loop servo mechanism
which uses position feedback to control exact
angular position of the rotor. These are
commonly used in robotic arms, legs etc. Servo
Motors do not rotate continuously, their rotation
is limited to fixed angles. Usually these motorshave rotation limit from 90º to 180° and some
special have limits 360° or more.
Servo Motors usually have three wires. RED
and BLACK wires are used to provide power.
Required voltage will depend upon the type of
servo you are using, so please refer the
specifications given by the manufacture. The
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://www.electrosome.com/pwm-pulse-width-modulation/)) signals on the control wire.
Keep Your Cloud PrivateAll of Our Servers Are the Most Secure & Powerful. Chat to
8/10/2019 Interfacing Servo Motor With PIC Microcontroller - MPLAB XC8
http://slidepdf.com/reader/full/interfacing-servo-motor-with-pic-microcontroller-mplab-xc8 2/10
11/12/2014 Interfacing Servo Motor with PIC Microcontroller - MPLAB XC8
http://electrosome.com/servo-motor-pic-mplab-xc8/ 2
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 800μS to 2200μS 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-Rotation-
Pulse-Width-Modulation1.jpg)
Keep Your CloudPrivate
All of Our Servers Are the
Most Secure & Powerful.
Chat to Save!
8/10/2019 Interfacing Servo Motor With PIC Microcontroller - MPLAB XC8
http://slidepdf.com/reader/full/interfacing-servo-motor-with-pic-microcontroller-mplab-xc8 3/10
11/12/2014 Interfacing Servo Motor with PIC Microcontroller - MPLAB XC8
http://electrosome.com/servo-motor-pic-mplab-xc8/ 3
Servo Angular Rotation Pulse Width Modulation ( http://electrosome.com/pwm-pulse-width-modulation/)
Circuit Diagram
(http://electrosome.com/wp-content/uploads/2014/08/Interfacing-Servo-Motor-with-PIC-
Microcontroller.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.
MPLAB XC8 Code
#define _XTAL_FREQ 8000000
#include <xc.h>
// BEGIN CONFIG
#pragma config FOSC = HS
#pragma config WDTE = OFF
(http://electrosome.com)
(http://electrosome.com/cart/)
8/10/2019 Interfacing Servo Motor With PIC Microcontroller - MPLAB XC8
http://slidepdf.com/reader/full/interfacing-servo-motor-with-pic-microcontroller-mplab-xc8 4/10
11/12/2014 Interfacing Servo Motor with PIC Microcontroller - MPLAB XC8
http://electrosome.com/servo-motor-pic-mplab-xc8/ 4
#pragma config PWRTE = OFF
#pragma config BOREN = ON
#pragma config LVP = OFF
#pragma config CPD = OFF
#pragma config WRT = OFF
#pragma config CP = OFF
//END CONFIG
void servoRotate0() //0 Degree{
unsigned int i;
for(i=0;i<50;i++)
{
RB0 = 1;
__delay_us(800);
RB0 = 0;
__delay_us(19200);
}
}
void servoRotate90() //90 Degree
{
unsigned int i;
for(i=0;i<50;i++)
{
RB0 = 1;
__delay_us(1500);
RB0 = 0;
__delay_us(18500);
}}
void servoRotate180() //180 Degree
{
unsigned int i;
for(i=0;i<50;i++)
{
RB0 = 1;
__delay_us(2200);
RB0 = 0;
__delay_us(17800); }
}
void main()
{
TRISB = 0; // PORTB as Ouput Port
do
{
servoRotate0(); //0 Degree
8/10/2019 Interfacing Servo Motor With PIC Microcontroller - MPLAB XC8
http://slidepdf.com/reader/full/interfacing-servo-motor-with-pic-microcontroller-mplab-xc8 5/10
8/10/2019 Interfacing Servo Motor With PIC Microcontroller - MPLAB XC8
http://slidepdf.com/reader/full/interfacing-servo-motor-with-pic-microcontroller-mplab-xc8 6/10
11/12/2014 Interfacing Servo Motor with PIC Microcontroller - MPLAB XC8
http://electrosome.com/servo-motor-pic-mplab-xc8/ 6
electroSome
+ 470
Follow +1
2,877 people like this. Be the first of your friends.Like
CATEGORIES: MPLAB XC8 (HTTP:/ /ELECTROSOME.COM/CATEGORY/TUTORIALS/PIC-MICROCONTROLLER/MPLAB-XC8/) , PI C MICROCONTROLLER (HTTP:/ /EL ECTROSOME.COM/CATEGORY/TUTORIALS /PIC-MICROCONTROLLER/) ,
TUTORIALS (HTTP:/ /ELECTROSOME.COM/CATEGORY/TUTORIALS/)
TAGS: MICROCONTROLLER (HTTP:/ /EL ECTROSOME.COM/TAG/MICROCONTROLLER/) , MPLA B
(HTTP:/ /ELECTROSOME.COM/TAG/MPLAB/) , MPLAB XC8 (HTTP:/ /ELECTROSOME.COM/TAG/MPLAB-XC8/) , PIC
(HTTP:/ /EL ECTROSOME.COM/TAG/PIC/) , PROTEUS (HTTP:/ /EL ECTROSOME.COM/TAG/PROTEUS/) , SERVO MOTOR
(HTTP:/ /EL ECTROSOME.COM/TAG/SERVO-MOTOR/), TUTORIALS (HTTP:/ /ELE CTROSOME.COM/TAG/TUTORIALS/)
LOVE IT, SHARE IT
8/10/2019 Interfacing Servo Motor With PIC Microcontroller - MPLAB XC8
http://slidepdf.com/reader/full/interfacing-servo-motor-with-pic-microcontroller-mplab-xc8 7/10
11/12/2014 Interfacing Servo Motor with PIC Microcontroller - MPLAB XC8
http://electrosome.com/servo-motor-pic-mplab-xc8/ 7
Led Blinking using Raspberry Pi
•
— Our small youtube channel :
https://www.youtube.com/user/l...
Siren Generator using IC UM3561
•
— Yes, it is fine..
Wireless Transmitter and Receiver using
ASK RF Module
•
— Above circuits are 100%
working... Make sure that you are using
correct oscillator resistors..
HT12E Encoder IC for Remote Control
Systems
•
— 1.what data corresponds to an
open circuit?,,i,e,when a data input pin is
not grounded,what data value does it
2 Comments
• •
Copper Masud •
MG996R
how can i drive this servo , pleasee ?? your code dont work with this one..
• •
Ligo George • Mod
use pulse width according to that servo specifications.
RECENT POSTS
USING PUSH BUTTON SWITCH WITH PIC MICROCONTROLLER – CCS C
(HTTP://ELECTROSOME.COM/SWITCH-PIC-MICROCONTROLLER-CCS-C/)
USING UART OF PIC MICROCONTROLLER – MPLAB XC8 (HTTP://ELECTROSOME.COM/UART-PIC-
MICROCONTROLLER-MPLAB-XC8/)
8/10/2019 Interfacing Servo Motor With PIC Microcontroller - MPLAB XC8
http://slidepdf.com/reader/full/interfacing-servo-motor-with-pic-microcontroller-mplab-xc8 8/10
11/12/2014 Interfacing Servo Motor with PIC Microcontroller - MPLAB XC8
http://electrosome.com/servo-motor-pic-mplab-xc8/ 8
LED BLINKING USING RASPBERRY PI (HTTP://ELECTROSOME.COM/LED-
BLINKING-RASPBERRY-PI/)
GETTING STARTED WITH PIC MICROCONTROLLER – CCS C COMPILER
(HTTP://ELECTROSOME.COM/GETTING-STARTED-PIC-CCS-C/)
INTERFACING SERVO MOTOR WITH PIC MICROCONTROLLER – MPLAB XC8
(HTTP://ELECTROSOME.COM/SERVO-MOTOR-PIC-MPLAB-XC8/)
INTERFACING LCD WITH PIC MICROCONTROLLER – MPLAB XC8
(HTTP://ELECTROSOME.COM/LCD-PIC-MPLAB-XC8/)
INTERFACING HC-SR04 ULTRASONIC SENSOR WITH PIC MICROCONTROLLER
(HTTP://ELECTROSOME.COM/HC-SR04-ULTRASONIC-SENSOR-PIC/)
SIREN GENERATOR USING IC UM3561 (HTTP://ELECTROSOME.COM/SIREN-
GENERATOR-IC-UM3561/)
SUBMIT
SUBSCRIBE
8/10/2019 Interfacing Servo Motor With PIC Microcontroller - MPLAB XC8
http://slidepdf.com/reader/full/interfacing-servo-motor-with-pic-microcontroller-mplab-xc8 9/10
11/12/2014 Interfacing Servo Motor with PIC Microcontroller - MPLAB XC8
http://electrosome.com/servo-motor-pic-mplab-xc8/ 9
RECENT COMMENTS
LIGO GEORGE (HTTP://WWW.ELECTROSOME.COM/)
on Voltmeter and Ammeter using PIC Microcontroller (http://electrosome.com/voltmeter-ammeter-
pic/#comment-3321)
LIGO GEORGE (HTTP://WWW.ELECTROSOME.COM/)
on Getting Started with PL2303 USB to UART Converter (http://electrosome.com/pl2303-usb-to-uart-
converter/#comment-3320)
LIGO GEORGE (HTTP://WWW.ELECTROSOME.COM/)
on Voltmeter and Ammeter using PIC Microcontroller (http://electrosome.com/voltmeter-ammeter-
pic/#comment-3319)
PREETHI SHIVANAND (MAILTO:[email protected])
on Voltmeter and Ammeter using PIC Microcontroller (http://electrosome.com/voltmeter-ammeter-
pic/#comment-3314)
MOHAMMED SUHEL (MAILTO:[email protected])
on Getting Started with PL2303 USB to UART Converter (http://electrosome.com/pl2303-usb-to-uart-
converter/#comment-3312)
Even if you are using 0.47 ohm resistor... it actual value may [..]
You can connect TX to RX and RX to TX.. 3.3 and [..]
Yes it can. .but the accuracy of A/D converter degrades as Vref [..]
im sorry , i meant to say in series. I have used [..]
I am new to pl2303. I want to interface this module to [..]
8/10/2019 Interfacing Servo Motor With PIC Microcontroller - MPLAB XC8
http://slidepdf.com/reader/full/interfacing-servo-motor-with-pic-microcontroller-mplab-xc8 10/10
11/12/2014 Interfacing Servo Motor with PIC Microcontroller - MPLAB XC8
htt // l t / t i l b 8/ 10
Terms and conditions (http://electrosome.com/terms-conditions/) / Privacy Policy (http://electrosome.com/privacy-policy/) /
Shipping Policy (http://electrosome.com/shipping-policy/) / Refund Policy (http://electrosome.com/refund-policy/) /
About Us (http://electrosome.com/about-us/)
electroSome - Discover... Develop... Deliver...
NEYAMAT (MAILTO:[email protected])
on Interfacing Relay with PIC Microcontroller (http://electrosome.com/interfacing-relay-with-pic-
microcontroller/#comment-3311)
JIMMY NUTRON (MAILTO:[email protected])
on Voltmeter and Ammeter using PIC Microcontroller (http://electrosome.com/voltmeter-ammeter-
pic/#comment-3310)
SUJITH THYCATTUSSERY (MAILTO:[email protected])
on Generating PWM with PIC Microcontroller using CCP Module (http://electrosome.com/pwm-pic-
microcontroller/#comment-3309)
Hi, I want to build a multiple timer with 16F877a, ds1307, and [..]
Hi, what if, for example, my Vref+ is 20mV and my Vref- [..]
Please post a tutorial on 50hz pure sinewave generator.