TELEGRAM

Monday, February 6, 2012

How to interface Servo Motor with 8051 Microcontroller (AT89C51)

Posted by Thiru at 9:30 PM 0 Comments



8051 Microcontroller Servo Motor ProjectThis project demonstrates the operation of a servo motor. The control signals for the rotation of the motor are provided by 8051 microcontroller (AT89C51). Here, the servo arm is rotated by 5° from the previous position, starting from 0 °as initial position. As the servo reaches a limit, the arm comes back to the initial position (0°). For basic concepts and know-how of a servo motor, refer to the article Servo Motor.


DESCRIBTION(click here)
  • The servo motor is controlled by feeding pulse width modulated (PWM) signal at the control wire of the servo motor. In addition a 4.8V (ideally 5V) DC supply is provided to the red lead of the servo. The black lead of the servo is connected to Ground.

    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. Before connecting to the control wire of servo, the output from the microcontroller is fed through a comparator IC (LM324) so that the signal is protected from any loss due to overloading.

    In the program, one of the 8051 timers is configured to generate flag after every 50 µs. Usually the pulse durations corresponding to 0° and 180° angular positions are 1ms and 2ms, but these durations may vary for different servos. Here, a pulse with ON time of 700 µs sets the motor closer to 0° and a pulse of 5500 µs sets the motor to 180°. A variable is taken which is initialized to a value 14. A function using timer is written that has the variable mentioned above as an argument. This function generates time delay in the multiples of 50 µs. 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.
    Every time the value of variable is increased by 5. This increases the ON time of pulse by 250 µs (5 x 50 µs). So every new pulse has an ON time 250 µs greater than the previous one. This is followed by an OFF time of 18 ms. In this way, at every loop the servo is rotated by 5° ahead.
    As the value of variable reaches above 100 it is again set to 14. This moves the servo back to the initial position of 0° after a full rotation.

CODE(click here)
  • // Program to rotate servo by 5 degree from previous position starting from 0 degree // 0 degree = 700us // 180 degree = 5500us // Timer1 pulse after 50us -23 #include<reg51.h> sbit output=P1^0;   //Output to motor int count; void delay(unsigned int msec)   // Function for delay { int i,j; for(i=0;i<msec;i++) for(j=0;j<1275;j++); } void timer(int msec) // Function for timer { int i; TR1=1; for(i=0;i<msec;i++) { while(TF1==0); TF1=0; } TR1=0; } void main() { int i; TMOD=0x20; // Mode2 TH1= -23; // 50usec timer output=0; count=14; while(1) { if(count>=100) count=14; else count=count+5; for(i=0;i<200;i++) { output=1; timer(count); output=0; timer(360); } delay(100); } }
COMPONENTS(click here)
  • AT89C51 Microcontroller
    IC LM324

0 comments:

THANKS FOR UR COMMENT ....

How to interface GPS with 8051 Microcontroller (AT89C51)

Posted by Thiru at 9:22 PM 1 Comment


Interface GPS with 8051 Microcontroller (AT89C51)GPS has become an efficient tool in the field of scientific use, commerce, surveillance and tracking. This project presents a small application based on Global Positioning System. It depicts the use of GPS module/receiver to find latitude and longitude of its location. The data obtained from GPS receiver (GPGGA sentence) is processed by the microcontroller to extract its latitude and longitude values.

The GPS Module has been interfaced with
AT89C51 and the location values are displayed on a 16x2 LCD interface.


