Update vom 10.05.15
Dependencies: FreescaleIAP MODSERIAL mbed monitor timer0
Fork of 18_PT1000 by
main.cpp@20:b85406f52de3, 2015-05-11 (annotated)
- Committer:
- rs27
- Date:
- Mon May 11 17:32:06 2015 +0000
- Revision:
- 20:b85406f52de3
- Parent:
- 19:f3c41bbc809a
- Child:
- 21:6f524a6caabe
Stand 11.05.15
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rs27 | 19:f3c41bbc809a | 1 | // Version 1.0 erstellt am 25.04.2015 |
rs27 | 19:f3c41bbc809a | 2 | // 01.05.15 den Eingäng 4 auf 2 verlegt |
rs27 | 19:f3c41bbc809a | 3 | // den Eingang 5 auf 1 verlegt |
rs27 | 0:e248310dfcdb | 4 | |
rs27 | 0:e248310dfcdb | 5 | #include "mbed.h" |
rs27 | 19:f3c41bbc809a | 6 | #include "main.h" |
rs27 | 0:e248310dfcdb | 7 | #include "timer0.h" |
rs27 | 0:e248310dfcdb | 8 | #include "monitor.h" |
Sven3010 | 18:939d3df56218 | 9 | #include "MODSERIAL.h" |
rs27 | 0:e248310dfcdb | 10 | |
rs27 | 19:f3c41bbc809a | 11 | // timer 2 => optischer Alarm Periode = 500 entspricht Blinkfrequnz von 1 Selunde |
rs27 | 19:f3c41bbc809a | 12 | #define OA_PERIODE 500 |
rs27 | 19:f3c41bbc809a | 13 | // timer 3 => Minimale Zeit für den akustischen Alarm in ms >> soll 10000 entspricht 10 Sekunden |
rs27 | 19:f3c41bbc809a | 14 | #define AA_NIN 10000 |
rs27 | 19:f3c41bbc809a | 15 | // timer 4 => Verzögerung für des Entriegeln des Tasters. In dieser Zeit wird dann kein neuer |
rs27 | 19:f3c41bbc809a | 16 | // akustischer Alarm ausgelöst |
rs27 | 19:f3c41bbc809a | 17 | #define AA_DELAY 10000 |
rs27 | 0:e248310dfcdb | 18 | |
rs27 | 19:f3c41bbc809a | 19 | #define NEED_CONSOLE_OUTPUT 1 // Set this if you need debug messages on the console |
rs27 | 19:f3c41bbc809a | 20 | // mit Debug wird die Programmgröße von 32,8k um ca. 300 Byte vergrößert |
rs27 | 19:f3c41bbc809a | 21 | // dies ist nicht bedeutend, aber auch die Ausführungszeit der Ausgabebefehle |
rs27 | 19:f3c41bbc809a | 22 | // benötigt CPU Zeit |
rs27 | 19:f3c41bbc809a | 23 | #if NEED_CONSOLE_OUTPUT |
rs27 | 19:f3c41bbc809a | 24 | #define DEBUG(...) { pc.printf(__VA_ARGS__); } |
rs27 | 19:f3c41bbc809a | 25 | #else |
rs27 | 19:f3c41bbc809a | 26 | #define DEBUG(...) // nothing |
rs27 | 19:f3c41bbc809a | 27 | #endif // #if NEED_CONSOLE_OUTPUT |
Sven3010 | 18:939d3df56218 | 28 | |
rs27 | 6:f53dd76c8806 | 29 | //------------------------------------------------------------------------------ |
rs27 | 6:f53dd76c8806 | 30 | // Anlegen von Klassen |
Sven3010 | 4:46365f765d30 | 31 | |
rs27 | 2:f48d2eb0cc55 | 32 | timer0 down_timer; // Zeitsteuerung |
rs27 | 19:f3c41bbc809a | 33 | MODSERIAL pc(USBTX, USBRX); // tx, rx |
rs27 | 6:f53dd76c8806 | 34 | |
rs27 | 19:f3c41bbc809a | 35 | monitor mon; |
rs27 | 19:f3c41bbc809a | 36 | |
rs27 | 10:84387eed15b5 | 37 | Timer t; // Zeitmessung für Entprellen |
rs27 | 0:e248310dfcdb | 38 | |
rs27 | 6:f53dd76c8806 | 39 | //------------------------------------------------------------------------------ |
rs27 | 6:f53dd76c8806 | 40 | // Zuordnung von Eingängen und Ausgängen |
rs27 | 6:f53dd76c8806 | 41 | |
rs27 | 19:f3c41bbc809a | 42 | DigitalOut LED(PTE30); |
rs27 | 0:e248310dfcdb | 43 | |
rs27 | 19:f3c41bbc809a | 44 | DigitalOut OUT1(PTC6); // nicht belegt |
rs27 | 19:f3c41bbc809a | 45 | DigitalOut OUT2(PTC5); // LED Rot |
rs27 | 19:f3c41bbc809a | 46 | DigitalOut OUT3(PTC4); // LED Grün |
rs27 | 19:f3c41bbc809a | 47 | DigitalOut OUT4(PTC3); // LED Gelb |
rs27 | 19:f3c41bbc809a | 48 | DigitalOut OUT5(PTC2); // Summer |
rs27 | 19:f3c41bbc809a | 49 | DigitalOut OUT6(PTC1); // Relais |
rs27 | 0:e248310dfcdb | 50 | |
rs27 | 19:f3c41bbc809a | 51 | DigitalIn IN1(PTC7); // Notaus, schaltet gegen 24V => 24V oder 1 ist der Ruhezustand |
rs27 | 19:f3c41bbc809a | 52 | DigitalIn IN2(PTD4); // Sabotageschalter, schaltet gegen 24V => 24V oder 1 ist Ruhezustand |
rs27 | 19:f3c41bbc809a | 53 | DigitalIn IN3(PTD5); // KABA Türöffner Signal => 24V oder 1 ist Ruheezustand |
rs27 | 19:f3c41bbc809a | 54 | DigitalIn IN4(PTD6); // nicht belegt |
rs27 | 19:f3c41bbc809a | 55 | DigitalIn IN5(PTD7); // nicht belegt |
rs27 | 0:e248310dfcdb | 56 | |
rs27 | 19:f3c41bbc809a | 57 | DigitalInOut rst(PTA4); //Connect this to the reset pin |
rs27 | 6:f53dd76c8806 | 58 | |
rs27 | 6:f53dd76c8806 | 59 | //------------------------------------------------------------------------------ |
rs27 | 6:f53dd76c8806 | 60 | // Globale Variablen |
rs27 | 6:f53dd76c8806 | 61 | |
rs27 | 19:f3c41bbc809a | 62 | bool in; |
rs27 | 2:f48d2eb0cc55 | 63 | |
rs27 | 19:f3c41bbc809a | 64 | struct di_struct in1; // Eingang 1 |
rs27 | 19:f3c41bbc809a | 65 | struct di_struct in2; // Eingang 2 |
rs27 | 19:f3c41bbc809a | 66 | struct di_struct in3; // Eingang 3 |
rs27 | 0:e248310dfcdb | 67 | |
rs27 | 2:f48d2eb0cc55 | 68 | //------------------------------------------------------------------------------ |
rs27 | 2:f48d2eb0cc55 | 69 | // |
rs27 | 0:e248310dfcdb | 70 | |
rs27 | 19:f3c41bbc809a | 71 | int main() |
rs27 | 0:e248310dfcdb | 72 | { |
rs27 | 19:f3c41bbc809a | 73 | rst.input(); // SW watchdog ist derzeit nicht erforderlich |
Sven3010 | 3:72a65324d50d | 74 | |
rs27 | 2:f48d2eb0cc55 | 75 | //------------------------------------------------------------------------------ |
rs27 | 2:f48d2eb0cc55 | 76 | // RS232 Schnittstellt welche auf den CMSIS-DAP (USB Port) weitergeleitet wird |
rs27 | 2:f48d2eb0cc55 | 77 | // |
rs27 | 19:f3c41bbc809a | 78 | pc.baud(115200); |
rs27 | 19:f3c41bbc809a | 79 | pc.printf("\n N1380 V1.0 was compiled on %s %s \n", __DATE__,__TIME__); |
rs27 | 0:e248310dfcdb | 80 | |
rs27 | 19:f3c41bbc809a | 81 | |
rs27 | 19:f3c41bbc809a | 82 | //-------------------------------------------------------------------- |
rs27 | 19:f3c41bbc809a | 83 | // Anfangswerte setzen |
rs27 | 6:f53dd76c8806 | 84 | |
rs27 | 19:f3c41bbc809a | 85 | in1.old = 1; // 1 im Ruhezustand |
rs27 | 19:f3c41bbc809a | 86 | in1.aktiv = 0; |
rs27 | 19:f3c41bbc809a | 87 | in1.filter = 0; |
rs27 | 19:f3c41bbc809a | 88 | in1.optischer_alarm = 0; |
rs27 | 19:f3c41bbc809a | 89 | in1.summer = 0; |
rs27 | 0:e248310dfcdb | 90 | |
rs27 | 19:f3c41bbc809a | 91 | in2.old = 1; // 1 im Ruhezustand |
rs27 | 19:f3c41bbc809a | 92 | in2.aktiv = 0; |
rs27 | 19:f3c41bbc809a | 93 | in2.filter = 0; |
rs27 | 19:f3c41bbc809a | 94 | in2.optischer_alarm = 0; |
rs27 | 19:f3c41bbc809a | 95 | in2.summer = 0; |
rs27 | 19:f3c41bbc809a | 96 | |
rs27 | 19:f3c41bbc809a | 97 | in3.old = 1; // 1 im Ruhezustand |
rs27 | 19:f3c41bbc809a | 98 | in3.aktiv = 0; |
rs27 | 19:f3c41bbc809a | 99 | in3.filter = 0; |
rs27 | 2:f48d2eb0cc55 | 100 | |
rs27 | 2:f48d2eb0cc55 | 101 | //-------------------------------------------------------------------- |
rs27 | 19:f3c41bbc809a | 102 | // Softwaretimer für die Zeitsteuerung anlegen |
rs27 | 6:f53dd76c8806 | 103 | |
rs27 | 19:f3c41bbc809a | 104 | down_timer.SetCountdownTimer(0,1,500); // 1 ms Timer * 500 => ergibt 500 ms |
rs27 | 20:b85406f52de3 | 105 | down_timer.SetCountdownTimer(1,1,100); // 1 ms Timer * 10 => ergibt 10 ms, 100 ms für Einschaltverzögerung |
rs27 | 19:f3c41bbc809a | 106 | down_timer.SetCountdownTimer(2,1,0); // 1 ms Timer => reserviert für optischen Alarm |
rs27 | 19:f3c41bbc809a | 107 | down_timer.SetCountdownTimer(3,1,0); // 1 ms Timer => reserviert für akustischen Alarm |
rs27 | 19:f3c41bbc809a | 108 | down_timer.SetCountdownTimer(4,1,0); // 1 ms Timer => reserviert für nach Entriegelung |
rs27 | 2:f48d2eb0cc55 | 109 | |
rs27 | 0:e248310dfcdb | 110 | //-------------------------------------------------------------------- |
rs27 | 0:e248310dfcdb | 111 | // Schleife fuer die Datenerfassung |
rs27 | 19:f3c41bbc809a | 112 | |
rs27 | 0:e248310dfcdb | 113 | while(1) |
rs27 | 0:e248310dfcdb | 114 | { |
rs27 | 19:f3c41bbc809a | 115 | //------------------------------------------- |
rs27 | 19:f3c41bbc809a | 116 | // Prüfen ob Zeichen eingegeben wurden |
rs27 | 19:f3c41bbc809a | 117 | // wird in der aktiven Version ausgeblendet, ist nur zum Testen |
rs27 | 19:f3c41bbc809a | 118 | |
rs27 | 19:f3c41bbc809a | 119 | mon.get_line(); |
rs27 | 19:f3c41bbc809a | 120 | |
rs27 | 19:f3c41bbc809a | 121 | //------------------------------------------- |
rs27 | 19:f3c41bbc809a | 122 | // timer 0 steuert die LED auf dem Board mit der Takrate 0,5 Sekunden |
rs27 | 19:f3c41bbc809a | 123 | |
rs27 | 19:f3c41bbc809a | 124 | if (down_timer.GetTimerStatus(0) == 0) { |
rs27 | 19:f3c41bbc809a | 125 | down_timer.SetCountdownTimer(0,1,500); |
rs27 | 19:f3c41bbc809a | 126 | LED = !LED; |
rs27 | 19:f3c41bbc809a | 127 | |
rs27 | 19:f3c41bbc809a | 128 | } |
rs27 | 19:f3c41bbc809a | 129 | |
rs27 | 19:f3c41bbc809a | 130 | //------------------------------------------- |
rs27 | 19:f3c41bbc809a | 131 | // Eingänge abfragen und Aktionen ableiten |
rs27 | 19:f3c41bbc809a | 132 | // down |
rs27 | 19:f3c41bbc809a | 133 | |
rs27 | 19:f3c41bbc809a | 134 | if (down_timer.GetTimerStatus(1) == 0) |
rs27 | 19:f3c41bbc809a | 135 | { |
rs27 | 19:f3c41bbc809a | 136 | //down_timer 1 mit 10 ms gesetzt |
rs27 | 19:f3c41bbc809a | 137 | down_timer.SetCountdownTimer(1,1,10); |
Sven3010 | 18:939d3df56218 | 138 | |
rs27 | 19:f3c41bbc809a | 139 | //------------------------------------------------ |
rs27 | 19:f3c41bbc809a | 140 | // IN1 Nottaster auswerten, null im Ruhezustand |
rs27 | 19:f3c41bbc809a | 141 | // wird mit der negativen Flanke aktiviert |
rs27 | 19:f3c41bbc809a | 142 | // das Signal muss mindestens 10ms anliegen, damit es akzeptiert wird |
rs27 | 6:f53dd76c8806 | 143 | |
rs27 | 19:f3c41bbc809a | 144 | in = IN1; |
rs27 | 6:f53dd76c8806 | 145 | |
rs27 | 6:f53dd76c8806 | 146 | |
rs27 | 19:f3c41bbc809a | 147 | if(!in && in1.old) // Öffner im Ruhezustand 24 V >> durch Drücken wird eine neg. Flanke erzeugt |
rs27 | 16:3a4350104b68 | 148 | { |
rs27 | 19:f3c41bbc809a | 149 | in1.old = 0; |
rs27 | 19:f3c41bbc809a | 150 | in1.aktiv = 1; // Taster ist betätigt |
rs27 | 19:f3c41bbc809a | 151 | in1.optischer_alarm = 1; |
rs27 | 19:f3c41bbc809a | 152 | in1.summer = 1; |
rs27 | 19:f3c41bbc809a | 153 | down_timer.SetCountdownTimer(3,1,AA_NIN); // Zeit für Softtimer auf 10 Sekunden setzen |
rs27 | 19:f3c41bbc809a | 154 | DEBUG("\n negative Flanke IN1 \n"); |
rs27 | 19:f3c41bbc809a | 155 | } |
rs27 | 19:f3c41bbc809a | 156 | |
rs27 | 19:f3c41bbc809a | 157 | if (in && !in1.old) { // Öffner im Ruhenzustand 24 V >> durch Rückstellen enteht eine pos. Flanke |
rs27 | 19:f3c41bbc809a | 158 | in1.old = 1; |
rs27 | 19:f3c41bbc809a | 159 | in1.aktiv = 0; // Taster ist zurückgesetzt |
Sven3010 | 4:46365f765d30 | 160 | |
rs27 | 19:f3c41bbc809a | 161 | in1.summer = 0; |
rs27 | 19:f3c41bbc809a | 162 | down_timer.SetCountdownTimer(4,1,AA_DELAY); // Zeit für Entriegelung, Haube innerhalb von 10 Sekunden schließen |
rs27 | 19:f3c41bbc809a | 163 | DEBUG("\n positve Flanke IN1 \n"); |
rs27 | 6:f53dd76c8806 | 164 | } |
rs27 | 6:f53dd76c8806 | 165 | |
rs27 | 19:f3c41bbc809a | 166 | // optischer Alarm ausschalten, wenn IN3 wieder 0 bekommt ==> Quittierung |
rs27 | 19:f3c41bbc809a | 167 | |
rs27 | 20:b85406f52de3 | 168 | if (in1.optischer_alarm && in3.aktiv && !in1.aktiv) |
rs27 | 16:3a4350104b68 | 169 | { |
rs27 | 19:f3c41bbc809a | 170 | in1.optischer_alarm = 0; |
rs27 | 19:f3c41bbc809a | 171 | DEBUG("\n IN1 mit IN3 quittiert \n"); |
rs27 | 12:d5a745de5380 | 172 | } |
rs27 | 12:d5a745de5380 | 173 | |
rs27 | 19:f3c41bbc809a | 174 | |
rs27 | 19:f3c41bbc809a | 175 | //------------------------------------------------ |
rs27 | 19:f3c41bbc809a | 176 | // IN2 Sabotageschalter, 24V ist Ruhezustand |
rs27 | 19:f3c41bbc809a | 177 | // wird mit der negativen Flanke aktiviert |
rs27 | 19:f3c41bbc809a | 178 | // das Signal muss mindestens 10ms anliegen, damit es akzeptiert wird |
Sven3010 | 18:939d3df56218 | 179 | |
rs27 | 19:f3c41bbc809a | 180 | in = IN2; |
Sven3010 | 18:939d3df56218 | 181 | |
Sven3010 | 18:939d3df56218 | 182 | |
rs27 | 19:f3c41bbc809a | 183 | if(!in && in2.old) // Eingang neg. Flanke |
rs27 | 19:f3c41bbc809a | 184 | { |
rs27 | 19:f3c41bbc809a | 185 | in2.old = 0; // 0 im aktivierten Modus |
rs27 | 19:f3c41bbc809a | 186 | in2.aktiv = 1; // Eingang ist aktiv |
rs27 | 20:b85406f52de3 | 187 | //in2.optischer_alarm = 1; |
rs27 | 20:b85406f52de3 | 188 | in2.summer = 1; // am 11.05.15 entfernt, da Summer weiter untern aktiviert wird |
rs27 | 20:b85406f52de3 | 189 | //down_timer.SetCountdownTimer(3,1,AA_NIN); // Zeit für Softtimer auf 10 Sekunden setzen |
rs27 | 19:f3c41bbc809a | 190 | DEBUG("\n negative Flanke IN2 \n"); |
Sven3010 | 18:939d3df56218 | 191 | } |
rs27 | 19:f3c41bbc809a | 192 | |
rs27 | 19:f3c41bbc809a | 193 | if (in && !in2.old) // Eingang mit pos. Flanke |
rs27 | 19:f3c41bbc809a | 194 | { |
rs27 | 19:f3c41bbc809a | 195 | in2.old = 1; // 1 im Ruhezustand |
rs27 | 19:f3c41bbc809a | 196 | in2.aktiv = 0; // Eingang ist inaktiv |
rs27 | 19:f3c41bbc809a | 197 | in2.summer = 0; |
rs27 | 19:f3c41bbc809a | 198 | DEBUG("\n positve Flanke IN2 \n"); |
Sven3010 | 18:939d3df56218 | 199 | } |
rs27 | 20:b85406f52de3 | 200 | /* |
rs27 | 19:f3c41bbc809a | 201 | if (in2.aktiv && !in2.summer && !in1.summer && (down_timer.GetTimerStatus(4) == 0)) |
Sven3010 | 18:939d3df56218 | 202 | { |
rs27 | 19:f3c41bbc809a | 203 | in2.summer = 1; |
rs27 | 19:f3c41bbc809a | 204 | down_timer.SetCountdownTimer(3,1,AA_NIN); // Zeit für Softtimer auf 10 Sekunden setzen ( zum Testen auf 2 Sek. gesetzt ) |
rs27 | 19:f3c41bbc809a | 205 | DEBUG("\n IN2 Summer aktiviert \n"); |
Sven3010 | 18:939d3df56218 | 206 | } |
Sven3010 | 18:939d3df56218 | 207 | |
rs27 | 19:f3c41bbc809a | 208 | // nur zurückschalten, wenn IN3 wieder 1 ==> Quittierung |
rs27 | 19:f3c41bbc809a | 209 | |
rs27 | 19:f3c41bbc809a | 210 | if (in2.optischer_alarm && in3.aktiv) { |
rs27 | 19:f3c41bbc809a | 211 | in2.optischer_alarm = 0; |
rs27 | 19:f3c41bbc809a | 212 | DEBUG("\n IN2 mit IN3 quittiert \n"); |
rs27 | 19:f3c41bbc809a | 213 | } |
rs27 | 20:b85406f52de3 | 214 | */ |
rs27 | 19:f3c41bbc809a | 215 | //------------------------------------------------ |
rs27 | 19:f3c41bbc809a | 216 | // IN3 Signalstation, Öffner => 1 ist Ruheezustand |
rs27 | 19:f3c41bbc809a | 217 | |
rs27 | 19:f3c41bbc809a | 218 | in = IN3; |
rs27 | 19:f3c41bbc809a | 219 | |
rs27 | 19:f3c41bbc809a | 220 | if(in && !in3.old) // Eingang pos. Flanke |
rs27 | 19:f3c41bbc809a | 221 | { |
rs27 | 19:f3c41bbc809a | 222 | in3.old = 1; |
rs27 | 19:f3c41bbc809a | 223 | in3.aktiv = 0; // Eingang ist Ruhezustand |
Sven3010 | 18:939d3df56218 | 224 | |
Sven3010 | 18:939d3df56218 | 225 | } |
rs27 | 19:f3c41bbc809a | 226 | |
rs27 | 19:f3c41bbc809a | 227 | if (!in && in3.old) // Eingang mit neg Flanke |
rs27 | 19:f3c41bbc809a | 228 | { |
rs27 | 19:f3c41bbc809a | 229 | in3.old = 0; |
rs27 | 19:f3c41bbc809a | 230 | in3.aktiv = 1; // Eingang ist aktiv |
rs27 | 19:f3c41bbc809a | 231 | } |
rs27 | 19:f3c41bbc809a | 232 | |
rs27 | 19:f3c41bbc809a | 233 | |
rs27 | 19:f3c41bbc809a | 234 | //--------------------------------------------------------------------------------------------------------------------------------------- |
rs27 | 19:f3c41bbc809a | 235 | // Die Eingänge sind nun gelesen, jetzt kommt das Steuern der Ausgaänge |
rs27 | 19:f3c41bbc809a | 236 | // |
Sven3010 | 18:939d3df56218 | 237 | |
rs27 | 19:f3c41bbc809a | 238 | //------------------------------------------------ |
rs27 | 19:f3c41bbc809a | 239 | // Rot/Grüne LED (verriegelt/entriegelt): |
rs27 | 19:f3c41bbc809a | 240 | // rot Tor ist verriegelt |
rs27 | 19:f3c41bbc809a | 241 | // grün Tor ist entriegelt |
rs27 | 19:f3c41bbc809a | 242 | |
rs27 | 19:f3c41bbc809a | 243 | // 2. IN3 auf 0 = OUT2 aus und OUT3 ein Rot aus / Grün an (entriegelt) |
rs27 | 19:f3c41bbc809a | 244 | // 3. IN1 auf 1 = OUT2 aus und OUT3 ein Rot aus / Grün an (entriegelt) |
rs27 | 19:f3c41bbc809a | 245 | |
rs27 | 19:f3c41bbc809a | 246 | if (in3.aktiv || in1.aktiv) { |
rs27 | 19:f3c41bbc809a | 247 | OUT2 = LED_AUS; |
rs27 | 19:f3c41bbc809a | 248 | OUT3 = LED_EIN; |
rs27 | 19:f3c41bbc809a | 249 | } |
rs27 | 20:b85406f52de3 | 250 | else |
rs27 | 20:b85406f52de3 | 251 | // 1. IN3 auf 1 = OUT2 ein und OUT3 aus Rot an / Grün aus (verriegelt) |
rs27 | 20:b85406f52de3 | 252 | { |
rs27 | 20:b85406f52de3 | 253 | OUT2 = LED_EIN; |
rs27 | 20:b85406f52de3 | 254 | OUT3 = LED_AUS; |
rs27 | 20:b85406f52de3 | 255 | } |
rs27 | 19:f3c41bbc809a | 256 | |
rs27 | 19:f3c41bbc809a | 257 | //------------------------------------------------ |
rs27 | 19:f3c41bbc809a | 258 | // Gelbe LED (optischer Alarm): |
rs27 | 19:f3c41bbc809a | 259 | |
rs27 | 20:b85406f52de3 | 260 | if (in1.optischer_alarm) // sobald der optische Alarm aus Eingang 1 akiviert wurde, diesen in Blinkmode schalten |
rs27 | 19:f3c41bbc809a | 261 | { |
rs27 | 19:f3c41bbc809a | 262 | if (down_timer.GetTimerStatus(2) == 0) |
rs27 | 19:f3c41bbc809a | 263 | { |
rs27 | 19:f3c41bbc809a | 264 | down_timer.SetCountdownTimer(2,1,OA_PERIODE); // Zeit für Softtimer auf eine Sekunde setzen |
rs27 | 19:f3c41bbc809a | 265 | OUT4 = !OUT4; |
rs27 | 19:f3c41bbc809a | 266 | } |
rs27 | 19:f3c41bbc809a | 267 | } |
rs27 | 19:f3c41bbc809a | 268 | else |
rs27 | 19:f3c41bbc809a | 269 | { |
rs27 | 19:f3c41bbc809a | 270 | OUT4 = LED_AUS; |
rs27 | 19:f3c41bbc809a | 271 | } |
rs27 | 19:f3c41bbc809a | 272 | |
rs27 | 19:f3c41bbc809a | 273 | //------------------------------------------------ |
rs27 | 19:f3c41bbc809a | 274 | // Summer (OUT5 +24V) |
rs27 | 19:f3c41bbc809a | 275 | |
rs27 | 20:b85406f52de3 | 276 | |
rs27 | 19:f3c41bbc809a | 277 | if (in1.summer || in2.summer || (down_timer.GetTimerStatus(3) != 0)) // sobald der Eingang 1 oder Eingang 2 akiviert ist oder der Timer |
rs27 | 19:f3c41bbc809a | 278 | { // noch aktiv ist, den Summer aktivieren |
rs27 | 20:b85406f52de3 | 279 | DEBUG("\n Summer 1 = %d Summer 2 = %d \n",(uint8_t)in1.summer,(uint8_t)in2.summer); |
rs27 | 20:b85406f52de3 | 280 | OUT5 = 1; |
rs27 | 19:f3c41bbc809a | 281 | } |
rs27 | 19:f3c41bbc809a | 282 | else |
rs27 | 19:f3c41bbc809a | 283 | { |
rs27 | 19:f3c41bbc809a | 284 | OUT5 = 0; |
rs27 | 19:f3c41bbc809a | 285 | } |
rs27 | 19:f3c41bbc809a | 286 | |
rs27 | 19:f3c41bbc809a | 287 | //------------------------------------------------ |
rs27 | 19:f3c41bbc809a | 288 | // Relais K1: |
rs27 | 19:f3c41bbc809a | 289 | // Der Kontakt des Nottasters wird weitergegeben |
rs27 | 19:f3c41bbc809a | 290 | |
rs27 | 19:f3c41bbc809a | 291 | if (in1.aktiv) { // 1. IN1 auf 0 = OUT6 (K1) ein |
rs27 | 20:b85406f52de3 | 292 | OUT6 = 1; |
rs27 | 19:f3c41bbc809a | 293 | } else { // 2. IN1 auf 1 = OUT6 aus |
rs27 | 20:b85406f52de3 | 294 | OUT6 = 0; |
rs27 | 19:f3c41bbc809a | 295 | } |
rs27 | 19:f3c41bbc809a | 296 | |
rs27 | 19:f3c41bbc809a | 297 | } // end if (downtimer ... |
rs27 | 19:f3c41bbc809a | 298 | |
rs27 | 0:e248310dfcdb | 299 | } // end while |
rs27 | 0:e248310dfcdb | 300 | |
rs27 | 19:f3c41bbc809a | 301 | } // end main |
rs27 | 19:f3c41bbc809a | 302 |