Ignore:
Timestamp:
Aug 23, 2025, 3:27:52 PM (4 days ago)
Author:
f.jahn
Message:
LVP, OVP, LVP
OVP modes implementiert
  • Lüftersteuerung in eigenes Modul verlagert
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/firmware_v2/SES/src/mode_lvp_ovp.c

    r17 r24  
    2929#include "leds.h"
    3030#include "buzzer.h"
     31#include "chip_temperature.h"
    3132
    3233
     
    4647{
    4748  int faultInput;
    48   int lvpOROvpInput;
     49
    4950
    5051  if (HAL_GPIO_ReadPin(GPIO_INPUT_FAULT_GPIO_Port, GPIO_INPUT_FAULT_Pin) == GPIO_PIN_RESET)       
     
    5758  }
    5859
    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
    6761
    6862
     
    7569      BUZZER_Beep(BUZZER_ON_TIME_CONFIRM);
    7670      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");
    7872      smState = LVP_OVP_ON;
    7973
     
    8680      //LEDS_RT_Blink_Start(LED_RT_ON_TIME_WARN_FAULT_INPUT, LED_GN_OFF_TIME); //Fehler Anzeigen
    8781          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");
    8983      smState =LVP_OVP_ERROR;
    9084    }
     
    112106{
    113107  int faultInput = 0;
    114   int lvpOROvpInput = 0;
     108  static int lvpOROvpInput = 0;
    115109  static int lvpAndOvpInputTimeCounter = 0;
    116110  static int oldtime;
     
    125119  }
    126120 
    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))
    128122  {
    129123    if (HAL_GetTick() != oldtime)
    130124    {
    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)
    147127      {
    148128        lvpOROvpInput = 1;
     
    153133  }
    154134
     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
    155149 
    156150
    157   // Prüfe Wechsel in off mode
    158   if (BUTTON_GetMode() == BUTTON_OFF)
    159   {
    160     //Ausschalten muss immer möglich sein
    161     RELAIS_ResetPuls();
    162     BUZZER_Beep(BUZZER_ON_TIME_CONFIRM); //Bestätigung
    163     LEDS_GN_Off();
    164     LEDS_RT_Off();
    165     printf("NEW_STATE: LVP_OVP_OFF\n");
    166     smState = LVP_OVP_OFF;
    167   }
    168151
    169152  //Prüfe auf Fehlermode
     
    180163  }
    181164
    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))
    183179  {
    184180    RELAIS_ResetPuls();
     
    186182    LEDS_GN_Off();
    187183    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");
    189185    printf("NEW_STATE: LVP_OVP_Auto On, Relais off\n");
    190186   
    191187  }
    192188
    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))
    194191  {
    195192    RELAIS_SetPuls();
     
    197194    LEDS_GN_Off();
    198195    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");
    200197    printf("NEW_STATE: LVP_OVP_Auto On, Relais on\n");
    201198   
    202199  }
     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
    203216
    204217}
Note: See TracChangeset for help on using the changeset viewer.