DESCRIBTION(click here)
  • The GPS module continuously transmits serial data (RS232 protocol) in the form of sentences according to NMEA standards. The latitude and longitude values of the location are contained in the GPGGA sentence (refer NMEA format). In this program, these values are extracted from the GPGGA sentence and are displayed on LCD.

    The serial data is taken from the GPS module through
    MAX232 into the SBUF register of 8051 controller (refer serial interfacing with 8051). The serial data from the GPS receiver is taken by using the Serial Interrupt of the controller. This data consists of a sequence of NMEA sentences from which GPGGA sentence is identified and processed.

    The extraction of location values is done as follows. The first six bytes of the data received are compared with the pre-stored ($GPGGA) string and if matched then only data is further accounted for; otherwise the process is repeated again. From the comma delimited GPGGA sentence, latitude and longitude positions are extracted by finding the respective comma positions and extracting the data. The latitude and longitude positions extracted are displayed on the
    LCD interfaced with AT89C51.

    To obtain more details (other than latitude and longitude) from the GPS receiver, GPRMS sentence can be used. Refer next article.

    The circuit connections are as follows:
    Receiver1 (R1) of MAX232 has been used for the serial communication. The receiver pin of GPS module is connected to R1IN (pin13) of MAX232. R1OUT (pin 12) of MAX232 is connected to RxD (P3.0) of AT89C51.

    Pins 1-3 of port P1 (P1.0, P1.1 & P1.2 respectively) of AT89C51 are connected to the control pins (RS, R/W& EN) of LCD. The data pins of LCD are connected to Port P2 of the controller. The latitude and longitude positions are displayed on the LCD.
     


CODE(click here)
  • /* Basic program to show latitude and longitude on LCD extracted from GPGGA statement */ #include<reg51.h> #define port2 P2 sbit rs = P1^0; sbit rw = P1^1; sbit e = P1^2; char info[70]; char test[6]={"$GPGGA"}; char comma_position[15]; unsigned int check=0,i; unsigned char a; void receive_data(); void lcd_latitude(); void lcd_longitude(); //DELAY FUNCTION void delay(unsigned int msec) { int i,j ; for(i=0;i<msec;i++) for(j=0;j<1275;j++); } // LCD COMMAND SENDING FUNCTION void lcd_cmd(unsigned char item) { port2 = item; rs= 0; rw=0; e=1; delay(1); e=0; return; } // LCD DATA SENDING FUNCTION void lcd_data(unsigned char item) { port2 = item; rs= 1; rw=0; e=1; delay(1); e=0;     return; } // LCD STRING SENDING FUNCTION void lcd_string(unsigned char *str) { int i=0; while(str[i]!='\0') {         lcd_data(str[i]);         i++;         delay(10);    }         return; } // SERIAL PORT SETTING void serial() { TMOD=0x20;      //MODE=2 TH1=0xfa;     // 4800 BAUD SCON=0x50  ;    // SERIAL MODE 1 ,8- BIT DATA ,1 STOP BIT ,1 START BIT , RECEIVING ON TR1=1;         //TIMER START } void find_comma() { unsigned int i,count=0; for(i=0;i<70;i++) { if(info[i]==',') { comma_position[count++]=i; }     } } void compare() {   IE=0x00;       //Interrupt disable find_comma();   //Function to detect position of comma in the string lcd_latitude();   //Function to show Latitude lcd_longitude(); //Function to show Longitude check=0; IE=0x90;   //Interrupt enable } void receive_data()   interrupt 4   { info[check++]=SBUF;  //Read SBUF if(check<7)         //Condition to check the required data     { if(info[check-1]!=test[check-1]) check=0;     } RI=0; } void lcd_shape()      //Function to create shape of degree { lcd_cmd(64); lcd_data(10); lcd_data(17); lcd_data(17); lcd_data(10); lcd_data(0); lcd_data(0); lcd_data(0); lcd_data(0); } void lcd_latitude() //Function to display Latitude { unsigned int c2=comma_position[1]; //Position of second comma lcd_shape(); lcd_cmd(0x01);         // Clear LCD display lcd_cmd(0x84);         //Move cursor to position 6 of line 1 lcd_string("LATITUDE"); //Showing Latitude lcd_cmd(0xC0); //Beginning of second line   lcd_data(info[c2+1]); lcd_data(info[c2+2]); lcd_data(0); //Degree symbol lcd_data(info[c2+3]); lcd_data(info[c2+4]); lcd_data(info[c2+5]); lcd_data(info[c2+6]); lcd_data(info[c2+7]); lcd_data(info[c2+8]); lcd_data(info[c2+9]); lcd_data(0x27);          //ASCII of minute sign(') lcd_data(info[c2+10]); lcd_data(info[c2+11]); delay(250); } void lcd_longitude() { unsigned int c4=comma_position[3]; lcd_cmd(0x01);            //Clear LCD display lcd_cmd(0x84);            //Move cursor to position 4 of line 1 lcd_string("LONGITUDE"); //Showing Longitude lcd_cmd(0xC0);    //Begining of second line   lcd_data(info[c4+1]); lcd_data(info[c4+2]); lcd_data(info[c4+3]); lcd_data(0); lcd_data(info[c4+4]); lcd_data(info[c4+5]); lcd_data(info[c4+6]); lcd_data(info[c4+7]); lcd_data(info[c4+8]); lcd_data(info[c4+9]); lcd_data(info[c4+10]); lcd_data(0x27);               //ASCII of minute sign(') lcd_data(info[c4+11]); lcd_data(info[c4+12]); delay(250); } void main() { serial(); lcd_cmd(0x38);        //2 LINE, 5X7 MATRIX lcd_cmd(0x0e);         //DISPLAY ON, CURSOR BLINKING IE=0x90; while(1) { if(check==69) compare(); } }
