Hi folks
I am experiancing some diffrence between the test program and the results of the programed picaxe 28x2
they both use the same calculation adapted from the original that Hippy helped me with.
Both codes read the preloaded eeprom for the Air and leaf temperatues and obtain the correct SVP (saturated vapour pressure) result
as obtained from this site http://cronklab.wikidot.com/calculation-of-vapour-pressure-deficit
expanded by me up to 50'C. Both codes generate correct results for the SVP (+/- 0001 livable)
however the the test code gives correct results for any temperature for the VP (vapour pressure)
the 28x2 is way out both are using the same calculation ?
Using the VPD calculator of Arizona collage of agriculture as a refrance https://cals.arizona.edu/vpdcalc/
Apologies in advance this may come over 2 posts as I am posting both codes and screen shots
notes on the images the fist is the data from running 28x2 and 20x2 via the drf wireless link showing the results of the 2 sensors attached to the 20x2
a htu21d-f for the air tempreture (symbol Dry) and the %RH the leaf tempreture is from an inferred temp sensor (symbol leafM)
code programed to the 28x2. The next 2 show the values from the test program giving the correct results for temp's of 20 and 24 at a RH% of 58
test code
the gosub from the 20x2 showing the data layout and checksum format
regards john
I am experiancing some diffrence between the test program and the results of the programed picaxe 28x2
they both use the same calculation adapted from the original that Hippy helped me with.
Both codes read the preloaded eeprom for the Air and leaf temperatues and obtain the correct SVP (saturated vapour pressure) result
as obtained from this site http://cronklab.wikidot.com/calculation-of-vapour-pressure-deficit
expanded by me up to 50'C. Both codes generate correct results for the SVP (+/- 0001 livable)
however the the test code gives correct results for any temperature for the VP (vapour pressure)
the 28x2 is way out both are using the same calculation ?
Using the VPD calculator of Arizona collage of agriculture as a refrance https://cals.arizona.edu/vpdcalc/
Apologies in advance this may come over 2 posts as I am posting both codes and screen shots
notes on the images the fist is the data from running 28x2 and 20x2 via the drf wireless link showing the results of the 2 sensors attached to the 20x2
a htu21d-f for the air tempreture (symbol Dry) and the %RH the leaf tempreture is from an inferred temp sensor (symbol leafM)
code programed to the 28x2. The next 2 show the values from the test program giving the correct results for temp's of 20 and 24 at a RH% of 58
Code:
#picaxe 28X2
' 0 1 2 3 4 5 6 degC
Data( 6,11 , 6,57 , 7,06 , 7,58 , 8,13 , 8,72 , 9,35 )
' 7 8 8 10 11 12 13
Data( 10,02 , 10,73 , 11,48 , 12,28 , 13,12 , 14,02 , 14,97 )
' 14 15 16 17 18 19 20
Data( 15,98 , 17,05 , 18,18 , 19,37 , 20,64 , 21,97 , 23,38 )
' 21 22 23 24 25 26 27
Data( 24,86 , 26,43 ,28,09, 29,83 , 31,67 , 33,61 , 35,65 )
' 28 29 30 31 32 33 34
Data( 37,79 , 40,05 , 42,42 , 44,92 , 47,54 , 50,29 , 53,18 )
' 35 36 37 38 39 40 41
Data( 56,21 , 59,40 , 62,73 , 66,23 , 69,90 , 73,74, 77,76 )
' 42 43 44 45 46 47 48
Data( 82,08, 86,49, 91,11, 95,93, 100,98, 106,25, 111,75 )
data ( 117,50, 123,50)'49,50
symbol TD4=b4 symbol TD3=b3 symbol TD2=b2 symbol TD1=b1 symbol TD0=b0 'reusable variables b0 to b4
'PICAXE VARIABLES FOR I2C CLOCK and DISPLAY changable taken from readings in main prog RUN
symbol themode=b5
symbol sec =b6
symbol hour=b7
symbol mins=b8 'Read write variables to the DS1307 using the DS1307 as the
symbol day=b9 'Timer for the Data Logging and Display
symbol month=b10
symbol year=b11
symbol date=b12
symbol control=$10'RTC control bit
;I2c address for DS1307
symbol tiktok= %11010000
'********************************
'Set point values determned by operator via nextion
symbol photo=b15 'light sensor determin day or night non changeable
symbol Vdiff=w12'b24,b25
symbol Leaf=w13 symbol leafM=b27 symbol leafl=b26 'b27,b26 leaf tempreature and svp result
'Sensor results
symbol air=w14 symbol airM=b29 symbol airL=b28
symbol RH=b36 '%RH
symbol result=w15 'b31,b30 VPD calculation
symbol Dry = b33 ;air tempreture deg C
symbol SVP= w17 'b35,b34 data location for SVP tempreture values
'***********************
symbol volt=w23 symbol voltM=b47 symbol voltL=b46
'***********************
'Radio communication
'*******************
Symbol Qlf= $FE
symbol RX=A.1
symbol TX=A.2
symbol DRF=T9600
symbol minptr=102' for timing loop
'*******************
#Define ToBin(bcd) bcd / 16 * $FA + bcd
#Define ToBcd(bin) bin / 10 * 6 + bin
'*********************************
Hi2csetup i2cmaster,%11010000, i2cslow, i2cbyte
sec=30:mins=6:hour=15:day=7:date=28:month=8:year=19
pre_launch:
sec=ToBcd(sec)
mins = ToBcd(mins)
hour= ToBcd(hour)
day = ToBcd(day)
date = ToBcd(date)
month = ToBcd(month)
year = ToBcd(year)
hi2cout 0,(sec,mins,hour,day,date,month,year,control)
pause 100
hi2cin 0,(sec,mins,hour,day,date,month,year)
sec=toBin(sec):mins=ToBin(mins):hour=ToBin(hour):day=ToBin(day):date=Tobin(date):month=ToBin(month):year=ToBin(year)
sertxd("date ",#date," month ",#month," year ","20",#year,cr,lf)
main:
do
hi2cin 0,(sec,mins,hour)
sec=toBin(sec):mins=ToBin(mins):hour=ToBin(hour)
sertxd("hour ",#hour," mins ",#mins," sec ",#sec,cr,lf)
poke minptr,mins
high B.7
serout TX,DRF,(85,85,85,85,Qlf,"Hello")'wake up slave call
do
gosub TH
sertxd("b0 on release ",#b0,cr,lf)
loop until b0="Y"
gosub V_Cal
gosub display
do 'slave reads sensors ready for transmitting
hi2cin 1,(mins)
mins=ToBin(mins)
for b0 = 0 to 9
pause 100
next b0
peek minptr, @bptr'poke in sub dis
loop until mins<>@bptr
loop
TH: 'Connection for the DRF1276DM to the picaxe 28X2
'picaxe A.1(TXD)--------Pin 4 (RXD) DRF
'picaxe A.2(RXD)--------Pin 5 (TXD) DRF
'serout TX,DRF,(85,85,85,85,Qlf,"Hello")'wake up slave call
;serout TX,DRF,(Qlf,fail)
serin[40000],RX,drf,(Qlf),voltM,voltL,dry,RH,airM,airL,leafm,photo,b0
b2=0:b2=b2+voltM:b2=b2+voltL:b2=b2+dry:b2=b2+RH:b2=b2+airM:b2=b2+airL:b2=b2+leafM:b2=b2+photo
if b0=b2 then
sertxd("read matches ",#b0," w1 ",#b2,cr,lf)
b0="Y"
serout TX,DRF,(Qlf,b0)
hsersetup B9600_8, %01
elseif b0<>b2 then
sertxd("read does not match ",#b0," b2 ",#b2,cr,lf)
b0="N"
serout TX,DRF,(Qlf,b0)
endif
return
display:
sertxd(" Air= ",#airM,".",#airL," ","RH= ",#RH," ","Photo= ",#photo," ","volt= ",#voltM,".",#voltL," ",cr,lf)
bintoascii result,b50,b51,b52,b53,b54
if b50="0" then
b50=" "
endif
sertxd(" svp (from result)=",b50,b51,".",b52,b53,b54," ",cr,lf)
bintoascii leaf,b50,b51,b52,b53,b54
if b50="0" then
b50=" "
endif
sertxd(" svp (from leaf)=",b50,b51,".",b52,b53,b54," ",cr,lf)
bintoascii vdiff,b50,b51,b52,b53,b54
if b50="0" then
b50=" "
endif
sertxd(" vpd=",b50,b51,".",b52,b53,b54,cr,lf)
return
V_Cal:'*********** VPD CALCULATIONS ************
sertxd("Air temp= ",#dry," ",lf)
svp = dry * 2 : Read svp, result
svp = svp + 1 : Read svp, svp
sertxd( " eeprom for result= ",#result," eeprom for svp= ",#svp,cr,lf)
result = rh * result
svp = rh * svp
result = svp / 100 + result
result = svp // 100 / 50 + result
sertxd("leaf temp= ",#leafM,lf)
svp = leafm * 2 : Read svp, leaf
svp = svp + 1 : Read svp, svp
sertxd( " eeprom for leaf= ",#leaf," eeprom for svp= ",#svp,cr,lf)
leaf=leaf*100+svp
if result>leaf then
vdiff=result-leaf
elseif result<leaf then
vdiff=leaf-result
endif
return
Code:
Symbol tempC = b0
Symbol rh = b1
symbol vp = w1 ; b3:b2
symbol svp = w2 ; b5:b4
symbol Avpd = w5 ;b7:b6
symbol vpd=w6
'Data( 6,11 , 6,57 , 7,06 , 7,58 , 8,13 , 8,72 , 9,35 )
'Data( 10,02 , 10,73 , 11,48 , 12,28 , 13,12 , 14,02 , 14,97 )
'Data( 15,98 , 17,05 , 18,18 , 19,37 , 20,64 , 21,97 , 23,38 )
'Data( 24,86 , 26,43 ,28,09, 29,83 , 31,67 , 33,61 , 35,65 )
'Data( 37,79 , 40,05 , 42,42 , 44,92 , 47,54 , 50,29 , 53,18 )
'Data( 56,21 , 59,40 , 62,73 , 66,23 , 69,90 , 73,74 )
'Data( 77,76, 82,38 )
Data( 6,11 , 6,57 , 7,06 , 7,58 , 8,13 , 8,72 , 9,35 )'0,1,2,3,4,5,6 degC
Data( 10,02 , 10,73 , 11,48 , 12,28 , 13,12 , 14,02 , 14,97 )'7,8,9,10,11,12,13
Data( 15,98 , 17,05 , 18,18 , 19,37 , 20,64 , 21,97 , 23,38 )'14,15,16,17,18,19,20
Data( 24,86 , 26,43 ,28,09, 29,83 , 31,67 , 33,61 , 35,65 )'21,22,23,24,25,26,27
Data( 37,79 , 40,05 , 42,42 , 44,92 , 47,54 , 50,29 , 53,18 )'28,29,30,31,32,33,34
Data( 56,21 , 59,40 , 62,73 , 66,23 , 69,90 , 73,74, 77,76 )'35,36,37,38,39,40,41
Data( 82,08, 86,49, 91,11, 95,93, 100,98, 106,25, 111,75 )'42,43,44,45,46,47,48
data ( 117,50, 123,50)'49,50
TestProgram:
For rh = 58 To 58
For tempC = 20 To 20
SerTxd( #tempC, " C ", TAB, #rh, "%RH ",cr, LF )
Gosub CalculateVpd
Next
SerTxd( CR, LF )
Next
CalculateVpd:
'calculation for air vapour pressure
svp = tempC * 2 : Read svp, vp
svp = svp + 1 : Read svp, svp
sertxd( " eeprom for vp= ",#vp," eeprom for svp= ",#svp,cr,lf)
vp = rh * vp
svp = rh * svp
vp = svp / 100 + vp
vp = svp // 100 / 50 + vp
bintoascii vp,b5,b6,b7,b8,b9
if b5="0" then
b5=" "
endif
sertxd( "calculated air pressure result= ",b5,b6,".",b7,b8,b9,cr,lf)
'calculation for leaf saturated vapour pressure
svp = tempC * 2 : Read svp, avpd
svp = svp + 1 : Read svp, svp
sertxd( " eeprom for avpd= ",#avpd," eeprom for svp= ",#svp,cr,lf)
avpd=avpd*100+svp
bintoascii avpd,b5,b6,b7,b8,b9
if b5="0" then
b5=" "
endif
sertxd( " calculated saturated pressure= ",b5,b6,".",b7,b8,b9,cr,lf)
vpd=avpd-vp
bintoascii vpd,b5,b6,b7,b8,b9
if b5="0" then
b5=" "
endif
sertxd( " VPD of the air= ",b5,b6,".",b7,b8,b9,cr,lf)
Return
Code:
send:
b0=0:b0=b0+batth:b0=b0+battl:b0=b0+TemperatureMSB:b0=b0+humidity:b0=b0+whole:b0=b0+fract:b0=b0+whole1:b0=b0+lamp
serout TX,drf,(Qlf,battH,battL,TemperatureMSB,Humidity,whole,fract,whole1,lamp,b0)
serin[6000], RX,drf,(Qlf),b0
return
Attachments
-
407.3 KB Views: 3
-
407.7 KB Views: 3
-
405.1 KB Views: 3
Last edited: