Microcontroller › 8051 › Interfacing AT89S51 with ultrasonic sensor and LCD
- This topic has 40 replies, 28 voices, and was last updated 7 years, 1 month ago by
Shirsendu Das.
-
AuthorPosts
-
July 8, 2013 at 7:11 am #10111
ggc
Participantsend the circuit diagram i will send u the complete code to u my mail id is [email protected]
October 2, 2013 at 5:58 am #10503aniket r kambli
Participantpls help me with 80c51 ultrasonic distance finder using hc-sr04 module and led display assembly code
November 13, 2013 at 1:12 pm #10598Robert Wilson
Participantpls i neen help.Vending machines are more common these days and these can be seen all around. The vending machines dispense the drink of your choice based on the item you select. You might have come across these machines dispensing either hot drinks or cool drinks.
In this task you are expected to design a vending machine that can dispense both hot and cool drinks of you choice. The requirements are as follows,
- Turn “ON” the machine
- Select hot or cool drink
- Select options in the hot drink
- Select options in the cool drink
- Select the drink of your choice
- Display the availability/unavailability of the drink
- Select options in case of unavailability
- Option to select another drink (go to main menu)
- Display the cost of that drink
- Count the cash credited and display the amount
- Beep when the amount is paid fully
- Vending machine dispense the selected item
- pls i need idea to write the codes. in keli uvision and interfacing with lcd
March 7, 2014 at 6:01 am #11224ANITHA
Participant#include<reg52.h>#define First_Line 0x80#define Second_Line 0xc0#define Curser_On 0x0f#define Curser_Off 0x0c#define Clear_Display 0x01#define Data_Port P0sbit Lcd_rs = P2^7;sbit Lcd_rw = P2^6;sbit Lcd_en = P2^5;sbit RX= P3^2;sbit TX= P3^5;void Distance_Measure();void Lcd8_Init();void Lcd8_Command(unsigned char);void Lcd8_Write(unsigned char,unsigned char);void Lcd8_Display(unsigned char,const unsigned char*,unsigned int);void Lcd8_Decimal2(unsigned char,unsigned char);void Lcd8_Decimal3(unsigned char,unsigned char);void Lcd8_Decimal4(unsigned char,unsigned int);void Delay(unsigned int);void del();unsigned char i,inch1,inch2,result,obj_distance,rept,sec,j,a=0,c=0,kc,cu=0xc0,l,e[20],num[20],n,v[20];unsigned long int count=0,count1=0;void main(){EA=1;ET0=1;TMOD=0x01;TH0=TL0=0x00;TR0=1;relay2=0;Lcd8_Init();Delay(65000);Lcd8_Display(0x80,”Ultrasonic “,16);Lcd8_Display(0xc0,” “,16);Delay(65000);Delay(65000);Lcd8_Display(0xC0,”Distance: “,16);while(1){Distance_Measure();}}void Distance_Measure(){count=count1=0;TH0=0x00;TL0=0x00;TR0=0;for(i=0;i<10;i++){TX=0;Delay(1000);TX=1;Delay(10);TX=0;while(RX==0);TR0=1;while(RX==1);TR0=0;count=TH0<<8;count=count|TL0;TH0=TL0=0x00;count1=count1+count;Delay(5000);}count=count1/10;inch1=count%10000/1000;inch2=count%1000/100;result=(inch1*10)+inch2;obj_distance=result-2;Lcd8_Decimal3(0XCb,obj_distance);}void Lcd8_Init(){Lcd8_Command(0x38); //to select function setLcd8_Command(0x06); //entry mode setLcd8_Command(0x0c); //display onLcd8_Command(0x01); //clear display}void Lcd8_Command(unsigned char com){Data_Port=com;Lcd_en=1;Lcd_rs=Lcd_rw=0;Delay(125);Lcd_en=0;Delay(125);}void Lcd8_Write(unsigned char com,unsigned char lr){Lcd8_Command(com);Data_Port=lr; // DataLcd_en=Lcd_rs=1;Lcd_rw=0;Delay(125);Lcd_en=0;Delay(125);}void Lcd8_Display(unsigned char com,const unsigned char *word,unsigned int n){unsigned char Lcd_i;for(Lcd_i=0;Lcd_i<n;Lcd_i++){Lcd8_Write(com+Lcd_i,word[Lcd_i]);}}void Lcd8_Decimal2(unsigned char com,unsigned char val){unsigned int Lcd_hr,Lcd_t,Lcd_o;Lcd_hr=val%100;Lcd_t=Lcd_hr/10;Lcd_o=Lcd_hr%10;Lcd8_Write(com,Lcd_t+0x30);Lcd8_Write(com+1,Lcd_o+0x30);}void Lcd8_Decimal3(unsigned char com,unsigned char val){unsigned int Lcd_h,Lcd_hr,Lcd_t,Lcd_o;Lcd_h=val/100;Lcd_hr=val%100;Lcd_t=Lcd_hr/10;Lcd_o=Lcd_hr%10;Lcd8_Write(com,Lcd_h+0x30);Lcd8_Write(com+1,Lcd_t+0x30);Lcd8_Write(com+2,Lcd_o+0x30);}void Delay(unsigned int del){while(del–);}i am not getting output for this code.here u r using timer 1 pin is tx=P3^5; but tx pin will always high then u r using rx=P3^2;it is low after detecting the object it will be high.ET0=1;u r not using the timer 1 pin then how the interrupt will enable…………….while i am debugging this program i got access violation error at lcd int();….can you please explain for me sir i cannot understand sir.pls sirMarch 7, 2014 at 6:06 am #11225ANITHA
Participanti need c code for measuring the distance by using ultrasonic sensor……………can u pls send me
March 8, 2014 at 4:40 am #11243ANITHA
Participanty u r enabling the interrupt
March 12, 2014 at 9:08 pm #11294MOHIT SARAF
Participanthow can i generate o/p using buzzzer instead of led where buzzer frequency depends on the range usin c code
April 13, 2014 at 5:37 pm #11546sai
Participantwhy we will use sbit is that mandatory?
February 18, 2015 at 5:10 am #12623boominathan
Participantsir
i need ultrasonic sensor and 8051 using object identifier. anyone help me
February 25, 2015 at 2:24 pm #12647Mayank
ParticipantPlease!upload the circuit diagram of above project
April 27, 2015 at 4:21 pm #12837nishant
Participantvery nice..
May 13, 2015 at 8:11 pm #12887NIDHI SHARMA
ParticipantSir i need a C code for the interfacing of ultrasonic sensor with AT89s51.Pls reply
May 16, 2015 at 9:07 am #12890nitesh sinha
Participanti am doing distance measurement using at89c51 and ultrasonic sensor but i m not getting anything on the seven-segment display ,i am using three seven-segment display ,the code is given below
ORG 00HMOV DPTR,#SSDisplay // moves the address of LUT to DPTRMOV P1,#00000000B // sets P1 as output portMOV P0,#00000000B // sets P0 as output portCLR P3.0 // sets P3.0 as output for sending triggerSETB P3.1 // sets P3.1 as input for receiving echoMOV TMOD,#00100000B // sets timer1 as mode 2 auto reload timerMAIN: MOV TL1,#210D // loads the initial value to start counting fromMOV TH1,#210D // loads the reload valueMOV A,#00000000B // clears accumulatorSETB P3.0 // starts the trigger pulseACALL DELAY1 // gives 10uS width for the trigger pulseCLR P3.0 // ends the trigger pulseHERE: JNB P3.1,HERE // loops here until echo is receivedBACK: SETB TR1 // starts the timer1HERE1: JNB TF1,HERE1 // loops here until timer overflows (ie;48 count)CLR TR1 // stops the timerCLR TF1 // clears timer flag 1INC A // increments A for every timer1 overflowJB P3.1,BACK // jumps to BACK if echo is still availableMOV R4,A // saves the value of A to R4ACALL DLOOP // calls the display loopSJMP MAIN // jumps to MAIN loopDELAY1: MOV R6,#2D // 10uS delayLOOP1: DJNZ R6,LOOP1RETDLOOP: MOV R5,#50D // loads R5 with 100DBACK1: MOV A,R4 // loads the value in R4 to AMOV B,#100D // loads B with 100DDIV AB // isolates the first digitSETB P1.0 // activates LED display unit D1ACALL DISPLAY // calls DISPLAY subroutineMOV P0,A // moves digit drive pattern for 1st digit to P0ACALL DELAY // 1mS delayACALL DELAYMOV A,B // moves the remainder of 1st division to AMOV B,#10D // loads B with 10DDIV AB // isolates the second digitCLR P1.0 // deactivates LED display unit D1SETB P1.1 // activates LED display unit D2ACALL DISPLAYMOV P0,A // moves digit drive pattern for 2nd digit to P0ACALL DELAYACALL DELAYMOV A,B // moves the remainder of 2nd division to ACLR P1.1 // deactivates LED display unit D2SETB P1.2 // activates LED display unit D3ACALL DISPLAYMOV P0,A // moves the digit drive pattern for 3rd digit to P0ACALL DELAYACALL DELAYCLR P1.2 // deactivates LED display unit D3DJNZ R5,BACK1 // repeats the display loop 100 timesRETDELAY: MOV R7,#250D // 1mS delayLABEL2: DJNZ R7,LABEL2RETDISPLAY: MOVC A,@A+DPTR // gets the digit drive pattern for the content in ARETSSDisplay: DB 0C0H // Hex code to display DISPLAY 0DB 0F9H // DISPLAY 1DB 0A2H // DISPLAY 2DB 0B0H // DISPLAY 3DB 99H // DISPLAY 4DB 94H // DISPLAY 5DB 84H // DISPLAY 6DB 0F8H // DISPLAY 7DB 80H // DISPLAY 8DB 90H // DISPLAY 9ENDAugust 23, 2015 at 7:34 am #13206Electronics king
Participantyou can visit
Openelectronicsproject.blogspot.com
August 23, 2015 at 7:38 am #13207Electronics king
Participantmay be openelectronicsproject.blogspot.com help you
-
AuthorPosts
- You must be logged in to reply to this topic.