diff --git a/Src/bldc.c b/Src/bldc.c index c992b6d..cb57ba4 100644 --- a/Src/bldc.c +++ b/Src/bldc.c @@ -77,7 +77,7 @@ static int16_t offsetdcl = 2000; static int16_t offsetdcr = 2000; int16_t batVoltage = (400 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE; -static int32_t batVoltageFixdt = (400 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE << 20; // Fixed-point filter output initialized at 400 V*100/cell = 4 V/cell converted to fixed-point +static int32_t batVoltageFixdt = (400 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE << 16; // Fixed-point filter output initialized at 400 V*100/cell = 4 V/cell converted to fixed-point // ================================= // DMA interrupt frequency =~ 16 kHz diff --git a/Src/main.c b/Src/main.c index 969c04f..f4862f3 100644 --- a/Src/main.c +++ b/Src/main.c @@ -192,7 +192,7 @@ int main(void) { int16_t speedL = 0, speedR = 0; int16_t lastSpeedL = 0, lastSpeedR = 0; - int32_t board_temp_adcFixdt = adc_buffer.temp << 20; // Fixed-point filter output initialized with current ADC converted to fixed-point + int32_t board_temp_adcFixdt = adc_buffer.temp << 16; // Fixed-point filter output initialized with current ADC converted to fixed-point int16_t board_temp_adcFilt = adc_buffer.temp; int16_t board_temp_deg_c; diff --git a/Src/util.c b/Src/util.c index e7c92b7..dbed0fa 100644 --- a/Src/util.c +++ b/Src/util.c @@ -1186,10 +1186,10 @@ void sideboardSensors(uint8_t sensors) { /* =========================== Filtering Functions =========================== */ - /* Low pass filter fixed-point 32 bits: fixdt(1,32,20) - * Max: 2047.9375 - * Min: -2048 - * Res: 0.0625 + /* Low pass filter fixed-point 32 bits: fixdt(1,32,16) + * Max: 32767.99998474121 + * Min: -32768 + * Res: 1.52587890625e-05 * * Inputs: u = int16 or int32 * Outputs: y = fixdt(1,32,16)