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