mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 00:35:39 +03:00
Change current/voltage filters from biquad to pt1
This commit is contained in:
parent
b8bfc7ce12
commit
62fafe8041
2 changed files with 9 additions and 9 deletions
|
@ -88,7 +88,7 @@ void currentMeterReset(currentMeter_t *meter)
|
|||
// ADC/Virtual shared
|
||||
//
|
||||
|
||||
static biquadFilter_t adciBatFilter;
|
||||
static pt1Filter_t adciBatFilter;
|
||||
|
||||
#ifndef CURRENT_METER_SCALE_DEFAULT
|
||||
#define CURRENT_METER_SCALE_DEFAULT 400 // for Allegro ACS758LCB-100U (40mV/A)
|
||||
|
@ -141,7 +141,7 @@ currentMeterADCState_t currentMeterADCState;
|
|||
void currentMeterADCInit(void)
|
||||
{
|
||||
memset(¤tMeterADCState, 0, sizeof(currentMeterADCState_t));
|
||||
biquadFilterInitLPF(&adciBatFilter, GET_BATTERY_LPF_FREQUENCY(batteryConfig()->ibatLpfPeriod), HZ_TO_INTERVAL_US(50));
|
||||
pt1FilterInit(&adciBatFilter, pt1FilterGain(GET_BATTERY_LPF_FREQUENCY(batteryConfig()->ibatLpfPeriod), HZ_TO_INTERVAL(50)));
|
||||
}
|
||||
|
||||
void currentMeterADCRefresh(int32_t lastUpdateAt)
|
||||
|
@ -149,7 +149,7 @@ void currentMeterADCRefresh(int32_t lastUpdateAt)
|
|||
#ifdef USE_ADC
|
||||
const uint16_t iBatSample = adcGetChannel(ADC_CURRENT);
|
||||
currentMeterADCState.amperageLatest = currentMeterADCToCentiamps(iBatSample);
|
||||
currentMeterADCState.amperage = currentMeterADCToCentiamps(biquadFilterApply(&adciBatFilter, iBatSample));
|
||||
currentMeterADCState.amperage = currentMeterADCToCentiamps(pt1FilterApply(&adciBatFilter, iBatSample));
|
||||
|
||||
updateCurrentmAhDrawnState(¤tMeterADCState.mahDrawnState, currentMeterADCState.amperageLatest, lastUpdateAt);
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue