Shop OBEX P1 Docs P2 Docs Learn Events
HS 1101 Sensor — Parallax Forums

HS 1101 Sensor

KlapKlap Posts: 65
edited 2010-07-08 04:45 in Propeller 1
I am using the HS 1101 Sensor with the Propeller chip.
I have everything hooked up and working as shown in figure 1 (minus the 220 ohm resister):
http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/27920-HS1101-v1.0.pdf

But now I am not sure what RHconstant to use. Has anyone used this sensor and found a good RHconstant yet?
Using this equation: time := (phsa*10 - 12169)/24 #> 0

Here is all of my code:


'' HS1101
'' -- Aaron Klapheck
'' -- 7 July 2010

CON

  _clkmode      = xtal1 + pll16x                        ' use crystal x 16
  _xinfreq      = 5_000_000
  

OBJ

  debug : "FullDuplexSerialPlus"
  

PUB main | time

  'Beep to initialize routine.  
  ctra[noparse][[/noparse]30..26] := %00100
  ctra[noparse][[/noparse]5..0] := 0
  frqa := 112_367
  dira[noparse][[/noparse]0]~~
  waitcnt(clkfreq*2 + cnt)
  ctra := frqa := 0
  waitcnt(clkfreq/2 + cnt)

  debug.start(31, 30, 0, 9600)
  debug.str(string(debug#CLS))                          ' setup screen
  debug.str(string("Humidity"))
  
  ctra[noparse][[/noparse]30..26] := %01000                            ' POS detect mode
  ctra[noparse][[/noparse]5..0] := 11
  frqa := 1  
   
  
  repeat

    'Charge RC circuit

    dira[noparse][[/noparse]11] := outa[noparse][[/noparse]11] := 1
    waitcnt(clkfreq/100_000 + cnt)   ' wait for 10 microsecond

    'Start RC time decay measurement.

    phsa~
    dira[noparse][[/noparse]11]~

    waitcnt(clkfreq + cnt)   ' wait for 1 second

    time := (phsa*10 - 12169)/24 #> 0

    'Display Result

    debug.tx(debug#CRSRXY)
    debug.tx(1)
    debug.tx(1)
    debug.str(String("time = "))
    debug.dec(time)
    waitcnt(clkfreq/2 + cnt)
    






The numbers I am getting are just too high. Am I using the right slope? Or do I just need to offset the numbers?

Comments

  • agfaagfa Posts: 295
    edited 2010-07-06 01:09
    If I understand the pos detect counter mode correctly.· I think the problem your having is that the sample code is based on 2 microsecond units and the values·your·getting are·12.5 nanosecond units.

    If thats the case I·think you could change the line.
    time := (phsa*10 - 12169)/24 #> 0
    
    

    ·with

    time := (phsa*16_000 - 12169)/24 #> 0
    
    
  • KlapKlap Posts: 65
    edited 2010-07-06 05:18
    Sorry that did not work. It only made the number larger. The problem I am having is that the number is already too large. Has anyone worked with this sensor before and come up with a reliable equation yet?
    I am surprised that no one at Parallax has worked with this sensor before.
  • agfaagfa Posts: 295
    edited 2010-07-06 11:45
    Sorry, what I suggested would make the number larger.· The difference is a multiple of 1600.· Try dividing phsa by 160.· I played with the sensor, but the only things I recall·are that·I had to modify the formula because of the difference in units of time, and that my results were skewed because of stray capacitance·added by·the the jumper wires on and to my breadboard.· I also used the waitp** command instead of·a counter.· I ended up testing both charge and discharge properties and averaged the results.

    I found Tracy Allens site very helpful.

    http://www.emesystems.com/BS2rct.htm


    Edit:· I also adjusted for the difference in 5v and 3.3v charge times, So my formula·suggestions are most likey wrong.· I will·look at·my code after work today and see if I can·be more helpful.

    Post Edited (agfa) : 7/6/2010 11:59:44 AM GMT
  • KlapKlap Posts: 65
    edited 2010-07-07 02:12
    This equation appears to be giving me the right answer: time := (phsa - 12169)/24 #> 0
    Apparently you don't need to divide or multiply by anything. I am not sure the slope of the line is right though. I am also getting reading that are fluctuating between 39% and 44%. I don't think there should be than much fluctuation from second to second.
  • agfaagfa Posts: 295
    edited 2010-07-07 11:44
    Klap,

    The documentation describes using a RH gauge to create the plot.· The plot was used to get the RH constant and the divisor.· That is probably the best way to get it.

    My code only·returned a value·for capacitance.· But there is enough information in the documentation to get a new constant.· You could use the plot to get a range of capacitance values by converting the RC times to actual time and using the RC discharge constant for the stamp then re-plot using the discharge constant for the prop. Then convert to the time units to 12.5 ns.

    If you look at the plot, the constant is the time value for 0% RH multiplied by 10.· The divisor can be found by taking a·time value other than 0%RH subtracting the raw constant then dividing by that RH.

    The link I gave will show you how to get the discharge constant and the RC constant.

    That is the way I would do it.· When I get some more time I will do the conversion, out of curiosity.

    I'm sure, if there is an easier way, someone else will chime in.

    Sorry I couldn't be of more help.

    agfa
  • KlapKlap Posts: 65
    edited 2010-07-08 04:45
    I think you are right. I just need to get a thermometer and from it read the dry bulb temperature. Then cover the thermometer in a damp cloth and shake it to get the wet bulb temperature. From this data I will get the relative humidity which I will then compare with the answer I get from the propeller. Then I just have to do this one more time at a different relative humidity and to get both sets of points. With this data I could linearize the output from the humidity sensor to match the actual humidity. I just have to buy a mercury thermometer now.
Sign In or Register to comment.