measure ohm of HS15P
Fork of Frequency_counter by
This test program measures ohm of HS15P, humidity sensor.
C(micro F) with LMC555 | 0.1 | 0.15 | 0.22 | 0.33 | 0.47 | 0.68 | 1 |
CONV_KILO_OHM | 0.0072 | 0.0048 | 0.0033 | 0.0022 | 0.0015 | 0.0011 | 0.00072 |
If you get 2500 microseconds as interrupt time interval , it means 18 kilo ohm when 0.1 micro F. ( = 2500 * 0.0072 )
- ohm of HS15P is calculated from pulse interval of LMC555.
- CONV_KILO_OHM will be used.
- this program reads interval time.between interrupt in the P8.
- takes ON the P9 to oscillate LMC555 as short as enough to measure interval time
- last several interval times will be used for calculation.
- the time is defined as READ_TIMER .
- In current circit, VDD of LMC555 is about 1.55V, AC 0.4V between pins of HS15P.
- LMC555 consumes 120 micro A while oscillation, 90 micro A when level of P9 is OFF. (reset is ON)
- Total 1-2mA is consumed in the circit.
Related nootbook : https://mbed.org/users/strysd/notebook/measure_humidity_with_hs15p_and_lmc555/
Diff: main.cpp
- Revision:
- 3:bf0a5effbed2
- Parent:
- 2:c4d4f0f9d77c
- Child:
- 4:64d9c0bed75b
--- a/main.cpp Sat Jun 01 07:49:57 2013 +0000 +++ b/main.cpp Mon Jun 03 12:36:37 2013 +0000 @@ -2,8 +2,8 @@ //see mbed.org/users/strysd/notebook/measure_humidity_with_hs15p_and_lmc555/ #define ohm_constant 7.2 //if use 0.1 micro F +#define in_limit 20 //limit of interrupt times -Serial pc(USBTX, USBRX); InterruptIn in(p8); DigitalOut vcc555(p9); DigitalOut led(LED1); @@ -12,15 +12,16 @@ float t_period = 0;//between interrupts in microseconds float my_freq = 0;//Hz float my_ohm = 0;//ohm for HS15P -int in_limit = 10; -int in_count = 0; +int in_count = 0;//interrupt times void flip(void) { if(in_count > 0){ - t_period = t1.read_us();// Get time since last interrupt + if(in_count > 15){ + t_period = t1.read_us();// Get time since last interrupt + } + t1.reset();// Reset timer and wait for next interrupt in_count--; - t1.reset();// Reset timer and wait for next interrupt } else { //No use interrupt vcc555 = led = 0; @@ -34,24 +35,28 @@ in.mode(PullUp); in.rise(&flip);// Set up the interrupt for rising edge - pc.printf("\rStarting measure\n"); + printf("\rStarting measure\n"); while (1) { //Use interrupt + t_period = 0; t1.start(); in_count = in_limit; vcc555 = led = 1; wait_ms(200); - - if (t_period > 0){ - my_freq = (1000/t_period)*1000; // Convert to Hz - my_ohm = t_period * ohm_constant;// Convert to ohm - - pc.printf("\r %d Hz, %d micro sec, %d ohm \n", - (int)my_freq, (int)t_period, (int)my_ohm); + + if (t_period < 20 || t_period > 100000){ + //< 20 micro sec (> 50 kHz) + //> 0.1 sec (< 10 Hz) + printf("\r not ready\n"); + wait_ms(5000); } else { - pc.printf("\r not ready\n"); + my_freq = 1000000/t_period;// Convert to Hz + my_ohm = t_period * ohm_constant / 1000;// Convert to kilo ohm + printf("\r %d Hz, %d micro sec, %4.1f kilo ohm \n", + (int)my_freq, (int)t_period, my_ohm); } - wait_ms(1800); + + wait_ms(4800); } } \ No newline at end of file