Ignore:
Timestamp:
Aug 31, 2025, 6:56:29 PM (4 days ago)
Author:
f.jahn
Message:

Shunt Temperatursensor aktiviert

File:
1 edited

Legend:

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

    r20 r24  
    1717
    1818//      --- LOKALE DEFINES - bitte hier dokumentieren --------------------------------
    19 //#define FAST_CURRENT_FILTER  2
    20 
    21 
    2219
    2320#define I_SENSE_GAIN    40.0
     21#define ADC_OFFSET                                                        32768
     22#define ADC_RESOLUTION                                            32768 //65536/2 da im differential mode
    2423
    2524
     
    5150
    5251
    53 void FAST_CURRENT_Exec(uint32_t newvalP, uint32_t newvalM )
     52void FAST_CURRENT_Exec(uint32_t newVal )
    5453{
    55   static int measCounter;
    56   static unsigned long avgsumP = 0;
    57   uint32_t avgvalP;
    58 
    59   if (measCounter < INT32_MAX) measCounter++;
    60 
    61 
    62   // Filterlängen in 2er-Potenzen --> Compiler optimiert
    63  // avgsumP -= avgsumP / FAST_CURRENT_FILTER;
    64  // avgsumP += newvalP;
    65 //  avgvalP = avgsumP / FAST_CURRENT_FILTER;
    66 
    67 //  static unsigned long avgsumM = 0;
    68 //  uint32_t avgvalM;
    69   // Filterlängen in 2er-Potenzen --> Compiler optimiert
    70 //  avgsumM -= avgsumM / FAST_CURRENT_FILTER;
    71 //  avgsumM += newvalM;
    72 //  avgvalM = avgsumM / FAST_CURRENT_FILTER;
    73 
    74 
    75   //Berechne Differenzspannung am ADC Eingnag
    76   double diff;
    77   diff = (int32_t) newvalP - (int32_t) newvalM;
    78   diff = (diff * sys_data.s.values.realVdd)  / 65536;
    79 
     54 
    8055  //Umrechung auf Strom
    8156  double temp_current;
    82   temp_current = (diff / I_SENSE_GAIN) /  SHUNT_RESISTOR;
     57  temp_current = ((int32_t) newVal - ADC_OFFSET) * VREF ;
     58  temp_current = temp_current / ADC_RESOLUTION;
     59  temp_current = temp_current / I_SENSE_GAIN ;
     60  temp_current = temp_current / SHUNT_RESISTOR ;
    8361  sys_data.s.values.fast_current = temp_current * (sys_data.s.parameter.batteryCurrentGainCorrectionFaktor / 1000000.0);
    8462 
Note: See TracChangeset for help on using the changeset viewer.