Forum Replies Created
-
AuthorPosts
-
preethi
ParticipantThe input which is to be converted to digital form can be selected by using three address lines using three address lines. So, that you can connect three sensors at a time..
the code is as follows… but you have to write the logics of 3 sensors which you are using….i have left space for that ..and also once check the ports that you are using for adc, lcd connection as per your circuit diagram..i have declared roughly..
#include<reg51.h>sbit ale=P1^0; // Address latch enablesbit oe=P1^3; // Output enablesbit sc=P1^1; // Start conversionsbit eoc=P1^2; // End of conversionsbit clk=P1^7; // Clocksbit 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; //Port P2sbit rs=P3^0;sbit rw=P3^1;sbit en=P3^6;sfr input_port=0x80; //Port P0void 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(1);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(1);en=0;}lcd_data(unsigned char *disp) //Function to send string data to LCD.{int x;for(x=0;disp[x]!=0;x++){lcd_data(disp[x]);}}here you declare the function of your 3 sensors logic seperatlyvoid lcd_ini() //Function to inisialize the LCD{lcd_command(0x38); // for using 8-bit 2 row LCDdelay(5);lcd_command(0x0F); // for display on cursor blinkingdelay(5);lcd_command(0x80);delay(5); //Force cursor to blink at line 1 positon 0}void adc( ) //Function to drive ADC{while(1){if(temp1==0){ADD_C=0; // Selecting input channel 1 using address linesADD_B=0;ADD_A=0;}if(temp1==1){ADD_C=0; // Selecting input channel 2 using address linesADD_B=0;ADD_A=1;}if(temp1==2){ADD_C=0; // Selecting input channel 3 using address linesADD_B=1;ADD_A=0;}delay(2);ale=1;delay(2);sc=1;delay(1);ale=0;delay(1);sc=0;while(eoc==1);while(eoc==0);oe=1;BCD();delay(2);oe=0;temp1++;if(temp1=)
temp1=0;}}void main( ){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;temp1=0;key1=0;lcd_ini();here you add your desired sensor call statementadc( );}March 2, 2013 at 4:14 pm in reply to: 8051 problem asm code. unfinished temperature sensor, need help please. #9219preethi
Participanthi bob……..in your circuit you have connected adc0804 data pins to microcontroller port1 that means p1.0 to p1.7….But in your program you have given it to microcontroller port2 that means p2
and also
As per your circuit you have connected rd, wr, cs, intr pins of adc0804 to port 3……. but in the program it is declared as port1
So, make changes in your code for adc0804 to connect data pins of adc0804 to port1 and control pins rd, wr, cs, intr to port3 of microcontroller
correct lines as per your circuit are
rd equ P3.0 ;Read signal P3.0
wr equ P3.1 ;Write signal P3.1cs equ P3.2 ;Chip Select P3.2intr equ P3.3 ;INTR signal P3.3adc_port equ P1 ;ADC data pins P1preethi
Participantuse keil micro vision software to convert c code to hexa file
-
AuthorPosts