Strange effect of the angle LPF

I cannot use the angle LPF with my setup (SimpleFOCShield v2). Any non-zero value in motor.LPF_angle.Tf causes strange behaviors.

Here is the most simple example I could isolate (I’ve got other cases, with other modes):

This code sets target=3V in torque+voltage mode:

#include <SimpleFOC.h>

BLDCMotor motor = BLDCMotor(7);
BLDCDriver3PWM driver = BLDCDriver3PWM(9, 5, 6, 8);

SPIClass SPI_3(PC12, PC11, PC10);
MagneticSensorSPI sensor(PD2, 14, 0x3FFF);

InlineCurrentSense current_sense = InlineCurrentSense(0.01, 50.0, A0, A2);

Commander command = Commander(Serial);
void doMotor(char* cmd){ command.motor(&motor, cmd); }

void setup() {
  sensor.init(&SPI_3);
  motor.linkSensor(&sensor);

  driver.voltage_power_supply = 14.5;
  driver.init();

  motor.linkDriver(&driver);

  motor.controller = MotionControlType::torque;
  motor.torque_controller = TorqueControlType::voltage;

  // HERE WE ARE:
  // motor.LPF_angle.Tf = 0.005;

  Serial.begin(115200);
  motor.useMonitoring(Serial);
  motor.monitor_downsample = 0;
  motor.monitor_variables = 0xFF;
  
  current_sense.init();
  motor.linkCurrentSense(&current_sense);

  motor.init();
  motor.initFOC(); 

  motor.target = 3;

  command.add('M', doMotor, "motor");
  
  _delay(1000);
}


void loop() {
  motor.loopFOC();
  motor.move();
  motor.monitor();
  command.run();  
}

Here is what I get when the HERE WE ARE line is commented out (nice low current and high speed):

Here is what I get when the HERE WE ARE line is uncommented (high current and low speed):

Anyone understands what’s happening here?

Here is an update on this issue, in case someone lands here:

  • I cannot reproduce the issue with the small code I posted above, I don’t understand why.
  • I can still reproduce the issue with my (more complex) application.
  • BUT, the issue disappears when I switch from SimpleFOC v2.1.1 to v2.2. So I won’t investigate more.