Ignore:
Timestamp:
Sep 8, 2025, 6:57:30 PM (7 weeks ago)
Author:
f.jahn
Message:
  • Bug in ADC Kalibrierung (STM32 ADC Strom) behoben
  • DMA Buffer für ADC 1 und ADC wird vor Überschreibung während bearbeitung geschützt, indem Datenübertragung nur einmalig erfolgt und erst nach Auswertung wieder gestartet wird
  • RS485Modbus: Timeout Zeit wird für Baudraten >19200 korrekt berechnet
  • Hardware ID geändert
  • Separates Register für "Batterie Empty detection mode" auf Adresse 92 angelegt
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/fw_g473rct/SES/src/ah_counter.c

    r20 r26  
    175175  sys_data.s.values.mAhCounter = sys_data.s.values.mAsCounter / 3600LL;
    176176
    177   static uint16_t lowVoltageCnt;
    178   if (sys_data.s.values.batteryVoltage < sys_data.s.values.uBatEmptyTempComp && sys_data.s.values.batteryVoltage > 1000)
    179   {
    180           lowVoltageCnt++;
    181           if ((lowVoltageCnt >= 10) && (startMeasurement == 1)) // 5 Sekunden fest
    182           {
    183                   lowVoltageCnt = 10; //sys_data.s.parameter.tBatFull;
    184 
    185                   if ((sys_data.s.values.lastTimeVbatFull >= 3600U) && (sys_data.s.values.lastTimeVbatFull <= 200U * 3600U))    // This line prevents from very high discharge-currents to be used to estimate battery capacity
    186                   {
    187                           // This line is not so important anymore, because we do not allow mAh_AutoMode to be greater than zero
    188                           sys_data.s.values.detectedCapacity = sys_data.s.values.mAh_AutoMode >= 0 ? sys_data.s.values.mAh_AutoMode : -sys_data.s.values.mAh_AutoMode;
    189                           WH_COUNTER_SetDetectedEnergy();
    190                           startMeasurement = 0;
    191                           EEPROM_storeConfig(&sys_data, 0);     // Saving detected values
    192                   }
    193                   sys_data.s.values.lastTimeVbatEmpty = 0U;
    194           }
    195   }
    196   else lowVoltageCnt = 0;
    197 
     177  static uint16_t cnt;
     178  if (sys_data.s.parameter.batteryEmptyDetectionMode == 0)
     179  {
     180    if (sys_data.s.values.batteryVoltage < sys_data.s.values.uBatEmptyTempComp && sys_data.s.values.batteryVoltage > 1000) // Verhindert das beim abziehen der Sense ein Batt Empty erkannt wird
     181    {
     182          cnt++;
     183          if ((cnt >= 10) && (startMeasurement == 1)) // 5 Sekunden fest
     184          {
     185                  cnt = 10; //sys_data.s.parameter.tBatFull;
     186
     187                  if ((sys_data.s.values.lastTimeVbatFull >= 3600U) && (sys_data.s.values.lastTimeVbatFull <= 200U * 3600U))    // This line prevents from very high discharge-currents to be used to estimate battery capacity
     188                  {
     189                          // This line is not so important anymore, because we do not allow mAh_AutoMode to be greater than zero
     190                          sys_data.s.values.detectedCapacity = sys_data.s.values.mAh_AutoMode >= 0 ? sys_data.s.values.mAh_AutoMode : -sys_data.s.values.mAh_AutoMode;
     191                          WH_COUNTER_SetDetectedEnergy();
     192                          startMeasurement = 0;                   
     193                  }
     194                  sys_data.s.values.lastTimeVbatEmpty = 0U;
     195          }
     196    }
     197    else
     198    {
     199      cnt = 0;
     200    }
     201  }
     202  else
     203  {
     204        // Neuer Modus. Spannungsmessung wird ignoriert. Erkannt wird Batt Leer mit LVP Signal von LiPro
     205        // OVP darf nicht ausgehen, sonst handelt es sich um ein Temperaturabschaltung oder ein andere Fehler
     206        // 1000mV als Schwelle um sicher vor rauschen um den Nullpunkt zu seinzu sein
     207    if ((sys_data.s.values.ovp_sense > 1000) && (sys_data.s.values.lvp_sense < 1000))
     208    {
     209          cnt++;
     210          if ((cnt >= 10) && (startMeasurement == 1)) // 5 Sekunden fest
     211          {
     212                  cnt = 10; //sys_data.s.parameter.tBatFull;
     213
     214                  if ((sys_data.s.values.lastTimeVbatFull >= 3600U) && (sys_data.s.values.lastTimeVbatFull <= 240U * 3600U))    // This line prevents from very high discharge-currents to be used to estimate battery capacity
     215                  {
     216                          // This line is not so important anymore, because we do not allow mAh_AutoMode to be greater than zero
     217                          sys_data.s.values.detectedCapacity = sys_data.s.values.mAh_AutoMode >= 0 ? sys_data.s.values.mAh_AutoMode : -sys_data.s.values.mAh_AutoMode;
     218                          WH_COUNTER_SetDetectedEnergy();
     219                          startMeasurement = 0;                   
     220                  }
     221                  sys_data.s.values.lastTimeVbatEmpty = 0U;
     222          }
     223    }
     224    else
     225    {
     226      cnt = 0;
     227    }
     228  }
    198229
    199230
Note: See TracChangeset for help on using the changeset viewer.