Line 7... |
Line 7... |
7 |
R2aNU - roleta, 2. n.p., mistnost 10, sever, nahoru |
7 |
R2aNU - roleta, 2. n.p., mistnost 10, sever, nahoru |
8 |
S12A - svetlo, 1. n.p., mistnost 2, prostredni |
8 |
S12A - svetlo, 1. n.p., mistnost 2, prostredni |
9 |
|
9 |
|
10 |
Rozmisteni desek: |
10 |
Rozmisteni desek: |
11 |
|
11 |
|
12 |
[CAN] |
12 |
[IN D] |
13 |
[IN J] [IN D] |
13 |
[OUT E] |
- |
|
14 |
[IN H] [IN J] |
- |
|
15 |
[OUT B] |
14 |
[OUT A] [CPU] |
16 |
[CPU] |
15 |
|
17 |
|
16 |
[OUT F] [OUT B] [OUT E] |
18 |
[OUT G] [CAN] [OUT A] [OUT F] |
17 |
|
19 |
|
18 |
*/ |
20 |
*/ |
19 |
#include "main.h" |
21 |
#include "main.h" |
20 |
|
22 |
|
21 |
#case |
23 |
#case |
Line 23... |
Line 25... |
23 |
#use fast_io(B) |
25 |
#use fast_io(B) |
24 |
#use fast_io(E) |
26 |
#use fast_io(E) |
25 |
#use fast_io(F) |
27 |
#use fast_io(F) |
26 |
#use fast_io(D) |
28 |
#use fast_io(D) |
27 |
#use fast_io(J) |
29 |
#use fast_io(J) |
- |
|
30 |
#use fast_io(H) |
- |
|
31 |
#use fast_io(G) |
28 |
|
32 |
|
29 |
#define T_REVERS 5 // 5*256 ms = 1,25 s; pred prepnutim rele (zastaveni motoru a vybiti kondenzatoru) |
33 |
#define T_REVERS 2 // 2*256 ms = 0,5 s; pred prepnutim rele (zastaveni motoru a vybiti kondenzatoru) |
30 |
#define T_START 2 // 2*256 ms = 0,5 s; po prepnuti rele do sepnuti triaku |
34 |
#define T_START 1 // 1*256 ms = 0,3 s; po prepnuti rele do sepnuti triaku |
31 |
#define T_GO 117 // 117*256 ms = 30 s; max. beh rolety |
35 |
#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) |
36 |
#define T_GO_ZALUZIE 6 // cca 1,5 s; beh zaluzie (pouze na preklopeni lamel) |
33 |
#define T_RECEIVE 10 // cca 2,6 s |
37 |
#define T_RECEIVE 10 // cca 2,6 s |
34 |
#define ZAKMIT 2000 // pocet pruchodu hlavni smyckou pred opetovnou detekci prepnuti vypinace |
38 |
#define ZAKMIT 2000 // pocet pruchodu hlavni smyckou pred opetovnou detekci prepnuti vypinace |
35 |
|
39 |
|
Line 75... |
Line 79... |
75 |
#define OS202A PIN_E4 // t5 Svetlo Kaklik stred |
79 |
#define OS202A PIN_E4 // t5 Svetlo Kaklik stred |
76 |
#define OS209A PIN_E5 // t6 Svetlo Zizala koupelna |
80 |
#define OS209A PIN_E5 // t6 Svetlo Zizala koupelna |
77 |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
81 |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
78 |
#define RE PIN_E7 // t8 Rele pro rizeni smeru rolet |
82 |
#define RE PIN_E7 // t8 Rele pro rizeni smeru rolet |
79 |
|
83 |
|
- |
|
84 |
//#define O.... PIN_G0 // t8 |
- |
|
85 |
//#define O.... PIN_G1 // t7 |
- |
|
86 |
//#define O.... PIN_G2 // t6 |
- |
|
87 |
#define OS208A PIN_G3 // t5 Svetlo Zizala stred |
- |
|
88 |
#define OS100A PIN_G4 // t4 Svetlo prujezd venku |
- |
|
89 |
|
80 |
//#define I.... input(PIN_D0) // A |
90 |
//#define I.... input(PIN_D0) // A |
81 |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
91 |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
82 |
#define IS207AJ input(PIN_D2) // C Vypinac klubovna |
92 |
#define IS207AJ input(PIN_D2) // C Vypinac klubovna |
83 |
#define IR207VD input(PIN_D3) // D Vypinac roleta klubovna dolu |
93 |
#define IR207VD input(PIN_D3) // D Vypinac roleta klubovna dolu |
84 |
#define IR207VU input(PIN_D4) // E Vypinac roleta klubovna nahoru |
94 |
#define IR207VU input(PIN_D4) // E Vypinac roleta klubovna nahoru |
Line 93... |
Line 103... |
93 |
#define IS204AJ input(PIN_J4) // E Vypinac svetlo radiomistnost u dveri na chodbu |
103 |
#define IS204AJ input(PIN_J4) // E Vypinac svetlo radiomistnost u dveri na chodbu |
94 |
#define IR204ZD input(PIN_J5) // F Vypinac roleta radiomistnost dolu |
104 |
#define IR204ZD input(PIN_J5) // F Vypinac roleta radiomistnost dolu |
95 |
#define IR204ZU input(PIN_J6) // G Vypinac roleta radiomistnost nahoru |
105 |
#define IR204ZU input(PIN_J6) // G Vypinac roleta radiomistnost nahoru |
96 |
//#define I.... input(PIN_J7) // H |
106 |
//#define I.... input(PIN_J7) // H |
97 |
|
107 |
|
- |
|
108 |
#define IS208AN input(PIN_H0) // A Vypinac svetlo stred Zizala u dveri na chodbu //POZOR! Jsou prohozeny rolety J a V a smery U a D |
- |
|
109 |
#define IR208JD input(PIN_H1) // B Vypinac roleta vychod Zizala nahoru u dveri |
- |
|
110 |
#define IR208JU input(PIN_H2) // C Vypinac roleta vychod Zizala dolu u dveri |
- |
|
111 |
#define IR208VD input(PIN_H3) // D Vypinac roleta jih Zizala nahoru u dveri |
- |
|
112 |
#define IR208VU input(PIN_H4) // E Vypinac roleta jih Zizala dolu u dveri |
- |
|
113 |
//#define I.... input(PIN_H5) // F |
- |
|
114 |
//#define I.... input(PIN_H6) // G |
- |
|
115 |
#define Ispec input(PIN_H7) // H specialni vypinac u rozvadece 2.n.p. |
- |
|
116 |
|
- |
|
117 |
|
98 |
int1 s201AV; |
118 |
int1 s201AV; |
99 |
int1 s201AZ; |
119 |
int1 s201AZ; |
100 |
int1 s207AJ; |
120 |
int1 s207AJ; |
101 |
int1 s203AJ; |
121 |
int1 s203AJ; |
102 |
int1 s209AJ; |
122 |
int1 s209AJ; |
Line 107... |
Line 127... |
107 |
int1 r202NU; |
127 |
int1 r202NU; |
108 |
int1 s205A; |
128 |
int1 s205A; |
109 |
int1 s204AJ; |
129 |
int1 s204AJ; |
110 |
int1 r204ZD; |
130 |
int1 r204ZD; |
111 |
int1 r204ZU; |
131 |
int1 r204ZU; |
- |
|
132 |
int1 s208AN; |
- |
|
133 |
int1 r208VU; |
- |
|
134 |
int1 r208VD; |
- |
|
135 |
int1 r208JU; |
- |
|
136 |
int1 r208JD; |
- |
|
137 |
int1 ispec; |
112 |
|
138 |
|
113 |
#bit CREN = 0xFAB.4 // USART enable register |
139 |
#bit CREN = 0xFAB.4 // USART enable register |
114 |
|
140 |
|
115 |
#define LED1 PIN_C0 |
141 |
#define LED1 PIN_C0 // Vyvedeno na desku portu G |
116 |
#define LED2 PIN_C1 |
142 |
#define LED2 PIN_C1 // Vyvedeno na desku portu G |
117 |
|
143 |
|
118 |
#define ON(port) output_low(port); |
144 |
#define ON(port) output_low(port); |
119 |
#define OFF(port) output_high(port); |
145 |
#define OFF(port) output_high(port); |
120 |
|
146 |
|
121 |
typedef enum {RUN, STOP} roleta_state; |
147 |
typedef enum {RUN, STOP} roleta_state; |
Line 125... |
Line 151... |
125 |
#define R104V 2 |
151 |
#define R104V 2 |
126 |
#define R104J 3 |
152 |
#define R104J 3 |
127 |
#define R207V 4 |
153 |
#define R207V 4 |
128 |
#define R202J 5 |
154 |
#define R202J 5 |
129 |
#define R204Z 6 |
155 |
#define R204Z 6 |
- |
|
156 |
#define R208V 7 |
- |
|
157 |
#define R208J 8 |
130 |
|
158 |
|
131 |
typedef enum {UP, DOWN, REVERS_UP, REVERS_DOWN, RUN_UP, RUN_DOWN, RUN_UP_WAITING} relay_state; |
159 |
typedef enum {UP, DOWN, REVERS_UP, REVERS_DOWN, RUN_UP, RUN_DOWN, RUN_UP_WAITING} relay_state; |
132 |
relay_state relay; // Stavy rele |
160 |
relay_state relay; // Stavy rele |
133 |
|
161 |
|
134 |
int8 timer_run; // Bezpecnostni casovac behu rolety |
162 |
int8 timer_run; // Bezpecnostni casovac behu rolety |
Line 164... |
Line 192... |
164 |
if (rol[R104V]==RUN) ON(OR104V); |
192 |
if (rol[R104V]==RUN) ON(OR104V); |
165 |
if (rol[R104J]==RUN) ON(OR104J); |
193 |
if (rol[R104J]==RUN) ON(OR104J); |
166 |
if (rol[R207V]==RUN) ON(OR207V); |
194 |
if (rol[R207V]==RUN) ON(OR207V); |
167 |
if (rol[R202J]==RUN) ON(OR202J); |
195 |
if (rol[R202J]==RUN) ON(OR202J); |
168 |
if (rol[R204Z]==RUN) ON(OR204Z); |
196 |
if (rol[R204Z]==RUN) ON(OR204Z); |
- |
|
197 |
if (rol[R208V]==RUN) ON(OR208V); |
- |
|
198 |
if (rol[R208J]==RUN) ON(OR208J); |
169 |
} |
199 |
} |
170 |
|
200 |
|
171 |
void run(int8 roleta) // Spust konkretni roletu |
201 |
void run(int8 roleta) // Spust konkretni roletu |
172 |
{ |
202 |
{ |
173 |
switch (roleta) |
203 |
switch (roleta) |
Line 177... |
Line 207... |
177 |
case R104V: ON(OR104V); break; |
207 |
case R104V: ON(OR104V); break; |
178 |
case R104J: ON(OR104J); break; |
208 |
case R104J: ON(OR104J); break; |
179 |
case R207V: ON(OR207V); break; |
209 |
case R207V: ON(OR207V); break; |
180 |
case R202J: ON(OR202J); break; |
210 |
case R202J: ON(OR202J); break; |
181 |
case R204Z: ON(OR204Z); break; |
211 |
case R204Z: ON(OR204Z); break; |
- |
|
212 |
case R208V: ON(OR208V); break; |
- |
|
213 |
case R208J: ON(OR208J); break; |
182 |
} |
214 |
} |
183 |
} |
215 |
} |
184 |
|
216 |
|
185 |
void stop(int8 roleta) // Spust konkretni roletu |
217 |
void stop(int8 roleta) // Spust konkretni roletu |
186 |
{ |
218 |
{ |
Line 191... |
Line 223... |
191 |
case R104V: OFF(OR104V); break; |
223 |
case R104V: OFF(OR104V); break; |
192 |
case R104J: OFF(OR104J); break; |
224 |
case R104J: OFF(OR104J); break; |
193 |
case R207V: OFF(OR207V); break; |
225 |
case R207V: OFF(OR207V); break; |
194 |
case R202J: OFF(OR202J); break; |
226 |
case R202J: OFF(OR202J); break; |
195 |
case R204Z: OFF(OR204Z); break; |
227 |
case R204Z: OFF(OR204Z); break; |
- |
|
228 |
case R208V: OFF(OR208V); break; |
- |
|
229 |
case R208J: OFF(OR208J); break; |
196 |
} |
230 |
} |
197 |
} |
231 |
} |
198 |
|
232 |
|
199 |
void up(int8 roleta) // Pozadavek, aby roleta jela nahoru |
233 |
void up(int8 roleta) // Pozadavek, aby roleta jela nahoru |
200 |
{ |
234 |
{ |
Line 268... |
Line 302... |
268 |
|
302 |
|
269 |
set_tris_a(0); // Vystupy |
303 |
set_tris_a(0); // Vystupy |
270 |
set_tris_b(0); |
304 |
set_tris_b(0); |
271 |
set_tris_e(0); |
305 |
set_tris_e(0); |
272 |
set_tris_f(0); |
306 |
set_tris_f(0); |
- |
|
307 |
set_tris_g(0x20); |
273 |
set_tris_d(0xFF); // Vstupy |
308 |
set_tris_d(0xFF); // Vstupy |
274 |
set_tris_j(0xFF); |
309 |
set_tris_j(0xFF); |
- |
|
310 |
set_tris_h(0xFF); |
275 |
|
311 |
|
276 |
output_a(0xFF); // Vsechno zhasni a zastav |
312 |
output_a(0xFF); // Vsechno zhasni a zastav |
277 |
output_b(0xFF); |
313 |
output_b(0xFF); |
278 |
output_f(0xFF); |
314 |
output_f(0xFF); |
279 |
output_e(0xFF); |
315 |
output_e(0xFF); |
- |
|
316 |
output_g(0xFF); |
280 |
stop_all(); |
317 |
stop_all(); |
281 |
|
318 |
|
282 |
relay=RUN_UP_WAITING; // Rele je na zacatku vypnuto |
319 |
relay=RUN_UP_WAITING; // Rele je na zacatku vypnuto |
283 |
|
320 |
|
284 |
{ |
321 |
{ |
Line 306... |
Line 343... |
306 |
r202NU=IR202NU; |
343 |
r202NU=IR202NU; |
307 |
s205A=IS205A; |
344 |
s205A=IS205A; |
308 |
s204AJ=IS204AJ; |
345 |
s204AJ=IS204AJ; |
309 |
r204ZD=IR204ZD; |
346 |
r204ZD=IR204ZD; |
310 |
r204ZU=IR204ZU; |
347 |
r204ZU=IR204ZU; |
- |
|
348 |
s208AN=IS208AN; |
- |
|
349 |
r208VU=IR208VU; |
- |
|
350 |
r208VD=IR208VD; |
- |
|
351 |
r208JU=IR208JU; |
- |
|
352 |
r208JD=IR208JD; |
- |
|
353 |
ispec=Ispec; |
311 |
|
354 |
|
312 |
timer_run=0; // Zastav vsechny casovace |
355 |
timer_run=0; // Zastav vsechny casovace |
313 |
timer=0; |
356 |
timer=0; |
314 |
timer_revers=0; |
357 |
timer_revers=0; |
315 |
timer_start=0; |
358 |
timer_start=0; |
Line 453... |
Line 496... |
453 |
if(s203AJ!=IS203AJ) {s203AJ=IS203AJ; output_toggle(OS203A); zakmity=ZAKMIT;} |
496 |
if(s203AJ!=IS203AJ) {s203AJ=IS203AJ; output_toggle(OS203A); zakmity=ZAKMIT;} |
454 |
if(s209AJ!=IS209AJ) {s209AJ=IS209AJ; output_toggle(OS209A); zakmity=ZAKMIT;} |
497 |
if(s209AJ!=IS209AJ) {s209AJ=IS209AJ; output_toggle(OS209A); zakmity=ZAKMIT;} |
455 |
if(s205A!=IS205A) {s205A=IS205A; output_toggle(OS205A); zakmity=ZAKMIT;} |
498 |
if(s205A!=IS205A) {s205A=IS205A; output_toggle(OS205A); zakmity=ZAKMIT;} |
456 |
if(s204AJ!=IS204AJ) {s204AJ=IS204AJ; output_toggle(OS204A); zakmity=ZAKMIT;} |
499 |
if(s204AJ!=IS204AJ) {s204AJ=IS204AJ; output_toggle(OS204A); zakmity=ZAKMIT;} |
457 |
if(s202AN!=IS202AN) {s202AN=IS202AN; output_toggle(OS202A); zakmity=ZAKMIT;} |
500 |
if(s202AN!=IS202AN) {s202AN=IS202AN; output_toggle(OS202A); zakmity=ZAKMIT;} |
- |
|
501 |
if(s208AN!=IS208AN) {s208AN=IS208AN; output_toggle(OS208A); zakmity=ZAKMIT;} |
458 |
|
502 |
|
459 |
if(r207VU!=IR207VU) {r207VU=IR207VU; up(R207V); zakmity=ZAKMIT;} |
503 |
if(r207VU!=IR207VU) {r207VU=IR207VU; up(R207V); zakmity=ZAKMIT;} |
460 |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(R207V); zakmity=ZAKMIT;} |
504 |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(R207V); zakmity=ZAKMIT;} |
461 |
if(r202NU!=IR202NU) {r202NU=IR202NU; up(R202J); zakmity=ZAKMIT;} |
505 |
if(r202NU!=IR202NU) {r202NU=IR202NU; up(R202J); zakmity=ZAKMIT;} |
462 |
if(r202ND!=IR202ND) {r202ND=IR202ND; down(R202J); zakmity=ZAKMIT;} |
506 |
if(r202ND!=IR202ND) {r202ND=IR202ND; down(R202J); zakmity=ZAKMIT;} |
463 |
if(r204ZU!=IR204ZU) {r204ZU=IR204ZU; up(R204Z); zakmity=ZAKMIT;} |
507 |
if(r204ZU!=IR204ZU) {r204ZU=IR204ZU; up(R204Z); zakmity=ZAKMIT;} |
464 |
if(r204ZD!=IR204ZD) {r204ZD=IR204ZD; down(R204Z); zakmity=ZAKMIT;} |
508 |
if(r204ZD!=IR204ZD) {r204ZD=IR204ZD; down(R204Z); zakmity=ZAKMIT;} |
- |
|
509 |
if(r208VU!=IR208VU) {r208VU=IR208VU; up(R208V); zakmity=ZAKMIT;} |
- |
|
510 |
if(r208VD!=IR208VD) {r208VD=IR208VD; down(R208V); zakmity=ZAKMIT;} |
- |
|
511 |
if(r208JU!=IR208JU) {r208JU=IR208JU; up(R208J); zakmity=ZAKMIT;} |
- |
|
512 |
if(r208JD!=IR208JD) {r208JD=IR208JD; down(R208J); zakmity=ZAKMIT;} |
- |
|
513 |
|
- |
|
514 |
if(ispec!=Ispec) {ispec=Ispec; output_toggle(OS100A); zakmity=ZAKMIT;} |
465 |
} |
515 |
} |
466 |
else zakmity--; |
516 |
else zakmity--; |
467 |
|
517 |
|
468 |
switch (relay) |
518 |
switch (relay) |
469 |
{ |
519 |
{ |