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 |
[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 |
22 |
#use fast_io(A) // Aby se neztracely znaky pri cteni prikazu |
24 |
#use fast_io(A) // Aby se neztracely znaky pri cteni prikazu |
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 |
|
36 |
#define OR106Z PIN_A0 // t1 Roleta trucovna zapad |
40 |
#define OR106Z PIN_A0 // t1 Roleta trucovna zapad |
37 |
#define OR110N PIN_A1 // t2 Zaluzie koupelna dole sever |
41 |
#define OR110N PIN_A1 // t2 Zaluzie koupelna dole sever |
38 |
#define OR104V PIN_A2 // t3 Roleta lab vychod |
42 |
#define OR104V PIN_A2 // t3 Roleta lab vychod |
39 |
#define OR104J PIN_A3 // t4 Roleta lab jih |
43 |
#define OR104J PIN_A3 // t4 Roleta lab jih |
40 |
#define OR103V PIN_A4 // t5 Roleta loznice |
44 |
#define OR103V PIN_A4 // t5 Roleta loznice |
41 |
#define OR202J PIN_A5 // t6 Roleta Kaklik |
45 |
#define OR202J PIN_A5 // t6 Roleta Kaklik |
42 |
#define OR204Z PIN_A6 // t7 Roleta radiomistnost |
46 |
#define OR204Z PIN_A6 // t7 Roleta radiomistnost |
43 |
#define OR207V PIN_A7 // t8 Roleta klubovna |
47 |
#define OR207V PIN_A7 // t8 Roleta klubovna |
44 |
|
48 |
|
45 |
#define OR208V PIN_F0 // t1 Roleta Zizala vychod |
49 |
#define OR208V PIN_F0 // t1 Roleta Zizala vychod |
46 |
#define OR208J PIN_F1 // t2 Roleta Zizala jih |
50 |
#define OR208J PIN_F1 // t2 Roleta Zizala jih |
47 |
//??? #define OR107 PIN_F2 // t3 |
51 |
//??? #define OR107 PIN_F2 // t3 |
48 |
//??? #define OR107 PIN_F3 // t4 |
52 |
//??? #define OR107 PIN_F3 // t4 |
49 |
#define OR201Z PIN_F4 // t5 Roleta chodba nahore |
53 |
#define OR201Z PIN_F4 // t5 Roleta chodba nahore |
50 |
#define OR205N PIN_F5 // t6 Roleta puda |
54 |
#define OR205N PIN_F5 // t6 Roleta puda |
51 |
//??? #define OR105 PIN_F6 // t7 Roleta kuchyn |
55 |
//??? #define OR105 PIN_F6 // t7 Roleta kuchyn |
52 |
//#define O... PIN_F7 // t8 |
56 |
//#define O... PIN_F7 // t8 |
53 |
|
57 |
|
54 |
|
58 |
|
55 |
#define OS103J PIN_B0 // t1 Svetla loznice |
59 |
#define OS103J PIN_B0 // t1 Svetla loznice |
56 |
#define OS105Z PIN_B1 // t2 Svetlo kuchyn nad lavici |
60 |
#define OS105Z PIN_B1 // t2 Svetlo kuchyn nad lavici |
57 |
#define OS110N PIN_B2 // t3 Svetlo koupelna dole zachod a sprhca |
61 |
#define OS110N PIN_B2 // t3 Svetlo koupelna dole zachod a sprhca |
58 |
#define OS106A PIN_B3 // t4 Svetlo trucovna stred |
62 |
#define OS106A PIN_B3 // t4 Svetlo trucovna stred |
59 |
#define OS107A PIN_B4 // t5 Svetlo satna |
63 |
#define OS107A PIN_B4 // t5 Svetlo satna |
60 |
#define OS109A PIN_B5 // t6 Svetlo technologicka mistnost |
64 |
#define OS109A PIN_B5 // t6 Svetlo technologicka mistnost |
61 |
#define OS205A PIN_B6 // t7 Svetlo puda |
65 |
#define OS205A PIN_B6 // t7 Svetlo puda |
62 |
#define OS204A PIN_B7 // t8 Svetlo radiomistnost |
66 |
#define OS204A PIN_B7 // t8 Svetlo radiomistnost |
63 |
|
67 |
|
64 |
//#define OS105C PIN_C2 |
68 |
//#define OS105C PIN_C2 |
65 |
//#define PIN_C3 31763 |
69 |
//#define PIN_C3 31763 |
66 |
//#define PIN_C4 31764 |
70 |
//#define PIN_C4 31764 |
67 |
//#define PIN_C5 31765 |
71 |
//#define PIN_C5 31765 |
68 |
//#define PIN_C6 31766 //TX |
72 |
//#define PIN_C6 31766 //TX |
69 |
//#define PIN_C7 31767 //RX |
73 |
//#define PIN_C7 31767 //RX |
70 |
|
74 |
|
71 |
#define OS102A PIN_E0 // t1 Svetlo chodba |
75 |
#define OS102A PIN_E0 // t1 Svetlo chodba |
72 |
#define OS105A PIN_E1 // t2 Svetlo kuchyne stred |
76 |
#define OS105A PIN_E1 // t2 Svetlo kuchyne stred |
73 |
#define OS207A PIN_E2 // t3 Svetlo klubovna |
77 |
#define OS207A PIN_E2 // t3 Svetlo klubovna |
74 |
#define OS104A PIN_E3 // t4 Svetlo laborator |
78 |
#define OS104A PIN_E3 // t4 Svetlo laborator |
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 |
85 |
#define IS201AV input(PIN_D5) // F Vypinac chodba 2.n.p. vychod |
95 |
#define IS201AV input(PIN_D5) // F Vypinac chodba 2.n.p. vychod |
86 |
#define IS209AJ input(PIN_D6) // G Vypinac koupelna Zizala |
96 |
#define IS209AJ input(PIN_D6) // G Vypinac koupelna Zizala |
87 |
#define IS203AJ input(PIN_D7) // H Vypinac koupelna Kaklik |
97 |
#define IS203AJ input(PIN_D7) // H Vypinac koupelna Kaklik |
88 |
|
98 |
|
89 |
#define IS202AN input(PIN_J0) // A Vypinac svetlo Kaklik stred u dveri na chodbu |
99 |
#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 |
100 |
#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 |
101 |
#define IR202NU input(PIN_J2) // C Vypinac roleta Kaklik nahoru u dveri |
92 |
#define IS205A input(PIN_J3) // D Vypinac svetlo puda |
102 |
#define IS205A input(PIN_J3) // D Vypinac svetlo puda |
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; |
103 |
int1 r207VU; |
123 |
int1 r207VU; |
104 |
int1 r207VD; |
124 |
int1 r207VD; |
105 |
int1 s202AN; |
125 |
int1 s202AN; |
106 |
int1 r202ND; |
126 |
int1 r202ND; |
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; |
122 |
roleta_state rol[18]; // Stavy rolet |
148 |
roleta_state rol[18]; // Stavy rolet |
123 |
#define R103V 0 |
149 |
#define R103V 0 |
124 |
#define R110N 1 |
150 |
#define R110N 1 |
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 |
135 |
int8 timer_run_zaluzie; // Casovac zaluzie na preklopeni lamel |
163 |
int8 timer_run_zaluzie; // Casovac zaluzie na preklopeni lamel |
136 |
int8 timer_revers; // Prodleva na vybiti kondenzatoru pa zastaveni rolety pred prepnutim rele |
164 |
int8 timer_revers; // Prodleva na vybiti kondenzatoru pa zastaveni rolety pred prepnutim rele |
137 |
int8 timer_start; // Prodleva na prepnuti rele pred startem rolety |
165 |
int8 timer_start; // Prodleva na prepnuti rele pred startem rolety |
138 |
int8 timer; // Casovac komunikace |
166 |
int8 timer; // Casovac komunikace |
139 |
|
167 |
|
140 |
#int_TIMER0 |
168 |
#int_TIMER0 |
141 |
void TIMER0_isr(void) |
169 |
void TIMER0_isr(void) |
142 |
{ |
170 |
{ |
143 |
if(timer>0) timer--; |
171 |
if(timer>0) timer--; |
144 |
if(timer_run>0) timer_run--; |
172 |
if(timer_run>0) timer_run--; |
145 |
if(timer_revers>0) timer_revers--; |
173 |
if(timer_revers>0) timer_revers--; |
146 |
if(timer_start>0) timer_start--; |
174 |
if(timer_start>0) timer_start--; |
147 |
if(timer_run_zaluzie>0) timer_run_zaluzie--; |
175 |
if(timer_run_zaluzie>0) timer_run_zaluzie--; |
148 |
output_toggle(LED2); |
176 |
output_toggle(LED2); |
149 |
} |
177 |
} |
150 |
|
178 |
|
151 |
void stop_all() // Zastav vsechny rolety |
179 |
void stop_all() // Zastav vsechny rolety |
152 |
{ |
180 |
{ |
153 |
int8 n; |
181 |
int8 n; |
154 |
|
182 |
|
155 |
output_a(0xFF); |
183 |
output_a(0xFF); |
156 |
output_f(0xFF); |
184 |
output_f(0xFF); |
157 |
for(n=0; n<18; n++) rol[n]=STOP; |
185 |
for(n=0; n<18; n++) rol[n]=STOP; |
158 |
} |
186 |
} |
159 |
|
187 |
|
160 |
void run_all() // Spust rolety |
188 |
void run_all() // Spust rolety |
161 |
{ |
189 |
{ |
162 |
if (rol[R103V]==RUN) ON(OR103V); |
190 |
if (rol[R103V]==RUN) ON(OR103V); |
163 |
if (rol[R110N]==RUN) ON(OR110N); |
191 |
if (rol[R110N]==RUN) ON(OR110N); |
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) |
174 |
{ |
204 |
{ |
175 |
case R103V: ON(OR103V); break; |
205 |
case R103V: ON(OR103V); break; |
176 |
case R110N: ON(OR110N); break; |
206 |
case R110N: ON(OR110N); break; |
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 |
{ |
187 |
switch (roleta) |
219 |
switch (roleta) |
188 |
{ |
220 |
{ |
189 |
case R103V: OFF(OR103V); break; |
221 |
case R103V: OFF(OR103V); break; |
190 |
case R110N: OFF(OR110N); break; |
222 |
case R110N: OFF(OR110N); break; |
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 |
{ |
201 |
if (rol[roleta]==RUN) |
235 |
if (rol[roleta]==RUN) |
202 |
{ |
236 |
{ |
203 |
rol[roleta]=STOP; // Roleta jela, tak zastav |
237 |
rol[roleta]=STOP; // Roleta jela, tak zastav |
204 |
stop(roleta); |
238 |
stop(roleta); |
205 |
} |
239 |
} |
206 |
else |
240 |
else |
207 |
{ |
241 |
{ |
208 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
242 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
209 |
{ |
243 |
{ |
210 |
relay=REVERS_UP; // Reverzuj |
244 |
relay=REVERS_UP; // Reverzuj |
211 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
245 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
212 |
stop_all(); // Vsechno zastav |
246 |
stop_all(); // Vsechno zastav |
213 |
} |
247 |
} |
214 |
if (relay==RUN_UP) |
248 |
if (relay==RUN_UP) |
215 |
{ |
249 |
{ |
216 |
run(roleta); // Jede se spravnym smerem, tak jenom pust roletu |
250 |
run(roleta); // Jede se spravnym smerem, tak jenom pust roletu |
217 |
} |
251 |
} |
218 |
|
252 |
|
219 |
rol[roleta]=RUN; // Roleta stala, tak ji pust |
253 |
rol[roleta]=RUN; // Roleta stala, tak ji pust |
220 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
254 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
221 |
} |
255 |
} |
222 |
} |
256 |
} |
223 |
|
257 |
|
224 |
|
258 |
|
225 |
void down(int8 roleta) // Pozadavek, aby roleta jela dolu |
259 |
void down(int8 roleta) // Pozadavek, aby roleta jela dolu |
226 |
{ |
260 |
{ |
227 |
if (rol[roleta]==RUN) |
261 |
if (rol[roleta]==RUN) |
228 |
{ |
262 |
{ |
229 |
rol[roleta]=STOP; // Roleta jela, tak zastav |
263 |
rol[roleta]=STOP; // Roleta jela, tak zastav |
230 |
stop(roleta); |
264 |
stop(roleta); |
231 |
} |
265 |
} |
232 |
else |
266 |
else |
233 |
{ |
267 |
{ |
234 |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) // Rele je prepnuto na druhou stranu! |
268 |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) // Rele je prepnuto na druhou stranu! |
235 |
{ |
269 |
{ |
236 |
relay=REVERS_DOWN; // Reverzuj |
270 |
relay=REVERS_DOWN; // Reverzuj |
237 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
271 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
238 |
stop_all(); // Vsechno zastav |
272 |
stop_all(); // Vsechno zastav |
239 |
} |
273 |
} |
240 |
if (relay==RUN_DOWN) |
274 |
if (relay==RUN_DOWN) |
241 |
{ |
275 |
{ |
242 |
run(roleta); // Jede se spravnym smerem, tak jenom pust roletu |
276 |
run(roleta); // Jede se spravnym smerem, tak jenom pust roletu |
243 |
} |
277 |
} |
244 |
|
278 |
|
245 |
rol[roleta]=RUN; // Roleta stala, tak ji pust |
279 |
rol[roleta]=RUN; // Roleta stala, tak ji pust |
246 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
280 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
247 |
} |
281 |
} |
248 |
} |
282 |
} |
249 |
|
283 |
|
250 |
|
284 |
|
251 |
void main() |
285 |
void main() |
252 |
{ |
286 |
{ |
253 |
char buf[10]; // Buffer pro prijem prikazu |
287 |
char buf[10]; // Buffer pro prijem prikazu |
254 |
unsigned int16 zakmity=0; // Osetreni zakmitu vypinacu |
288 |
unsigned int16 zakmity=0; // Osetreni zakmitu vypinacu |
255 |
|
289 |
|
256 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
290 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
257 |
setup_adc(ADC_CLOCK_DIV_2); |
291 |
setup_adc(ADC_CLOCK_DIV_2); |
258 |
setup_psp(PSP_DISABLED); |
292 |
setup_psp(PSP_DISABLED); |
259 |
setup_spi(SPI_SS_DISABLED); |
293 |
setup_spi(SPI_SS_DISABLED); |
260 |
setup_wdt(WDT_OFF); |
294 |
setup_wdt(WDT_OFF); |
261 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8); |
295 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8); |
262 |
setup_timer_1(T1_DISABLED); |
296 |
setup_timer_1(T1_DISABLED); |
263 |
setup_timer_2(T2_DISABLED,0,1); |
297 |
setup_timer_2(T2_DISABLED,0,1); |
264 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
298 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
265 |
setup_ccp1(CCP_OFF); |
299 |
setup_ccp1(CCP_OFF); |
266 |
setup_comparator(NC_NC_NC_NC); |
300 |
setup_comparator(NC_NC_NC_NC); |
267 |
setup_vref(FALSE); |
301 |
setup_vref(FALSE); |
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 |
{ |
285 |
int n; |
322 |
int n; |
286 |
|
323 |
|
287 |
for(n=0;n<10;n++) |
324 |
for(n=0;n<10;n++) |
288 |
{ |
325 |
{ |
289 |
output_low(LED1); // Indikace restartu (pockame na nabiti kondenzatoru ve vstupnich obvodech) |
326 |
output_low(LED1); // Indikace restartu (pockame na nabiti kondenzatoru ve vstupnich obvodech) |
290 |
delay_ms(100); |
327 |
delay_ms(100); |
291 |
output_high(LED1); |
328 |
output_high(LED1); |
292 |
delay_ms(100); |
329 |
delay_ms(100); |
293 |
restart_wdt(); |
330 |
restart_wdt(); |
294 |
} |
331 |
} |
295 |
} |
332 |
} |
296 |
|
333 |
|
297 |
s201AV=IS201AV; // Precteme vychozi stav vypinacu |
334 |
s201AV=IS201AV; // Precteme vychozi stav vypinacu |
298 |
s201AZ=IS201AZ; |
335 |
s201AZ=IS201AZ; |
299 |
s207AJ=IS207AJ; |
336 |
s207AJ=IS207AJ; |
300 |
s203AJ=IS203AJ; |
337 |
s203AJ=IS203AJ; |
301 |
s209AJ=IS209AJ; |
338 |
s209AJ=IS209AJ; |
302 |
r207VU=IR207VU; |
339 |
r207VU=IR207VU; |
303 |
r207VD=IR207VD; |
340 |
r207VD=IR207VD; |
304 |
s202AN=IS202AN; |
341 |
s202AN=IS202AN; |
305 |
r202ND=IR202ND; |
342 |
r202ND=IR202ND; |
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; |
316 |
timer_run_zaluzie=0; |
359 |
timer_run_zaluzie=0; |
317 |
zakmity=0; |
360 |
zakmity=0; |
318 |
|
361 |
|
319 |
enable_interrupts(INT_TIMER0); // Spust casovani |
362 |
enable_interrupts(INT_TIMER0); // Spust casovani |
320 |
enable_interrupts(GLOBAL); |
363 |
enable_interrupts(GLOBAL); |
321 |
|
364 |
|
322 |
CREN=0; CREN=1; // Reinitialise USART |
365 |
CREN=0; CREN=1; // Reinitialise USART |
323 |
|
366 |
|
324 |
while(TRUE) |
367 |
while(TRUE) |
325 |
{ |
368 |
{ |
326 |
restart_wdt(); |
369 |
restart_wdt(); |
327 |
|
370 |
|
328 |
if(kbhit()) // Chce po nas nekdo neco? |
371 |
if(kbhit()) // Chce po nas nekdo neco? |
329 |
{ |
372 |
{ |
330 |
buf[0]=getc(); |
373 |
buf[0]=getc(); |
331 |
if((buf[0]=='S')||(buf[0]=='R')) // Jinym znakem nesmi zacinat prikaz |
374 |
if((buf[0]=='S')||(buf[0]=='R')) // Jinym znakem nesmi zacinat prikaz |
332 |
{ |
375 |
{ |
333 |
int8 n=0; // Ukazatel do prijimaciho bufferu |
376 |
int8 n=0; // Ukazatel do prijimaciho bufferu |
334 |
timer=T_RECEIVE; // Timeout pro prijem znaku |
377 |
timer=T_RECEIVE; // Timeout pro prijem znaku |
335 |
|
378 |
|
336 |
do |
379 |
do |
337 |
{ |
380 |
{ |
338 |
if(kbhit()) // Je dalsi znak? |
381 |
if(kbhit()) // Je dalsi znak? |
339 |
{ |
382 |
{ |
340 |
n++; |
383 |
n++; |
341 |
buf[n]=getc(); |
384 |
buf[n]=getc(); |
342 |
} |
385 |
} |
343 |
} while ((buf[n]!='\r')&&(timer>0)&&(n<7)); |
386 |
} while ((buf[n]!='\r')&&(timer>0)&&(n<7)); |
344 |
|
387 |
|
345 |
if (timer==0) { CREN=0; CREN=1; } // Reinitialise USART |
388 |
if (timer==0) { CREN=0; CREN=1; } // Reinitialise USART |
346 |
|
389 |
|
347 |
output_toggle(LED1); // Ukonceni prijimani prikazu |
390 |
output_toggle(LED1); // Ukonceni prijimani prikazu |
348 |
|
391 |
|
349 |
if((timer>0)) |
392 |
if((timer>0)) |
350 |
{ |
393 |
{ |
351 |
|
394 |
|
352 |
if((buf[0]=='S')&&(n>=4)) // Zmena stavu svetla |
395 |
if((buf[0]=='S')&&(n>=4)) // Zmena stavu svetla |
353 |
{ |
396 |
{ |
354 |
if(buf[1]=='1') |
397 |
if(buf[1]=='1') |
355 |
{ |
398 |
{ |
356 |
switch(buf[2]) |
399 |
switch(buf[2]) |
357 |
{ |
400 |
{ |
358 |
case '2': |
401 |
case '2': |
359 |
output_toggle(OS102A); |
402 |
output_toggle(OS102A); |
360 |
break; |
403 |
break; |
361 |
case '3': |
404 |
case '3': |
362 |
output_toggle(OS103J); |
405 |
output_toggle(OS103J); |
363 |
break; |
406 |
break; |
364 |
case '4': |
407 |
case '4': |
365 |
output_toggle(OS104A); |
408 |
output_toggle(OS104A); |
366 |
break; |
409 |
break; |
367 |
case '5': |
410 |
case '5': |
368 |
if(buf[3]=='A') {output_toggle(OS105A);} |
411 |
if(buf[3]=='A') {output_toggle(OS105A);} |
369 |
if(buf[3]=='Z') {output_toggle(OS105Z);} |
412 |
if(buf[3]=='Z') {output_toggle(OS105Z);} |
370 |
break; |
413 |
break; |
371 |
case '6': |
414 |
case '6': |
372 |
output_toggle(OS106A); |
415 |
output_toggle(OS106A); |
373 |
break; |
416 |
break; |
374 |
case '7': |
417 |
case '7': |
375 |
output_toggle(OS107A); |
418 |
output_toggle(OS107A); |
376 |
break; |
419 |
break; |
377 |
case '8': |
420 |
case '8': |
378 |
// output_toggle(OS108A); |
421 |
// output_toggle(OS108A); |
379 |
break; |
422 |
break; |
380 |
case '9': |
423 |
case '9': |
381 |
output_toggle(OS109A); |
424 |
output_toggle(OS109A); |
382 |
break; |
425 |
break; |
383 |
case 'a': |
426 |
case 'a': |
384 |
// output_toggle(OS110J); |
427 |
// output_toggle(OS110J); |
385 |
output_toggle(OS110N); |
428 |
output_toggle(OS110N); |
386 |
break; |
429 |
break; |
387 |
} |
430 |
} |
388 |
} |
431 |
} |
389 |
} |
432 |
} |
390 |
|
433 |
|
391 |
if((buf[0]=='R')&&(n>=5)) // Zmena stavu rolety |
434 |
if((buf[0]=='R')&&(n>=5)) // Zmena stavu rolety |
392 |
{ |
435 |
{ |
393 |
if(buf[1]=='1') |
436 |
if(buf[1]=='1') |
394 |
{ |
437 |
{ |
395 |
switch(buf[2]) |
438 |
switch(buf[2]) |
396 |
{ |
439 |
{ |
397 |
case '3': |
440 |
case '3': |
398 |
if(buf[4]=='U') {up(R103V);} else {down(R103V);} |
441 |
if(buf[4]=='U') {up(R103V);} else {down(R103V);} |
399 |
break; |
442 |
break; |
400 |
case '4': |
443 |
case '4': |
401 |
if(buf[3]=='V') if((buf[4]=='U')) {up(R104V);} else {down(R104V);} |
444 |
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);} |
445 |
if(buf[3]=='J') if((buf[4]=='U')) {up(R104J);} else {down(R104J);} |
403 |
break; |
446 |
break; |
404 |
case 'a': |
447 |
case 'a': |
405 |
if((buf[4]=='U')) |
448 |
if((buf[4]=='U')) |
406 |
{//up(R110N); |
449 |
{//up(R110N); |
407 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
450 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
408 |
{ |
451 |
{ |
409 |
relay=REVERS_UP; // Reverzuj |
452 |
relay=REVERS_UP; // Reverzuj |
410 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
453 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
411 |
stop_all(); // Vsechno zastav |
454 |
stop_all(); // Vsechno zastav |
412 |
} |
455 |
} |
413 |
if (relay==RUN_UP) |
456 |
if (relay==RUN_UP) |
414 |
{ |
457 |
{ |
415 |
run(R110N); // Jede se spravnym smerem, tak jenom pust roletu |
458 |
run(R110N); // Jede se spravnym smerem, tak jenom pust roletu |
416 |
} |
459 |
} |
417 |
|
460 |
|
418 |
rol[R110N]=RUN; // Roleta stala, tak ji pust |
461 |
rol[R110N]=RUN; // Roleta stala, tak ji pust |
419 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
462 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
420 |
} |
463 |
} |
421 |
else |
464 |
else |
422 |
{//down(R110N); |
465 |
{//down(R110N); |
423 |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) // Rele je prepnuto na druhou stranu! |
466 |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) // Rele je prepnuto na druhou stranu! |
424 |
{ |
467 |
{ |
425 |
relay=REVERS_DOWN; // Reverzuj |
468 |
relay=REVERS_DOWN; // Reverzuj |
426 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
469 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
427 |
stop_all(); // Vsechno zastav |
470 |
stop_all(); // Vsechno zastav |
428 |
} |
471 |
} |
429 |
if (relay==RUN_DOWN) |
472 |
if (relay==RUN_DOWN) |
430 |
{ |
473 |
{ |
431 |
run(R110N); // Jede se spravnym smerem, tak jenom pust roletu |
474 |
run(R110N); // Jede se spravnym smerem, tak jenom pust roletu |
432 |
} |
475 |
} |
433 |
|
476 |
|
434 |
rol[R110N]=RUN; // Roleta stala, tak ji pust |
477 |
rol[R110N]=RUN; // Roleta stala, tak ji pust |
435 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
478 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
436 |
} |
479 |
} |
437 |
timer_run_zaluzie=T_GO_ZALUZIE; |
480 |
timer_run_zaluzie=T_GO_ZALUZIE; |
438 |
break; |
481 |
break; |
439 |
} |
482 |
} |
440 |
} |
483 |
} |
441 |
} |
484 |
} |
442 |
|
485 |
|
443 |
} |
486 |
} |
444 |
} |
487 |
} |
445 |
} |
488 |
} |
446 |
|
489 |
|
447 |
// mistni vypinace z 2. n.p. |
490 |
// mistni vypinace z 2. n.p. |
448 |
if (0==zakmity) |
491 |
if (0==zakmity) |
449 |
{ |
492 |
{ |
450 |
if(s201AV!=IS201AV) {s201AV=IS201AV; output_toggle(OS102A); zakmity=ZAKMIT;} |
493 |
if(s201AV!=IS201AV) {s201AV=IS201AV; output_toggle(OS102A); zakmity=ZAKMIT;} |
451 |
if(s201AZ!=IS201AZ) {s201AZ=IS201AZ; output_toggle(OS102A); zakmity=ZAKMIT;} |
494 |
if(s201AZ!=IS201AZ) {s201AZ=IS201AZ; output_toggle(OS102A); zakmity=ZAKMIT;} |
452 |
if(s207AJ!=IS207AJ) {s207AJ=IS207AJ; output_toggle(OS207A); zakmity=ZAKMIT;} |
495 |
if(s207AJ!=IS207AJ) {s207AJ=IS207AJ; output_toggle(OS207A); zakmity=ZAKMIT;} |
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 |
{ |
470 |
case UP: |
520 |
case UP: |
471 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
521 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
472 |
{ |
522 |
{ |
473 |
relay=RUN_UP; // Zmen stav na "jede se" |
523 |
relay=RUN_UP; // Zmen stav na "jede se" |
474 |
run_all(); // Sepni triaky u rolet, ktere maji jet |
524 |
run_all(); // Sepni triaky u rolet, ktere maji jet |
475 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
525 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
476 |
} |
526 |
} |
477 |
break; |
527 |
break; |
478 |
|
528 |
|
479 |
case DOWN: |
529 |
case DOWN: |
480 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
530 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
481 |
{ |
531 |
{ |
482 |
relay=RUN_DOWN; // Zmen stav na "jede se" |
532 |
relay=RUN_DOWN; // Zmen stav na "jede se" |
483 |
run_all(); // Sepni triaky u rolet, ktere maji jet |
533 |
run_all(); // Sepni triaky u rolet, ktere maji jet |
484 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
534 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
485 |
} |
535 |
} |
486 |
break; |
536 |
break; |
487 |
|
537 |
|
488 |
case RUN_UP: |
538 |
case RUN_UP: |
489 |
if (timer_run==0) // Vyprsel bezpecnostni casovac |
539 |
if (timer_run==0) // Vyprsel bezpecnostni casovac |
490 |
{ |
540 |
{ |
491 |
timer=RUN_UP_WAITING; |
541 |
timer=RUN_UP_WAITING; |
492 |
stop_all(); // Vsechno zastav |
542 |
stop_all(); // Vsechno zastav |
493 |
} |
543 |
} |
494 |
break; |
544 |
break; |
495 |
|
545 |
|
496 |
case RUN_DOWN: |
546 |
case RUN_DOWN: |
497 |
if (timer_run==0) // Vyprsel bezpecnostni casovac |
547 |
if (timer_run==0) // Vyprsel bezpecnostni casovac |
498 |
{ |
548 |
{ |
499 |
relay=REVERS_UP; // Vsechno zastav a reverzuj pro prepnuti rele do klidove polohy bez energizace civky |
549 |
relay=REVERS_UP; // Vsechno zastav a reverzuj pro prepnuti rele do klidove polohy bez energizace civky |
500 |
stop_all(); |
550 |
stop_all(); |
501 |
timer_revers=T_REVERS; |
551 |
timer_revers=T_REVERS; |
502 |
} |
552 |
} |
503 |
break; |
553 |
break; |
504 |
|
554 |
|
505 |
case REVERS_UP: |
555 |
case REVERS_UP: |
506 |
if (timer_revers==0) // Uz se snad vybil kondenzator, muzeme reverzovat |
556 |
if (timer_revers==0) // Uz se snad vybil kondenzator, muzeme reverzovat |
507 |
{ |
557 |
{ |
508 |
relay=UP; // Prepni rele |
558 |
relay=UP; // Prepni rele |
509 |
OFF(RE); |
559 |
OFF(RE); |
510 |
timer_start=T_START; // Pockej na prepnuti rele |
560 |
timer_start=T_START; // Pockej na prepnuti rele |
511 |
} |
561 |
} |
512 |
break; |
562 |
break; |
513 |
|
563 |
|
514 |
case REVERS_DOWN: |
564 |
case REVERS_DOWN: |
515 |
if (timer_revers==0) // Uz se snad vybil kondenzator, muzeme reverzovat |
565 |
if (timer_revers==0) // Uz se snad vybil kondenzator, muzeme reverzovat |
516 |
{ |
566 |
{ |
517 |
relay=DOWN; // Prepni rele |
567 |
relay=DOWN; // Prepni rele |
518 |
ON(RE); |
568 |
ON(RE); |
519 |
timer_start=T_START; // Pockej na prepnuti rele |
569 |
timer_start=T_START; // Pockej na prepnuti rele |
520 |
} |
570 |
} |
521 |
break; |
571 |
break; |
522 |
} |
572 |
} |
523 |
|
573 |
|
524 |
// Zaluzie ma kratsi beh |
574 |
// Zaluzie ma kratsi beh |
525 |
if ((timer_run_zaluzie==0)&&(rol[R110N]==RUN)) {rol[R110N]=STOP; OFF(OR110N);} |
575 |
if ((timer_run_zaluzie==0)&&(rol[R110N]==RUN)) {rol[R110N]=STOP; OFF(OR110N);} |
526 |
} |
576 |
} |
527 |
} |
577 |
} |