Tabsoft / Richard,
I've incorporated the code below into my main program and whilst it runs fine, it does flash up a fair few "bad read" errors. Is there anything I could tweak to reduce these occurancies
Code:read_dht: for bits=4 to 0 step-1 dht[bits]=0 next tmr2=0 dht_dir=0 dht_data=0 pause 18 'start it up dht_data=1 pauseus 30 dht_dir=1 pauseus 40 'wait till middle of response pulse window if ( dht_data)then goto badresponse 'no response then give up while (!dht_data) wend t2con=6 while ( dht_data) wend t2con=0 if ((tmr2 <45)||(tmr2>55))then goto badpresence ' confirm presence ? for bits =39 to 0 step -1 tmr2=0 while (!dht_data) wend t2con=6 while ( dht_data) wend t2con=0 if ((tmr2>12)&&(tmr2<50)) then ' noise ? if (tmr2 >31 ) then dht.0[bits] = 1 endif else goto badread ' noise ? endif next crc=0 for bits=1 to 4 crc=crc+ dht[bits] next if crc != dht[0] then goto badcrc 'crc return badread: LCDOut $FE,$94 +8,"Bad read" pause 1000 LCDOut $FE,$94 +8," " ' next return badcrc: for bits=4 to 0 step-1 LCDOut $FE,$94 +16,hex dht[bits],"," pause 1000 next return badresponse: LCDOut $FE,$94+8,"No Response" return badpresence: LCDOut $FE,$d4,"pr",#tmr2 return




Bookmarks