HS1101 humidity sensor

Status
Not open for further replies.

Mizoro

Newbie level 4
Joined
Mar 25, 2012
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,344
hey guys, i need to read from hs1101 humidity sensor wired up in this pic attached i'm using PIC18f2550 and miKroC for compiler i'm using timer0 interrupt for calculating time of decay but i need to get the right reading without using any of pic comparators , please someone help me
 

Well, you could use the ADC, no?
thanx for reply, i already use ADC ,i start the sequence by activating that terminal as a digital high then low to let the cap charge ,in this moment i start the timer and wait for the voltage to reach some level ,but i don't know whether the delay i use is enough for the cap to charge or not and i don't know the proper voltage level to stop timer at either ,I've been trying so many times but i can't reach a stable reading and i can't utilize that reading since the onl equation i find is :RH = (time*10 - RHconst)/24 and that is the problem
 

You've got me confused. If you are using the ADC, why would you need the comparator? What do you mean by 'unstable readings? how are you reading the voltage?
 

You've got me confused. If you are using the ADC, why would you need the comparator? What do you mean by 'unstable readings? how are you reading the voltage?
sorry but i did say in the first post that i need to read without using any comparator,i only use TIMER0 and ADC here is my code :

void interrupt() {
if(INTCON.TMR0IF){
TMR0L = TimerValue;
Num++;
INTCON.TMR0IF =0; // Clear TMR0 interrupt flag
}
USB_Interrupt_Proc();
}
void timeCalc(){
while(1){
x=ADC_Read(4);
x=(x*5)/1023;
if(x<.45){
TMR0ON_bit =0;
Writebuff[1] =Num;
HID_write(&writebuff, 64);
delay_ms(300);
break;
}

}
}


void main(){

unsigned char v,cnt;

ADCON1=0b00001111;
CMCON |= 7;
T0CON =0b01000011;
INTCON.TMR0IE=1;
INTCON.GIE =1;
INTCON.PEIE =1;

HID_Enable(&readbuff,&writebuff);

while(1){
Num=0;
TRISA.B5=0;
PORTA.B5=1;
delay_ms(500);
TRISA.B5=1;
PORTA.B5=0;
TMR0ON_bit =1;
timeCalc();
}

}


i've enabled prescaler with the ratio 1/16 starting with 245 as an initializaion that makes an interrupt stands for 53.33 us using 12.0 MHz crystal, what i mean by unstable: i got the number of interrupts reading swing with a large value such as ,60,88,202,110 and that depends on the volt level i use for stopping the timer ,i hope u can get me now ,best regards, thank you
 

Well, I STILL don't see why you are talking about a comparator if you're looking at this with the adc. I don't quite understand what you are doing, exactly; can you explain this a little better. It appears that you are charging and discharging the sensor(cap) through a 220 ohm resistor, is that right? This appears to be a little small, since it will only give you a nominal time constant of 33 nS. I THINK what you would want to do is start charging the cap through a resistor, and sample the voltage output. From your samples you should be able to determine the time constant, and, thus, the capacitance.
 



i'm STILL telling you sir ,i'm not talking about comparators,i repeat i'm not using comparators ,i just mentioned that i CANNOT use comparator due to hardware limitation,since i've seen some applications that uses comparator instead of "if state" as you can see in my code this line CMCON |=7; that is for disabling comparator, all i got is one input ADC channel and this scheme in data sheet i've attached and timers for calculating that relative humidity ,it's basically built on charging the cap so rapidly then allowing it to discharge through the 10M resistor then calculating decay time please if you see abetter setting for that code tell me,REGARDS
 

How are you "allowing it to discharge through the 10M"? First of all, you've got leakage current on the port that you are driving the cap with. Then, you've got a relatively HUGE input current for your ADC. If you look at the data sheet you'll see that:

1) Recommended source impedance for the ADC is 2K (not 10M)
2) The input current for the ADC is 150 uA

If you want to use the method you are proposing, I think you need a buffer.

And, in your original post you stated that you wanted to do this "without using any of pic comparators". I was questioning why you were even THINKING about using a comparator.
 


i only used the resistor value stated in the pic which comes originally from data sheet , i would gladly welcome any suggestions , and i really want to get it connected without any buffers just the resistor network , and i mentioned not using comparators to make sure that it's not an option ,i thought that the capacitor charges through 220R resistor neglecting 10M then discharges through 10M due to high input impedance of ADC,i might be wrong but i don't ave any other explanation i need to figure out some way to get RH with only these resistors and the proper code.
 

We've already established that the ADC input is not high impedance.

Maybe another approach would be to apply a square wave to the RC, and measure the peak output voltage, since it would essentially be a low pass filter.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…