Line 1... |
Line 1... |
1 |
/**** IR Mrakomer 4 ****/ |
1 |
/**** IR Mrakomer 4 ****/ |
2 |
#define VERSION "4.0" |
2 |
#define VERSION "4.0" |
3 |
#define ID "$Id: irmrak4.c 1277 2009-01-07 00:44:17Z kakl $" |
3 |
#define ID "$Id: irmrak4.c 1278 2009-01-07 00:47:35Z kakl $" |
4 |
#include "irmrak4.h" |
4 |
#include "irmrak4.h" |
5 |
|
5 |
|
6 |
#define MAXHEAT 10 // Number of cycles for heating |
6 |
#define MAXHEAT 10 // Number of cycles for heating |
7 |
#define MAXOPEN 10 // Number of cycles for dome open |
7 |
#define MAXOPEN 10 // Number of cycles for dome open |
8 |
#define MEASURE_DELAY 10000 |
8 |
#define MEASURE_DELAY 10000 |
Line 31... |
Line 31... |
31 |
} |
31 |
} |
32 |
|
32 |
|
33 |
void delay(int16 cycles) |
33 |
void delay(int16 cycles) |
34 |
{ |
34 |
{ |
35 |
int16 i; |
35 |
int16 i; |
36 |
|
36 |
|
37 |
for(i=0; i<cycles; i++) {toggle_dome(); delay_us(100);} |
37 |
for(i=0; i<cycles; i++) {toggle_dome(); delay_us(100);} |
38 |
|
38 |
|
39 |
restart_wdt(); |
39 |
restart_wdt(); |
40 |
} |
40 |
} |
41 |
|
41 |
|
Line 91... |
Line 91... |
91 |
|
91 |
|
92 |
delay_ms(1000); |
92 |
delay_ms(1000); |
93 |
restart_wdt(); |
93 |
restart_wdt(); |
94 |
printf("\n\r* Mrakomer %s (C) 2007 KAKL *\n\r",VER); // Welcome message |
94 |
printf("\n\r* Mrakomer %s (C) 2007 KAKL *\n\r",VER); // Welcome message |
95 |
printf("* %s *\n\r",REV); |
95 |
printf("* %s *\n\r",REV); |
96 |
printf("<#seq.> <ambient temp.> <space temp.> <status>\n\r\n\r"); |
96 |
printf("<#seq.> <ambient temp.> <space temp.> <heating> <dome>\n\r\n\r"); |
97 |
tempa=ReadTemp(SA, RAM_Tamb); // Dummy read |
97 |
tempa=ReadTemp(SA, RAM_Tamb); // Dummy read |
98 |
temp=ReadTemp(SA, RAM_Tobj1); |
98 |
temp=ReadTemp(SA, RAM_Tobj1); |
99 |
|
99 |
|
100 |
n=0; |
100 |
n=0; |
101 |
heat=0; |
101 |
heat=0; |
Line 109... |
Line 109... |
109 |
while(TRUE) |
109 |
while(TRUE) |
110 |
{ |
110 |
{ |
111 |
while(kbhit()) getc(); // Flush USART buffer |
111 |
while(kbhit()) getc(); // Flush USART buffer |
112 |
CREN=0; CREN=1; // Reinitialise USART |
112 |
CREN=0; CREN=1; // Reinitialise USART |
113 |
|
113 |
|
114 |
do |
114 |
do |
115 |
{ |
115 |
{ |
116 |
delay(MEASURE_DELAY); |
116 |
delay(MEASURE_DELAY); |
117 |
if (heat>0) |
117 |
if (heat>0) |
118 |
{ |
118 |
{ |
119 |
output_high(HEATING); |
119 |
output_high(HEATING); |
120 |
heat--; |
120 |
heat--; |
121 |
} |
121 |
} |
122 |
else |
122 |
else |
123 |
{ |
123 |
{ |
124 |
output_low(HEATING); |
124 |
output_low(HEATING); |
125 |
} |
125 |
} |
Line 127... |
Line 127... |
127 |
if (open>0) open--; |
127 |
if (open>0) open--; |
128 |
} while (!kbhit()); |
128 |
} while (!kbhit()); |
129 |
|
129 |
|
130 |
{ |
130 |
{ |
131 |
char ch; |
131 |
char ch; |
132 |
|
132 |
|
133 |
ch=getc(); |
133 |
ch=getc(); |
134 |
|
134 |
|
135 |
switch (ch) |
135 |
switch (ch) |
136 |
{ |
136 |
{ |
137 |
case 'h': |
137 |
case 'h': |
138 |
heat=MAXHEAT; // Needs heating |
138 |
heat=MAXHEAT; // Needs heating |
139 |
break; |
139 |
break; |
140 |
|
140 |
|
141 |
case 'c': |
141 |
case 'c': |
142 |
heat=0; // Needs colder |
142 |
heat=0; // Needs colder |
143 |
break; |
143 |
break; |
144 |
|
144 |
|
145 |
case 'o': |
145 |
case 'o': |
146 |
open=MAXOPEN; // Open the dome |
146 |
open=MAXOPEN; // Open the dome |
147 |
break; |
147 |
break; |
148 |
|
148 |
|
149 |
case 'l': |
149 |
case 'l': |
150 |
open=0; // Lock the dome |
150 |
open=0; // Lock the dome |
151 |
break; |
151 |
break; |
152 |
} |
152 |
} |
153 |
} |
153 |
} |
Line 161... |
Line 161... |
161 |
to=temp*2-27315; |
161 |
to=temp*2-27315; |
162 |
|
162 |
|
163 |
{ // printf |
163 |
{ // printf |
164 |
char output[30]; // Output buffer |
164 |
char output[30]; // Output buffer |
165 |
int8 j; // Counter |
165 |
int8 j; // Counter |
166 |
|
166 |
|
167 |
sprintf(output,"#%Lu %Ld %Ld %u %u\n\r\0", n, ta, to, heat, open); |
167 |
sprintf(output,"#%Lu %Ld %Ld %u %u\n\r\0", n, ta, to, heat, open); |
168 |
|
168 |
|
169 |
j=0; |
169 |
j=0; |
170 |
while(output[j]!=0) |
170 |
while(output[j]!=0) |
171 |
{ |
171 |
{ |
172 |
delay(SEND_DELAY); |
172 |
delay(SEND_DELAY); |
173 |
putc(output[j++]); |
173 |
putc(output[j++]); |