
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
||
|
guten morgen! vielen dank für das bild. Nun habe ich mal den quelltext von der cctool seite auf basic++ portiert. jetzt bekomme ich ganz komische werte zurück. die werte wandern um 0,5 aufwärts und dann wieder abwärts. hier mal den quelltext-> (vielleicht habe ich etwas übersehen. '-------------------------------------------------------------- 'Ansteuerungsbeispiel für Feuchtesensor SHT15 (#1515-0) 'CCTools 2005 cctools.hs-control.de (19.04.2005) 'portiert von Pierre '-------------------------------------------------------------- 'Die rH-Wert ist nicht Temperaturkompensiert ! define Clock port[7] define Data port[8] define power as port [5] define tempW word[1] 'Überlappung mit Byte 1 & 2 !!!! define temp byte[1] 'temporäres Datenbyte define temp2 byte[2] 'temporäres Datenbyte define i byte[3] define ack byte[4] define dataW word[3] define dataWhi byte[5] define dataWlo byte[6] define Temperatur word[4] define Feuchte word[5] define tempW2 word[6] define cmd byte declare function SHTinit() declare function SHTstart() declare function SHTwrite(a ref cmd) declare function SHTread() declare function SHTreadinit() declare function SHTwloop() declare function SHTgettemp() declare function SHTgethyg() #main SHTinit() power = 0 do Temperatur = SHTgettemp() Feuchte = SHTgethyg() put 12 print "Temperatur:" print Temperatur/100 & "," & abs((Temperatur/10))mod 10 & abs(Temperatur) mod 10 & "°C" print "Feuchte: " if Feuchte>=0 then print Feuchte/10 & "," & Feuchte mod 10 & "%rH" else print "Fehler" pause 50 loop until 1=2 '----------------------------------------------------------- function SHTinit() deact Data Clock = 0 for i=0 to 10 pulse Clock next end function '----------------------------------------------------------- function SHTstart() Clock =-1 Data = 0 Clock = 0 Clock =-1 deact Data Clock = 0 end function '----------------------------------------------------------- function SHTwrite(a ref cmd) for i=0 to 7 if (temp shl i) and 80h then deact Data else Data = 0 pulse Clock next deact Data Clock = -1 temp=(Data=0) Clock =0 end function '----------------------------------------------------------- function SHTread() temp=0 for i=0 to 7 Clock =-1 temp=(temp shl 1) or (Data and 1) Clock = 0 next if ack then Data = 0 else deact Data pulse Clock deact Data return temp end function '----------------------------------------------------------- function SHTreadint() tempW = timer end function '----------------------------------------------------------- function SHTgettemp() SHTstart() cmd = 00011b temp = SHTwrite(cmd) dataW = SHTreadint-4000 return dataW end function '----------------------------------------------------------- function SHTgethyg() SHTstart() cmd = 00101b temp = SHTwrite(cmd) Feuchte=SHTreadint() if Feuchte and 8000h then return -1 tempW = Feuchte shr 4 i = Feuchte mod 16 looktab shtab,tempW,tempW2 tempW = tempW - 1 looktab shtab,tempW,tempW tempW2 = ((tempW2 - tempW) * i) shr 4 Feuchte = tempW + tempW2 return Feuchte end function '----------------------------------------------------------- table shtab -40 -34 -28 -21 -15 -8 -2 5 11 17 .......... end table |
| Antwort schreiben |