source: trunk/firmware/Core/src/mode_secondaryprotection.c

Last change on this file was 10, checked in by f.jahn, 5 months ago

LED Modul hinzugefügt

File size: 2.4 KB
Line 
1//Secondary Protection Modus
2//Schaltet ab: Wenn LVP und OVP gleichzeitig kommen. --> Kein Auto Reconnect!
3//Schaltet ab: Wenn Fault kommt --> keine automatisches Reconnect!
4
5#include "mode_secondaryprotection.h"
6
7
8#include "stdio.h"
9#include "mode_secondaryprotection.h"
10#include "button.h"
11#include "relais.h"
12#include "main.h"
13#include "leds.h"
14
15  //Prüfe FAULT Eingang
16
17
18void MODE_SECONDARYPROTECTION_Exec(void)
19{
20
21  int faultInput = 0;
22  int lvpAndOvpInput = 0;
23  static int faultMode = 0;
24
25
26  //Prüfe Fehler
27  if (HAL_GPIO_ReadPin(GPIO_INPUT_FAULT_GPIO_Port, GPIO_INPUT_FAULT_Pin) == GPIO_PIN_RESET)       
28  {
29    faultInput = 1;
30
31    if (faultMode == 0)
32    {
33      faultMode = 1;
34      LEDS_RT_Blink_Start(1000, 1000);         
35      printf("FAULT DETECTED!\n");
36    }
37
38    if (BUTTON_GetMode() != BUTTON_OFF)
39    {
40       BUTTON_SetModeOff();
41    }
42
43    if (RELAIS_GetState() == 1)
44    {
45      printf("RESET RELAIS: FAULT DETECTED!\n");
46      RELAIS_ResetPuls();       
47    }     
48  }
49  else
50  {
51    faultInput = 0;
52  } 
53
54  if ((HAL_GPIO_ReadPin(GPIO_INPUT_LVP_GPIO_Port, GPIO_INPUT_LVP_Pin) == GPIO_PIN_SET) &&  (HAL_GPIO_ReadPin(GPIO_INPUT_OVP_GPIO_Port, GPIO_INPUT_OVP_Pin) == GPIO_PIN_SET))
55  {
56    lvpAndOvpInput = 1;
57
58    if (faultMode == 0)
59    {
60      faultMode = 1;
61      LEDS_RT_Blink_Start(500, 1000);       
62      printf("FAULT DETECTED!\n");
63    }
64
65    if (BUTTON_GetMode() != BUTTON_OFF)
66    {
67       BUTTON_SetModeOff();
68    }
69
70    if (RELAIS_GetState() == 1)
71    {
72      printf("RESET RELAIS: SECONDARY PROTECTION (OVP AND LVP = LOW)!\n");
73      RELAIS_ResetPuls();
74    }     
75  }
76  else
77  {
78    lvpAndOvpInput = 0;
79  } 
80
81
82
83  //Prüfen ob ausgeschaltet werden muss
84  if (RELAIS_GetState() == 1)
85  {
86    if (BUTTON_GetMode() == BUTTON_OFF)       
87    {
88      RELAIS_ResetPuls();
89    } 
90  }
91
92
93  //Prüfen ob eingeschaltet werden kann
94  if ((RELAIS_GetState() == 0) && (faultInput == 0) && (lvpAndOvpInput == 0))
95  {
96   
97    if (BUTTON_GetMode() == BUTTON_MANUAL_ON) 
98    {     
99      LEDS_RT_Off(); //Falls im LED im Fehlermode, so können wir diese jetzt wieder ausschalten
100      faultMode = 0;
101      RELAIS_SetPuls();
102     
103    } 
104    else if (BUTTON_GetMode() == BUTTON_AUTO)
105    {
106      LEDS_RT_Off(); //Falls im LED im Fehlermode, so können wir diese jetzt wieder ausschalten
107      faultMode = 0;
108      RELAIS_SetPuls();
109    } 
110  }
111}
Note: See TracBrowser for help on using the repository browser.