Interfacing Servo Motor with PIC Microcontroller using MPLAB and XC8

This is our 11th tutorial of Learning PIC microcontrollers using MPLAB and XC8. In this tutorial we will learn How to control Servo Motor with PIC Microcontroller. If you have already worked with Servo motors you can skip the first half of this tutorial but if you are new to servo motor itself then continue reading.

Interfacing Servo Motor with PIC Microcontroller using MPLAB and XC8
Interfacing Servo Motor with PIC Microcontroller

Till now, we have covered many basic tutorials like  LED blinking with PICTimers in PICinterfacing LCDinterfacing 7-segmentADC using PIC etc. If you are an absolute beginner, then please visit the complete list of PIC tutorials here and start learning.

In our previous tutorial we learnt how to generate PWM signals using PIC Microcontroller, the signals were generated based on the value read from the potentiometer. If you have understood all programs then, Congratulations you have already coded for a Servo motor also. YES, Servo motors respond to the PWM signals (which we create using timers here) we will learn why and how in this tutorial. We will simulate and build the hardware setup for this project and you can find the detailed Video at the end of this Tutorial.

What is a Servo Motor?

A Servo Motor is a type of actuator (mostly circular) that allows angular control. There are many types of Servo motors available but in this tutorial let us concentrate on the hobby servo motors shown below.Servo motors

Hobby servos are a popular because they are the inexpensive method of motion control. They provide an off-the-shelf solution for most of the R/C and robotic hobbyist’s needs. They also eliminate the need to custom design a control system for each application.

Most of the hobby servo motors have a rotational angel of 0- 180° but you can also get 360° servo motor if you’re interested. This tutorial uses a 0- 180° servo motor.  There are two types of Servo motors based on the gear, one is the Plastic Gear Servo Motor and the other is Metal Gear Servo Motor. Metal gear is used in places where the motor is subjected to more wear and tear, but it comes only at a high price.

Servo motors are rated in kg/cm (kilogram per centimetre) most hobby servo motors are rated at 3kg/cm or 6kg/cm or 12kg/cm. This kg/cm tells you how much weight your servo motor can lift at a particular distance. For example: A 6kg/cm Servo motor should be able to lift 6kg if the load is suspended 1cm away from the motors shaft, the greater the distance the lesser the weight carrying capacity. Learn here the Basics of Servo motor.

Interfacing Servo Motors with Microcontrollers:

Interfacing hobby Servo motors with MCU is very easy. Servos have three wires coming out of them. Out of which two will be used for Supply (positive and negative) and one will be used for the signal that is to be sent from the MCU. In this tutorial we will be using a MG995 Metal Gear Servo Motor which is most commonly used for RC cars humanoid bots etc.

For more detail: Interfacing Servo Motor with PIC Microcontroller using MPLAB and XC8

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.