5 ' --- Alarme intrusion --- 10 const device = 3B 15 lcdinit : cls : csroff 20 ' --- Déclaration des variables utilisées --- 21 dim X10 as byte : dim X11 as byte : dim X12 as byte 22 dim X20 as byte : dim X21 as byte : dim X22 as byte 23 dim X30 as byte : dim X31 as byte : dim X32 as byte 24 dim X40 as byte : dim X41 as byte : dim X42 as byte : dim X43 as byte : dim X44 as byte : dim X45 as byte 25 dim X50 as byte : dim X51 as byte : dim X52 as byte : dim X53 as byte : dim X54 as byte : dim X55 as byte : dim X56 as byte : dim X57 as byte : dim X58 as byte 26 dim TP1 as integer : dim TP2 as integer : dim TP3 as integer : dim TP4 as integer : dim TP5 as integer : dim TP6 as integer : dim TP7 as integer 27 dim B1 as byte : dim B2 as byte : dim B3 as byte : dim B4 as byte 28 dim B1MEM as byte : dim B2MEM as byte : dim B3MEM as byte : dim B4MEM as byte 29 dim UBATT as integer : dim UR4 as integer : dim CH as byte : dim N as byte 30 ' --- Affichage du message d'accueil --- 31 locate 0,0 : print "*** Alarme ***" : locate 0,1 : print "** Intrusion **" : locate 0,2 : print "----------------" : locate 0,3 : print "(c) ELEKTOR 2008" 32 sound 7,159,4 : delay 5000 40 ' --- Affichage du menu principal --- 45 gosub 1000 50 ' --- Gestion des différents grafcets --- 51 ' --- Activation des étapes initiales et initialisation des temporisations --- 52 X10 = 1 : X20 = 1 : X30 = 1 : X40 = 1 : X50 = 1 53 TP1 = 0 : TP2 = 0 : TP3 = 0 : TP4 = 0 : TP5 = 0 : TP6 = 0 : TP7 = 0 60 ' --- Lecture du clavier et des boucles de détection --- 61 gosub 2000 62 gosub 3000 70 ' --- Evolution des étapes des cinq grafcets --- 71 if X10 = 1 and CH = 4 and X20 = 1 and X30 = 1 and X40 = 1 then X11 = 1 : X10 = 0 : CH = 0 72 if X11 = 1 and CH = 9 then X12 = 1 : X11 = 0 : CH = 0 73 if X11 = 1 and CH <> 0 and CH <> 9 then X10 = 1 : X11 = 0 : CH = 0 74 if X12 = 1 and TP1 = 15 then X10 = 1 : X12 = 0 81 if X20 = 1 and CH = 8 and X10 = 1 and X30 = 1 and X40 = 1 then X21 = 1 : X20 = 0 : CH = 0 82 if X21 = 1 and CH = 9 then X22 = 1 : X21 = 0 : CH = 0 83 if X21 = 1 and CH <> 0 and CH <> 9 then X20 = 1 : X21 = 0 : CH = 0 84 if X22 = 1 and TP2 = 25 then X20 = 1 : X22 = 0 91 if X30 = 1 and CH = 12 and X10 = 1 and X20 = 1 and X40 = 1 then X31 = 1 : X30 = 0 : CH = 0 92 if X31 = 1 and CH = 9 then X32 = 1 : X31 = 0 : CH = 0 93 if X31 = 1 and CH <> 0 and CH <> 9 then X30 = 1 : X31 = 0 : CH = 0 94 if X32 = 1 and TP3 = 25 then X30 = 1 : X32 = 0 100 if X40 = 1 and CH = 3 and X10 = 1 and X20 = 1 and X30 =1 then X41 = 1 : X40 = 0 : CH = 0 101 if X41 = 1 and CH = 7 then X42 = 1 : X41 = 0 : CH = 0 102 if X41 = 1 and CH <> 7 and CH <> 0 then X40 = 1 : X41 = 0 : CH = 0 103 if X42 = 1 and CH = 11 then X43 = 1 : X42 = 0 : CH = 0 104 if X42 = 1 and CH <> 11 and CH <> 0 then X40 = 1 : X42 = 0 : CH = 0 105 if X43 = 1 and CH = 2 then X44 = 1 : X43 = 0 : CH = 0 106 if X43 = 1 and CH <> 2 and CH <> 0 then X40 = 1 : X43 = 0 : CH = 0 107 if X44 = 1 and CH = 9 then X45 = 1 : X44 = 0 : CH = 0 108 if X44 = 1 and CH <> 9 and CH <> 0 then X40 = 1 : X44 = 0 : CH = 0 109 if X45 = 1 and TP4 = 1 then X40 = 1 : X45 = 0 : CH = 0 120 if X50 = 1 and X12 = 1 then X51 = 1 : X50 = 0 121 if X51 = 1 and X10 = 1 then X50 = 1 : X51 = 0 122 if X50 = 1 and X22 = 1 then X52 = 1 : X50 = 0 123 if X52 = 1 and X20 = 1 then X50 = 1 : X52 = 0 124 if X50 = 1 and X32 = 1 then X53 = 1 : X50 = 0 125 if X53 = 1 and X30 = 1 then X50 = 1 : X53 = 0 126 if X50 = 1 and X45 = 1 then X54 = 1 : X50 = 0 127 if X54 = 1 and TP5 = 300 then X55 = 1 : X54 = 0 128 if X55 = 1 and B1 = 1 then X56 = 1 : X55 = 0 129 if X55 = 1 and B2 = 1 then X56 = 1 : X55 = 0 130 if X55 = 1 and B3 = 1 then X56 = 1 : X55 = 0 131 if X55 = 1 and B4 = 1 then X56 = 1 : X55 = 0 132 if X55 = 1 and X45 = 1 then X50 = 1 : X55 = 0 133 if X56 = 1 and TP6 = 150 then X57 = 1 : X56 = 0 134 if X56 = 1 and X45 = 1 then X50 = 1 : X56 = 0 135 if X57 = 1 and TP7 = 900 then X58 = 1 : X57 = 0 136 if X57 = 1 and X45 = 1 then X50 = 1 : X57 = 0 137 if X58 = 1 and X45 = 1 then X50 = 1 : X58 = 0 200 ' --- Gestion des temporisations --- 201 if X10 = 1 then TP1 = 0 202 if X20 = 1 then TP2 = 0 203 if X30 = 1 then TP3 = 0 204 if X40 = 1 then TP4 = 0 205 if X50 = 1 then TP5 = 0 : TP6 = 0 : TP7 = 0 210 if X12 = 1 then TP1 = TP1 + 1 : gosub 5000 211 if X22 = 1 then TP2 = TP2 + 1 : gosub 5000 212 if X32 = 1 then TP3 = TP3 + 1 : gosub 5000 213 if X45 = 1 then TP4 = TP4 + 1 : gosub 5000 214 if X54 = 1 then TP5 = TP5 + 1 : gosub 5000 215 if X56 = 1 then TP6 = TP6 + 1 : gosub 5000 216 if X57 = 1 then TP7 = TP7 + 1 : gosub 5000 300 ' --- Gestion des actions associées aux étapes --- 305 if X50 = 1 then gosub 1000 310 if X51 = 1 then gosub 5500 320 if X52 = 1 then gosub 6000 330 if X53 = 1 then gosub 7000 340 if X54 = 1 then gosub 7500 350 if X55 = 1 then gosub 7600 360 if X56 = 1 then gosub 7700 370 if X57 = 1 then gosub 7800 380 if X58 = 1 then gosub 7000 390 goto 60 1000 ' --- SP : Affichage Menu Principal --- 1010 out 6,0 1020 locate 0,0 : print "<1>: Test alarme" 1030 locate 0,1 : print "<2>: Boucles/Bat" 1040 locate 0,2 : print "<3>: Intrusions " 1050 locate 0,3 : print "???? : Marche " 1060 return 2000 ' --- SP : Gestion du clavier --- 2005 CH = 0 2010 CH = padin(1) 2020 if CH <> 0 then sound 7,159,4 2030 return 3000 ' --- Lecture de l'état des boucles de détection --- 3010 B1 = KEYIN(0,25) 3020 B2 = KEYIN(1,25) 3030 B3 = KEYIN(2,25) 3040 B4 = KEYIN(3,25) 3050 return 4000 ' --- Mesure de la tension de la batterie --- 4010 UR4 = ADIN(4) 4020 UBATT = (UR4 / 10) * 158 4030 return 5000 ' --- Boucle unité de temporisation --- 5010 for N = 1 to 8 5020 next N 5030 return 5500 ' --- Test Alarme --- 5505 locate 0,0 : print " " 5510 locate 0,1 : print " Test Alarme " 5515 locate 0,2 : print " en cours... " 5520 locate 0,3 : print " " 5525 out 6,1 5530 return 6000 ' --- Affichage état boucles et tension batterie --- 6010 gosub 3000 6020 locate 0,0 : print "Etat boucles : " 6030 locate 0,1 : print " B1: " : locate 8,1 : print " B2: " 6040 locate 0,2 : print " B3: " : locate 8,2 : print " B4: " 6050 if B1 = 0 then locate 5,1 : print "F" 6060 if B1 = 1 then locate 5,1 : print "O" 6070 if B2 = 0 then locate 13,1 : print "F" 6080 if B2 = 1 then locate 13,1 : print "O" 6090 if B3 = 0 then locate 5,2 : print "F" 6100 if B3 = 1 then locate 5,2 : print "O" 6110 if B4 = 0 then locate 13,2 : print "F" 6120 if B4 = 1 then locate 13,2 : print "O" 6130 gosub 4000 6140 locate 0,3 : print "U bat.= ";dec(UBATT);" mV" 6150 return 7000 ' --- Affichage des intrusions --- 7010 out 6,0 7020 locate 0,0 : print "Intrusions : " 7025 locate 0,1 : print " " 7030 locate 0,2 : print " B1: " : locate 8,2 : print " B2: " 7040 locate 0,3 : print " B3: " : locate 8,3 : print " B4: " 7050 if B1MEM = 0 then locate 5,2 : print "NON" 7060 if B1MEM = 1 then locate 5,2 : print "OUI" 7070 if B2MEM = 0 then locate 13,2 : print "NON" 7080 if B2MEM = 1 then locate 13,2 : print "OUI" 7090 if B3MEM = 0 then locate 5,3 : print "NON" 7100 if B3MEM = 1 then locate 5,3 : print "OUI" 7110 if B4MEM = 0 then locate 13,3 : print "NON" 7120 if B4MEM = 1 then locate 13,3 : print "OUI" 7130 return 7500 ' --- Affichage message de mise en service --- 7505 locate 0,0 : print " " 7510 locate 0,1 : print "Mise en service " 7520 locate 0,2 : print "prise en compte." 7530 locate 0,3 : print " " 7540 return 7600 ' --- Affichage message alarme en service --- 7605 locate 0,0 : print " " 7610 locate 0,1 : print " ALARME " 7620 locate 0,2 : print " EN SERVICE ! " 7625 locate 0,3 : print " " 7630 B1MEM = 0 : B2MEM = 0 : B3MEM = 0 : B4MEM = 0 7635 return 7700 ' --- Mémorisation des intrusions --- 7705 locate 0,0 : print " " 7710 locate 0,1 : print " Intrusion " 7720 locate 0,2 : print " en cours... " 7725 locate 0,3 : print " " 7730 if X56 = 1 and B1 = 1 then B1MEM = 1 7740 if X56 = 1 and B2 = 1 then B2MEM = 1 7750 if X56 = 1 and B3 = 1 then B3MEM = 1 7760 if X56 = 1 and B4 = 1 then B4MEM = 1 7770 return 7800 ' --- Fonctionnement Alarme Sonore --- 7805 locate 0,0 : print " " 7810 locate 0,1 : print " ALARME " 7820 locate 0,2 : print " EFFECTIVE ! " 7825 locate 0,3 : print " " 7830 if X57 = 1 then out 6,1 7840 return