/Designs/dum/SW/2patra/1np/main.c |
---|
1,3 → 1,20 |
/* |
Ovladani domu rozvadec 1. n.p. pod schodama |
Syntaxe prikazu: |
<Roleta/Svetlo><#patro><#mistnost><Nord/Jih/Vychod/Zapad/A/B><Up/Down> |
R2aNU - roleta, 2. n.p., mistnost 10, sever, nahoru |
S12A - svetlo, 1. n.p., mistnost 2, prostredni |
Rozmisteni desek: |
[IN B] [IN D] |
[CPU] |
[IN A] [CAN] [IN E] [IN F] |
*/ |
#include "main.h" |
#case |
11,14 → 28,14 |
#define R104JZU input(PIN_A6) // Roleta laborator jih |
#define R104JZD input(PIN_A7) |
#define S103JZ input(PIN_B0) // Svetlo loznice jih vypinac u dveri |
#define S103JN input(PIN_B1) // -"- vypinac KAKL |
#define S103JV input(PIN_B2) // -"- vypinac mama |
#define R103VZU input(PIN_B3) // Roleta loznice vypinac u dveri |
#define R103VZD input(PIN_B4) |
#define S106AV input(PIN_B5) // Hlavni svetlo trucovna vypinac u dveri do kuchyne |
#define S107AN input(PIN_B6) // Svetlo satna vypinac do chodby |
#define S109AJ input(PIN_B7) // Svetlo tech. mistnost vypinac do chodby |
#define S103JZ input(PIN_B0) // A Svetlo loznice jih vypinac u dveri |
#define S103JN input(PIN_B1) // B -"- vypinac KAKL |
#define S103JV input(PIN_B2) // C -"- vypinac mama |
#define R103VZU input(PIN_B3) // D Roleta loznice vypinac u dveri |
#define R103VZD input(PIN_B4) // E |
//#define S input(PIN_B5) // F |
#define S107AN input(PIN_B6) // G Svetlo satna vypinac do chodby |
#define S109AJ input(PIN_B7) // H Svetlo tech. mistnost vypinac do chodby |
#define OS101A PIN_C0 // Spinac svetla v bunecce prizemi |
#define OS105V PIN_C1 // Svetlo nad chlebarnou |
40,25 → 57,26 |
#define S110AN input(PIN_D6) // Vypinac koupelna sever |
#define S108AV input(PIN_D7) // Dvere do spajzu |
/* |
#define PIN_E0 31776 |
#define PIN_E1 31777 |
#define PIN_E2 31778 |
#define PIN_E3 31779 |
#define PIN_E4 31780 |
#define PIN_E5 31781 |
#define PIN_E6 31782 |
#define PIN_E7 31783 |
//#define S input(PIN_E0) // A |
//#define S input(PIN_E1) // B |
//#define S input(PIN_E2) // C |
//#define S input(PIN_E3) // D |
//#define S input(PIN_E4) // E |
//#define S input(PIN_E5) // F |
//#define S input(PIN_E6) // G |
//#define S input(PIN_E7) // H |
#define PIN_F0 31784 |
#define PIN_F1 31785 |
#define PIN_F2 31786 |
#define PIN_F3 31787 |
#define PIN_F4 31788 |
#define PIN_F5 31789 |
#define PIN_F6 31790 |
#define PIN_F7 31791 |
#define S106AV input(PIN_F0) // A Hlavni svetlo trucovna vypinac u dveri do kuchyne |
#define R106JVD input(PIN_F1) // B Roleta trucovna jih vypinac u dveri do kuchyne |
#define R106JVU input(PIN_F2) // C |
#define R106ZVD input(PIN_F3) // D Roleta trucovna zapad vypinac u dveri do kuchyne |
#define R106ZVU input(PIN_F4) // E |
#define S107AJ input(PIN_F5) // F Svetlo satna vypinac u trucovny |
#define S109AN input(PIN_F6) // G Svetlo technologicka mistnost vypinac do prujezdu |
#define S106AN input(PIN_F7) // H Hlavni svetlo trucovna vypinac u dveri do satny |
/* |
#define PIN_G0 31792 |
#define PIN_G1 31793 |
#define PIN_G2 31794 |
104,7 → 122,6 |
int1 s103JV; |
int1 r103VZU; |
int1 r103VZD; |
int1 s106AV; |
int1 s107AN; |
int1 s109AJ; |
int1 s101AN; |
115,6 → 132,14 |
int1 s102AN; |
int1 s110AN; |
int1 s108AV; |
int1 r106JVU; |
int1 r106JVD; |
int1 r106ZVU; |
int1 r106ZVD; |
int1 s106AV; |
int1 s106AN; |
int1 s107AJ; |
int1 s109AN; |
#define send(s) \ |
{\ |
125,7 → 150,6 |
void main() |
{ |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
setup_adc(ADC_CLOCK_DIV_2); |
setup_psp(PSP_DISABLED); |
141,6 → 165,20 |
OFF(OS101A); |
{ |
int n; |
for(n=0;n<10;n++) |
{ |
output_low(LED1); // Indikace restartu (pockame na nabiti kondenzatoru ve vstupnich obvodech) |
delay_ms(100); |
output_high(LED1); |
delay_ms(100); |
restart_wdt(); |
} |
} |
s105AN=S105AN; // Poznamenej vychozi stav vypinacu |
r110NJU=R110NJU; |
r110NJD=R110NJD; |
154,7 → 192,6 |
s103JV=S103JV; |
r103VZU=R103VZU; |
r103VZD=R103VZD; |
s106AV=S106AV; |
s107AN=S107AN; |
s109AJ=S109AJ; |
s101AN=S101AN; |
165,6 → 202,14 |
s102AN=S102AN; |
s110AN=S110AN; |
s108AV=S108AV; |
r106JVU=R106JVU; |
r106JVD=R106JVD; |
r106ZVU=R106ZVU; |
r106ZVD=R106ZVD; |
s106AV=S106AV; |
s106AN=S106AN; |
s107AJ=S107AJ; |
s109AN=S109AN; |
while(TRUE) |
{ |
188,7 → 233,6 |
if(r103VZU!=R103VZU) {r103VZU=R103VZU; send(R13VU);} |
if(r103VZD!=R103VZD) {r103VZD=R103VZD; send(R13VD);} |
if(s106AV!=S106AV) {s106AV=S106AV; send(S16A);} |
if(s107AN!=S107AN) {s107AN=S107AN; send(S17A);} |
if(s109AJ!=S109AJ) {s109AJ=S109AJ; send(S19A);} |
199,6 → 243,15 |
if(s110AN!=S110AN) {s110AN=S110AN; send(S1aA);} |
if(s108AV!=S108AV) {s108AV=S108AV; send(S18A);} |
if(r106JVU!=R106JVU) {r106JVU=R106JVU; send(R16JU);} |
if(r106JVD!=R106JVD) {r106JVD=R106JVD; send(R16JD);} |
if(r106ZVU!=R106ZVU) {r106ZVU=R106ZVU; send(R16ZU);} |
if(r106ZVD!=R106ZVD) {r106ZVD=R106ZVD; send(R16ZD);} |
if(s106AV!=S106AV) {s106AV=S106AV; send(S16A);} |
if(s106AN!=S106AN) {s106AN=S106AN; send(S16A);} |
if(s107AJ!=S107AJ) {s107AJ=S107AJ; send(S17A);} |
if(s109AN!=S109AN) {s109AN=S109AN; send(S19A);} |
if(get_timer0()>65000) {output_toggle(LED2); set_timer0(0);} |
} |
} |
/Designs/dum/SW/2patra/1np/main.pjt |
---|
20,10 → 20,10 |
Count=1 |
1=C:\Users\kakl\Documents\MLAB\Designs\dum\SW\2patra\1np\main |
[Opened Files] |
1=main.c |
1=..\1np\main.c |
2=main.h |
3=..\..\..\..\..\..\..\..\..\Program Files\PICC\Devices\18F8310.h |
4=..\2np\main.c |
4= |
5= |
6=..\..\..\..\..\Modules\PIC\PIC18F8xTQ8001A\SW\PIC18F8310\blik.h |
7=..\..\..\..\..\Modules\PIC\PIC18F8xTQ8001A\SW\PIC18F8310\blik.c |
/Designs/dum/SW/2patra/2np/main.c |
---|
30,14 → 30,15 |
#use fast_io(H) |
#use fast_io(G) |
#define T_REVERS 2 // 2*256 ms = 0,5 s; pred prepnutim rele (zastaveni motoru a vybiti kondenzatoru) |
#define T_START 1 // 1*256 ms = 0,3 s; po prepnuti rele do sepnuti triaku |
#define T_GO 117 // 117*256 ms = 30 s; max. beh rolety |
#define T_GO_ZALUZIE 6 // cca 1,5 s; beh zaluzie (pouze na preklopeni lamel) |
#define T_RECEIVE 10 // cca 2,6 s |
#define ZAKMIT 2000 // pocet pruchodu hlavni smyckou pred opetovnou detekci prepnuti vypinace |
#define T_REVERS 2 // 2*256 ms = 0,5 s; pred prepnutim rele (zastaveni motoru a vybiti kondenzatoru) |
#define T_START 1 // 1*256 ms = 0,3 s; po prepnuti rele do sepnuti triaku |
#define T_GO 117 // 117*256 ms = 30 s; max. beh rolety |
#define T_GO_ZALUZIE 2500/256 // cca 2 s; beh zaluzie (pouze na preklopeni lamel) |
#define T_RECEIVE 10 // cca 2,6 s |
#define TIMEOUT_SPAJZ 255 // Timeout svetlo spajz cca minuta |
#define ZAKMIT 2000 // pocet pruchodu hlavni smyckou pred opetovnou detekci prepnuti vypinace |
#define OR106Z PIN_A0 // t1 Roleta trucovna zapad |
//!!! STUDENAK na triaku spolecny vyvod !!! #define O PIN_A0 // t1 |
#define OR110N PIN_A1 // t2 Zaluzie koupelna dole sever |
#define OR104V PIN_A2 // t3 Roleta lab vychod |
#define OR104J PIN_A3 // t4 Roleta lab jih |
48,12 → 49,12 |
#define OR208V PIN_F0 // t1 Roleta Zizala vychod |
#define OR208J PIN_F1 // t2 Roleta Zizala jih |
//??? #define OR107 PIN_F2 // t3 |
//??? #define OR107 PIN_F3 // t4 |
//??? #define OR107 PIN_F2 // t3 Roleta satna |
#define OR106J PIN_F3 // t4 Roleta trucovna jih |
#define OR201Z PIN_F4 // t5 Roleta chodba nahore |
#define OR205N PIN_F5 // t6 Roleta puda |
//??? #define OR105 PIN_F6 // t7 Roleta kuchyn |
//#define O... PIN_F7 // t8 |
#define OR106Z PIN_F7 // t8 Roleta trucovna zapad |
#define OS103J PIN_B0 // t1 Svetla loznice |
83,7 → 84,7 |
//#define O.... PIN_G0 // t8 |
//#define O.... PIN_G1 // t7 |
//#define O.... PIN_G2 // t6 |
#define OS108A PIN_G2 // t6 Svetlo spajz |
#define OS208A PIN_G3 // t5 Svetlo Zizala stred |
#define OS100A PIN_G4 // t4 Svetlo prujezd venku |
103,7 → 104,7 |
#define IS204AJ input(PIN_J4) // E Vypinac svetlo radiomistnost u dveri na chodbu |
#define IR204ZD input(PIN_J5) // F Vypinac roleta radiomistnost dolu |
#define IR204ZU input(PIN_J6) // G Vypinac roleta radiomistnost nahoru |
//#define I.... input(PIN_J7) // H |
#define IS108A input(PIN_J7) // H Mikrospinac spajz |
#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 |
#define IR208JD input(PIN_H1) // B Vypinac roleta vychod Zizala nahoru u dveri |
155,6 → 156,8 |
#define R204Z 6 |
#define R208V 7 |
#define R208J 8 |
#define R106J 9 |
#define R106Z 10 |
typedef enum {UP, DOWN, REVERS_UP, REVERS_DOWN, RUN_UP, RUN_DOWN, RUN_UP_WAITING} relay_state; |
relay_state relay; // Stavy rele |
164,11 → 167,13 |
int8 timer_revers; // Prodleva na vybiti kondenzatoru pa zastaveni rolety pred prepnutim rele |
int8 timer_start; // Prodleva na prepnuti rele pred startem rolety |
int8 timer; // Casovac komunikace |
int8 tS108; // Casovac svetlo spajz |
#int_TIMER0 |
void TIMER0_isr(void) |
{ |
if(timer>0) timer--; |
if(tS108>0) tS108--; |
if(timer_run>0) timer_run--; |
if(timer_revers>0) timer_revers--; |
if(timer_start>0) timer_start--; |
196,6 → 201,8 |
if (rol[R204Z]==RUN) ON(OR204Z); |
if (rol[R208V]==RUN) ON(OR208V); |
if (rol[R208J]==RUN) ON(OR208J); |
if (rol[R106J]==RUN) ON(OR106J); |
if (rol[R106Z]==RUN) ON(OR106Z); |
} |
void run(int8 roleta) // Spust konkretni roletu |
211,6 → 218,8 |
case R204Z: ON(OR204Z); break; |
case R208V: ON(OR208V); break; |
case R208J: ON(OR208J); break; |
case R106J: ON(OR106J); break; |
case R106Z: ON(OR106Z); break; |
} |
} |
227,6 → 236,8 |
case R204Z: OFF(OR204Z); break; |
case R208V: OFF(OR208V); break; |
case R208J: OFF(OR208J); break; |
case R106J: OFF(OR106J); break; |
case R106Z: OFF(OR106Z); break; |
} |
} |
444,6 → 455,10 |
if(buf[3]=='V') if((buf[4]=='U')) {up(R104V);} else {down(R104V);} |
if(buf[3]=='J') if((buf[4]=='U')) {up(R104J);} else {down(R104J);} |
break; |
case '6': |
if(buf[3]=='J') if((buf[4]=='U')) {up(R106J);} else {down(R106J);} |
if(buf[3]=='Z') if((buf[4]=='U')) {up(R106Z);} else {down(R106Z);} |
break; |
case 'a': |
if((buf[4]=='U')) |
{//up(R110N); |
515,6 → 530,10 |
} |
else zakmity--; |
// Spajz mikrospinac i svetlo |
if(IS108A) {output_high(OS108A); tS108=TIMEOUT_SPAJZ;} |
if((!IS108A)&&(tS108>0)) {output_low(OS108A);} else {output_high(OS108A);} |
switch (relay) |
{ |
case UP: |