INFO - FAQ - CC2-Forum - CCPro-Forum |
|
so also hab es noch mal umgeshrieben jetz ist relais 1 immer an und geht bei jedem durchlauf kurz aus????? weis aber nicht warum kannst du mir da noch mal helfen danke für deine geduld mit mir 'Digitalports define Clock Port[1] 'Serial clock input für SHT75 define Data Port[2] 'Serial data für SHT75 define DS Port[3]'DATA IN für Relaisplatine define SH Port[4] 'Shift CLK für Relaisplatine define ST Port[5] 'Stotre CLK für Relaisplatine 'Variablen 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 rel byte[13] 'Byte-Puffer für rel1 bis rel8 define rel1 bit[97] 'Relais 1 define rel2 bit[98] 'Relais 2 define rel3 bit[99] 'Relais 3 define rel4 bit[100] 'Relais 4 define rel5 bit[101] 'Relais 5 define rel6 bit[102] 'Relais 6 define rel7 bit[103] 'Relais 7 define rel8 bit[104] 'Relais 8 define rn byte[14] 'Relaisnummer gosub SHTinit #messen 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 gosub Lüfter goto messen #Lüfter rel = off gosub alleaus if temperatur >320 then goto r1 if temperatur >310 then goto r2 if temperatur >300 then goto r3 if temperatur >290 then goto r4 if temperatur >280 then goto r5 if temperatur >270 then goto r6 if temperatur >260 then goto r7 if temperatur >250 then goto r8 #zurück return #r1 rel1=on goto next #r2 rel2=on goto next #r3 rel3=on goto next #r4 rel4=on goto next #r5 rel5=on goto next #r6 rel6=on goto next #r7 rel7=on goto next #r8 rel8=on #next gosub shift pulse ST goto zurück #alleaus gosub shift pulse ST return #shift for rn=7 to 0 step -1 DS=(rel shr rn) and 1 pulse SH next return '-------------------------------- benötigt für sensor ----------------------------------------------- #SHTinit deact Data Clock = 0 for i=0 to 10 pulse Clock return #SHTstart Clock =-1 Data = 0 Clock = 0 Clock =-1 deact Data Clock = 0 return #SHTwrite for i=0 to 7 if (temp shl i) and &h80 then deact Data else Data = 0 pulse Clock next i deact Data Clock = -1 temp=(Data=0) Clock =0 return temp #SHTread temp=0 for i=0 to 7 Clock =-1 temp=(temp shl 1) or (Data and 1) Clock = 0 next i if ack then Data = 0 else deact Data pulse Clock deact Data return temp #SHTreadint tempW = timer #SHTwloop if timer-tempW>=50 then return &hF000 if Data then goto SHTwloop ack = 1 dataWhi=SHTread 'High-Byte ack = 0 dataWlo=SHTread 'Low-Byte return dataW #SHTgettemp gosub SHTstart temp = &b00011 : gosub SHTwrite dataW = SHTreadint-4000 return dataW #SHTgethyg gosub SHTstart temp = &b00101 : gosub SHTwrite Feuchte=SHTreadint if Feuchte and &h8000 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 table shtab "sht.tab" |
Antwort schreiben |