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 1720 2010-12-10 20:47:52Z kakl $" |
3 |
#define ID "$Id: irmrak4.c 1862 2011-02-20 17:22:55Z 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 17... |
Line 17... |
17 |
#define MAXOPEN 20 // Number of cycles for dome open |
17 |
#define MAXOPEN 20 // Number of cycles for dome open |
18 |
#define MEASURE_DELAY 6000 // Delay to a next measurement |
18 |
#define MEASURE_DELAY 6000 // Delay to a next measurement |
19 |
#define RESPONSE_DELAY 100 // Reaction time after receiving a command |
19 |
#define RESPONSE_DELAY 100 // Reaction time after receiving a command |
20 |
#define SAFETY_COUNT 90 // Time of one emergency cycle |
20 |
#define SAFETY_COUNT 90 // Time of one emergency cycle |
21 |
#define SEND_DELAY 50 // Time between two characters on RS232 |
21 |
#define SEND_DELAY 50 // Time between two characters on RS232 |
- |
|
22 |
#define TEMPERATURE_INSIDE 1800 // Keep this temperature inside MM's box |
22 |
|
23 |
|
23 |
#define DOME PIN_B4 // Dome controll port |
24 |
#define DOME PIN_B4 // Dome controll port |
24 |
#define HEATING PIN_B3 // Heating for defrosting |
25 |
#define HEATING PIN_B3 // Heating for defrosting |
25 |
|
26 |
|
26 |
|
27 |
|
Line 54... |
Line 55... |
54 |
// printf("#\r\n"); |
55 |
// printf("#\r\n"); |
55 |
printf("# commands: h, c, o, l, x, i, r, a, s, u\r\n"); |
56 |
printf("# commands: h, c, o, l, x, i, r, a, s, u\r\n"); |
56 |
// printf("# h_eat, c_old, o_pen, l_ock, x_open, "); |
57 |
// printf("# h_eat, c_old, o_pen, l_ock, x_open, "); |
57 |
// printf("i_nfo, r_epeat, a_uto, s_single, u_pdate\r\n"); |
58 |
// printf("i_nfo, r_epeat, a_uto, s_single, u_pdate\r\n"); |
58 |
// printf("#\r\n"); |
59 |
// printf("#\r\n"); |
59 |
printf("# ver seq in[1/100 C] sky[1/100 C] sky[1/100 C] "); |
60 |
// printf("# ver seq in[1/100 C] sky[1/100 C] sky[1/100 C] "); |
60 |
printf("out[1/100 C] heat[s] dome[s] check\r\n\r\n"); |
61 |
// printf("out[1/100 C] heat[s] dome[s] check\r\n\r\n"); |
61 |
|
62 |
|
62 |
//---WDT |
63 |
//---WDT |
63 |
restart_wdt(); |
64 |
restart_wdt(); |
64 |
} |
65 |
} |
65 |
|
66 |
|
Line 134... |
Line 135... |
134 |
|
135 |
|
135 |
/*-------------------------------- MAIN --------------------------------------*/ |
136 |
/*-------------------------------- MAIN --------------------------------------*/ |
136 |
void main() |
137 |
void main() |
137 |
{ |
138 |
{ |
138 |
unsigned int16 seq, temp, tempa; |
139 |
unsigned int16 seq, temp, tempa; |
139 |
signed int16 ta, to1, to2, tTouch; |
140 |
signed int16 ta, to1, to2, tTouch, told; |
140 |
int8 tLSB,tMSB; // Temperatures from TouchMemory |
141 |
int8 tLSB,tMSB; // Temperatures from TouchMemory |
141 |
int8 safety_counter; |
142 |
int8 safety_counter; |
142 |
int1 repeat; // Status flags |
143 |
int1 repeat; // Status flags |
143 |
int1 automatic; |
144 |
int1 automatic; |
144 |
|
145 |
|
Line 175... |
Line 176... |
175 |
|
176 |
|
176 |
delay(RESPONSE_DELAY); |
177 |
delay(RESPONSE_DELAY); |
177 |
|
178 |
|
178 |
if (safety_counter>=SAFETY_COUNT) |
179 |
if (safety_counter>=SAFETY_COUNT) |
179 |
{ |
180 |
{ |
- |
|
181 |
if (heat>0) { output_high(HEATING); } else { output_low(HEATING); } |
- |
|
182 |
|
180 |
if (heat>0) heat--; |
183 |
if (heat>0) heat--; |
181 |
if (open>0) open--; |
184 |
if (open>0) open--; |
182 |
|
185 |
|
183 |
if (heat>0) { output_high(HEATING); } else { output_low(HEATING); } |
- |
|
184 |
|
- |
|
185 |
safety_counter=0; |
186 |
safety_counter=0; |
186 |
//---WDT |
187 |
//---WDT |
187 |
restart_wdt(); |
188 |
restart_wdt(); |
188 |
} |
189 |
} |
189 |
} while (!kbhit()&&!repeat); |
190 |
} while (!kbhit()&&!repeat); |
Line 287... |
Line 288... |
287 |
} |
288 |
} |
288 |
} |
289 |
} |
289 |
|
290 |
|
290 |
if(automatic) // Solve automatic mode |
291 |
if(automatic) // Solve automatic mode |
291 |
{ |
292 |
{ |
292 |
if(ta<1800) heat=MAXHEAT; // Need heating |
293 |
if(((ta<400)||(ta<(tTouch+400)))&&(ta<2000)&&(ta<told)) heat=1; // Need heating |
- |
|
294 |
told=ta; |
293 |
if((abs(to1-to2)<80)&&(tTouch>to1)&&(abs(tTouch-to1)>1500)) |
295 |
if((abs(to1-to2)<100)&&(tTouch>to1)&&(abs(tTouch-to1)>800)) |
294 |
open=MAXOPEN; // Open the dome |
296 |
open=1; // Open the dome |
295 |
} |
297 |
} |
296 |
|
298 |
|
297 |
{ // printf |
299 |
{ // printf |
298 |
char output[8]; // Output buffer |
300 |
char output[8]; // Output buffer |
299 |
int8 j; // String pointer |
301 |
int8 j; // String pointer |