Line 143... |
Line 143... |
143 |
if(timer>0) timer--; |
143 |
if(timer>0) timer--; |
144 |
if(timer_run>0) timer_run--; |
144 |
if(timer_run>0) timer_run--; |
145 |
if(timer_revers>0) timer_revers--; |
145 |
if(timer_revers>0) timer_revers--; |
146 |
if(timer_start>0) timer_start--; |
146 |
if(timer_start>0) timer_start--; |
147 |
if(timer_run_zaluzie>0) timer_run_zaluzie--; |
147 |
if(timer_run_zaluzie>0) timer_run_zaluzie--; |
148 |
//!!!output_toggle(LED2); |
148 |
output_toggle(LED2); |
149 |
} |
149 |
} |
150 |
|
150 |
|
151 |
void stop_all() // Zastav vsechny rolety |
151 |
void stop_all() // Zastav vsechny rolety |
152 |
{ |
152 |
{ |
153 |
int8 n; |
153 |
int8 n; |
154 |
|
154 |
|
155 |
for(n=0; n<18; n++) rol[n]=STOP; |
- |
|
156 |
output_a(0xFF); |
155 |
output_a(0xFF); |
157 |
output_f(0xFF); |
156 |
output_f(0xFF); |
- |
|
157 |
for(n=0; n<18; n++) rol[n]=STOP; |
158 |
} |
158 |
} |
159 |
|
159 |
|
160 |
void run_all() // Spust rolety |
160 |
void run_all() // Spust rolety |
161 |
{ |
161 |
{ |
162 |
if (rol[R103V]==RUN) ON(OR103V); |
162 |
if (rol[R103V]==RUN) ON(OR103V); |
Line 180... |
Line 180... |
180 |
case R202J: ON(OR202J); break; |
180 |
case R202J: ON(OR202J); break; |
181 |
case R204Z: ON(OR204Z); break; |
181 |
case R204Z: ON(OR204Z); break; |
182 |
} |
182 |
} |
183 |
} |
183 |
} |
184 |
|
184 |
|
- |
|
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 |
|
185 |
void up(int8 roleta) // Pozadavek, aby roleta jela nahoru |
199 |
void up(int8 roleta) // Pozadavek, aby roleta jela nahoru |
186 |
{ |
200 |
{ |
187 |
if (rol[roleta]==RUN) |
201 |
if (rol[roleta]==RUN) |
188 |
{ |
202 |
{ |
189 |
rol[roleta]=STOP; // Roleta jela, tak zastav |
203 |
rol[roleta]=STOP; // Roleta jela, tak zastav |
- |
|
204 |
stop(roleta); |
190 |
} |
205 |
} |
191 |
else |
206 |
else |
192 |
{ |
207 |
{ |
193 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
208 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
194 |
{ |
209 |
{ |
Line 196... |
Line 211... |
196 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
211 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
197 |
stop_all(); // Vsechno zastav |
212 |
stop_all(); // Vsechno zastav |
198 |
} |
213 |
} |
199 |
if (relay==RUN_UP) |
214 |
if (relay==RUN_UP) |
200 |
{ |
215 |
{ |
201 |
run(R207V); // Jede se spravnym smerem, tak jenom pust roletu |
216 |
run(roleta); // Jede se spravnym smerem, tak jenom pust roletu |
202 |
} |
217 |
} |
203 |
|
218 |
|
204 |
rol[roleta]=RUN; // Roleta stala, tak ji pust |
219 |
rol[roleta]=RUN; // Roleta stala, tak ji pust |
205 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
220 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
206 |
} |
221 |
} |
Line 210... |
Line 225... |
210 |
void down(int8 roleta) // Pozadavek, aby roleta jela dolu |
225 |
void down(int8 roleta) // Pozadavek, aby roleta jela dolu |
211 |
{ |
226 |
{ |
212 |
if (rol[roleta]==RUN) |
227 |
if (rol[roleta]==RUN) |
213 |
{ |
228 |
{ |
214 |
rol[roleta]=STOP; // Roleta jela, tak zastav |
229 |
rol[roleta]=STOP; // Roleta jela, tak zastav |
- |
|
230 |
stop(roleta); |
215 |
} |
231 |
} |
216 |
else |
232 |
else |
217 |
{ |
233 |
{ |
218 |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) // Rele je prepnuto na druhou stranu! |
234 |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) // Rele je prepnuto na druhou stranu! |
219 |
{ |
235 |
{ |
Line 221... |
Line 237... |
221 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
237 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
222 |
stop_all(); // Vsechno zastav |
238 |
stop_all(); // Vsechno zastav |
223 |
} |
239 |
} |
224 |
if (relay==RUN_DOWN) |
240 |
if (relay==RUN_DOWN) |
225 |
{ |
241 |
{ |
226 |
run(R207V); // Jede se spravnym smerem, tak jenom pust roletu |
242 |
run(roleta); // Jede se spravnym smerem, tak jenom pust roletu |
227 |
} |
243 |
} |
228 |
|
244 |
|
229 |
rol[roleta]=RUN; // Roleta stala, tak ji pust |
245 |
rol[roleta]=RUN; // Roleta stala, tak ji pust |
230 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
246 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
231 |
} |
247 |
} |
Line 298... |
Line 314... |
298 |
timer_revers=0; |
314 |
timer_revers=0; |
299 |
timer_start=0; |
315 |
timer_start=0; |
300 |
timer_run_zaluzie=0; |
316 |
timer_run_zaluzie=0; |
301 |
zakmity=0; |
317 |
zakmity=0; |
302 |
|
318 |
|
303 |
enable_interrupts(INT_TIMER0); |
319 |
enable_interrupts(INT_TIMER0); // Spust casovani |
304 |
enable_interrupts(GLOBAL); |
320 |
enable_interrupts(GLOBAL); |
305 |
|
321 |
|
306 |
CREN=0; CREN=1; // Reinitialise USART |
322 |
CREN=0; CREN=1; // Reinitialise USART |
307 |
|
323 |
|
308 |
while(TRUE) |
324 |
while(TRUE) |
Line 377... |
Line 393... |
377 |
if(buf[1]=='1') |
393 |
if(buf[1]=='1') |
378 |
{ |
394 |
{ |
379 |
switch(buf[2]) |
395 |
switch(buf[2]) |
380 |
{ |
396 |
{ |
381 |
case '3': |
397 |
case '3': |
382 |
//!!! if(buf[4]=='U') {up(&r103V,&tr103V);} else {down(&r103V,&tr103V);} |
398 |
if(buf[4]=='U') {up(R103V);} else {down(R103V);} |
383 |
break; |
399 |
break; |
384 |
case '4': |
400 |
case '4': |
385 |
//!!! if(buf[3]=='V') if((buf[4]=='U')) |
401 |
if(buf[3]=='V') if((buf[4]=='U')) {up(R104V);} else {down(R104V);} |
386 |
//!!! if(buf[3]=='J') if((buf[4]=='U')) {up(&r104J,&tr104J);} else {down(&r104J,&tr104J);} |
402 |
if(buf[3]=='J') if((buf[4]=='U')) {up(R104J);} else {down(R104J);} |
387 |
break; |
403 |
break; |
388 |
case 'a': |
404 |
case 'a': |
- |
|
405 |
if((buf[4]=='U')) |
- |
|
406 |
{//up(R110N); |
389 |
//!!! if((buf[4]=='U')) {up(&r110N,&tr110N);} else {down(&r110N,&tr110N);} |
407 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
390 |
break; |
408 |
{ |
- |
|
409 |
relay=REVERS_UP; // Reverzuj |
- |
|
410 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
- |
|
411 |
stop_all(); // Vsechno zastav |
391 |
} |
412 |
} |
- |
|
413 |
if (relay==RUN_UP) |
- |
|
414 |
{ |
- |
|
415 |
run(R110N); // Jede se spravnym smerem, tak jenom pust roletu |
392 |
} |
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 |
393 |
} |
432 |
} |
394 |
|
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; |
- |
|
438 |
break; |
395 |
} |
439 |
} |
396 |
} |
440 |
} |
397 |
} |
441 |
} |
398 |
|
442 |
|
399 |
//!!! switch(r110N) // Zaluzie ma specielni rizeni |
443 |
} |
- |
|
444 |
} |
- |
|
445 |
} |
400 |
|
446 |
|
401 |
// mistni vypinace z 2. n.p. |
447 |
// mistni vypinace z 2. n.p. |
402 |
if (0==zakmity) |
448 |
if (0==zakmity) |
403 |
{ |
449 |
{ |
404 |
if(s201AV!=IS201AV) {s201AV=IS201AV; output_toggle(OS102A); zakmity=ZAKMIT;} |
450 |
if(s201AV!=IS201AV) {s201AV=IS201AV; output_toggle(OS102A); zakmity=ZAKMIT;} |
Line 408... |
Line 454... |
408 |
if(s209AJ!=IS209AJ) {s209AJ=IS209AJ; output_toggle(OS209A); zakmity=ZAKMIT;} |
454 |
if(s209AJ!=IS209AJ) {s209AJ=IS209AJ; output_toggle(OS209A); zakmity=ZAKMIT;} |
409 |
if(s205A!=IS205A) {s205A=IS205A; output_toggle(OS205A); zakmity=ZAKMIT;} |
455 |
if(s205A!=IS205A) {s205A=IS205A; output_toggle(OS205A); zakmity=ZAKMIT;} |
410 |
if(s204AJ!=IS204AJ) {s204AJ=IS204AJ; output_toggle(OS204A); zakmity=ZAKMIT;} |
456 |
if(s204AJ!=IS204AJ) {s204AJ=IS204AJ; output_toggle(OS204A); zakmity=ZAKMIT;} |
411 |
if(s202AN!=IS202AN) {s202AN=IS202AN; output_toggle(OS202A); zakmity=ZAKMIT;} |
457 |
if(s202AN!=IS202AN) {s202AN=IS202AN; output_toggle(OS202A); zakmity=ZAKMIT;} |
412 |
|
458 |
|
413 |
if(r207VU!=IR207VU) // Zmenil se stav vypinace |
- |
|
414 |
{ |
- |
|
415 |
r207VU=IR207VU; // Poznamenej soucasny stav vypinace |
- |
|
416 |
|
- |
|
417 |
if (rol[R207V]==RUN) |
- |
|
418 |
{ |
- |
|
419 |
rol[R207V]=STOP; // Roleta jela, tak zastav |
- |
|
420 |
OFF(OR207V); |
- |
|
421 |
} |
- |
|
422 |
else |
- |
|
423 |
{ |
- |
|
424 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
- |
|
425 |
{ |
- |
|
426 |
relay=REVERS_UP; // Reverzuj |
- |
|
427 |
timer_revers=T_REVERS; |
- |
|
428 |
stop_all(); // Vsechno zastav |
- |
|
429 |
} |
- |
|
430 |
if (relay==RUN_UP) |
- |
|
431 |
{ |
- |
|
432 |
ON(OR207V); // Jede se spravnym smerem, tak jenom pust roletu |
- |
|
433 |
} |
- |
|
434 |
rol[R207V]=RUN; // Poznamenej, ze se jede, a natahni bezpecnostni casovac |
- |
|
435 |
timer_run=T_GO; |
- |
|
436 |
} |
- |
|
437 |
zakmity=ZAKMIT; |
- |
|
438 |
} |
- |
|
439 |
if(r207VD!=IR207VD) |
- |
|
440 |
{ |
- |
|
441 |
r207VD=IR207VD; |
- |
|
442 |
|
- |
|
443 |
if (rol[R207V]==RUN) |
- |
|
444 |
{ |
- |
|
445 |
rol[R207V]=STOP; |
- |
|
446 |
OFF(OR207V); |
- |
|
447 |
} |
- |
|
448 |
else |
- |
|
449 |
{ |
- |
|
450 |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) |
- |
|
451 |
{ |
- |
|
452 |
relay=REVERS_DOWN; |
- |
|
453 |
timer_revers=T_REVERS; |
- |
|
454 |
stop_all(); |
- |
|
455 |
} |
- |
|
456 |
if (relay==RUN_DOWN) |
- |
|
457 |
{ |
- |
|
458 |
ON(OR207V); |
- |
|
459 |
} |
- |
|
460 |
rol[R207V]=RUN; |
- |
|
461 |
timer_run=T_GO; |
- |
|
462 |
} |
- |
|
463 |
zakmity=ZAKMIT; |
- |
|
464 |
} |
- |
|
465 |
|
- |
|
466 |
if(r207VU!=IR207VU) {r207VU=IR207VU; up(R207V); zakmity=ZAKMIT;} |
459 |
if(r207VU!=IR207VU) {r207VU=IR207VU; up(R207V); zakmity=ZAKMIT;} |
467 |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(R207V); zakmity=ZAKMIT;} |
460 |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(R207V); zakmity=ZAKMIT;} |
468 |
if(r202NU!=IR202NU) {r202NU=IR202NU; up(R202J); zakmity=ZAKMIT;} |
461 |
if(r202NU!=IR202NU) {r202NU=IR202NU; up(R202J); zakmity=ZAKMIT;} |
469 |
if(r202ND!=IR202ND) {r202ND=IR202ND; down(R202J); zakmity=ZAKMIT;} |
462 |
if(r202ND!=IR202ND) {r202ND=IR202ND; down(R202J); zakmity=ZAKMIT;} |
470 |
if(r204ZU!=IR204ZU) {r204ZU=IR204ZU; up(R204Z); zakmity=ZAKMIT;} |
463 |
if(r204ZU!=IR204ZU) {r204ZU=IR204ZU; up(R204Z); zakmity=ZAKMIT;} |
Line 525... |
Line 518... |
525 |
ON(RE); |
518 |
ON(RE); |
526 |
timer_start=T_START; // Pockej na prepnuti rele |
519 |
timer_start=T_START; // Pockej na prepnuti rele |
527 |
} |
520 |
} |
528 |
break; |
521 |
break; |
529 |
} |
522 |
} |
- |
|
523 |
|
- |
|
524 |
// Zaluzie ma kratsi beh |
- |
|
525 |
if ((timer_run_zaluzie==0)&&(rol[R110N]==RUN)) {rol[R110N]=STOP; OFF(OR110N);} |
530 |
} |
526 |
} |
531 |
} |
527 |
} |