Let's come back to our topic. Previously, I have discussed the DC Motor control in Proteus ISIS and Stepper Motor Control in Proteus ISIS. So, now we are left with only one motor which is Servo Motor. Today's topic, as the name suggests is about the Servo Motor Control using PIC Microcontroller. The microcontroller, I am going to use in this tutorial is PIC16F877A. In this tutorial, I will design a circuit for Servo Motor Control and will also provide the code, which I have used for Servo Motor Control. If you are working on a Servo motor then you should also check Control Servo Motor with Arduino. in which I have design a servo motor control circuit using Arduino board. The code is also given there. Moreover, you should also check Angle control of Servo Motor with 555 Timer.
A Brief Intro About Servo Motor
- Servo motor is simply another motor having a much better control system already installed in it.
- The beaut of servo lies in its precise angular movement. In other words, you can move the motor at any angle you want. Like I want to move the motor to 30 degrees then I can do it quite easily in servo, which is not possible in DC or stepper.
- Moreover, it has just 3 wires to control, one is GND, one is Vcc and the third one which is usually the middle one is for controlling purposes.
- Now when you apply signal to the middle one, it starts moving. Now, how much it will move depends on the length of signal applied. If the signal applied is small, it will cover small distance.
Servo Motor Control Circuit in Proteus ISIS
- First of all select the below components from the Proteus library and add it in your workspace.
Components Used:
These components are used while designing this simulation:- PIC16F877a.
- Servo Motor.
- Crystal Oscillator. ( 16MHz )
- Resistors. ( We need 3 resistors of 10k ohm )
- Capacitors. ( We need 2 capacitors of 33pF )
- Two Push Buttons.
Working Principle:
- Now, design your circuit as shown in the below figure:
- When I started this simulation the motor moved to the -90 degree angle. Now when I press the button, it will move in the opposite direction.
- That's how it works. Just a simple motor nothing much complicated.
PIC Microcontroller Code for Servo Motor Control
- Here's the code which I have used for controlling this servo motor. Burn this code in your PIC Microcontroller.
#define M1 PORTB.F7 #define M2 PORTB.F6 #define B1 PORTD.F0 #define B2 PORTD.F1 int a; void main() { TRISB=0; TRISD=0xFF; PORTB = 0; a = 1; while(1){ if((B1 == 0) && (a==1)){ PortB=0xFF; delay_ms(100); PortB=0x00; delay_ms(1); PortB=0xff; a=0; } if(B2 == 0){ PortB=0x00; } } }Note:
- The code and the Proteus Simulation has already been emailed to all the subscribed members. If you are new here then subscribe to our newsletter and it will be emailed to you as well.