News for hackers. Stuff that matters.
Re:ESP32-S31 by BenjiWiebe on Wednesday June 03, 2026 @01:48PM (#48387230)
Also why do you need 1uS for motor control? 1uS is 0.1 degrees of rotation at 16,666 RPM if I did the math right.

I don't know much about motor control, is it normal to need that fast of feedback?

Re:ESP32-S31 by phkahler on Wednesday June 03, 2026 @02:04PM (#48387476)
>> Also why do you need 1uS for motor control?

It's not that important if you use current sensors on the motor phases. But then you're looking at HALL sensors or a shunt with a very high gain amplifier with good common mode rejection - looking for mV signals on top of a +12V or +48V square wave at PWM frequency.

By using low-side shunts under each half-bridge you don't need the common mode rejection, but you can only measure phase current while the low side FET for that phase is on. That means limiting the PWM duty cycle to ensure that FET is on long enough to measure current, so we trade available voltage range for sample time.

I've also written code to measure all phase voltages with a single low-side current shunt under the whole 3-phase bridge. That requires careful phase shifting of the PWM signals and very fast conversion time, but you don't have to compromise available voltage range 0-100 percent duty cycle is possible.

Typically we run the control loop at PWM frequency, but the measurements need to be faster than that.

Re:ESP32-S31 by actionfromafar on Wednesday June 03, 2026 @06:45PM (#48391148)
That's wild. Would never have guessed.
Re:ESP32-S31 by namibj on Thursday June 04, 2026 @06:12PM (#48405331)
You can also have two shunts per phase, one low side and one high side. The "hall" "shunts" are pretty good though.
Re:ESP32-S31 by topspin on Wednesday June 03, 2026 @02:06PM (#48387507)
Field-oriented Control schemes modulate phase currents at high frequency; the feedback loop must be much faster than the motor phases. Until fairly recently, this stuff was the exclusive province of dedicated ICs (Trinamic et al.) and FPGA. Today, FoC can be done in (mostly) software with MCUs.

Fast feedback loops are also necessary in SMPS, another area where precision, low latency MCU peripherals and software are actively displacing traditional approaches.

Re:ESP32-S31 by tomcam on Wednesday June 03, 2026 @05:26PM (#48390330)
I didn’t know that. Thanks for letting me… meet the FOCers

I’ll see myself out of the Internet now.

Re:ESP32-S31 by imtringued on Thursday June 04, 2026 @06:28AM (#48396608)
But even if you update your PWM signal on every PWM cycle, you won't go much beyond 30kHz. At some point you're running into high switching losses on your MOSFETs.
Re:ESP32-S31 by namibj on Thursday June 04, 2026 @06:15PM (#48405369)
There are solutions to those worries.... https://epc-co.com/epc/products/gan-fets-and-ics/epc23102
Re:ESP32-S31 by nathanfries on Wednesday June 03, 2026 @02:30PM (#48387839)
I similarly don't know much about motor control or hardware in general, but would this maybe open up multiplexing options?
Re:ESP32-S31 by greenavocado on Wednesday June 03, 2026 @01:54PM (#48387329)
People will always find a reason to complain or pretend they are controlling rocket motor servos with their ESP32
Re:ESP32-S31 by PowerElectronix on Wednesday June 03, 2026 @04:46PM (#48389794)
The closed loop experiences a phase margin loss that is exponential with the frequency. At lower frecuencies it is negligible, but if you get close to the frequency of the delay the phase margin reduction becomes dramatic and the control goes from stable to unstable very fast.

If the sensor has a limited bandwidth, you add the conversion delay and then the computation delay on top of that you end up with a max workable loop bandwidth in the low tens of kHz and anything higher will have overshoots, oscillations, etc.

Re:ESP32-S31 by topspin on Wednesday June 03, 2026 @05:29PM (#48390361)
You see this in low cost products like MKS SERVO42x, where they're doing FoC with a GD32 MCU. It works; the motor runs cool, smooth and quiet, but the system is limited to 3000 RPM, and struggles with rapid acceleration because the control loop is too slow.
Re:ESP32-S31 by mianos on Wednesday June 03, 2026 @10:25PM (#48392897)
I have tried one. It has no torque. For what looks like an awesome product, it does not have the power to drive a peristaltic pump. I used the same motor on a TMC stepper controller and it's completely silent and works. It's open loop, so comparing apples to oranges but I am not sure what the MKS servo driver on a motor could actually do, aside from spin unloaded.
Re:ESP32-S31 by topspin on Thursday June 04, 2026 @06:09PM (#48405299)
These can deliver 2.5-3A/phase, which should ample for a pump. Respectfully, I wonder what motor was involved and whether the current was configured: they come out of the box with conservative configuration so people don't burn up motors.
Re:ESP32-S31 by mianos on Friday June 05, 2026 @07:05PM (#48419497)
Nema 17
Re:ESP32-S31 by GeorgeTirebiter on Thursday June 04, 2026 @10:20AM (#48399064)
This is exactly correct. Low 10s of kHz is quite functional for machines moving in human space / speed.

If one is trying to do some assembly line (max # of operations per second), the power requirements alone get hard to manage. And then you're managing back EMF, eddy currents, heck, air resistance!

My rule: have dedicated low-level hw provide smooth PID response, mostly on the P term; and have a higher-level control produce the setpoint. Faster response means less need to rely on I or D terms as much (just because delta-T is so relatively small).

[dead]
Re:ESP32-S31 by benj111 on Wednesday June 03, 2026 @05:31PM (#48390386)
Have you never heard something that is surprising to you, and then asked for more information?

Well no. Probably not...