Ignore:
Timestamp:
Feb 23, 2025, 1:25:41 PM (5 months ago)
Author:
f.jahn
Message:

LED Modul hinzugefügt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/firmware/Core/src/mode_mainswitch.c

    r9 r10  
     1// Keine LVP und OVP Überwachung aber Fault wird geprüft!
     2// Falls nicht benötigt, nicht anschließen ?! Ist Low active mit PullUp
     3
     4
     5#include "stdio.h"
    16#include "mode_mainswitch.h"
    27#include "button.h"
    38#include "relais.h"
     9#include "main.h"
     10#include "leds.h"
    411
    512
     
    714void MODE_MAINSWITCH_Exec(void)
    815{
    9   //Prüfen ob eingeschaltet werden muss
    10   if (RELAIS_GetState() == 0)
    11   {
    12     if (BUTTON_GetMode() == BUTTON_MANUAL_ON)
    13     {
    14       RELAIS_SetPuls();
    15     }
    16     else if (BUTTON_GetMode() == BUTTON_AUTO)
    17     {
    18       RELAIS_SetPuls();
    19     }
     16
     17  //Prüfe FAULT Eingang
     18  int faultInput;
     19  static int faultMode = 0;
    2020
    2121
     22
     23
     24
     25  if (HAL_GPIO_ReadPin(GPIO_INPUT_FAULT_GPIO_Port, GPIO_INPUT_FAULT_Pin) == GPIO_PIN_RESET)       
     26  {
     27    faultInput = 1;
     28
     29    if (faultMode == 0)
     30    {
     31      faultMode = 1;
     32      LEDS_RT_Blink_Start(1000, 1000);   
     33      BUTTON_SetModeOff();
     34      printf("FAULT DETECTED!\n");
     35    }
     36
     37    if (BUTTON_GetMode() != BUTTON_OFF)
     38    {
     39       BUTTON_SetModeOff();
     40    }
     41
     42    if (RELAIS_GetState() == 1)
     43    {
     44      printf("RESET RELAIS: FAULT DETECTED!\n");
     45      RELAIS_ResetPuls();
     46
     47      //Wir wollen nicht, das das Relais automatisch wieder startet, wenn Fault nicht mehr aktiv. Daher schalten wir
     48      //Button Mode auf Off
     49     
     50    }     
    2251  }
    23 
     52  else
     53  {
     54    faultInput = 0;
     55  }
    2456
    2557
     
    2759  if (RELAIS_GetState() == 1)
    2860  {
    29     if (BUTTON_GetMode() == BUTTON_OFF)
     61    if (BUTTON_GetMode() == BUTTON_OFF)      
    3062    {
    3163      RELAIS_ResetPuls();
     
    3466
    3567
    36  
     68  //Prüfen ob eingeschaltet werden kann
     69  if ((RELAIS_GetState() == 0) && (faultInput == 0))
     70  {
     71    if (BUTTON_GetMode() == BUTTON_MANUAL_ON)
     72    {
     73      LEDS_RT_Off(); //Falls im LED im Fehlermode, so können wir diese jetzt wieder ausschalten
     74      faultMode = 0;
     75      RELAIS_SetPuls();
     76    }
     77    else if (BUTTON_GetMode() == BUTTON_AUTO)
     78    {
     79      LEDS_RT_Off(); //Falls im LED im Fehlermode, so können wir diese jetzt wieder ausschalten
     80      faultMode=0;
     81      RELAIS_SetPuls();
     82    }
     83  }
    3784}
Note: See TracChangeset for help on using the changeset viewer.