PDA

View Full Version : sht_75 and SHT XX pgm correction



iw2fvo
- 24th November 2011, 17:20
I have found a problem in the pic basic pro program used to compute relative humidity and dew point . Those program are available in this forum.
I will like now to post the corrected program that allows correct computation of RH_tc and dew point even if the temperature is below 0 deg C.
I hope it could help someone!
Regards,
Ambrogio

quote:


for S_RH=100 TO 3500 STEP 50 ' change them as needed to generate an output list
for s_t=1000 to 8000 step 500 ' change them as needed to generate an output list

if S_T => 4000 then
TEMP=S_T-4000 ' TEMP *100
SIGNtc="+" ' POSITIVE
ELSE
TEMP=4000-S_T ' TEMP *100
SIGNtc="-" ' NEGATIVE
ENDIF

DEBUG "S_T=",DEC S_T," T=",SIGNtc,DEC TEMP/100,".",DEC1 TEMP/10

COMPUTE_RH_T:

WY=405*S_RH
WY=DIV32 100
WX=S_RH*S_RH
WX=DIV32 1000
WX=WX*28
WX=DIV32 100
RHLIN=WY-WX-400 ' RH_LINEAR

WY=(8*S_RH+1000)/10
IF SIGNTC="+" THEN
IF TEMP> 2500 THEN
WX=(TEMP-2500)*WY
WX=DIV32 100
RHTC=RHLIN+WX/100
ELSE
WX=(2500-TEMP)*WY
WX=DIV32 100
RHTC=RHLIN-WX/100
ENDIF
ELSE
WX=(2500+TEMP)*WY
WX=DIV32 10000
RHTC=RHLIN-WX
ENDIF

DEBUG " S_RH=",DEC S_RH," RHlin=",DEC RHLIN/100,".",DEC1 RHLIN/10," RHtc=",_
DEC RHTC/100,".",DEC1 RHTC/10,"%"


COMPUTE_DP: ' COMPUTE DEW POINT....................................

'** Dewpoint Calculation
' See: SENSIRION Application Note "Dewpoint Calculation"
' logEW = (0.66077+7.5*T/(237.3+T)+(log(RH)-2)
' DP = ((0.66077-logEW)*237.3)/(logEW-8.16077)

TempDP=Temp/10

logEW=6608

'sign=TempDP.bit15

if s_t<4000 then ' we are below zero °C
sign=1
else
sign=0 ' we are above zero °C
endif

wz=ABS TempDP

wx=(7*wz)+(wz/2)

'debug "Wx=",dec wx,13,10

if sign=0 then
wy=2373+wz
else
wy=2373-wz
endif

wj=wx/wy

For ix=15 to 0 step -1

wx=(wx//wy)<<1

wz.bit0(ix)=wx/wy
next ix
wx=(-sign^((wj*10000)+(wz**10000)))+sign

logEW=wx+logEW

wx=RHtc/10

wj=(NCD wx) - 1

wx=wx<<(15-wj)

wz=0

For ix=14 to 0 step -1

wy=wx**wx


wz.bit0(ix)=wy.bit15

bt=~wy.bit15

wx=wy<< bt+(bt & wx.bit15)

next ix

wx=((wj*4000)**49321)+(wz**6021)

logEW=wx+logEW-30000

sign=logEW.bit15

logEW=(-sign^(((ABS logEW)+2)/4))+sign

wx=1652-logEW

sign=~wx.bit15

wx=ABS wx

wy=20402-logEW

wj=wx/wy

For ix=15 to 0 step -1

wx=(wx//wy)<<1

wz.bit0(ix)=wx/wy

Next

DP=((23730**wz)+5)/10

DP=(-sign^DP)+sign


'debug "DP=",DEC2 ABS DP/10,".",DEC1 ABS dp,13,10
'debug "dpC=",rep "-"\sign,dec abs DP/10,".",dec1 abs DP,13,10
'lcdout ins,line3,"dp=" ,DEC2 ABS DP/10,".",DEC1 ABS dp
'lcdout ins,line4,"dp=" ,rep "-"\sign,DEC ABS DP/10,".",DEC1 ABS dp
DEBUG " dp=", rep "-"\sign,DE

next s_t
next s_rh

unquote.

Andre_Pretorius
- 16th August 2015, 18:05
Hi There

Can I ask that you post the complete corrected program, I am trying to get the sensor working with a 16F913 and are having issues. Another question in all the examples nobody use I2CREAD and I2CWRITE is there a reason?

Andre

iw2fvo
- 17th August 2015, 14:15
this is what Sensirion says about the interface :
quote
The serial interface of the SHT7x is optimized for sensor
readout and effective power consumption. The sensor
cannot be addressed by I2C protocol, however, the sensor
can be connected to an I2C bus without interference with
other devices connected to the bus. Microcontroller must
switch between protocols.
unquote.

I would like to see the complete program too. I have one working here since about 2011 and I am interested if something new is available .
Thanks
Ambrogio

iw2fvo
- 18th August 2015, 08:53
here I am again,
Any possibility to see the final complete code ... ?
I knew there was a problem in dew point calculation at negative temperature ) °C ) ... any advice ?
Thanks
ambrogio

Andre_Pretorius
- 19th August 2015, 19:19
Mine still gives the same value no matter what I do, will work on it again this weekend.

iw2fvo
- 17th October 2015, 09:06
I am still searching for a really working code of this sensor ... if any
Thanks
Ambro