Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem in interfacing two sensors temperature and humildity sensor adc0808 mp89s52

Status
Not open for further replies.

rubalkumar

Newbie level 4
Newbie level 4
Joined
May 15, 2013
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,357
i am getting a problem in interfacing a two sensors simultaneously with 89s52 along with adc0808,
am using temperature and humiditiy sensors to adc and then to mp?but am not getting the correct output of temperature , it is fluctuating..what shud i do?plz help me.. after 5 days i have final demo.. and plz help me..
 

i am getting a problem in interfacing a two sensors simultaneously with 89s52 along with adc0808,
am using temperature and humiditiy sensors to adc and then to mp?but am not getting the correct output of temperature , it is fluctuating..what shud i do?plz help me.. after 5 days i have final demo.. and plz help me..

Both, temperature and humidity, are quantities that do not change rapidly.
Take several readings over, say, 5s, 50s, 500s, or so, and calculate averages …
:wink:
IanP
 

this is my code... and my project is fuzzy based...automatic control of speed of fan..m using two fans..and using two sensors temp. as well humidity sensors through adc 0808 to 89s52mc


.. help me plz out of this..
#include<reg51.h>


#define input_adc1 P1 //Input port to read the values of ADc1 say Humidity

#define input_adc2 P3 //Input port to read the values of ADc2 say Temperature



sbit rd1= P0^0; // Write pin. It is used to start the conversion.
sbit wr1= P0^1; // Read pin. It is used to extract the data from internal register to the output pins of ADC1.
sbit intr1= P0^2; // Interrupt pin. This is used to indicate the end of conversion. It goes low when conversion is complete.




sbit rd2= P0^3; // Write pin. It is used to start the conversion.
sbit wr2= P0^4; // Read pin. It is used to extract the data from internal register to the output pins of ADC2.
sbit intr2= P0^5; // Interrupt pin. This is used to indicate the end of conversion. It goes low when conversion is complete.




sbit cf_low=P2^0;
sbit cf_med=P2^1;
sbit cf_high=P2^2;
sbit cf_vhigh=P2^3;





sbit ef_low=P2^4;
sbit ef_med=P2^5;
sbit ef_high=P2^6;




unsigned char key=0;
int temp_data=0;
int humidity_data=0;
int humidity=0;
int temperature=0;






void cfan_stop()
{
cf_low=0;
cf_med=0;
cf_high=0;
cf_vhigh=0;

}



void cfan_low()
{
cf_low=1;
cf_med=0;
cf_high=0;
cf_vhigh=0;

}



void cfan_med()
{
cf_low=0;
cf_med=1;
cf_high=0;
cf_vhigh=0;

}

void cfan_high()
{
cf_low=0;
cf_med=0;
cf_high=1;
cf_vhigh=0;



}

void cfan_vhigh()
{
cf_low=0;
cf_med=0;
cf_high=0;
cf_vhigh=1;

}




void efan_stop()
{
ef_low=0;
ef_med=0;
ef_high=0;



}



void efan_low()
{
ef_low=1;
ef_med=0;
ef_high=0;


}

void efan_med()
{
ef_low=0;
ef_med=1;
ef_high=0;



}




void efan_high()
{
ef_low=0;
ef_med=0;
ef_high=1;


}




void delay(unsigned char count)
{
unsigned char i;
unsigned int j;
for(i=0;i<count;i++)
for(j=0;j<1275;j++);



}




void get_data()
{
key++;
temp_data=temp_data+input_adc1;
humidity_data=humidity_data+input_adc2;




if(key==11)
{



temp_data=temp_data/key;
temp_data=temp_data*10;
temp_data=temp_data/25;
temperature=temp_data-3;

humidity_data=humidity_data/key;
humidity_data=humidity_data*10;
humidity_data=humidity_data/25;


humidity=humidity_data-3;
key=0;
temp_data=0;
humidity_data=0;




}


}

void fuzzy_logic()
{
if(temperature<=10 && humidity <=25)
{


cfan_stop();
efan_stop();

}
else if(temperature<=10 && humidity>25 && humidity<75)
{


cfan_stop();
efan_low();

}
else if(temperature<=10 && humidity>50 && humidity<100)
{


cfan_low();
efan_med();

}
else if(temperature>10 && temperature<=20 && humidity <=25)
{


cfan_stop();
efan_stop();

}
else if(temperature>10 && temperature<=20 && humidity>25 && humidity<=75)
{


cfan_stop();
efan_med();

}
else if(temperature>10 && temperature<=20 && humidity>50 && humidity<=100)
{


cfan_low();
efan_med();

}
else if(temperature>10 && temperature<=30 && humidity <=25)
{


cfan_low();
efan_stop();

}
else if(temperature>10 && temperature<=30 && humidity>25 && humidity<=75)
{


cfan_med();
efan_low();

}
else if(temperature>10 && temperature<=30 && humidity>50 && humidity<=100)
{


cfan_high();
efan_high();

}
else if(temperature>20 && temperature<=40 && humidity<=25)
{


cfan_high();
efan_stop();

}
else if(temperature>20 && temperature<=40 && humidity>25 && humidity<=75)
{


cfan_high();
efan_med();

}
else if(temperature>20 && temperature<=40 && humidity>50 && humidity<=100)
{


cfan_vhigh();


efan_stop();

}
else if(temperature>30 && temperature<=40 && humidity<=25)
{


cfan_high();
efan_stop();

}
else if(temperature>30 && temperature<=40 && humidity>25 && humidity<=75)
{


cfan_vhigh();
efan_med();

}
else if(temperature>30 && temperature<=40 && humidity>50 && humidity<=100)
{



cfan_vhigh();
efan_high();

}




}

