Changeset 24 for trunk/fw_g473rct/SES/src/fast_current.c
- Timestamp:
- Aug 31, 2025, 6:56:29 PM (4 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/fw_g473rct/SES/src/fast_current.c
r20 r24 17 17 18 18 // --- LOKALE DEFINES - bitte hier dokumentieren -------------------------------- 19 //#define FAST_CURRENT_FILTER 220 21 22 19 23 20 #define I_SENSE_GAIN 40.0 21 #define ADC_OFFSET 32768 22 #define ADC_RESOLUTION 32768 //65536/2 da im differential mode 24 23 25 24 … … 51 50 52 51 53 void FAST_CURRENT_Exec(uint32_t new valP, uint32_t newvalM)52 void FAST_CURRENT_Exec(uint32_t newVal ) 54 53 { 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 80 55 //Umrechung auf Strom 81 56 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 ; 83 61 sys_data.s.values.fast_current = temp_current * (sys_data.s.parameter.batteryCurrentGainCorrectionFaktor / 1000000.0); 84 62
Note: See TracChangeset
for help on using the changeset viewer.