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 2 // 2*256 ms = 0,5 s; 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 Roleta 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, RUN_UP_WAITING} 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; |
- |
|
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); |
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 |
void run(int8 roleta) // Spust konkretni roletu |
171 |
void run(int8 roleta) // Spust konkretni roletu |
172 |
{ |
172 |
{ |
173 |
switch (roleta) |
173 |
switch (roleta) |
174 |
{ |
174 |
{ |
175 |
case R103V: ON(OR103V); break; |
175 |
case R103V: ON(OR103V); break; |
176 |
case R110N: ON(OR110N); break; |
176 |
case R110N: ON(OR110N); break; |
177 |
case R104V: ON(OR104V); break; |
177 |
case R104V: ON(OR104V); break; |
178 |
case R104J: ON(OR104J); break; |
178 |
case R104J: ON(OR104J); break; |
179 |
case R207V: ON(OR207V); break; |
179 |
case R207V: ON(OR207V); break; |
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 |
{ |
195 |
relay=REVERS_UP; // Reverzuj |
210 |
relay=REVERS_UP; // Reverzuj |
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 |
} |
207 |
} |
222 |
} |
208 |
|
223 |
|
209 |
|
224 |
|
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 |
{ |
220 |
relay=REVERS_DOWN; // Reverzuj |
236 |
relay=REVERS_DOWN; // Reverzuj |
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 |
} |
232 |
} |
248 |
} |
233 |
|
249 |
|
234 |
|
250 |
|
235 |
void main() |
251 |
void main() |
236 |
{ |
252 |
{ |
237 |
char buf[10]; // Buffer pro prijem prikazu |
253 |
char buf[10]; // Buffer pro prijem prikazu |
238 |
unsigned int16 zakmity=0; // Osetreni zakmitu vypinacu |
254 |
unsigned int16 zakmity=0; // Osetreni zakmitu vypinacu |
239 |
|
255 |
|
240 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
256 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
241 |
setup_adc(ADC_CLOCK_DIV_2); |
257 |
setup_adc(ADC_CLOCK_DIV_2); |
242 |
setup_psp(PSP_DISABLED); |
258 |
setup_psp(PSP_DISABLED); |
243 |
setup_spi(SPI_SS_DISABLED); |
259 |
setup_spi(SPI_SS_DISABLED); |
244 |
setup_wdt(WDT_OFF); |
260 |
setup_wdt(WDT_OFF); |
245 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8); |
261 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8); |
246 |
setup_timer_1(T1_DISABLED); |
262 |
setup_timer_1(T1_DISABLED); |
247 |
setup_timer_2(T2_DISABLED,0,1); |
263 |
setup_timer_2(T2_DISABLED,0,1); |
248 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
264 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
249 |
setup_ccp1(CCP_OFF); |
265 |
setup_ccp1(CCP_OFF); |
250 |
setup_comparator(NC_NC_NC_NC); |
266 |
setup_comparator(NC_NC_NC_NC); |
251 |
setup_vref(FALSE); |
267 |
setup_vref(FALSE); |
252 |
|
268 |
|
253 |
set_tris_a(0); // Vystupy |
269 |
set_tris_a(0); // Vystupy |
254 |
set_tris_b(0); |
270 |
set_tris_b(0); |
255 |
set_tris_e(0); |
271 |
set_tris_e(0); |
256 |
set_tris_f(0); |
272 |
set_tris_f(0); |
257 |
set_tris_d(0xFF); // Vstupy |
273 |
set_tris_d(0xFF); // Vstupy |
258 |
set_tris_j(0xFF); |
274 |
set_tris_j(0xFF); |
259 |
|
275 |
|
260 |
output_a(0xFF); // Vsechno zhasni a zastav |
276 |
output_a(0xFF); // Vsechno zhasni a zastav |
261 |
output_b(0xFF); |
277 |
output_b(0xFF); |
262 |
output_f(0xFF); |
278 |
output_f(0xFF); |
263 |
output_e(0xFF); |
279 |
output_e(0xFF); |
264 |
stop_all(); |
280 |
stop_all(); |
265 |
|
281 |
|
266 |
relay=RUN_UP_WAITING; // Rele je na zacatku vypnuto |
282 |
relay=RUN_UP_WAITING; // Rele je na zacatku vypnuto |
267 |
|
283 |
|
268 |
{ |
284 |
{ |
269 |
int n; |
285 |
int n; |
270 |
|
286 |
|
271 |
for(n=0;n<10;n++) |
287 |
for(n=0;n<10;n++) |
272 |
{ |
288 |
{ |
273 |
output_low(LED1); // Indikace restartu (pockame na nabiti kondenzatoru ve vstupnich obvodech) |
289 |
output_low(LED1); // Indikace restartu (pockame na nabiti kondenzatoru ve vstupnich obvodech) |
274 |
delay_ms(100); |
290 |
delay_ms(100); |
275 |
output_high(LED1); |
291 |
output_high(LED1); |
276 |
delay_ms(100); |
292 |
delay_ms(100); |
277 |
restart_wdt(); |
293 |
restart_wdt(); |
278 |
} |
294 |
} |
279 |
} |
295 |
} |
280 |
|
296 |
|
281 |
s201AV=IS201AV; // Precteme vychozi stav vypinacu |
297 |
s201AV=IS201AV; // Precteme vychozi stav vypinacu |
282 |
s201AZ=IS201AZ; |
298 |
s201AZ=IS201AZ; |
283 |
s207AJ=IS207AJ; |
299 |
s207AJ=IS207AJ; |
284 |
s203AJ=IS203AJ; |
300 |
s203AJ=IS203AJ; |
285 |
s209AJ=IS209AJ; |
301 |
s209AJ=IS209AJ; |
286 |
r207VU=IR207VU; |
302 |
r207VU=IR207VU; |
287 |
r207VD=IR207VD; |
303 |
r207VD=IR207VD; |
288 |
s202AN=IS202AN; |
304 |
s202AN=IS202AN; |
289 |
r202ND=IR202ND; |
305 |
r202ND=IR202ND; |
290 |
r202NU=IR202NU; |
306 |
r202NU=IR202NU; |
291 |
s205A=IS205A; |
307 |
s205A=IS205A; |
292 |
s204AJ=IS204AJ; |
308 |
s204AJ=IS204AJ; |
293 |
r204ZD=IR204ZD; |
309 |
r204ZD=IR204ZD; |
294 |
r204ZU=IR204ZU; |
310 |
r204ZU=IR204ZU; |
295 |
|
311 |
|
296 |
timer_run=0; // Zastav vsechny casovace |
312 |
timer_run=0; // Zastav vsechny casovace |
297 |
timer=0; |
313 |
timer=0; |
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) |
309 |
{ |
325 |
{ |
310 |
restart_wdt(); |
326 |
restart_wdt(); |
311 |
|
327 |
|
312 |
if(kbhit()) // Chce po nas nekdo neco? |
328 |
if(kbhit()) // Chce po nas nekdo neco? |
313 |
{ |
329 |
{ |
314 |
buf[0]=getc(); |
330 |
buf[0]=getc(); |
315 |
if((buf[0]=='S')||(buf[0]=='R')) // Jinym znakem nesmi zacinat prikaz |
331 |
if((buf[0]=='S')||(buf[0]=='R')) // Jinym znakem nesmi zacinat prikaz |
316 |
{ |
332 |
{ |
317 |
int8 n=0; // Ukazatel do prijimaciho bufferu |
333 |
int8 n=0; // Ukazatel do prijimaciho bufferu |
318 |
timer=T_RECEIVE; // Timeout pro prijem znaku |
334 |
timer=T_RECEIVE; // Timeout pro prijem znaku |
319 |
|
335 |
|
320 |
do |
336 |
do |
321 |
{ |
337 |
{ |
322 |
if(kbhit()) // Je dalsi znak? |
338 |
if(kbhit()) // Je dalsi znak? |
323 |
{ |
339 |
{ |
324 |
n++; |
340 |
n++; |
325 |
buf[n]=getc(); |
341 |
buf[n]=getc(); |
326 |
} |
342 |
} |
327 |
} while ((buf[n]!='\r')&&(timer>0)&&(n<7)); |
343 |
} while ((buf[n]!='\r')&&(timer>0)&&(n<7)); |
328 |
|
344 |
|
329 |
if (timer==0) { CREN=0; CREN=1; } // Reinitialise USART |
345 |
if (timer==0) { CREN=0; CREN=1; } // Reinitialise USART |
330 |
|
346 |
|
331 |
output_toggle(LED1); // Ukonceni prijimani prikazu |
347 |
output_toggle(LED1); // Ukonceni prijimani prikazu |
332 |
|
348 |
|
333 |
if((timer>0)) |
349 |
if((timer>0)) |
334 |
{ |
350 |
{ |
335 |
|
351 |
|
336 |
if((buf[0]=='S')&&(n>=4)) // Zmena stavu svetla |
352 |
if((buf[0]=='S')&&(n>=4)) // Zmena stavu svetla |
337 |
{ |
353 |
{ |
338 |
if(buf[1]=='1') |
354 |
if(buf[1]=='1') |
339 |
{ |
355 |
{ |
340 |
switch(buf[2]) |
356 |
switch(buf[2]) |
341 |
{ |
357 |
{ |
342 |
case '2': |
358 |
case '2': |
343 |
output_toggle(OS102A); |
359 |
output_toggle(OS102A); |
344 |
break; |
360 |
break; |
345 |
case '3': |
361 |
case '3': |
346 |
output_toggle(OS103J); |
362 |
output_toggle(OS103J); |
347 |
break; |
363 |
break; |
348 |
case '4': |
364 |
case '4': |
349 |
output_toggle(OS104A); |
365 |
output_toggle(OS104A); |
350 |
break; |
366 |
break; |
351 |
case '5': |
367 |
case '5': |
352 |
if(buf[3]=='A') {output_toggle(OS105A);} |
368 |
if(buf[3]=='A') {output_toggle(OS105A);} |
353 |
if(buf[3]=='Z') {output_toggle(OS105Z);} |
369 |
if(buf[3]=='Z') {output_toggle(OS105Z);} |
354 |
break; |
370 |
break; |
355 |
case '6': |
371 |
case '6': |
356 |
output_toggle(OS106A); |
372 |
output_toggle(OS106A); |
357 |
break; |
373 |
break; |
358 |
case '7': |
374 |
case '7': |
359 |
output_toggle(OS107A); |
375 |
output_toggle(OS107A); |
360 |
break; |
376 |
break; |
361 |
case '8': |
377 |
case '8': |
362 |
// output_toggle(OS108A); |
378 |
// output_toggle(OS108A); |
363 |
break; |
379 |
break; |
364 |
case '9': |
380 |
case '9': |
365 |
output_toggle(OS109A); |
381 |
output_toggle(OS109A); |
366 |
break; |
382 |
break; |
367 |
case 'a': |
383 |
case 'a': |
368 |
// output_toggle(OS110J); |
384 |
// output_toggle(OS110J); |
369 |
output_toggle(OS110N); |
385 |
output_toggle(OS110N); |
370 |
break; |
386 |
break; |
371 |
} |
387 |
} |
372 |
} |
388 |
} |
373 |
} |
389 |
} |
374 |
|
390 |
|
375 |
if((buf[0]=='R')&&(n>=5)) // Zmena stavu rolety |
391 |
if((buf[0]=='R')&&(n>=5)) // Zmena stavu rolety |
376 |
{ |
392 |
{ |
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! |
- |
|
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; |
390 |
break; |
438 |
break; |
391 |
} |
439 |
} |
392 |
} |
440 |
} |
393 |
} |
441 |
} |
394 |
|
442 |
|
395 |
} |
443 |
} |
396 |
} |
444 |
} |
397 |
} |
445 |
} |
398 |
|
446 |
|
399 |
//!!! switch(r110N) // Zaluzie ma specielni rizeni |
- |
|
400 |
|
- |
|
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;} |
405 |
if(s201AZ!=IS201AZ) {s201AZ=IS201AZ; output_toggle(OS102A); zakmity=ZAKMIT;} |
451 |
if(s201AZ!=IS201AZ) {s201AZ=IS201AZ; output_toggle(OS102A); zakmity=ZAKMIT;} |
406 |
if(s207AJ!=IS207AJ) {s207AJ=IS207AJ; output_toggle(OS207A); zakmity=ZAKMIT;} |
452 |
if(s207AJ!=IS207AJ) {s207AJ=IS207AJ; output_toggle(OS207A); zakmity=ZAKMIT;} |
407 |
if(s203AJ!=IS203AJ) {s203AJ=IS203AJ; output_toggle(OS203A); zakmity=ZAKMIT;} |
453 |
if(s203AJ!=IS203AJ) {s203AJ=IS203AJ; output_toggle(OS203A); zakmity=ZAKMIT;} |
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;} |
471 |
if(r204ZD!=IR204ZD) {r204ZD=IR204ZD; down(R204Z); zakmity=ZAKMIT;} |
464 |
if(r204ZD!=IR204ZD) {r204ZD=IR204ZD; down(R204Z); zakmity=ZAKMIT;} |
472 |
} |
465 |
} |
473 |
else zakmity--; |
466 |
else zakmity--; |
474 |
|
467 |
|
475 |
switch (relay) |
468 |
switch (relay) |
476 |
{ |
469 |
{ |
477 |
case UP: |
470 |
case UP: |
478 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
471 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
479 |
{ |
472 |
{ |
480 |
relay=RUN_UP; // Zmen stav na "jede se" |
473 |
relay=RUN_UP; // Zmen stav na "jede se" |
481 |
run_all(); // Sepni triaky u rolet, ktere maji jet |
474 |
run_all(); // Sepni triaky u rolet, ktere maji jet |
482 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
475 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
483 |
} |
476 |
} |
484 |
break; |
477 |
break; |
485 |
|
478 |
|
486 |
case DOWN: |
479 |
case DOWN: |
487 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
480 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
488 |
{ |
481 |
{ |
489 |
relay=RUN_DOWN; // Zmen stav na "jede se" |
482 |
relay=RUN_DOWN; // Zmen stav na "jede se" |
490 |
run_all(); // Sepni triaky u rolet, ktere maji jet |
483 |
run_all(); // Sepni triaky u rolet, ktere maji jet |
491 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
484 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
492 |
} |
485 |
} |
493 |
break; |
486 |
break; |
494 |
|
487 |
|
495 |
case RUN_UP: |
488 |
case RUN_UP: |
496 |
if (timer_run==0) // Vyprsel bezpecnostni casovac |
489 |
if (timer_run==0) // Vyprsel bezpecnostni casovac |
497 |
{ |
490 |
{ |
498 |
timer=RUN_UP_WAITING; |
491 |
timer=RUN_UP_WAITING; |
499 |
stop_all(); // Vsechno zastav |
492 |
stop_all(); // Vsechno zastav |
500 |
} |
493 |
} |
501 |
break; |
494 |
break; |
502 |
|
495 |
|
503 |
case RUN_DOWN: |
496 |
case RUN_DOWN: |
504 |
if (timer_run==0) // Vyprsel bezpecnostni casovac |
497 |
if (timer_run==0) // Vyprsel bezpecnostni casovac |
505 |
{ |
498 |
{ |
506 |
relay=REVERS_UP; // Vsechno zastav a reverzuj pro prepnuti rele do klidove polohy bez energizace civky |
499 |
relay=REVERS_UP; // Vsechno zastav a reverzuj pro prepnuti rele do klidove polohy bez energizace civky |
507 |
stop_all(); |
500 |
stop_all(); |
508 |
timer_revers=T_REVERS; |
501 |
timer_revers=T_REVERS; |
509 |
} |
502 |
} |
510 |
break; |
503 |
break; |
511 |
|
504 |
|
512 |
case REVERS_UP: |
505 |
case REVERS_UP: |
513 |
if (timer_revers==0) // Uz se snad vybil kondenzator, muzeme reverzovat |
506 |
if (timer_revers==0) // Uz se snad vybil kondenzator, muzeme reverzovat |
514 |
{ |
507 |
{ |
515 |
relay=UP; // Prepni rele |
508 |
relay=UP; // Prepni rele |
516 |
OFF(RE); |
509 |
OFF(RE); |
517 |
timer_start=T_START; // Pockej na prepnuti rele |
510 |
timer_start=T_START; // Pockej na prepnuti rele |
518 |
} |
511 |
} |
519 |
break; |
512 |
break; |
520 |
|
513 |
|
521 |
case REVERS_DOWN: |
514 |
case REVERS_DOWN: |
522 |
if (timer_revers==0) // Uz se snad vybil kondenzator, muzeme reverzovat |
515 |
if (timer_revers==0) // Uz se snad vybil kondenzator, muzeme reverzovat |
523 |
{ |
516 |
{ |
524 |
relay=DOWN; // Prepni rele |
517 |
relay=DOWN; // Prepni rele |
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 |
} |