Microcontroller › 8051 › plz let me know what is the error in this simple program…….. of lcd interfacing
- This topic has 5 replies, 2 voices, and was last updated 12 years, 2 months ago by AJISH ALFRED.
-
AuthorPosts
-
October 12, 2012 at 5:39 pm #1985priyankaParticipantplz let me know what is the error in this simple program……..#include <regx52.h>#define dataport P2;sbit rs = P0^5;sbit rw = P0^6;sbit e = P0^7;void lcd_cmd(unsigned char value){dataport = value;rs = 0;rw = 0;e = 1;msdelay(1);e = 0;}void lcd_data(unsigned char value){dataport = value;rs=1;rw=0;e=1;msdelay(1);e=0;}void msdelay(unsigned int item){unsigned int i,j;for(i=0;i<item;i++)for(j=0;j<1275;j++);}void main(){lcd_cmd(0x38);msdelay(250);lcd_cmd(0x0e);msdelay(250);lcd_cmd(0x06);msdelay(250);lcd_cmd(0x86);msdelay(250);lcd_data(‘M’);msdelay(250);lcd_data(‘D’);msdelay(250);lcd_data(‘E’);msdelay(250);}October 16, 2012 at 5:54 pm #8669AJISH ALFREDParticipant
Hi,
Why do you think that there is an error in the code? Please provide details about the problem that you are facing while running the code.
October 18, 2012 at 12:57 pm #8674priyankaParticipantactually erliar it was showing error near ‘=’ but now it is running perfectly. I dont know how….ayways thanks for responding…but what does it actually mean when we have an error of this type…
October 19, 2012 at 1:02 pm #8676AJISH ALFREDParticipantPlease copy and paste the complete ‘error dialoge’ here, I’ll try to explain.
October 28, 2012 at 12:26 pm #8696priyankaParticipantsir can u plz explain me the actual principle n logic of coversion of voltage into temp(display) – working of lm35 with respective codes…i am ok with the lcd display i want to know how to colabrate the output of adc with 8051…plz let me know the principle…..
October 29, 2012 at 4:58 pm #8701AJISH ALFREDParticipantAlright.
Lets take LM35;
LM35 is a 3-pin device with a VCC, GND and OUT (output pin). The voltage at the OUT pin is always the temperatue equivalent.
For example if the temperature is 32 degree, the voltage at the OUT pin will be 0.32 volts. All you have to do is to convert this anlog value to its digital equivalent using an ADC, so that the controller can read it.
Now the ADC;
ADC (Analog to Digital Converter) can convert the voltage at its analog input pin to corresponging digital at its digital pins.
For example an ADC0804 has an AIN (analog input pin). If you apply a 2 volts at this pin then the eight digital out pins (D0 to D7) will represent the binary equivalent of 2*(256/5); provided that you’ve connected the REF (ADC reference pin) to 5 volt.
As there are 8 digital output pins, you can directly connect the ADC to any of the 8-pin digital port of the controller and read the entire port. If you store it to a charater type data, it will represent the value;
(TEMPERATURE/100)(256/5).
Just to give you an idea, suggest you to cross check the expressions with the actual datasheet.
-
AuthorPosts
- You must be logged in to reply to this topic.