Stm32 outputs the same waveform on different pins

Hi. At the moment i’m still experiment with simplefoc with stm32 setup and ir2104.
But according to my oscilloscop the stm32 outputs the same waveform on different pins.

#include <SimpleFOC.h>

BLDCMotor motor = BLDCMotor(11);

BLDCDriver3PWM driver = BLDCDriver3PWM(PA8, PA9, PA10);

void setup() {

driver.voltage_power_supply = 12;
driver.voltage_limit = 6;

driver.pwm_frequency = 10000;

motor.LPF_velocity.Tf = 0.01f;
motor.voltage_limit = 12; // [V]

motor.controller = MotionControlType::velocity_openloop;



void loop() {

 motor.loopFOC();// FOC algorithm function =  10; // Set target velocity


I complied the code with arduino ide and uploaded with stm32cubeprogrammer.

Hi @Vlad_Daniel ,

If your driver.voltage_limit is 6V, the motor.voltage_limit should be 3V. Certainly it can’t be higher than the driver limit.

When using open loop mode, you don’t need the call to loopFOC, although it won’t hurt.

Could you share a picture of the waveforms you are seeing?

with measures:


So this waveform looks fine - PWM at 50% duty cycle and 10kHz frequency, which is the frequency you chose.

You’ll have to zoom out a bit on the oscilloscope and then you should see that PWM duty cycle varies over time.
And if you show more than one phase at the same time you should see that there is a difference between the phase signals if you zoom out so that you can many PWM periods at the same time.

the 3 pins have the same waveform
this is the video

Please zoom out more and display more than one phase at the same time. You’ll see that the waveforms are not actually the same, even though all the phases carry a PWM signal that looks similar when they are viewed individually…

but why is the motor stalling?I mean its like is trying to go back and forward with delay. shaking the whole setup apart.

There can be many reasons:

One of the most common mistakes is to use the wrong number of pole pairs. In the code above you set 11PP, are you sure it’s correct? Although for open loop mode it should not matter.

Have you fixed the voltage limits as I noted above? It’s unlikely to work well with the motor limit set to 2x the driver limit.

Can you share your driver circuit schematics? Is it a self made driver based on IR2104?

Also, which motor are you using, what’s the winding resistance?

i fix the voltage. its hoverboard motor like 250W. the resistance is like 0.6 ohm.
As for the schematic i used this topic:

can someone compile me the code so that i can uploaded with cube stm32.
Maybe something is wrong when i do it with arduino ide.

I don’t know where you got the IR2104 drivers, but I came across drivers that worked only when I connected the PWM output of the microcontroller to the Input and SD pins at the same time. I.e. I used esp32 and outputs 25, 26, 27 in 3 pwm mode. I connected 25 pins to the input and sd pins of the first halfbridge driver, 26 pins to the second driver, and 27 to the third.

got them from aliexpress.
this is the waveform zoom out

i dont have a second probe to display the second waveform.
At the moment the SD input is connected to the stm32 but i did not input it in the program yet.

Looking at your vertical video I would say you still have clipping in this signal. Given your motor is 0.6Ω, perhaps you should set the motor.voltage_limit to something low, like 1V, and see if this helps things. You’ll have to watch the currents on a lower resistance motor, especially in open loop mode.