COMPONENTS(click here)
  • AT89C51 Microcontroller
    MAX232
    LCD

1 comments:

THANKS FOR UR COMMENT ....

Categories

Labels

AERONAUTICAL AEROSPACE AGRICULTURE ANDROID Android project titles Animation projects Artificial Intelligence AUTOMOBILE BANK JOBS BANK RECRUITMENTS BIG DATA PROJECT TITLES Bio instrumentation Project titles BIO signal Project titles BIO-TECHNOLOGY BIOINFORMATICS BIOMEDICAL Biometrics projects CAREER CAT 2014 Questions CHEMICAL CIVIL Civil projects cloud computing COMP- PROJ-DOWN COMPUTER SCIENCE PROJECT DOWNLOADS COMPUTER(CSE) CONFERENCE Data mining Projects Data protection. Design projects DIGITAL SIGNAL PROCESSING IEEE Project titles Dot net projects EBOOKS ELECTRICAL MINI PROJECTS ELECTRICAL PROJECTS DOWNLOADS ELECTRONICS MINI PROJECTS ELECTRONICS PROJECT DOWNLOADS EMG PROJECTS employment Engineering projects Exams Facts final year projects FOOD TECHNOLOGY FREE IEEE 2014 project Free IEEE Paper FREE IEEE PROJECTS GATE GAte scorecard GOVT JOBS Green projects GSM BASED Guest authors HIGHWAY IEEE 2014 projects ieee 2015 projects IEEE computer science projects IEEE Paper IEEE PAPER 2015 ieee project titles IEEE projects IEEE Transactions INDUSTRIAL INNOVATIVE PROJECTS INTERFACING IT IT LIST Java projects labview projects LATEST TECHNOLOGY list of project centers Low cost projects m.com MARINE Matlab codes MATLAB PROJECT TITLES MATLAB PROJECTS MBA MBA 2015 projects MCA MECHANICAL MECHANICAL PROJECTS DOWNLOAD MINI PROJECTS modelling projects MP3 MP3 cutter Mp4 Networking topics ns2 projects online jobs PETROCHEMICAL PHYSIOLOGICAL MODELLING projects physiotheraphy Projects Power electronics power system projects PRODUCTION project centers project downloads Prosthesis projects RAILWAY RECRUITMENT 2012 Recent RECENT TECHNOLOGY RECENT TECHNOLOGY LIST RECRUITMENT Rehabilitation projects renewable power respiration projects RESUME FORMAT. Ring Tone Cutter Robotics projects. Robots in medical social network jobs Solar projects Songs Cutter Speech-music separation-Abstract structural engineering TECHNOLOGY technology management TELE COMMUNICATION Telegram project TEXTILE TOP ENGINEERING COLLEGES Training VLSI

Disclaimer

This blogs is an effort to club the scattered information about engineering and project titles and ideas available in the web. While every effort is made to ensure the accuracy of the information on this site, no liability is accepted for any consequences of using it. Most of the material and information are taken from other blogs and site with the help of search engines. If any posts here are hitting the copyrights of any publishers, kindly mail the details to educations360@gmail.com It will be removed immediately.

Alexa Rank

back to top