void main()
{



P1=0xFF;
P3=0xFF;


P0=0x00;
P2=0x00;


while(1)
{
rd1=1;
wr1=0;
delay(2);
wr1=1;



rd2=1;
wr2=0;
delay(2);
wr2=1;


while(intr1==1||intr2==1);



rd1=0;

delay(2);
intr1=1;

rd2=0;
delay(2);
intr2=1;


get_data();


fuzzy_logic();



}



}
 

Where are you calculating the average of the readings? You are just adding the value found in each loop but not calculating the average.


How can you do this?


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
rd1=1;
wr1=0;
delay(2);
wr1=1;
 
 
 
rd2=1;
wr2=0;
delay(2);
wr2=1;
 
 
while(intr1==1||intr2==1);
 
 
 
rd1=0;
 
delay(2);
intr1=1;
 
rd2=0;
delay(2);
intr2=1;



You have to read one channel at a time then get the value into a variable and then read the next channel. You are issuing read for both channels first, so, only the 2nd channel is read properly.



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
rd1=1;
wr1=0;
delay(2);
wr1=1;
 
while(intr1);
 
rd1=0;
delay(2);
 
temp_data = input_adc1;
//convert temp_data to string and display here
 
rd2=1;
wr2=0;
delay(2);
wr2=1;
 
while(intr2);
 
rd2=0;
delay(2);
intr2=1;
 
temp_data = input_adc2;
//convert temp_data to string and display here

 
Last edited:
the above written code for calculation of temp. and humidity values is corrct.plz help me..




void get_data()
{
key++;
temp_data=temp_data+input_adc1;
humidity_data=humidity_data+input_adc2;




if(key==11)
{



temp_data=temp_data/key;
temp_data=temp_data*10;
temp_data=temp_data/25;
temperature=temp_data-3;

humidity_data=humidity_data/key;
humidity_data=humidity_data*10;
humidity_data=humidity_data/25;


humidity=humidity_data-3;
key=0;
temp_data=0;
humidity_data=0;

- - - Updated - - -

it will be very thnkful,,if u will provide me the correct code...plz reply soon
 

range for temperature 0 to 60 n celsius
and for humidity it it should be in percentage..
plz rep. thanks for helping in advance..
 

Percentage of what? How do I know your sensor value? What is the range of humidity your sensor works for? Why don't you answer the simple questions? Show your circuit.

91095d1368604963-0808.jpg
 

Attachments

  • 0808.jpg
    0808.jpg
    163.8 KB · Views: 97

Percentage of what? How do I know your sensor value? What is the range of humidity your sensor works for? Why don't you answer the simple questions? Show your circuit.

91095d1368604963-0808.jpg

HUMIDITY SENSOR MODULE SY-HS-220 These module convert the relative humidity to the output voltage. Specifications: RATED VOLTAGE DC 5.0V CURRENT CONSUMTION <-3.0mA OPERATING TEMPERATURE RANGE 0-60°C OPERATING HUMIDITY RANGE 30-90%RH STORABLE TEMPERATURE RANGE -30°C ˜ 85°C STORABLE HUMIDITY RANGE within 95%RH STANDARD OUTPUT RANGE DC 1.980 mV (at 25°C, 60%RH) ACCURACY ± 5% RH (at 25°C, 60%RH) 1356498987sy-hs-230-humidity-sensor-module-250x250.jpg

and for temperature it is lm35 (+2 to 150 c)

,, right now i donot have any circuit layout..bt i will provide after an hour
 
Last edited:

Operating temperature and humidity range? Is it device operating parameters? Post datasheet of the device. What is the max voltage that humidity sensor module give? Is the range within 0 to 5V DC?
If its max o/p is 5V then what is the humidity for that value. Is the device o/p linear?
 

Untitled.pngUntitled1.pnghumidity sensor module sy-hs-220

- - - Updated - - -

Untitled.pngUntitled1.pngHUMIDITY SENSOR MODULE SY-HS-220

- - - Updated - - -

sir reply me soon.. m waitng and m in problem
 

Compile this project for your Clock frequency and test it in hardware and reply.

Try this new code. Circuit is attached. Change port pins as needed. You have to use 3V reference for ADC.
 

Attachments

  • 8051 ADC Code v2.rar
    81.3 KB · Views: 71
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top