fazeelat
Newbie level 4
I am using ADC0808, microcontroller 89S52, and 16X2 Alpha-numeric LCD to display the sensed data using sensor (LM35) connected to ADC0808.
my step size is 10mV by keeping Vref=2.56 but can't obtain accurate temperature on LCD please help me in conversion of binary output of ADC into ASCII data for LCD
here is the C code written in keil ..... plz someone help me
my step size is 10mV by keeping Vref=2.56 but can't obtain accurate temperature on LCD please help me in conversion of binary output of ADC into ASCII data for LCD
here is the C code written in keil ..... plz someone help me
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 #include<reg52.h> sbit ale=P1^0; //address latch enable sbit oe=P1^3; //output enable sbit sc=P1^1; //start conversion sbit eoc=P1^2; //end of conversion sbit clk=P1^7; // clock sbit ADD_A=P1^4; // Address pins for selecting input channels. sbit ADD_B=P1^5; sbit ADD_C=P1^6; sfr lcd_data_pin=0xA0; //P2 port sbit rs=P3^5; sbit rw=P3^6; sbit en=P3^7; sbit led=P3^4; sfr input_port=0x80; //P0 port unsigned int value; void timer0() interrupt 1 // Function to generate clock of frequency 500KHZ using Timer 0 interrupt. { clk=~clk; } void delay(unsigned int count) // Function to provide time delay in msec. { int i,j; for(i=0;i<count;i++) for(j=0;j<1275;j++); } void lcd_command(unsigned char comm) //Function to send command to LCD. { lcd_data_pin=comm; en=1; rs=0; rw=0; delay(5); en=0; } void lcd_data(unsigned char disp) //Function to send data to LCD. { lcd_data_pin=disp; en=1; rs=1; rw=0; delay(5); en=0; } lcd_dataa(unsigned char *disp) //Function to send string data to LCD. { int i=0; while(disp[i]!='\0') { lcd_data(disp[i]); i++; delay(10); } return; } void lcd_ini() //Function to inisialize the LCD { lcd_command(0x38); delay(2); lcd_command(0x0F); delay(2); lcd_command(0x80); //Force cursor to blink at line 1 positon 0 delay(2); } void BCD(unsigned char value) // Binary to decimal conversion to send the data to LCD { unsigned char x,d1,d2,d3,d4,d5,d6; x=value/10; d1=value%10; d2=x%10; d3=x/10; d4=d1+48; d5=d2+48; lcd_command(0x01); lcd_dataa("TEMP :"); lcd_data(d5); lcd_command(0x87); lcd_data(d4); lcd_command(0x88); lcd_data(223); delay(10); lcd_data('C'); delay(10); led=0; } void adc() //Function to drive ADC { while(1) { ADD_C=0; // Selecting input channel 2 using address lines ADD_B=0; ADD_A=1; delay(2); ale=1; delay(2); sc=1; delay(1); ale=0; delay(1); sc=0; while(eoc==1); while(eoc==0); oe=1; value=input_port; BCD(value); lcd_command(0x85); delay(2); oe=0; } } void main() { input_port=0xFF; eoc=1; ale=0; oe=0; sc=0; TMOD=0x02; //timer0 setting for generating clock of 500KHz using interrupt enable mode. TH0=0xFD; IE=0x82; TR0=1; lcd_ini(); adc(); }
Last edited by a moderator: