Arduino Projects    |   Raspberry Pi  |     Electronic Circuits   |   Electronics Reference Design Library  |   AVR    |    PIC    |    8051    |    Electronic Projects

Servo Motor control through Keypad using 8051 Microcontroller (AT89C51)

Summary

Developed By: 
Himanshu Choudhary
The basic operations of servo motor control have been discussed in interfacing servo with 8051. This project allows the servo motor to move to an angle specified by the user. The pulse train required to rotate the servo is produced by AT89C51 microcontroller. The desired angle of rotation is provided through a 4x3 keypad interfaced to the microcontroller. A 16x2 LCD is also connected with the microcontroller to display the angle of rotation entered by the user.
 
8051 Microcontroller based Servo motor control project

Description

For basic operations and control of servo motor, refer interfacing servo with 8051. The first pin of port P1 (P1^0) of AT89C51 microcontroller is set as the output pin to provide control signal to the servo motor. Ports P0 and P2 are used to interface keypad and data pins of LCD, respectively. Ports P1^3, P1^4 and P1^5 are connected to RS, RW and EN pins of LCD, respectively. (For more details, refer LCD interfacing with 8051)
 
 
Before connecting to the control wire of servo, the output from the microcontroller (P1^0) is fed through a comparator IC (LM324) so that the signal is protected from any loss due to overloading.
 
When the circuit is powered, the LCD prompts the user to enter the angle of rotation. The user can enter the angle in degrees through keypad. The angle entered by the user is also displayed on the LCD screen. As the user presses ‘*’ button of keypad, the angle of rotation is accepted by the microcontroller and the servo moves to the user defined angular position. If an angle greater than 180° is entered, the difference of the input with 180° is considered as the angle of rotation.
 
The program uses one of the 8051 timers to generate a 50 µs delay. A timer function is written which produces delay in multiples of 50 µs. A variable is taken as the argument to this function that determines the multiples. Initially when the microcontroller executes program, a pulse with ON time of 700 µs (14 x 50 µs) followed by OFF time of 18 ms is generated. This shifts the servo horn to 0° angle.
 
The angle entered by the user is stored in a variable whose value is added to the argument of the timer function. For example, if the user enters 90, the argument of the timer function is increased by 90 and becomes 104 (90 + 14). The ON time for the next train of pulses then corresponds to multiple of 50 µs. In this case the ON time of the next train of pulses will be 5200 µs (104 x 50 usec) followed by OFF time of 18 ms. This maintains the servo at 90° angle until the user enters the next angle.

 

Circuit Diagram

Video

Code

This Code is only visible to Registered users. Please Login/Register

 

Components

LM324 | LM324N Datasheet
IC LM324

LM324 is a 14pin IC consisting of four independent operational amplifiers (op-amps) compensated in a single package. Op-amps are high gain...

AT89C51 Microcontroller, Atmel 89C51 Controller Image
AT89C51 Microcontroller

AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ATMEL 89C51 has 4KB of Flash programmable and erasable read only memory (...

16 x 2 LCD | 16x2 Character LCD Module
LCD

 

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. These modules are preferred over seven segments...

Free TI Design & Simulation Tools

 

WEBENCH Design Center

WEBENCH Design Environments are unique and powerful software tools that deliver customized power, lighting, filtering, clocking and sensing designs in seconds. These easy-to-use tools help you generate, optimize and simulate designs that conform to your unique specifications. They allow you to make value-based tradeoffs at a design, system and supply chain level before your design is committed to production.


Design & Simulation Tools

Power Design

 


Sensors, Filter, Clock and Amplifier Design


Download Tools, Models and Symbols


Resources

 

You are here