| 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 2177 2011-09-05 18:56:16Z kaklik $" |
3 |
#define ID "$Id: irmrak4.c 4248 2015-10-19 18:09:23Z 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 142... |
Line 142... |
| 142 |
int8 safety_counter; |
142 |
int8 safety_counter; |
| 143 |
int8 heatTime; |
143 |
int8 heatTime; |
| 144 |
int1 repeat; // Status flags |
144 |
int1 repeat; // Status flags |
| 145 |
int1 automatic; |
145 |
int1 automatic; |
| 146 |
|
146 |
|
| - |
|
147 |
//KAKL!!! |
| - |
|
148 |
int8 SN[10]; |
| - |
|
149 |
|
| - |
|
150 |
|
| 147 |
output_high(DOME); // Close Dome |
151 |
output_high(DOME); // Close Dome |
| 148 |
output_low(HEATING); // Heating off |
152 |
output_low(HEATING); // Heating off |
| 149 |
|
153 |
|
| 150 |
delay_ms(1000); |
154 |
delay_ms(1000); |
| 151 |
restart_wdt(); |
155 |
restart_wdt(); |
| Line 268... |
Line 272... |
| 268 |
//---WDT |
272 |
//---WDT |
| 269 |
restart_wdt(); |
273 |
restart_wdt(); |
| 270 |
delay(MEASURE_DELAY); // Delay to a next measurement |
274 |
delay(MEASURE_DELAY); // Delay to a next measurement |
| 271 |
|
275 |
|
| 272 |
{ |
276 |
{ |
| 273 |
int8 SN[10]; |
277 |
//KAKL!!! int8 SN[10]; |
| 274 |
int8 n; |
278 |
int8 n; |
| 275 |
|
279 |
|
| 276 |
touch_present(); //Issues a reset and returns true if the touch device is there. |
280 |
touch_present(); //Issues a reset and returns true if the touch device is there. |
| 277 |
touch_write_byte(0xCC); |
281 |
touch_write_byte(0xCC); |
| 278 |
touch_write_byte(0xBE); |
282 |
touch_write_byte(0xBE); |
| Line 288... |
Line 292... |
| 288 |
{ |
292 |
{ |
| 289 |
tTouch=-27315; |
293 |
tTouch=-27315; |
| 290 |
} |
294 |
} |
| 291 |
} |
295 |
} |
| 292 |
|
296 |
|
| - |
|
297 |
/* |
| 293 |
if(automatic) // Solve automatic mode |
298 |
if(automatic) // Solve automatic mode |
| 294 |
{ |
299 |
{ |
| 295 |
if (heatTime==0) |
300 |
if (heatTime==0) |
| 296 |
{ |
301 |
{ |
| 297 |
if((tTouch<=-300)&&(ta<=300)) {heat=(700-tTouch)/400;} else {heat=1;} // Needs warmer? |
302 |
if((tTouch<=-300)&&(ta<=300)) {heat=(700-tTouch)/400;} else {heat=1;} // Needs warmer? |
| Line 306... |
Line 311... |
| 306 |
|
311 |
|
| 307 |
if((abs(to1-to2)<100)&&(tTouch>to1)&&(abs(tTouch-to1)>800)) open=1; // Control the dome |
312 |
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 |
313 |
if(to1<-10000) open=0; // Sensor Error protection |
| 309 |
if(tTouch<-10000) open=0; |
314 |
if(tTouch<-10000) open=0; |
| 310 |
} |
315 |
} |
| 311 |
|
316 |
*/ |
| 312 |
{ // printf |
317 |
{ // printf |
| 313 |
char output[8]; // Output buffer |
318 |
char output[8]; // Output buffer |
| 314 |
int8 j; // String pointer |
319 |
int8 j; // String pointer |
| 315 |
int8 check=0; // Checksum is calculated between '$' and '*' |
320 |
int8 check=0; // Checksum is calculated between '$' and '*' |
| 316 |
|
321 |
|
| Line 331... |
Line 336... |
| 331 |
j=0; while(output[j]!=0) { delay(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
336 |
j=0; while(output[j]!=0) { delay(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
| 332 |
sprintf(output,"%u \0", heat); |
337 |
sprintf(output,"%u \0", heat); |
| 333 |
j=0; while(output[j]!=0) { delay(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
338 |
j=0; while(output[j]!=0) { delay(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
| 334 |
sprintf(output,"%u \0", open); |
339 |
sprintf(output,"%u \0", open); |
| 335 |
j=0; while(output[j]!=0) { delay(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
340 |
j=0; while(output[j]!=0) { delay(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
| - |
|
341 |
//KAKL!!! sprintf(output,"*%X\r\n\0", check); |
| 336 |
sprintf(output,"*%X\r\n\0", check); |
342 |
sprintf(output,"*%X \0", check); |
| - |
|
343 |
j=0; while(output[j]!=0) { delay(SEND_DELAY); putc(output[j++]); } |
| - |
|
344 |
{ |
| - |
|
345 |
int n; |
| - |
|
346 |
for (n=0;n<9;n++) |
| - |
|
347 |
{ |
| - |
|
348 |
sprintf(output,"%X \0", SN[n]); |
| - |
|
349 |
|
| - |
|
350 |
j=0; while(output[j]!=0) { delay(SEND_DELAY); putc(output[j++]); } |
| - |
|
351 |
} |
| - |
|
352 |
} |
| - |
|
353 |
sprintf(output,"\r\n\0"); |
| 337 |
j=0; while(output[j]!=0) { delay(SEND_DELAY); putc(output[j++]); } |
354 |
j=0; while(output[j]!=0) { delay(SEND_DELAY); putc(output[j++]); } |
| - |
|
355 |
|
| 338 |
delay(SEND_DELAY); |
356 |
delay(SEND_DELAY); |
| 339 |
} |
357 |
} |
| 340 |
|
358 |
|
| 341 |
//---WDT |
359 |
//---WDT |
| 342 |
restart_wdt(); |
360 |
restart_wdt(); |