Servo Motor Control using Microcontroller PIC16F877A

Servo Motor Control

Servo motors are widely used in robotics and industries for motion control. They can be controlled by PWM signals where the required angle of rotation can be located by a particular PWM signal. So In this article we’ll see in detail on PWM servo control and how servo motor control using pic16f877a is possible. Servo motors have an output shaft which is connected to an arm and the mechanical connections are attached with this arm, which can rotate a maximum of 180 degree. It has three connection wires: V positive, V negative and control signal. Signal is normally connected with microcontrollers to feed PWM signal as required. The position of servo arm is determined by PWM signal:Servo Motor Control

  • 1500µs for servo neutral position.
  • If the signal is less than 1500µs then the arm moves back to a particular angle (anti clockwise).
  • If the signal value is greater than 1500µs then the arm move clock wise to a particular angle depending on the signal value.

Read: How to generate PWM using PIC microcontroller?
PWM DC motor speed controller using PIC16F877A

PWM of 1000µS will move the arm to zero position which is the minimum position and 2000µS will move the arm to maximum. Servo motor has inbuilt control circuit to convert the PWM signal to the position value, it has a movable potentiometer which is used to locate the position by balancing mechanism.

Servo motor control circuit

Components Required

  1. PIC16F877A
  2. Crystal 20MHz
  3. Capacitor (33pf x 2)
  4. Resistor (10K x 3)
  5. Servo motor
  6. Push buttons x 3

Working

  • Here I use three switches to rotate the arm to -90 degree (minimum position), zero degree and +90 degree.
  • Arm rotates these three positions by pressing the switches.
  • The application of this in a robot is to turn the front wheel by pressing the buttons on the remote, but here rotation is 90 degree so you have to minimize this by changing the PWM signal.Servo Motor Control schematic
    • Here we have used the mikroC compiler.
    • Port B is used to connect servo motor and controlling switch, the controlling switches are connected to +5V through a 10K (called pull up) resistor.
    • The control signal of a servo motor is connected to 7th bit of port and switches are connected to 0th, 1st and 2nd pin of PORTB.
    • Three sub functions are used to move the arm left, straight and right for -90, 0 and +90 rotation.
    • In main function, there is an infinite loop which continuously checks the 0, 1 and 2nd pins of PORTB.

     

     

    Read more: Servo Motor Control using Microcontroller PIC16F877A

Leave a Comment

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