[STMG431B-ESC1] Burned phase with example sketch

Hello,
If I were you, I’d buy a small, adjustable laboratory power supply with current limiting.
You’re really taking unnecessary risks testing without mastering with a lipo battery.

Is that a problem when both limits are the same?
If I understood correctly, the motor limit usually is 1/2 the driver limit. (because it is centered around zero or something)

@multisystem I’m using the charger for my lipos (HOTA D6). It has a power supply mode where I cant set voltage and current. Don’t see why I should buy an extra PSU.

@o_lampe Thanks. I have implemented your suggestion. The motor inits fine and spins with FOC enabled.

The only issue is the heat generation now. Both motor and ESC get really hot even when the PSU only indicates 0.8A. If I had to guess it’s around 70°C for the ESC. Motor is around 50°C.
I was hoping to use at least 10-20A but that does not seem possible.
My other ESCs (drone ones) barely get warm when using 25A per motor or more. The motors also stay cold. (The airstream probably helps). I don’t quite get why these ones get so warm.

Any tuning I can do in SimpleFOC to reduce heat generation? Should I try the intended way using the STM studio configurator and see if it is possible using their suggested way? If that would stay cold(er) I would be open to try and improve SimpleFOC. Not sure how deep you already dug on that.

That board may have external pullups already, but if not then
sensor.pullup = Pullup::USE_INTERN;
sensor.init();

For the heating, have you tuned the zero offset yet? As said previously, use SinePWM, command the motor to spin both directions, and adjust motor.zero_electric_angle until both top out at the same speed. Once you’ve found a good value, you can pass it to motor.initFOC so you don’t have to hunt for it every time (it will have to be redone if you change the position of the sensor mount relative to the stator, or the order the motor wires are connected to the ESC).

To improve further, you could try SmoothingSensor. That will give a more precise angle for the current sensing to dynamically minimize the wasted d-axis current. Once you have that working, try SpaceVectorPWM and Trapezoid120 to see if one of them gives a more favorable waveform (some motors produce sinusoidal back EMF, some produce trapezoidal, and ideally the drive waveform should have matching shape). Without SmoothingSensor, SinePWM should produce a properly timed trapezoid (thanks to the virtual stator arms described in my post #37), but then current sense doesn’t have a high resolution angle to work with.

I only have experience with that when I changed a motor wiring from wye to delta. I had to re-arrange the hall sensors, but that’s probably the same as @dekutree64 has mentioned?

Well, because being able to set a current limit will prevent your hardware from burning as you develop and tune the software…

The HOTA D6 looks very advanced, but it’s a battery charger… does it have a PSU mode or something? Otherwise I’d be concerned in any case about what’s going on on the power rails… a charger will generally assume its trying to charge a battery, and implement all kinds of protections which might interfere with the power.

Personally I’d prefer to use the battery rather than the charger as the power source. But using a battery has the problem, especially if it’s a RC car type or drone battery, that it can deliver huge amounts of current very quickly - so not very forgiving of mistakes in the software.

Generally speaking I would say that people find that a well-tuned, properly calibrated system using closed loop FOC uses significantly less power (and therefore heat) for the same torque/speed than a standard 6-step ESC.

That said, if you follow the many threads concerning the B-G431-ESC1 on this forum, this ESC seems to have design problems that mean it just gets hot, even at low power levels and with FOC. I can’t say why, perhaps its layout is too dense, or perhaps we’ve just never found good timings for its FETs, but you won’t get anywhere near its rated current using SimpleFOC.

Perhaps your experience will be different using the more optimised code of the ST motor control studio, I could not say.

Just shooting from the hip (as always :roll_eyes: )
Maybe the default PWM frequency of sFOC is to high?

I’m not familiar with all the posts regarding this board…AFAIK, it’s impossible to see through-shots in 3PWM mode? And in 6PWM mode there is enough dead-time, I guess.

It’s not the pwm frequency, I adjusted it with minimal effect. You really gotta poke around with an oscope, I think it is more likely a hardware issue, i.e. it would still get hot with other code running on it.