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.