Rev 1884 Rev 1958
Line 1... Line 1...
1 /**** IR Mrakomer 4 ****/ 1 /**** IR Mrakomer 4 ****/
2 #define VERSION "4.1" 2 #define VERSION "4.1"
3 #define ID "$Id: irmrak4.c 1884 2011-02-26 10:11:40Z kakl $" 3 #define ID "$Id: irmrak4.c 1958 2011-04-24 14:44:01Z kakl $"
4   4  
5 #include "irmrak4.h" 5 #include "irmrak4.h"
6   6  
7 #bit CREN = 0x18.4 // USART registers 7 #bit CREN = 0x18.4 // USART registers
8 #bit SPEN = 0x18.7 8 #bit SPEN = 0x18.7
Line 135... Line 135...
135   135  
136 /*-------------------------------- MAIN --------------------------------------*/ 136 /*-------------------------------- MAIN --------------------------------------*/
137 void main() 137 void main()
138 { 138 {
139 unsigned int16 seq, temp, tempa; 139 unsigned int16 seq, temp, tempa;
140 signed int16 ta, to1, to2, tTouch, taOld; 140 signed int16 ta, to1, to2, tTouch;
141 int8 tLSB,tMSB; // Temperatures from TouchMemory 141 int8 tLSB,tMSB; // Temperatures from TouchMemory
142 int8 safety_counter; 142 int8 safety_counter;
143 int8 heatTime, heatPower; 143 int8 heatTime;
144 int1 repeat; // Status flags 144 int1 repeat; // Status flags
145 int1 automatic; 145 int1 automatic;
146   146  
147 output_high(DOME); // Close Dome 147 output_high(DOME); // Close Dome
148 output_low(HEATING); // Heating off 148 output_low(HEATING); // Heating off
Line 152... Line 152...
152   152  
153 seq=0; // Variables initiation 153 seq=0; // Variables initiation
154 heat=0; 154 heat=0;
155 open=0; 155 open=0;
156 heatTime=0; 156 heatTime=0;
157 heatPower=0; -  
158 taOld=2000; -  
159 repeat=TRUE; 157 repeat=TRUE;
160 automatic=FALSE; 158 automatic=FALSE;
161   159  
162 welcome(); 160 welcome();
163   161  
Line 293... Line 291...
293 } 291 }
294 292
295 if(automatic) // Solve automatic mode 293 if(automatic) // Solve automatic mode
296 { 294 {
297 if (heatTime==0) 295 if (heatTime==0)
298 { 296 {
299 if((ta<taOld)&&(heatPower<20)) heatPower++; // Need wormer ? 297 if((tTouch<=-300)&&(ta<=300)) {heat=(700-tTouch)/400;} else {heat=1;} // Needs warmer?
300 if((ta>taOld)&&(heatPower>0)) heatPower--; // Need colder ? -  
301 -  
302 if((ta>=300)&&(ta<2000)) heatPower=1; -  
303 if(ta>=2000) heatPower=0; -  
304   -  
305 taOld=ta; -  
306 heatTime=20; 298 heatTime=MAXHEAT;
307 if(ta>-10000) heat=heatPower; -  
308 } 299 }
309 heatTime--; 300 heatTime--;
-   301
-   302 if(ta>2000) heat=0; // Overtemperature protection
-   303 if(tTouch>2000) heat=0;
-   304 if(ta<-10000) heat=0; // Sensor Error protection
-   305 if(tTouch<-10000) heat=0;
310 306
311 if((abs(to1-to2)<100)&&(tTouch>to1)&&(abs(tTouch-to1)>800)) open=1; // Open the dome 307 if((abs(to1-to2)<100)&&(tTouch>to1)&&(abs(tTouch-to1)>800)) open=1; // Control the dome
-   308 if(to1<-10000) open=0; // Sensor Error protection
-   309 if(tTouch<-10000) open=0;
312 } 310 }
313   311  
314 { // printf 312 { // printf
315 char output[8]; // Output buffer 313 char output[8]; // Output buffer
316 int8 j; // String pointer 314 int8 j; // String pointer