EmbeddedRelated.com
Forums
Memfault State of IoT Report

Sensirion RH sensor Temp Compensation using an 8 bit PIC

Started by K Ludger October 24, 2008
"K Ludger" <kjhi@hjhk.org> wrote in message 
news:49016bad$0$10566$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
> > I'm trying to implement temperature compensation on a Sensirion SHT11 RH > sensor. >
<snip> Yep, been there. Forget about polynomials at runtime. Use a LUT. Devise a best-fit utility which will allow you to define a sequence of straight lines which fit the curve within the accuracy you need. Will certainly take less const data memory space than the difference in code. Steve -- http://wwww.sfdesign.co.uk
Walter Banks <walter@bytecraft.com> writes:
> K Ludger wrote: > > "Walter Banks" <walter@bytecraft.com> wrote > > > K Ludger wrote: > > > > > >> I'm trying to implement temperature compensation on a Sensirion SHT11 RH > > >> sensor.
> > > You don't need dynamic range you are looking for precision. The first > > > question you need to ask is > > > > > > What do you want to know about RH? > > > How much precision? > > > > 0.1% precision, I've used a modified (multiplied by 10) version of > > Sensirions 2 segment linearisation and this seem work ok.
> > At 50% RH the TC is ~0.12%/C. Over a temp range of say 10-->40C this would > > be ~3% which would be significant as the SHT11 sensor is good for around 3% > > If I were implementing this I would implement > > Temp Comp in %RH = (Temp - 25)[0.01 + 0.00008.(ADC value)] + RHuncompensated > > in 8:16 fixed point. The reason for using fixed point is you need precision > and not dynamic range that is provided by floating point. I would > use 8:16 for all variables to reduce the conversion issues and keep > code size reasonable.
This suggestion is quite reasonable, but it's overkill. An 8:8 format would suffice as it's stated above that the sensor itself is only accurate to 3%. Numerical analysis 101 says that the result can't be more accurate than the data with which one starts. If the accuracy of the sensor is as stated, a table lookup is probably quickest and easiest. It can probably be a one-point table at that. BTW: Is RH meaningful at or below freezing?
> The only major library call would be to a 24*24 mult with a > 48 bit result. With care the mult can be unsigned. All three > +/- can be done inline.

"Steve at fivetrees" <steve@NOSPAMTAfivetrees.com> wrote in message 
news:PrSdnV-pqOfwx5vUnZ2dneKdnZydnZ2d@pipex.net...
> "K Ludger" <kjhi@hjhk.org> wrote in message > news:49016bad$0$10566$5a62ac22@per-qv1-newsreader-01.iinet.net.au... >> >> I'm trying to implement temperature compensation on a Sensirion SHT11 RH >> sensor. >> > <snip> > > Yep, been there. > > Forget about polynomials at runtime. Use a LUT. Devise a best-fit utility > which will allow you to define a sequence of straight lines which fit the > curve within the accuracy you need. Will certainly take less const data > memory space than the difference in code. > > Steve > -- > http://wwww.sfdesign.co.uk >
Thanks Steve. PS - you have 4 x w's in your sig.

"Everett M. Greene" wrote:

> > If I were implementing this I would implement > > > > Temp Comp in %RH = (Temp - 25)[0.01 + 0.00008.(ADC value)] + RHuncompensated > > > > in 8:16 fixed point. The reason for using fixed point is you need precision > > and not dynamic range that is provided by floating point. I would > > use 8:16 for all variables to reduce the conversion issues and keep > > code size reasonable. > > This suggestion is quite reasonable, but it's overkill. > An 8:8 format would suffice as it's stated above that > the sensor itself is only accurate to 3%. Numerical > analysis 101 says that the result can't be more > accurate than the data with which one starts.
I agree that the result is reasonable to be 8.8 however the polynomial has one term (0.00008) that is 8 parts in 10^6. This is needs at least a 16 bit fract to be relavent.
> If the accuracy of the sensor is as stated, a table > lookup is probably quickest and easiest. It can > probably be a one-point table at that. > > BTW: Is RH meaningful at or below freezing?
Yes. RH in air below freezing exists. The air at that temperature is dry but not completely so. There is a parallax app note for the Sensirion SHT11 sensors with example code in basic. I went to the Sensirion site and it appears that there are two polynomials needed to get accurate readings. The first to get RHuncompensated and the second to compensate for temperature variances. Regards w..
"K Ludger" <kjlkj@kljl.org> wrote in message 
news:4906c055$0$22624$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
> > Thanks Steve. > > PS - you have 4 x w's in your sig.
I did, didn't I? (Confession: I type the sig, rather than paste it. Bad habit. I typo'ed. D'oh!) Steve -- http://www.fivetrees.com <- that's the chap!

Memfault State of IoT Report