INFO - FAQ - CC2-Forum - CCPro-Forum |
|
also das programm so soll es mal funktionieren mit meinen ports und variablen aber es geht nicht (da sind die beispiel programme nur ein bissl umgeschrieben) was mach ich falsch: '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 define rs byte[15] 'Relaistatus 0=aus 1=an #messen gosub SHTinit Temperatur = SHTgettemp Feuchte = SHTgethyg #Lüfter for rn=5 to 8 rs=0 next if temperatur <=230 then rn=5 if temperatur >230 and <=250 then rn=6 if temperatur >250 and <=279 then rn=7 if temperatur >280 then rn=8 'Relais: 5=stufe 1 temp<20°C, 6=stufe 2 temp>23°C, 7=stufe 3 Temp>25°C, 8=stufe 4 temp>=28°C gosub einschalten #Heizer rn=2 'Relais: 2 if temperatur <= 170 then gosub einschalten if temperatur >= 220 then gosub ausschalten ' temp <=17°C an, temp>= 22°C aus #Befeuchter rn=3 'Relais: 3 if feuchte <= 300 then gosub einschalten if feuchte >= 600 then gosub ausschalten'RLF <= 30% an, RLF >=60% aus '-------------------------messen--------------------- #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" '-----------------------Relais schalten #einschalten rs=1 gosub Relaisschalten return #ausschalten rs=0 gosub Relaisschalten return '______________________________________________________RELAIS START #Relaisschalten rn=rn-1 on rn goto r1,r2,r3,r4,r5,r6,r7,r8 #zurück return #r1 rel1=rs goto next #r2 rel2=rs goto next #r3 rel3=rs goto next #r4 rel4=rs goto next #r5 rel5=rs goto next #r6 rel6=rs goto next #r7 rel7=rs goto next #r8 rel8=rs #next gosub shift pulse ST goto zurück #shift 'Routine zum seriellen Senden der Daten zur Scheiberegistererweiterung for rn=7 to 0 step -1 DS=(rel shr i) and 1 pulse SH next return '____________________________________________________RELAIS ENDE |
Antwort schreiben |