Changeset 24 for trunk/firmware_v2/SES/src/mode_lvp_ovp.c
- Timestamp:
- Aug 23, 2025, 3:27:52 PM (4 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/firmware_v2/SES/src/mode_lvp_ovp.c
r17 r24 29 29 #include "leds.h" 30 30 #include "buzzer.h" 31 #include "chip_temperature.h" 31 32 32 33 … … 46 47 { 47 48 int faultInput; 48 int lvpOROvpInput; 49 49 50 50 51 if (HAL_GPIO_ReadPin(GPIO_INPUT_FAULT_GPIO_Port, GPIO_INPUT_FAULT_Pin) == GPIO_PIN_RESET) … … 57 58 } 58 59 59 if ((HAL_GPIO_ReadPin(GPIO_INPUT_LVP_GPIO_Port, GPIO_INPUT_LVP_Pin) == GPIO_PIN_RESET) || (HAL_GPIO_ReadPin(GPIO_INPUT_OVP_GPIO_Port, GPIO_INPUT_OVP_Pin) == GPIO_PIN_RESET)) 60 { 61 lvpOROvpInput = 1; 62 }else { 63 lvpOROvpInput = 0; 64 } 65 66 60 67 61 68 62 … … 75 69 BUZZER_Beep(BUZZER_ON_TIME_CONFIRM); 76 70 LEDS_GN_Blink_Start(LED_GN_ON_TIME_ON_MODE, LED_GN_OFF_TIME); 77 printf(" NEW_STATE: LVP_OVP_ON\n");71 printf("LVP_OVP_SM_Off: NEW_STATE: LVP_OVP_ON\n"); 78 72 smState = LVP_OVP_ON; 79 73 … … 86 80 //LEDS_RT_Blink_Start(LED_RT_ON_TIME_WARN_FAULT_INPUT, LED_GN_OFF_TIME); //Fehler Anzeigen 87 81 LEDS_RT_BlinkCode_Start(BLINK_CODE_ERROR_FAULT_INPUT, LED_RT_ON_TIME_WARN_FAULT_INPUT, LED_RT_OFF_TIME, LED_RT_OFF_TIME *5); //Fehler Anzeigen 88 printf(" NEW_STATE: LVP_OVP_ERROR\n");82 printf("LVP_OVP_SM_Off: NEW_STATE: LVP_OVP_ERROR_FAULT_INPUT\n"); 89 83 smState =LVP_OVP_ERROR; 90 84 } … … 112 106 { 113 107 int faultInput = 0; 114 int lvpOROvpInput = 0;108 static int lvpOROvpInput = 0; 115 109 static int lvpAndOvpInputTimeCounter = 0; 116 110 static int oldtime; … … 125 119 } 126 120 127 if ((HAL_GPIO_ReadPin(GPIO_INPUT_LVP_GPIO_Port, GPIO_INPUT_LVP_Pin) == GPIO_PIN_ RESET) || (HAL_GPIO_ReadPin(GPIO_INPUT_OVP_GPIO_Port, GPIO_INPUT_OVP_Pin) == GPIO_PIN_RESET))121 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)) 128 122 { 129 123 if (HAL_GetTick() != oldtime) 130 124 { 131 lvpAndOvpInputTimeCounter++; 132 if (lvpAndOvpInputTimeCounter > 30000) 133 { 134 lvpOROvpInput = 0; 135 lvpAndOvpInputTimeCounter=0; 136 } 137 oldtime = HAL_GetTick(); 138 } 139 } 140 141 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)) 142 { 143 if (HAL_GetTick() != oldtime) 144 { 145 lvpAndOvpInputTimeCounter++; 146 if (lvpAndOvpInputTimeCounter > 30000) 125 if (lvpAndOvpInputTimeCounter < 5000)lvpAndOvpInputTimeCounter++; 126 if (lvpAndOvpInputTimeCounter >= 5000) 147 127 { 148 128 lvpOROvpInput = 1; … … 153 133 } 154 134 135 if ((HAL_GPIO_ReadPin(GPIO_INPUT_LVP_GPIO_Port, GPIO_INPUT_LVP_Pin) == GPIO_PIN_RESET) && (HAL_GPIO_ReadPin(GPIO_INPUT_OVP_GPIO_Port, GPIO_INPUT_OVP_Pin) == GPIO_PIN_RESET)) 136 { 137 // if (HAL_GetTick() != oldtime) 138 // { 139 // lvpAndOvpInputTimeCounter++; 140 // if (lvpAndOvpInputTimeCounter > 30000) 141 // { 142 lvpOROvpInput = 0; 143 lvpAndOvpInputTimeCounter=0; 144 // } 145 // oldtime = HAL_GetTick(); 146 // } 147 } 148 155 149 156 150 157 // Prüfe Wechsel in off mode158 if (BUTTON_GetMode() == BUTTON_OFF)159 {160 //Ausschalten muss immer möglich sein161 RELAIS_ResetPuls();162 BUZZER_Beep(BUZZER_ON_TIME_CONFIRM); //Bestätigung163 LEDS_GN_Off();164 LEDS_RT_Off();165 printf("NEW_STATE: LVP_OVP_OFF\n");166 smState = LVP_OVP_OFF;167 }168 151 169 152 //Prüfe auf Fehlermode … … 180 163 } 181 164 182 if (lvpOROvpInput == 0) 165 if (CHIP_TEMPERATURE_GetTemp() > 80) 166 { 167 RELAIS_ResetPuls(); 168 BUZZER_Beep(BUZZER_ON_TIME_REJECT); //Warnung 169 LEDS_GN_Off(); 170 LEDS_RT_BlinkCode_Start(BLINK_CODE_ERROR_TEMP, LED_RT_ON_TIME_WARN_TEMP, LED_GN_OFF_TIME, LED_GN_OFF_TIME *5); //Fehler Anzeigen 171 BUTTON_SetModeOff(); //Damit nicht von alleine wieder eingeschaltet wird 172 printf("NEW_STATE: MAINSWITCH_ERROR, Temp too high\n"); 173 smState = LVP_OVP_ERROR; 174 } 175 176 177 //LVP oder OVP hat stattgefunden, und Relais ist ein, dann aus 178 if ((lvpOROvpInput == 1) && (RELAIS_GetState() == 1)) 183 179 { 184 180 RELAIS_ResetPuls(); … … 186 182 LEDS_GN_Off(); 187 183 LEDS_RT_BlinkCode_Start(BLINK_CODE_ERROR_OVP_LVP, LED_RT_ON_TIME_WARN_OVP_AND_LVP_INPUT, LED_RT_OFF_TIME, LED_RT_OFF_TIME *5); //Fehler Anzeigen 188 printf("LVP OR OVP FALLING!\n");184 printf("LVP OR OVP OFF!\n"); 189 185 printf("NEW_STATE: LVP_OVP_Auto On, Relais off\n"); 190 186 191 187 } 192 188 193 if (lvpOROvpInput == 1) 189 //KEIN LVP und keine OVP Abschaltung, Relais ist aber noch aus, dann einschalten 190 if ((lvpOROvpInput == 0) && (RELAIS_GetState() == 0)) 194 191 { 195 192 RELAIS_SetPuls(); … … 197 194 LEDS_GN_Off(); 198 195 LEDS_GN_Blink_Start(LED_GN_ON_TIME_ON_MODE, LED_GN_OFF_TIME); 199 printf("LVP AND OVP RISING!\n");196 printf("LVP AND OVP ON!\n"); 200 197 printf("NEW_STATE: LVP_OVP_Auto On, Relais on\n"); 201 198 202 199 } 200 201 // Prüfe Wechsel in off mode 202 if (BUTTON_GetMode() == BUTTON_OFF) 203 { 204 //Ausschalten muss immer möglich sein 205 RELAIS_ResetPuls(); 206 BUZZER_Beep(BUZZER_ON_TIME_CONFIRM); //Bestätigung 207 LEDS_GN_Off(); 208 LEDS_RT_Off(); 209 printf("NEW_STATE: LVP_OVP_OFF\n"); 210 smState = LVP_OVP_OFF; 211 //Damit beim drücken auf on erstmal eingeschaltet wird 212 lvpAndOvpInputTimeCounter=0; 213 lvpOROvpInput = 0; 214 } 215 203 216 204 217 }
Note: See TracChangeset
for help on using the changeset viewer.