' ' SW fuer Bad C-control ' '-------------------- 'Variablen Zuweisung durch preproc Script: define dallasKeller 7 define dallasAussentemp 2 'dallas/1wire define bas_1 byte[23] 'ans Ende wegen dummer Autovergabe define bas_2 byte[24] define temp word define tmp1 byte define crc byte define chip byte define loopcnt byte 'update this per ASM update ! define Dreset &H0101 define Dwrite &H011D define Dread &H0141 define dallasidscnt 11 'dallas ROM Ids see table at end 'div define clock 5 '0,1 sec 'defineend required for preproc '-------------------- #start chip=hour-1 'check if file is empty open# for read if eof then gosub readfileheader close# #main if rxd then gosub readfile if filefree<(11*24) then beep 600,10,0 if filefree<(11*24) then print "ALARM Filesize critical, please read file" pause 3*clock if hour=chip then main gosub dallas chip=hour 'temperature actions see TempAction goto main '------------------ #dallas if filefree<11 then print "ALARM EEPROM is full, no dallas scan" if filefree<11 then return open# for append 'print# day*256+hour 'conv to word as file and table store words. print# month*1024+day*32+hour 'conv to word as file and table store words. loopcnt=0 #getdallas 'calc temp forall dallas bas_2 = &HCC ' Reset & "Skip-Rom" sys Dreset ' Sprung in Assembler if bas_1=255 then print "WARNING Dallas reset error, device not present ?" if bas_1=255 then loopcnt=loopcnt+1 if bas_1=255 and loopcnt<10 then goto getdallas if bas_1=255 then print "WARNING Dallas FAILURE. skipping" if bas_1=255 then return bas_2 = &H44 ' "Convert-Temp" Kommando sys Dwrite loopcnt=0 #readyloop pause 30 ' >0.7 s warten sys Dread if bas_2=0 then print "NOTE Dallas not yet ready ..." if bas_2 = 0 then loopcnt=loopcnt+1 if bas_2 = 0 and loopcnt<10 then goto readyloop ' busy? if bas_2 = 0 then print "WARNING Dallas FAILURE. skipping" if bas_2 = 0 then return 'fetch temp per dallas for chip=0 to dallasidscnt-1 'call chip via id looktab dallasids,chip*9,bas_2 if bas_2=0 then next 'jump over disconnected chip loopcnt=0 #getchip bas_2 = &H55 sys Dreset if bas_1=255 then print "WARNING Dallas reset error" if bas_1=255 then loopcnt=loopcnt+1 if bas_1=255 and loopcnt<10 then goto getchip if bas_1=255 then print "WARNING Dallas FAILURE. skipping" if bas_1=255 then return for temp=0 to 7 looktab dallasids,chip*9+temp+1,bas_2 sys Dwrite next bas_2 = &HBE ' "Read-Scratchpad" sys Dwrite 'read temp sys Dread temp = bas_2 crc=0 looktab crctab,(bas_2 xor crc),crc sys Dread temp=bas_2*256+temp 'if bas_2 > 128 then temp = -1-(65535 xor temp) 'not funktioniert nicht binaer, daher xor 'CRC check looktab crctab,(bas_2 xor crc),crc sys Dread looktab crctab,(bas_2 xor crc),crc sys Dread looktab crctab,(bas_2 xor crc),crc sys Dread looktab crctab,(bas_2 xor crc),crc sys Dread looktab crctab,(bas_2 xor crc),crc sys Dread looktab crctab,(bas_2 xor crc),crc tmp1=bas_2 'count remain sys Dread looktab crctab,(bas_2 xor crc),crc 'count per C temp=temp and &Hfffe 'print temp;" ";tmp1;" ";bas_2;" ";10*temp/2;" ";-2+(10*bas_2-10*tmp1)/bas_2 temp=10*temp/2-2+(10*bas_2-10*tmp1)/bas_2 sys Dread if crc <> bas_2 then print "WARNING Dallas chip ";chip;" CRC error" if crc <> bas_2 then loopcnt=loopcnt+1 if crc <> bas_2 and loopcnt<10 then goto getchip 'crc fails if crc <> bas_2 then print "WARNING Dallas chip ";chip;" FAILURE. skipping" 'if crc <> bas_2 then next: print garbage for file parser print "NOTE chip ";chip;" temp= "; 'if temp_sig then print " "; else print "-"; print temp/10 'if temp and &H01 then print ",5" else print print# temp temp=temp/10 if crc = bas_2 then gosub TempAction next close# return #readfile get crc if crc<>&H33 then return 'magic cmd close# open# for read #readfile1 if eof then goto readfileheader input# temp print temp goto readfile1 #readfileheader print "EOF" close# open# for write 'clear file 'write header print# 0 'foo at date column for loopcnt=0 to dallasidscnt-1 looktab dallasids,loopcnt*9,bas_2 if bas_2 then print# loopcnt next close# return end 'dallas ROM Ids: chip 0 = row 0, chip 1 .... Die erste column zeigt angeschlossenen chip an. table dallasids 'Wohnzimmer: der Sensor 0 ist in der Ecke vom Wohnzimmer 1 16 88 65 87 0 8 0 120 0 16 153 128 80 0 8 0 185 'Aussentemp: der Sensor 2 ist aussen am Kabelkanal zur Kabelbruecke 1' Stock 1 16 8 46 87 0 8 0 40 0 16 204 79 87 0 8 0 183 0 16 61 188 80 0 8 0 156 0 16 182 178 80 0 8 0 44 0 16 71 50 87 0 8 0 36 'Keller: der Sensor ist im Keller nahe an Aussenwand 1 16 137 94 87 0 8 0 152 0 16 26 73 87 0 8 0 93 'Mauer aussen: der Sensor liegt 15cm hinter der Aussenmauer (mauerdicke 60cm). 1 16 12 208 80 0 8 0 118 'Mauer innen: der Sensor liegt bei 45cm hinter der Aussenmauer, also 15cm hinter der Innenmauer (mauerdicke 60cm). 1 16 89 91 80 0 8 0 8 tabend table crctab 0 94 188 226 97 63 221 131 194 156 126 32 163 253 31 65 157 195 33 127 252 162 64 30 95 1 227 189 62 96 130 220 35 125 159 193 66 28 254 160 225 191 93 3 128 222 60 98 190 224 2 92 223 129 99 61 124 34 192 158 29 67 161 255 70 24 250 164 39 121 155 197 132 218 56 102 229 187 89 7 219 133 103 57 186 228 6 88 25 71 165 251 120 38 196 154 101 59 217 135 4 90 184 230 167 249 27 69 198 152 122 36 248 166 68 26 153 199 37 123 58 100 134 216 91 5 231 185 140 210 48 110 237 179 81 15 78 16 242 172 47 113 147 205 17 79 173 243 112 46 204 146 211 141 111 49 178 236 14 80 175 241 19 77 206 144 114 44 109 51 209 143 12 82 176 238 50 108 142 208 83 13 239 177 240 174 76 18 145 207 45 115 202 148 118 40 171 245 23 73 8 86 180 234 105 55 213 139 87 9 235 181 54 104 138 212 149 203 41 119 244 170 72 22 233 183 85 11 136 214 52 106 43 117 151 201 74 20 246 168 116 42 200 150 21 75 169 247 182 232 10 84 215 137 107 53 tabend 'syscode "ds1820.obj"