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