5 ' --- Centrale domotique 3 voies --- 10 const device = 3B 20 lcdinit : csroff 30 ' Déclaration des variables de la voie 1 31 dim X10 as byte : dim X11 as byte : dim X12 as byte : dim X13 as byte 32 dim mode11 as byte : dim mode12 as byte : dim mode13 as byte 33 dim tempo11 as integer : dim tempo12 as integer : dim tempo13 as integer 34 dim INC1 as byte : dim T1 as integer 40 ' Déclaration des variables de la voie 2 41 dim X20 as byte : dim X21 as byte : dim X22 as byte : dim X23 as byte 42 dim mode21 as byte : dim mode22 as byte : dim mode23 as byte 43 dim tempo21 as integer : dim tempo22 as integer : dim tempo23 as integer 44 dim INC2 as byte : dim T2 as integer 50 ' Déclaration des variables de la voie 3 51 dim X30 as byte : dim X31 as byte : dim X32 as byte : dim X33 as byte 52 dim mode31 as byte : dim mode32 as byte : dim mode33 as byte 53 dim tempo31 as integer : dim tempo32 as integer : dim tempo33 as integer 54 dim INC3 as byte : dim T3 as integer 55 ' Déclaration des variables communes 56 dim S0 as byte : dim S1 as byte : dim S2 as byte : dim S3 as byte : dim F as integer 60 gosub 1000 : ' Affichage message d'accueil 61 sound 7,159,2 62 delay 2000 63 gosub 2000 : ' Configuration de la voie 1 64 gosub 2400 : ' Configuration de la voie 2 70 gosub 2700 : ' Configuration de la voie 3 71 locate 0,0 : print "Centrale OK " 72 if mode11 = 1 then locate 0,1 : print "1 - Telerupteur " 73 if mode12 = 1 then locate 0,1 : print "1 - Minuterie " 74 if mode13 = 1 then locate 0,1 : print "1 - Simulateur " 75 if mode21 = 1 then locate 0,2 : print "2 - Telerupteur " 76 if mode22 = 1 then locate 0,2 : print "2 - Minuterie " 77 if mode23 = 1 then locate 0,2 : print "2 - Simulateur " 78 if mode31 = 1 then locate 0,3 : print "3 - Telerupteur " 79 if mode32 = 1 then locate 0,3 : print "3 - Minuterie " 80 if mode33 = 1 then locate 0,3 : print "3 - Simulateur " 85 ' --- Gestion des Grafcets --- 90 ' Initialisation des grafcets 100 X10 = 1 : X11 = 0 : X12 = 0 : X13 = 0 : T1 = 0 : tempo11 = 0 : tempo12 = 0 : tempo13 = 0 102 X20 = 1 : X21 = 0 : X22 = 0 : X23 = 0 : T2 = 0 : tempo21 = 0 : tempo22 = 0 : tempo23 = 0 104 X30 = 1 : X31 = 0 : X32 = 0 : X33 = 0 : T3 = 0 : tempo31 = 0 : tempo32 = 0 : tempo33 = 0 110 ' Lecture des entrées 120 gosub 3000 130 if X10 = 1 and (S1 = 0 and mode13 = 0) then X11 = 1 : X10 = 0 131 if X10 = 1 and (T1 = 1 and mode13 = 1) then X12 = 1 : X10 = 0 : T1 = 0 132 if X11 = 1 and (S1 = 1 and mode11 = 1) then X12 = 1 : X11 = 0 133 if X11 = 1 and (S1 = 1 and mode12 = 1) then X12 = 1 : X11 = 0 134 if X12 = 1 and (S1 = 0 and mode11 = 1) then X13 = 1 : X12 = 0 135 if X12 = 1 and (T1 = 1 and mode12 = 1) then X10 = 1 : X12 = 0 : T1 = 0 136 if X12 = 1 and (T1 = 1 and mode13 = 1) then X10 = 1 : X12 = 0 : T1 = 0 137 if X13 = 1 and (S1 = 1 and mode11 = 1) then X10 = 1 : X13 = 0 140 if X20 = 1 and (S2 = 0 and mode23 = 0) then X21 = 1 : X20 = 0 141 if X20 = 1 and (T2 = 1 and mode23 = 1) then X22 = 1 : X20 = 0 : T2 = 0 142 if X21 = 1 and (S2 = 1 and mode21 = 1) then X22 = 1 : X21 = 0 143 if X21 = 1 and (S2 = 1 and mode22 = 1) then X22 = 1 : X21 = 0 144 if X22 = 1 and (S2 = 0 and mode21 = 1) then X23 = 1 : X22 = 0 145 if X22 = 1 and (T2 = 1 and mode22 = 1) then X20 = 1 : X22 = 0 : T2 = 0 146 if X22 = 1 and (T2 = 1 and mode23 = 1) then X20 = 1 : X22 = 0 : T2 = 0 147 if X23 = 1 and (S2 = 1 and mode21 = 1) then X20 = 1 : X23 = 0 150 if X30 = 1 and (S3 = 0 and mode33 = 0) then X31 = 1 : X30 = 0 151 if X30 = 1 and (T3 = 1 and mode33 = 1) then X32 = 1 : X30 = 0 : T3 = 0 152 if X31 = 1 and (S3 = 1 and mode31 = 1) then X32 = 1 : X31 = 0 153 if X31 = 1 and (S3 = 1 and mode32 = 1) then X32 = 1 : X31 = 0 154 if X32 = 1 and (S3 = 0 and mode31 = 1) then X33 = 1 : X32 = 0 155 if X32 = 1 and (T3 = 1 and mode32 = 1) then X30 = 1 : X32 = 0 : T3 = 0 156 if X32 = 1 and (T3 = 1 and mode33 = 1) then X30 = 1 : X32 = 0 : T3 = 0 157 if X33 = 1 and (S3 = 1 and mode31 = 1) then X30 = 1 : X33 = 0 200 ' Gestion des sorties et des temporisations 210 if X11 = 1 or X12 = 1 then out 9,1 else out 9,0 220 if X10 = 1 then tempo12 = 0 : tempo13 = 0 230 if X12 = 1 then tempo11 = 0 240 if X21 = 1 or X22 = 1 then out 10,1 else out 10,0 250 if X20 = 1 then tempo22 = 0 : tempo23 = 0 260 if X22 = 1 then tempo21 = 0 270 if X31 = 1 or X32 = 1 then out 11,1 else out 11,0 280 if X30 = 1 then tempo32 = 0 : tempo33 = 0 290 if X32 = 1 then tempo31 = 0 300 ' Gestion des temporisations 310 gosub 4000 320 S0 = keyin (0,25) 330 if S0 = 0 then goto 60 990 goto 110 1000 ' SP Affichage message d'accueil 1010 cls : locate 0,0 : print " Centrale" 1020 locate 0,1 : print " Domotique" 1030 locate 0,2 : print "(c) ELEKTOR 2008" : csroff 1040 locate 0,3 : print "----------------" 1050 return 2000 ' SP Configuration de la voie 1 2010 cls : mode11 = 0 : mode12 = 0 : mode13 = 0 : locate 0,0 : print "Config. voie 1 :" : locate 0,1 : print "----------------" 2020 locate 0,2 : print "- TELERUPTEUR ? " 2030 locate 0,3 : print "Validation " : sound 7,159,2 2040 for F = 1 to 100 2045 S0 = keyin (0,25): delay 20 2050 if S0 = 0 then mode11 = 1 : mode12 = 0 : mode13 = 0 : INC1 = 0 : goto 2200 2055 next F 2060 locate 0,2 : print "- MINUTERIE ? " 2070 locate 0,3 : print "Validation " : sound 7,159,2 2080 for F = 1 to 100 2090 S0 = keyin (0,25): delay 20 2100 if S0 = 0 then mode11 = 0 : mode12 = 1 : mode13 = 0 : INC1 = 1 : goto 2200 2110 next F 2120 locate 0,2 : print "- SIMULATEUR ? " 2130 locate 0,3 : print "Validation " : sound 7,159,2 2140 for F = 1 to 100 2150 S0 = keyin (0,25): delay 20 2160 if S0 = 0 then mode11 = 0 : mode12 = 0 : mode13 = 1 : INC1 = 1 : goto 2200 2170 next F 2200 ' Validation de la configuration 2205 if mode11 = 0 and mode12 = 0 and mode13 = 0 then mode11 = 1 : INC1 = 0 : mode12 = 0 : mode13 = 0 2206 cls : locate 0,0 : print "Validation : " : locate 0,1 : print "----------------" 2210 if mode11 = 1 then locate 0,2 : print "1 : TELERUPTEUR " 2220 if mode12 = 1 then locate 0,2 : print "1 : MINUTERIE " 2230 if mode13 = 1 then locate 0,2 : print "1 : SIMULATEUR " 2235 sound 7,159,16 2240 locate 0,3 : print " " : delay 1000 : sound 7,159,2 2251 locate 0,3 : print "Accepter : " 2252 for F = 1 to 200 2253 S0 = keyin (0,25) 2254 if S0 = 0 then sound 7,159,16 : goto 2300 2255 next F 2290 goto 2010 2300 return 2400 ' SP Configuration de la voie 2 2410 cls : mode21 = 0 : mode22 = 0 : mode23 = 0 : locate 0,0 : print "Config. voie 2 :" : locate 0,1 : print "----------------" 2420 locate 0,2 : print "- TELERUPTEUR ? " 2430 locate 0,3 : print "Validation " : sound 7,159,2 2440 for F = 1 to 100 2445 S0 = keyin (0,25): delay 20 2450 if S0 = 0 then mode21 = 1 : mode22 = 0 : mode23 = 0 : INC2 = 0 : goto 2600 2455 next F 2460 locate 0,2 : print "- MINUTERIE ? " 2470 locate 0,3 : print "Validation " : sound 7,159,2 2480 for F = 1 to 100 2490 S0 = keyin (0,25): delay 20 2500 if S0 = 0 then mode21 = 0 : mode22 = 1 : mode23 = 0 : INC2 = 1 : goto 2600 2510 next F 2520 locate 0,2 : print "- SIMULATEUR ? " 2530 locate 0,3 : print "Validation " : sound 7,159,2 2540 for F = 1 to 100 2550 S0 = keyin (0,25): delay 20 2560 if S0 = 0 then mode21 = 0 : mode22 = 0 : mode23 = 1 : INC2 = 1 : goto 2600 2570 next F 2600 ' Validation de la configuration 2605 if mode21 = 0 and mode22 = 0 and mode23 = 0 then mode21 = 1 : INC2 = 0 : mode22 = 0 : mode23 = 0 2606 cls : locate 0,0 : print "Validation : " : locate 0,1 : print "----------------" 2610 if mode21 = 1 then locate 0,2 : print "2 : TELERUPTEUR " 2620 if mode22 = 1 then locate 0,2 : print "2 : MINUTERIE " 2630 if mode23 = 1 then locate 0,2 : print "2 : SIMULATEUR " 2635 sound 7,159,16 2640 locate 0,3 : print " " : delay 1000 : sound 7,159,2 2651 locate 0,3 : print "Accepter : " 2652 for F = 1 to 200 2653 S0 = keyin (0,25) 2654 if S0 = 0 then sound 7,159,16 : goto 2695 2655 next F 2690 goto 2410 2695 return 2700 ' SP Configuration de la voie 3 2710 cls : mode31 = 0 : mode32 = 0 : mode33 = 0 : locate 0,0 : print "Config. voie 3 :" : locate 0,1 : print "----------------" 2720 locate 0,2 : print "- TELERUPTEUR ? " 2730 locate 0,3 : print "Validation " : sound 7,159,2 2740 for F = 1 to 100 2745 S0 = keyin (0,25): delay 20 2750 if S0 = 0 then mode31 = 1 : mode32 = 0 : mode33 = 0 : INC3 = 0 : goto 2900 2755 next F 2760 locate 0,2 : print "- MINUTERIE ? " 2770 locate 0,3 : print "Validation " : sound 7,159,2 2780 for F = 1 to 100 2790 S0 = keyin (0,25): delay 20 2800 if S0 = 0 then mode31 = 0 : mode32 = 1 : mode33 = 0 : INC3 = 1 : goto 2900 2810 next F 2820 locate 0,2 : print "- SIMULATEUR ? " 2830 locate 0,3 : print "Validation " : sound 7,159,2 2840 for F = 1 to 100 2850 S0 = keyin (0,25): delay 20 2860 if S0 = 0 then mode31 = 0 : mode32 = 0 : mode33 = 1 : INC3 = 1 : goto 2900 2870 next F 2900 ' Validation de la configuration 2905 if mode31 = 0 and mode32 = 0 and mode33 = 0 then mode31 = 1 : INC3 = 0 : mode32 = 0 : mode33 = 0 2906 cls : locate 0,0 : print "Validation : " : locate 0,1 : print "----------------" 2910 if mode31 = 1 then locate 0,2 : print "3 : TELERUPTEUR " 2920 if mode32 = 1 then locate 0,2 : print "3 : MINUTERIE " 2930 if mode33 = 1 then locate 0,2 : print "3 : SIMULATEUR " 2935 sound 7,159,16 2940 locate 0,3 : print " " : delay 1000 : sound 7,159,2 2951 locate 0,3 : print "Accepter : " 2952 for F = 1 to 200 2953 S0 = keyin (0,25) 2954 if S0 = 0 then sound 7,159,16 : goto 2995 2955 next F 2990 goto 2710 2995 return 3000 ' SP --- Lecture des entrées --- 3010 S1 = keyin (1,20) : S2 = keyin (2,20) : S3 = keyin (3,20) 3020 return 4000 ' Gestion des temporisations 4010 if X10 = 1 then tempo11 = tempo11 + INC1 4020 if X12 = 1 and mode12 = 1 then tempo12 = tempo12 + INC1 4030 if X12 = 1 and mode13 = 1 then tempo13 = tempo13 + INC1 4050 if tempo11 = 100 then T1 = 1 4060 if tempo12 = 200 then T1 = 1 4070 if tempo13 = 300 then T1 = 1 4080 if X20 = 1 then tempo21 = tempo21 + INC2 4090 if X22 = 1 and mode22 = 1 then tempo22 = tempo22 + INC2 4100 if X22 = 1 and mode23 = 1 then tempo23 = tempo23 + INC2 4110 if tempo21 = 100 then T2 = 1 4120 if tempo22 = 200 then T2 = 1 4130 if tempo23 = 300 then T2 = 1 4140 if X30 = 1 then tempo31 = tempo31 + INC3 4150 if X32 = 1 and mode32 = 1 then tempo32 = tempo32 + INC3 4160 if X32 = 1 and mode33 = 1 then tempo33 = tempo33 + INC3 4170 if tempo31 = 100 then T3 = 1 4180 if tempo32 = 200 then T3 = 1 4190 if tempo33 = 300 then T3 = 1 4200 return