2080 |
kakl |
1 |
/* |
|
|
2 |
Ovladani domu rozvadec 2. n.p. |
|
|
3 |
|
|
|
4 |
Syntaxe prikazu: |
|
|
5 |
|
|
|
6 |
<Roleta/Svetlo><#patro><#mistnost><Nord/Jih/Vychod/Zapad/A/B><Up/Down> |
|
|
7 |
R2aNU - roleta, 2. n.p., mistnost 10, sever, nahoru |
|
|
8 |
S12A - svetlo, 1. n.p., mistnost 2, prostredni |
|
|
9 |
|
2081 |
kakl |
10 |
Rozmisteni desek: |
|
|
11 |
|
|
|
12 |
[CAN] |
|
|
13 |
[IN J] [IN D] |
|
|
14 |
[OUT A] [CPU] |
|
|
15 |
|
|
|
16 |
[OUT F] [OUT B] [OUT E] |
|
|
17 |
|
2080 |
kakl |
18 |
*/ |
1746 |
kakl |
19 |
#include "main.h" |
|
|
20 |
|
|
|
21 |
#case |
2085 |
kakl |
22 |
#use fast_io(A) // Aby se neztracely znaky pri cteni prikazu |
|
|
23 |
#use fast_io(B) |
|
|
24 |
#use fast_io(E) |
|
|
25 |
#use fast_io(F) |
|
|
26 |
#use fast_io(D) |
|
|
27 |
#use fast_io(J) |
1746 |
kakl |
28 |
|
2231 |
kakl |
29 |
#define T_REVERS 5 // 5*256 ms = 1,25 s; pred prepnutim rele (zastaveni motoru a vybiti kondenzatoru) |
2232 |
kakl |
30 |
#define T_START 2 // 2*256 ms = 0,5 s; po prepnuti rele do sepnuti triaku |
2231 |
kakl |
31 |
#define T_GO 117 // 117*256 ms = 30 s; max. beh rolety |
|
|
32 |
#define T_GO_ZALUZIE 6 // cca 1,5 s; beh zaluzie (pouze na preklopeni lamel) |
|
|
33 |
#define T_RECEIVE 10 // cca 2,6 s |
|
|
34 |
#define ZAKMIT 2000 // pocet pruchodu hlavni smyckou pred opetovnou detekci prepnuti vypinace |
1747 |
kakl |
35 |
|
2232 |
kakl |
36 |
#define OR106Z PIN_A0 // t1 Roleta trucovna zapad |
2231 |
kakl |
37 |
#define OR110N PIN_A1 // t2 Zaluzie koupelna dole sever |
|
|
38 |
#define OR104V PIN_A2 // t3 Roleta lab vychod |
|
|
39 |
#define OR104J PIN_A3 // t4 Roleta lab jih |
|
|
40 |
#define OR103V PIN_A4 // t5 Roleta loznice |
|
|
41 |
#define OR202J PIN_A5 // t6 Roleta Kaklik |
|
|
42 |
#define OR204Z PIN_A6 // t7 Roleta radiomistnost |
|
|
43 |
#define OR207V PIN_A7 // t8 Roleta klubovna |
1746 |
kakl |
44 |
|
2231 |
kakl |
45 |
#define OR208V PIN_F0 // t1 Roleta Zizala vychod |
|
|
46 |
#define OR208J PIN_F1 // t2 Roleta Zizala jih |
|
|
47 |
//??? #define OR107 PIN_F2 // t3 |
|
|
48 |
//??? #define OR107 PIN_F3 // t4 |
|
|
49 |
#define OR201Z PIN_F4 // t5 Roleta chodba nahore |
|
|
50 |
#define OR205N PIN_F5 // t6 Roleta puda |
|
|
51 |
//??? #define OR105 PIN_F6 // t7 Roleta kuchyn |
|
|
52 |
//#define O... PIN_F7 // t8 |
|
|
53 |
|
|
|
54 |
|
2080 |
kakl |
55 |
#define OS103J PIN_B0 // t1 Svetla loznice |
|
|
56 |
#define OS105Z PIN_B1 // t2 Svetlo kuchyn nad lavici |
2084 |
kakl |
57 |
#define OS110N PIN_B2 // t3 Svetlo koupelna dole zachod a sprhca |
2080 |
kakl |
58 |
#define OS106A PIN_B3 // t4 Svetlo trucovna stred |
|
|
59 |
#define OS107A PIN_B4 // t5 Svetlo satna |
|
|
60 |
#define OS109A PIN_B5 // t6 Svetlo technologicka mistnost |
2084 |
kakl |
61 |
#define OS205A PIN_B6 // t7 Svetlo puda |
|
|
62 |
#define OS204A PIN_B7 // t8 Svetlo radiomistnost |
1746 |
kakl |
63 |
|
|
|
64 |
//#define OS105C PIN_C2 |
|
|
65 |
//#define PIN_C3 31763 |
|
|
66 |
//#define PIN_C4 31764 |
|
|
67 |
//#define PIN_C5 31765 |
|
|
68 |
//#define PIN_C6 31766 //TX |
|
|
69 |
//#define PIN_C7 31767 //RX |
|
|
70 |
|
2085 |
kakl |
71 |
#define OS102A PIN_E0 // t1 Svetlo chodba |
|
|
72 |
#define OS105A PIN_E1 // t2 Svetlo kuchyne stred |
|
|
73 |
#define OS207A PIN_E2 // t3 Svetlo klubovna |
|
|
74 |
#define OS104A PIN_E3 // t4 Svetlo laborator |
|
|
75 |
#define OS202A PIN_E4 // t5 Svetlo Kaklik stred |
|
|
76 |
#define OS209A PIN_E5 // t6 Svetlo Zizala koupelna |
|
|
77 |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
2231 |
kakl |
78 |
#define RE PIN_E7 // t8 Rele pro rizeni smeru rolet |
2085 |
kakl |
79 |
|
2084 |
kakl |
80 |
//#define I.... input(PIN_D0) // A |
|
|
81 |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
|
|
82 |
#define IS207AJ input(PIN_D2) // C Vypinac klubovna |
|
|
83 |
#define IR207VD input(PIN_D3) // D Vypinac roleta klubovna dolu |
|
|
84 |
#define IR207VU input(PIN_D4) // E Vypinac roleta klubovna nahoru |
|
|
85 |
#define IS201AV input(PIN_D5) // F Vypinac chodba 2.n.p. vychod |
|
|
86 |
#define IS209AJ input(PIN_D6) // G Vypinac koupelna Zizala |
|
|
87 |
#define IS203AJ input(PIN_D7) // H Vypinac koupelna Kaklik |
|
|
88 |
|
|
|
89 |
#define IS202AN input(PIN_J0) // A Vypinac svetlo Kaklik stred u dveri na chodbu |
|
|
90 |
#define IR202ND input(PIN_J1) // B Vypinac roleta Kaklik dolu u dveri |
|
|
91 |
#define IR202NU input(PIN_J2) // C Vypinac roleta Kaklik nahoru u dveri |
|
|
92 |
#define IS205A input(PIN_J3) // D Vypinac svetlo puda |
|
|
93 |
#define IS204AJ input(PIN_J4) // E Vypinac svetlo radiomistnost u dveri na chodbu |
|
|
94 |
#define IR204ZD input(PIN_J5) // F Vypinac roleta radiomistnost dolu |
|
|
95 |
#define IR204ZU input(PIN_J6) // G Vypinac roleta radiomistnost nahoru |
|
|
96 |
//#define I.... input(PIN_J7) // H |
|
|
97 |
|
2080 |
kakl |
98 |
int1 s201AV; |
|
|
99 |
int1 s201AZ; |
|
|
100 |
int1 s207AJ; |
|
|
101 |
int1 s203AJ; |
|
|
102 |
int1 s209AJ; |
|
|
103 |
int1 r207VU; |
|
|
104 |
int1 r207VD; |
2084 |
kakl |
105 |
int1 s202AN; |
|
|
106 |
int1 r202ND; |
|
|
107 |
int1 r202NU; |
|
|
108 |
int1 s205A; |
|
|
109 |
int1 s204AJ; |
|
|
110 |
int1 r204ZD; |
|
|
111 |
int1 r204ZU; |
1746 |
kakl |
112 |
|
1747 |
kakl |
113 |
#bit CREN = 0xFAB.4 // USART enable register |
|
|
114 |
|
2080 |
kakl |
115 |
#define LED1 PIN_C0 |
|
|
116 |
#define LED2 PIN_C1 |
1746 |
kakl |
117 |
|
|
|
118 |
#define ON(port) output_low(port); |
|
|
119 |
#define OFF(port) output_high(port); |
|
|
120 |
|
2231 |
kakl |
121 |
typedef enum {RUN, STOP} roleta_state; |
|
|
122 |
roleta_state rol[18]; // Stavy rolet |
|
|
123 |
#define R103V 0 |
|
|
124 |
#define R110N 1 |
|
|
125 |
#define R104V 2 |
|
|
126 |
#define R104J 3 |
|
|
127 |
#define R207V 4 |
|
|
128 |
#define R202J 5 |
|
|
129 |
#define R204Z 6 |
1746 |
kakl |
130 |
|
2232 |
kakl |
131 |
typedef enum {UP, DOWN, REVERS_UP, REVERS_DOWN, RUN_UP, RUN_DOWN, RUN_UP_WAITING} relay_state; |
2231 |
kakl |
132 |
relay_state relay; // Stavy rele |
1747 |
kakl |
133 |
|
2231 |
kakl |
134 |
int8 timer_run; // Bezpecnostni casovac behu rolety |
|
|
135 |
int8 timer_run_zaluzie; // Casovac zaluzie na preklopeni lamel |
|
|
136 |
int8 timer_revers; // Prodleva na vybiti kondenzatoru pa zastaveni rolety pred prepnutim rele |
|
|
137 |
int8 timer_start; // Prodleva na prepnuti rele pred startem rolety |
|
|
138 |
int8 timer; // Casovac komunikace |
|
|
139 |
|
1747 |
kakl |
140 |
#int_TIMER0 |
|
|
141 |
void TIMER0_isr(void) |
|
|
142 |
{ |
1748 |
kakl |
143 |
if(timer>0) timer--; |
2231 |
kakl |
144 |
if(timer_run>0) timer_run--; |
|
|
145 |
if(timer_revers>0) timer_revers--; |
|
|
146 |
if(timer_start>0) timer_start--; |
|
|
147 |
if(timer_run_zaluzie>0) timer_run_zaluzie--; |
2233 |
kakl |
148 |
output_toggle(LED2); |
1747 |
kakl |
149 |
} |
|
|
150 |
|
2231 |
kakl |
151 |
void stop_all() // Zastav vsechny rolety |
|
|
152 |
{ |
|
|
153 |
int8 n; |
|
|
154 |
|
|
|
155 |
output_a(0xFF); |
|
|
156 |
output_f(0xFF); |
2233 |
kakl |
157 |
for(n=0; n<18; n++) rol[n]=STOP; |
2231 |
kakl |
158 |
} |
|
|
159 |
|
|
|
160 |
void run_all() // Spust rolety |
|
|
161 |
{ |
|
|
162 |
if (rol[R103V]==RUN) ON(OR103V); |
|
|
163 |
if (rol[R110N]==RUN) ON(OR110N); |
|
|
164 |
if (rol[R104V]==RUN) ON(OR104V); |
|
|
165 |
if (rol[R104J]==RUN) ON(OR104J); |
|
|
166 |
if (rol[R207V]==RUN) ON(OR207V); |
|
|
167 |
if (rol[R202J]==RUN) ON(OR202J); |
|
|
168 |
if (rol[R204Z]==RUN) ON(OR204Z); |
|
|
169 |
} |
|
|
170 |
|
2232 |
kakl |
171 |
void run(int8 roleta) // Spust konkretni roletu |
1747 |
kakl |
172 |
{ |
2232 |
kakl |
173 |
switch (roleta) |
1747 |
kakl |
174 |
{ |
2232 |
kakl |
175 |
case R103V: ON(OR103V); break; |
|
|
176 |
case R110N: ON(OR110N); break; |
|
|
177 |
case R104V: ON(OR104V); break; |
|
|
178 |
case R104J: ON(OR104J); break; |
|
|
179 |
case R207V: ON(OR207V); break; |
|
|
180 |
case R202J: ON(OR202J); break; |
|
|
181 |
case R204Z: ON(OR204Z); break; |
1747 |
kakl |
182 |
} |
|
|
183 |
} |
|
|
184 |
|
2233 |
kakl |
185 |
void stop(int8 roleta) // Spust konkretni roletu |
|
|
186 |
{ |
|
|
187 |
switch (roleta) |
|
|
188 |
{ |
|
|
189 |
case R103V: OFF(OR103V); break; |
|
|
190 |
case R110N: OFF(OR110N); break; |
|
|
191 |
case R104V: OFF(OR104V); break; |
|
|
192 |
case R104J: OFF(OR104J); break; |
|
|
193 |
case R207V: OFF(OR207V); break; |
|
|
194 |
case R202J: OFF(OR202J); break; |
|
|
195 |
case R204Z: OFF(OR204Z); break; |
|
|
196 |
} |
|
|
197 |
} |
|
|
198 |
|
2232 |
kakl |
199 |
void up(int8 roleta) // Pozadavek, aby roleta jela nahoru |
1747 |
kakl |
200 |
{ |
2232 |
kakl |
201 |
if (rol[roleta]==RUN) |
1747 |
kakl |
202 |
{ |
2232 |
kakl |
203 |
rol[roleta]=STOP; // Roleta jela, tak zastav |
2233 |
kakl |
204 |
stop(roleta); |
1747 |
kakl |
205 |
} |
2232 |
kakl |
206 |
else |
|
|
207 |
{ |
|
|
208 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
|
|
209 |
{ |
|
|
210 |
relay=REVERS_UP; // Reverzuj |
|
|
211 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
|
|
212 |
stop_all(); // Vsechno zastav |
|
|
213 |
} |
|
|
214 |
if (relay==RUN_UP) |
|
|
215 |
{ |
2233 |
kakl |
216 |
run(roleta); // Jede se spravnym smerem, tak jenom pust roletu |
2232 |
kakl |
217 |
} |
|
|
218 |
|
|
|
219 |
rol[roleta]=RUN; // Roleta stala, tak ji pust |
|
|
220 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
|
|
221 |
} |
1747 |
kakl |
222 |
} |
|
|
223 |
|
|
|
224 |
|
2232 |
kakl |
225 |
void down(int8 roleta) // Pozadavek, aby roleta jela dolu |
|
|
226 |
{ |
|
|
227 |
if (rol[roleta]==RUN) |
|
|
228 |
{ |
|
|
229 |
rol[roleta]=STOP; // Roleta jela, tak zastav |
2233 |
kakl |
230 |
stop(roleta); |
2232 |
kakl |
231 |
} |
|
|
232 |
else |
|
|
233 |
{ |
|
|
234 |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) // Rele je prepnuto na druhou stranu! |
|
|
235 |
{ |
|
|
236 |
relay=REVERS_DOWN; // Reverzuj |
|
|
237 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
|
|
238 |
stop_all(); // Vsechno zastav |
|
|
239 |
} |
|
|
240 |
if (relay==RUN_DOWN) |
|
|
241 |
{ |
2233 |
kakl |
242 |
run(roleta); // Jede se spravnym smerem, tak jenom pust roletu |
2232 |
kakl |
243 |
} |
|
|
244 |
|
|
|
245 |
rol[roleta]=RUN; // Roleta stala, tak ji pust |
|
|
246 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
|
|
247 |
} |
|
|
248 |
} |
|
|
249 |
|
|
|
250 |
|
1746 |
kakl |
251 |
void main() |
|
|
252 |
{ |
2085 |
kakl |
253 |
char buf[10]; // Buffer pro prijem prikazu |
2153 |
kakl |
254 |
unsigned int16 zakmity=0; // Osetreni zakmitu vypinacu |
1746 |
kakl |
255 |
|
1748 |
kakl |
256 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
257 |
setup_adc(ADC_CLOCK_DIV_2); |
|
|
258 |
setup_psp(PSP_DISABLED); |
|
|
259 |
setup_spi(SPI_SS_DISABLED); |
|
|
260 |
setup_wdt(WDT_OFF); |
2085 |
kakl |
261 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8); |
1748 |
kakl |
262 |
setup_timer_1(T1_DISABLED); |
|
|
263 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
264 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
|
|
265 |
setup_ccp1(CCP_OFF); |
|
|
266 |
setup_comparator(NC_NC_NC_NC); |
|
|
267 |
setup_vref(FALSE); |
2085 |
kakl |
268 |
|
|
|
269 |
set_tris_a(0); // Vystupy |
|
|
270 |
set_tris_b(0); |
|
|
271 |
set_tris_e(0); |
|
|
272 |
set_tris_f(0); |
|
|
273 |
set_tris_d(0xFF); // Vstupy |
|
|
274 |
set_tris_j(0xFF); |
1747 |
kakl |
275 |
|
2080 |
kakl |
276 |
output_a(0xFF); // Vsechno zhasni a zastav |
|
|
277 |
output_b(0xFF); |
|
|
278 |
output_f(0xFF); |
|
|
279 |
output_e(0xFF); |
2231 |
kakl |
280 |
stop_all(); |
1747 |
kakl |
281 |
|
2232 |
kakl |
282 |
relay=RUN_UP_WAITING; // Rele je na zacatku vypnuto |
2231 |
kakl |
283 |
|
2081 |
kakl |
284 |
{ |
|
|
285 |
int n; |
|
|
286 |
|
|
|
287 |
for(n=0;n<10;n++) |
|
|
288 |
{ |
|
|
289 |
output_low(LED1); // Indikace restartu (pockame na nabiti kondenzatoru ve vstupnich obvodech) |
|
|
290 |
delay_ms(100); |
|
|
291 |
output_high(LED1); |
|
|
292 |
delay_ms(100); |
|
|
293 |
restart_wdt(); |
|
|
294 |
} |
|
|
295 |
} |
1746 |
kakl |
296 |
|
2080 |
kakl |
297 |
s201AV=IS201AV; // Precteme vychozi stav vypinacu |
|
|
298 |
s201AZ=IS201AZ; |
|
|
299 |
s207AJ=IS207AJ; |
|
|
300 |
s203AJ=IS203AJ; |
|
|
301 |
s209AJ=IS209AJ; |
|
|
302 |
r207VU=IR207VU; |
|
|
303 |
r207VD=IR207VD; |
2084 |
kakl |
304 |
s202AN=IS202AN; |
|
|
305 |
r202ND=IR202ND; |
|
|
306 |
r202NU=IR202NU; |
|
|
307 |
s205A=IS205A; |
|
|
308 |
s204AJ=IS204AJ; |
|
|
309 |
r204ZD=IR204ZD; |
|
|
310 |
r204ZU=IR204ZU; |
2232 |
kakl |
311 |
|
|
|
312 |
timer_run=0; // Zastav vsechny casovace |
|
|
313 |
timer=0; |
|
|
314 |
timer_revers=0; |
|
|
315 |
timer_start=0; |
|
|
316 |
timer_run_zaluzie=0; |
|
|
317 |
zakmity=0; |
|
|
318 |
|
2233 |
kakl |
319 |
enable_interrupts(INT_TIMER0); // Spust casovani |
1748 |
kakl |
320 |
enable_interrupts(GLOBAL); |
2081 |
kakl |
321 |
|
2232 |
kakl |
322 |
CREN=0; CREN=1; // Reinitialise USART |
|
|
323 |
|
1746 |
kakl |
324 |
while(TRUE) |
|
|
325 |
{ |
2085 |
kakl |
326 |
restart_wdt(); |
1748 |
kakl |
327 |
|
|
|
328 |
if(kbhit()) // Chce po nas nekdo neco? |
1746 |
kakl |
329 |
{ |
1748 |
kakl |
330 |
buf[0]=getc(); |
|
|
331 |
if((buf[0]=='S')||(buf[0]=='R')) // Jinym znakem nesmi zacinat prikaz |
1746 |
kakl |
332 |
{ |
1748 |
kakl |
333 |
int8 n=0; // Ukazatel do prijimaciho bufferu |
2231 |
kakl |
334 |
timer=T_RECEIVE; // Timeout pro prijem znaku |
1748 |
kakl |
335 |
|
|
|
336 |
do |
1746 |
kakl |
337 |
{ |
1748 |
kakl |
338 |
if(kbhit()) // Je dalsi znak? |
1747 |
kakl |
339 |
{ |
1748 |
kakl |
340 |
n++; |
|
|
341 |
buf[n]=getc(); |
1747 |
kakl |
342 |
} |
1748 |
kakl |
343 |
} while ((buf[n]!='\r')&&(timer>0)&&(n<7)); |
|
|
344 |
|
|
|
345 |
if (timer==0) { CREN=0; CREN=1; } // Reinitialise USART |
|
|
346 |
|
|
|
347 |
output_toggle(LED1); // Ukonceni prijimani prikazu |
|
|
348 |
|
|
|
349 |
if((timer>0)) |
1746 |
kakl |
350 |
{ |
1748 |
kakl |
351 |
|
|
|
352 |
if((buf[0]=='S')&&(n>=4)) // Zmena stavu svetla |
1747 |
kakl |
353 |
{ |
1748 |
kakl |
354 |
if(buf[1]=='1') |
|
|
355 |
{ |
|
|
356 |
switch(buf[2]) |
|
|
357 |
{ |
|
|
358 |
case '2': |
2080 |
kakl |
359 |
output_toggle(OS102A); |
1748 |
kakl |
360 |
break; |
|
|
361 |
case '3': |
2080 |
kakl |
362 |
output_toggle(OS103J); |
1748 |
kakl |
363 |
break; |
|
|
364 |
case '4': |
2080 |
kakl |
365 |
output_toggle(OS104A); |
1748 |
kakl |
366 |
break; |
|
|
367 |
case '5': |
2080 |
kakl |
368 |
if(buf[3]=='A') {output_toggle(OS105A);} |
|
|
369 |
if(buf[3]=='Z') {output_toggle(OS105Z);} |
1748 |
kakl |
370 |
break; |
|
|
371 |
case '6': |
2080 |
kakl |
372 |
output_toggle(OS106A); |
1748 |
kakl |
373 |
break; |
|
|
374 |
case '7': |
2080 |
kakl |
375 |
output_toggle(OS107A); |
1748 |
kakl |
376 |
break; |
|
|
377 |
case '8': |
2080 |
kakl |
378 |
// output_toggle(OS108A); |
1748 |
kakl |
379 |
break; |
|
|
380 |
case '9': |
2080 |
kakl |
381 |
output_toggle(OS109A); |
1748 |
kakl |
382 |
break; |
|
|
383 |
case 'a': |
2080 |
kakl |
384 |
// output_toggle(OS110J); |
|
|
385 |
output_toggle(OS110N); |
1748 |
kakl |
386 |
break; |
|
|
387 |
} |
|
|
388 |
} |
1747 |
kakl |
389 |
} |
1748 |
kakl |
390 |
|
|
|
391 |
if((buf[0]=='R')&&(n>=5)) // Zmena stavu rolety |
|
|
392 |
{ |
|
|
393 |
if(buf[1]=='1') |
|
|
394 |
{ |
|
|
395 |
switch(buf[2]) |
|
|
396 |
{ |
|
|
397 |
case '3': |
2233 |
kakl |
398 |
if(buf[4]=='U') {up(R103V);} else {down(R103V);} |
1748 |
kakl |
399 |
break; |
|
|
400 |
case '4': |
2233 |
kakl |
401 |
if(buf[3]=='V') if((buf[4]=='U')) {up(R104V);} else {down(R104V);} |
|
|
402 |
if(buf[3]=='J') if((buf[4]=='U')) {up(R104J);} else {down(R104J);} |
1748 |
kakl |
403 |
break; |
|
|
404 |
case 'a': |
2233 |
kakl |
405 |
if((buf[4]=='U')) |
|
|
406 |
{//up(R110N); |
|
|
407 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
|
|
408 |
{ |
|
|
409 |
relay=REVERS_UP; // Reverzuj |
|
|
410 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
|
|
411 |
stop_all(); // Vsechno zastav |
|
|
412 |
} |
|
|
413 |
if (relay==RUN_UP) |
|
|
414 |
{ |
|
|
415 |
run(R110N); // Jede se spravnym smerem, tak jenom pust roletu |
|
|
416 |
} |
|
|
417 |
|
|
|
418 |
rol[R110N]=RUN; // Roleta stala, tak ji pust |
|
|
419 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
|
|
420 |
} |
|
|
421 |
else |
|
|
422 |
{//down(R110N); |
|
|
423 |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) // Rele je prepnuto na druhou stranu! |
|
|
424 |
{ |
|
|
425 |
relay=REVERS_DOWN; // Reverzuj |
|
|
426 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
|
|
427 |
stop_all(); // Vsechno zastav |
|
|
428 |
} |
|
|
429 |
if (relay==RUN_DOWN) |
|
|
430 |
{ |
|
|
431 |
run(R110N); // Jede se spravnym smerem, tak jenom pust roletu |
|
|
432 |
} |
|
|
433 |
|
|
|
434 |
rol[R110N]=RUN; // Roleta stala, tak ji pust |
|
|
435 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
|
|
436 |
} |
|
|
437 |
timer_run_zaluzie=T_GO_ZALUZIE; |
1748 |
kakl |
438 |
break; |
|
|
439 |
} |
|
|
440 |
} |
|
|
441 |
} |
|
|
442 |
|
1746 |
kakl |
443 |
} |
|
|
444 |
} |
|
|
445 |
} |
1748 |
kakl |
446 |
|
2080 |
kakl |
447 |
// mistni vypinace z 2. n.p. |
2085 |
kakl |
448 |
if (0==zakmity) |
|
|
449 |
{ |
|
|
450 |
if(s201AV!=IS201AV) {s201AV=IS201AV; output_toggle(OS102A); zakmity=ZAKMIT;} |
|
|
451 |
if(s201AZ!=IS201AZ) {s201AZ=IS201AZ; output_toggle(OS102A); zakmity=ZAKMIT;} |
|
|
452 |
if(s207AJ!=IS207AJ) {s207AJ=IS207AJ; output_toggle(OS207A); zakmity=ZAKMIT;} |
|
|
453 |
if(s203AJ!=IS203AJ) {s203AJ=IS203AJ; output_toggle(OS203A); zakmity=ZAKMIT;} |
|
|
454 |
if(s209AJ!=IS209AJ) {s209AJ=IS209AJ; output_toggle(OS209A); zakmity=ZAKMIT;} |
2233 |
kakl |
455 |
if(s205A!=IS205A) {s205A=IS205A; output_toggle(OS205A); zakmity=ZAKMIT;} |
2085 |
kakl |
456 |
if(s204AJ!=IS204AJ) {s204AJ=IS204AJ; output_toggle(OS204A); zakmity=ZAKMIT;} |
|
|
457 |
if(s202AN!=IS202AN) {s202AN=IS202AN; output_toggle(OS202A); zakmity=ZAKMIT;} |
|
|
458 |
|
2232 |
kakl |
459 |
if(r207VU!=IR207VU) {r207VU=IR207VU; up(R207V); zakmity=ZAKMIT;} |
|
|
460 |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(R207V); zakmity=ZAKMIT;} |
2233 |
kakl |
461 |
if(r202NU!=IR202NU) {r202NU=IR202NU; up(R202J); zakmity=ZAKMIT;} |
2232 |
kakl |
462 |
if(r202ND!=IR202ND) {r202ND=IR202ND; down(R202J); zakmity=ZAKMIT;} |
2233 |
kakl |
463 |
if(r204ZU!=IR204ZU) {r204ZU=IR204ZU; up(R204Z); zakmity=ZAKMIT;} |
2232 |
kakl |
464 |
if(r204ZD!=IR204ZD) {r204ZD=IR204ZD; down(R204Z); zakmity=ZAKMIT;} |
2085 |
kakl |
465 |
} |
|
|
466 |
else zakmity--; |
2232 |
kakl |
467 |
|
|
|
468 |
switch (relay) |
|
|
469 |
{ |
|
|
470 |
case UP: |
|
|
471 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
|
|
472 |
{ |
|
|
473 |
relay=RUN_UP; // Zmen stav na "jede se" |
|
|
474 |
run_all(); // Sepni triaky u rolet, ktere maji jet |
|
|
475 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
|
|
476 |
} |
|
|
477 |
break; |
2231 |
kakl |
478 |
|
2232 |
kakl |
479 |
case DOWN: |
|
|
480 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
|
|
481 |
{ |
|
|
482 |
relay=RUN_DOWN; // Zmen stav na "jede se" |
|
|
483 |
run_all(); // Sepni triaky u rolet, ktere maji jet |
|
|
484 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
|
|
485 |
} |
|
|
486 |
break; |
|
|
487 |
|
|
|
488 |
case RUN_UP: |
|
|
489 |
if (timer_run==0) // Vyprsel bezpecnostni casovac |
|
|
490 |
{ |
|
|
491 |
timer=RUN_UP_WAITING; |
|
|
492 |
stop_all(); // Vsechno zastav |
|
|
493 |
} |
|
|
494 |
break; |
|
|
495 |
|
|
|
496 |
case RUN_DOWN: |
|
|
497 |
if (timer_run==0) // Vyprsel bezpecnostni casovac |
|
|
498 |
{ |
|
|
499 |
relay=REVERS_UP; // Vsechno zastav a reverzuj pro prepnuti rele do klidove polohy bez energizace civky |
|
|
500 |
stop_all(); |
|
|
501 |
timer_revers=T_REVERS; |
|
|
502 |
} |
|
|
503 |
break; |
|
|
504 |
|
|
|
505 |
case REVERS_UP: |
|
|
506 |
if (timer_revers==0) // Uz se snad vybil kondenzator, muzeme reverzovat |
|
|
507 |
{ |
|
|
508 |
relay=UP; // Prepni rele |
|
|
509 |
OFF(RE); |
|
|
510 |
timer_start=T_START; // Pockej na prepnuti rele |
|
|
511 |
} |
|
|
512 |
break; |
|
|
513 |
|
|
|
514 |
case REVERS_DOWN: |
|
|
515 |
if (timer_revers==0) // Uz se snad vybil kondenzator, muzeme reverzovat |
|
|
516 |
{ |
|
|
517 |
relay=DOWN; // Prepni rele |
|
|
518 |
ON(RE); |
|
|
519 |
timer_start=T_START; // Pockej na prepnuti rele |
|
|
520 |
} |
|
|
521 |
break; |
|
|
522 |
} |
2233 |
kakl |
523 |
|
|
|
524 |
// Zaluzie ma kratsi beh |
|
|
525 |
if ((timer_run_zaluzie==0)&&(rol[R110N]==RUN)) {rol[R110N]=STOP; OFF(OR110N);} |
2231 |
kakl |
526 |
} |
1746 |
kakl |
527 |
} |