
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
||
|
hi also ich habe vor mit der c-control die relaisplatine ELR4SR anzusteuern. die temperatur werte bekomme ich mit hilfe des temperatursensors sht75. habe schon ein kleines programm geschrieben was aber nicht richtig funktioniert. habe nicht so den plan vom programmieren. das programm zeigt die richtige temperatur und luftfeuchte im hyperterminal an aber schaltet kein relais hoffe ihr könnt mir weiterhelfen vielen dank hier mein programm: '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 gosub SHTinit #messen Temperatur = SHTgettemp Feuchte = SHTgethyg 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 if temperatur >250 then rn=1 if temperatur >260 then rn=2 if temperatur >270 then rn=3 if temperatur >280 then rn=4 if temperatur >290 then rn=5 if temperatur >300 then rn=6 if temperatur >310 then rn=7 if temperatur >320 then rn=8 gosub Relaisschalten 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" '--------------------------------ende benötigt für sensor ----------------------------------------------- #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 for rn=7 to 0 step -1 DS=(rel shr i) and 1 pulse SH next return und die benötigte tabelle: -40 -34 -28 -21 -15 -8 -2 5 11 17 24 30 36 43 49 55 61 68 74 80 86 92 99 105 111 117 123 129 135 141 147 153 160 166 172 178 183 189 195 201 207 213 219 225 231 237 242 248 254 260 266 271 277 283 289 294 300 306 311 317 322 328 334 339 345 350 356 361 367 372 378 383 389 394 400 405 411 416 421 427 432 437 443 448 453 459 464 469 474 479 485 490 495 500 505 510 516 521 526 531 536 541 546 551 556 561 566 571 576 581 586 590 595 600 605 610 615 620 624 629 634 639 643 648 653 658 662 667 671 676 681 685 690 695 699 704 708 713 717 722 726 731 735 740 744 748 753 757 762 766 770 775 779 783 787 792 796 800 804 809 813 817 821 825 829 834 838 842 846 850 854 858 862 866 870 874 878 882 886 890 894 898 901 905 909 913 917 921 924 928 932 936 939 943 947 951 954 958 962 965 969 972 976 980 983 987 990 994 997 1001 1004 1008 1011 1015 1018 1021 1025 1028 1031 1035 1038 1041 1045 1048 1051 1055 1058 1061 1064 1068 1071 1074 1077 1080 1083 1086 1090 1093 1096 1099 1102 1105 1108 1111 1114 1117 1120 1123 1126 1129 1132 1134 1137 1140 1143 1146 |
| Antwort schreiben |