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