| 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 1862 2011-02-20 17:22:55Z kakl $" |
3 |
#define ID "$Id: irmrak4.c 1884 2011-02-26 10:11:40Z 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 51... |
Line 51... |
| 51 |
|
51 |
|
| 52 |
if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0; |
52 |
if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0; |
| 53 |
printf("\r\n\r\n# Mrakomer %s (C) 2007 UST\n\r",VER); // Welcome message |
53 |
printf("\r\n\r\n# Mrakomer %s (C) 2007 UST\n\r",VER); // Welcome message |
| 54 |
printf("#%s\r\n",&REV[4]); |
54 |
printf("#%s\r\n",&REV[4]); |
| 55 |
// printf("#\r\n"); |
55 |
// printf("#\r\n"); |
| 56 |
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"); |
| 57 |
// printf("# h_eat, c_old, o_pen, l_ock, x_open, "); |
57 |
// printf("# h_eat, c_old, o_pen, l_ock, x_open, "); |
| 58 |
// 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"); |
| 59 |
// printf("#\r\n"); |
59 |
// printf("#\r\n"); |
| 60 |
// 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] "); |
| 61 |
// 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"); |
| 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, told; |
140 |
signed int16 ta, to1, to2, tTouch, taOld; |
| 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 |
int1 repeat; // Status flags |
144 |
int1 repeat; // Status flags |
| 144 |
int1 automatic; |
145 |
int1 automatic; |
| 145 |
|
146 |
|
| 146 |
output_high(DOME); // Close Dome |
147 |
output_high(DOME); // Close Dome |
| 147 |
output_low(HEATING); // Heating off |
148 |
output_low(HEATING); // Heating off |
| Line 150... |
Line 151... |
| 150 |
restart_wdt(); |
151 |
restart_wdt(); |
| 151 |
|
152 |
|
| 152 |
seq=0; // Variables initiation |
153 |
seq=0; // Variables initiation |
| 153 |
heat=0; |
154 |
heat=0; |
| 154 |
open=0; |
155 |
open=0; |
| - |
|
156 |
heatTime=0; |
| - |
|
157 |
heatPower=0; |
| - |
|
158 |
taOld=2000; |
| 155 |
repeat=TRUE; |
159 |
repeat=TRUE; |
| 156 |
automatic=FALSE; |
160 |
automatic=FALSE; |
| 157 |
|
161 |
|
| 158 |
welcome(); |
162 |
welcome(); |
| 159 |
|
163 |
|
| Line 288... |
Line 292... |
| 288 |
} |
292 |
} |
| 289 |
} |
293 |
} |
| 290 |
|
294 |
|
| 291 |
if(automatic) // Solve automatic mode |
295 |
if(automatic) // Solve automatic mode |
| 292 |
{ |
296 |
{ |
| - |
|
297 |
if (heatTime==0) |
| - |
|
298 |
{ |
| 293 |
if(((ta<400)||(ta<(tTouch+400)))&&(ta<2000)&&(ta<told)) heat=1; // Need heating |
299 |
if((ta<taOld)&&(heatPower<20)) heatPower++; // Need wormer ? |
| - |
|
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 |
|
| 294 |
told=ta; |
305 |
taOld=ta; |
| - |
|
306 |
heatTime=20; |
| 295 |
if((abs(to1-to2)<100)&&(tTouch>to1)&&(abs(tTouch-to1)>800)) |
307 |
if(ta>-10000) heat=heatPower; |
| - |
|
308 |
} |
| - |
|
309 |
heatTime--; |
| - |
|
310 |
|
| 296 |
open=1; // Open the dome |
311 |
if((abs(to1-to2)<100)&&(tTouch>to1)&&(abs(tTouch-to1)>800)) open=1; // Open the dome |
| 297 |
} |
312 |
} |
| 298 |
|
313 |
|
| 299 |
{ // printf |
314 |
{ // printf |
| 300 |
char output[8]; // Output buffer |
315 |
char output[8]; // Output buffer |
| 301 |
int8 j; // String pointer |
316 |
int8 j; // String pointer |