Motor stuttering at low and high speed with openloop

Hello all,
I already this topic Open loop velocity control not working at low velocity but I couldn’t link my case with this one.
Here is the setup.
Motors : 2x2206 100T and 1x2804 100Kv (Moteur de cardan sans balais pour appareil photo numérique CNC, support FPV, 2208 80T, 2204 260KV, 2804 100KV, 2805 agglomKV, 2206 100T - AliExpress 26)
Driver : Mimi L298N (Same as L298B but smaller and limited to 10V !!!, Max 1.5A)
Boards: BlackPills (stm32f411)

I gathered some info about motors (2206, 260Kv, 12 poles Res=80mOhm) (2804, 100Kv, 14 Poles, 100mOhm)
I Tried different Voltage 3.7, 5V, 7.2V and this has no change.

Motors stuttere at low speed and jeks at high speed

Here the code

#include <SimpleFOC.h>

// target variable
float target_velocity=1;
float prev_target_velocity=0;

BLDCMotor motor = BLDCMotor(4, NOT_SET, 260, NOT_SET);
BLDCDriver3PWM driver = BLDCDriver3PWM(PA_2, PA_1, PA_0);

float voltage_limit = 3.7;

// commander interface
Commander command = Commander(Serial, '\r', true);
void onTarget(char* cmd){ command.scalar(&target_velocity, cmd); }
void onTarget2(char* cmd){ command.scalar(&voltage_limit, cmd); }

void setup() {
  Serial.begin(115200);

  SimpleFOCDebug::enable(&Serial);

  _delay(1000);

  // driver config
  // power supply voltage [V]
  driver.voltage_power_supply = 5;
  driver.voltage_limit = voltage_limit;   // Volts
  driver.init();
  // link the motor and the driver
  motor.linkDriver(&driver);

  // choose FOC modulation (optional) - SinePWM or SpaceVectorPWM
  motor.foc_modulation = FOCModulationType::SpaceVectorPWM;

  // limiting voltage
  motor.voltage_limit = voltage_limit;   // Volts

  // or current  - if phase resistance provided
  motor.current_limit = 1; // Amps

  motor.controller = MotionControlType::velocity_openloop;

  // initialize motor
  motor.init();

  // align encoder and start FOC
  motor.initFOC();

  Serial.println("Motor ready");
  _delay(1000);

  // add target command T
  command.add('T', onTarget, "target velocity");
  command.add('V', onTarget2, "Voltage limit");

  Serial.println("Set the target velocity using serial terminal:");
  _delay(1000);
}

void loop() {
  motor.loopFOC();
  motor.move(target_velocity);

  motor.voltage_limit = voltage_limit;   // Volts
  driver.voltage_limit = voltage_limit;   // Volts

  if (prev_target_velocity != target_velocity) {
    Serial.print("Velocity= "); Serial.print(target_velocity);
    prev_target_velocity = target_velocity;
  }
  // iterative function setting the velocity target
  command.run();
}

I know there is something wrong … but what ?

Hey @MORDRET_Pierre-Yves,

Welcome to SimpleFOC!

A few points I note:

  1. The motors you link, in my experience, have around 5-10ohm phase resistance. Not 100mOhm like you write. Did you measure them?
    But in your sample code you’re not using the resistance value, so it should not matter.

  2. You’re using the same voltage limit on motor and driver, which will lead to a lot of overmodulation. Please try with motor.voltage_limit = driver.voltage_limit/2.0f;

  3. Please remove the KV value from the motor constructor for initial testing. You can always add it back later.

  4. The L298N is a very old transistor based h-bridge. It’s hard to get good performance out of it. In particular, I think running it at 5V is a bit low, you might have better results with the motor supply voltage at 10V, well above the logic switching voltage (3.3V for the black pill MCUs).