Stepper open loop strange current


I am experimenting with stepper motor and StepperDriver4PWM. I configured stepper in MotionControlType::velocity_openloop. I notice noise from stepper when rotating, so i measured current with oscilloscope:
Posnetek zaslona 2022-03-07 123726

I guess that noise comes from non-sinus form of current.
Why current(green) doesn’t start flowing with start of pwm signal(yellow)?
I measured that current start at cca 7% duty cycle and above.
How can i correct for that?

Best regards, Matjaž

Hi, and welcome @matjaz87 !

Do I understand you correctly: the output of SimpleFOC via the PWM driver is <7% duty cycle, the output of the driver stage is no current?
What is your driver architecture, which driver or FETs are you using, if I may ask?

Do I understand you correctly: the output of SimpleFOC via the PWM driver is <7% duty cycle, the output of the driver stage is no current?
Yes, and when output is above 7% duty cycle, current starts.

I tried with L298N and BLDC-SHIELD_IFX007T. Results are almost the same.

Hi @matjaz87,

May I ask the time-scale of the above plot? And what frequency do you run the PWM at?

Both of these boards have very slow switching times - I wonder if this can be the issue?
→ e.g. 25kHz x 7% is about 2.8µs - but the turn-on times of a L298 are also measured in µs, and depending on the setup can be even more than this… so basically the transistor just doesn’t have time to properly switch on before it is switched off again…

You can try with a better driver, or if you have set a low voltage_limit compared to the PSU voltage, you might improve things with lower PSU voltage, so the low duty cycles are not used as much.

Hi @runger

Time scale is 10 ms/div. PWM is 25 kHz generated by nucleo-f401RE board. PSU voltage is 24 V. I running NEMA11 motor with cca 5 Ohm resistance per phase.

I tried with PSU voltage 7.5 V, and is better, but it is still quite loud when rotating. Current shape is better, but it still doesn’t flow from the start of PWM.

Do you have any suggestion for faster driver?

What do you think, is it possible to constrain PWM from 7% to 100%? In this way PWM will start from 7%.

What about current regulation, is this hard to make?

Thank you for your answers :slight_smile:

Hi @matjaz87,

It’s difficult right now, you have to hunt around. Generally more available are the demo boards from TI or ST for their various motor drivers, but those cost $$ - usually $50-$150, depending on what it can do. Many of them accept 3-PWM or 6-PWM input and can be used with SimpleFOC.
Other than that, keep looking back in the SimpleFOC store, and maybe you can try some of what you see when you search “SimpleFOC” on AliExpress…

We don’t have a minimum PWM threshold, that I’m aware of. I have to think about it, but I think you might be able to achieve this effect by setting the dead-time to the right value, if you’re using 6-PWM. Or you could clone the library source code from GitHub and modify the setPwm function in the driver code (BLDCDriver6PWM.cpp or BLDCDriver3PWM.cpp) to contstrain the value between 0.07 and 1.0 - but I guess you should allow the value 0.0 as well…

Your hardware has to support this by offering current-sensing. If you get a driver with inline current sensing, you can try it right now, for low-side current sensing we plan to have it implemented in the next release.

Hi @runger

I tried with B-G431B-ESC1 board. I drive only 1phase in stepper motor for test. I got sinus current from this driver.
I repeated test again, same setup with L298 and IFX007T, phase current was non sinus.

I am happy that i solved this issue. I am still not sure about root cause, probably switching of transistor was to slow.
I am asking myself how IFX007 preform as BLCD driver? Probably very bad…

Hey @matjaz87,

You’re right.
L298N and BTN8982/IFX007 have very slow rise time and they are unfortunately not very good drivers for the FOC. Not for Stepper or BLDC motors.
We have had many posts now about their performance problems and I’ll make sure to list them in the docs.
We have been very optimistinc about them at first because of their low cost and convenience but unfortunately many people are reaching their limits.
Thanks for reporting back.

I’ve at first developed the stepper code on 2 simplefocshields (using 4 out of 6 phases). They performed very well, bgc I did not test.

I’ve also tested the samd21 based smartstepper integrated driver, it is a bit loud, but it does work well.


They are not that cheap anymore, unfortunately. Due to the recent silicon shortage, COVID, and war in Ukraine, the prices have gone through the roof, nearly 10 times (1000%).

This is the latest price for the chips in stock.

A board needs 3 of those so you will need about $100 just for the drivers.

They used to cost about $3 per chip.