Fixed initial condition bug
- the initial condition for the Battery and Board temperature was wrongly set - the filter is fixdt(1,32,16), so the shift should be by 16 bits.
This commit is contained in:
parent
b8d9c8c8bc
commit
ac90ed1b6b
|
@ -77,7 +77,7 @@ static int16_t offsetdcl = 2000;
|
||||||
static int16_t offsetdcr = 2000;
|
static int16_t offsetdcr = 2000;
|
||||||
|
|
||||||
int16_t batVoltage = (400 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE;
|
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
|
// DMA interrupt frequency =~ 16 kHz
|
||||||
|
|
|
@ -192,7 +192,7 @@ int main(void) {
|
||||||
int16_t speedL = 0, speedR = 0;
|
int16_t speedL = 0, speedR = 0;
|
||||||
int16_t lastSpeedL = 0, lastSpeedR = 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_adcFilt = adc_buffer.temp;
|
||||||
int16_t board_temp_deg_c;
|
int16_t board_temp_deg_c;
|
||||||
|
|
||||||
|
|
|
@ -1186,10 +1186,10 @@ void sideboardSensors(uint8_t sensors) {
|
||||||
|
|
||||||
/* =========================== Filtering Functions =========================== */
|
/* =========================== Filtering Functions =========================== */
|
||||||
|
|
||||||
/* Low pass filter fixed-point 32 bits: fixdt(1,32,20)
|
/* Low pass filter fixed-point 32 bits: fixdt(1,32,16)
|
||||||
* Max: 2047.9375
|
* Max: 32767.99998474121
|
||||||
* Min: -2048
|
* Min: -32768
|
||||||
* Res: 0.0625
|
* Res: 1.52587890625e-05
|
||||||
*
|
*
|
||||||
* Inputs: u = int16 or int32
|
* Inputs: u = int16 or int32
|
||||||
* Outputs: y = fixdt(1,32,16)
|
* Outputs: y = fixdt(1,32,16)
|
||||||
|
|
Loading…
Reference in New Issue