6
\$\begingroup\$

The ESP32 microcontroller has MCPWM units (Motor Control PWM), used to control motors, and LED Control PWM. The ESP32 docs say the LEDC can be used to generate PWM for other purposes as well, and in fact I am using it to drive a servo. However, what makes it different from the MCPWM, which also produces a PWM signal?

\$\endgroup\$

2 Answers 2

7
\$\begingroup\$

According to the ESP32 documentation, the LEDC module has both 8 bit and 16 bit PWM units, so it has a high-speed mode and a low-speed mode. It can drive most LEDs at 1 KHZ or laser LEDs at 100 KHZ, or high-powered LEDs at 500 HZ.

You can use it to amplitude or frequency modulate analog oscillators or audio gain control for sound effects. Your imagination is your limit.

The MCPWM has limited speed but wide pulse-width adjustment. Motors are mechanical devices so feeding them ultra-fast or ultra-short pulses would do no good, unless low pass filters were added, which would waste power.

Motors will work with somewhat fast PWM due to their inertia and high inductance, which acts as a low pass filter.

Normally a motor speed control stays within the range that the motor can filter naturally, due to its inductance. The capture inputs for the motor generate ISRs to judge if motor is overloaded, or an absence of load.

The same ISRs can be used to judge motor current vs. expected current and detect cogging due to a dynamic load. The motors can be synchronous to internal optional clocks.

Here are the links to the datasheet.

LED PWM Control

Motor PWM Control

\$\endgroup\$
11
  • 4
    \$\begingroup\$ Whenever I see some reference to "motor control PWM" I don't just think about PWM. I think about rather more complex, multi-output, coordinated, non-overlapping, multi-phase PWM used to drive motors. Is the MCPWM one of these fancier kinds with multiple coordinated outputs? Or just your basic counter+compare function for a single I/O? \$\endgroup\$
    – jonk
    Mar 8, 2018 at 1:26
  • 1
    \$\begingroup\$ It can control 3 motors by duty-cycle, and has fault detection for each motor. It is motor-specific firmware. \$\endgroup\$
    – user105652
    Mar 8, 2018 at 1:37
  • 4
    \$\begingroup\$ Looks like two hardware functional module blocks, each with support for "on the fly" frequency and duty % changes. I see sync+capture+fault as well as dead-time capabilities and that they can drive bridge circuits. Okay. So that's what I normally think about when I see "motor control PWM." Stuff like that. Thanks for the added links. The OP will probably need a library module to drive it, given the level of question. Otherwise, the OP would be telling us a lot more detail about what they need to achieve. So I hope there is a library for the OP. Otherwise, they will be dead in the water. \$\endgroup\$
    – jonk
    Mar 8, 2018 at 3:04
  • 2
    \$\begingroup\$ Motors do FINE with fast PWM. In fact, they function as low pass filters. \$\endgroup\$ Aug 27, 2019 at 15:44
  • 2
    \$\begingroup\$ I've routinely used commercial 20kHz PWM systems. Many are somewhat higher than that, to avoid annoying squeal. \$\endgroup\$ Aug 27, 2019 at 23:05
4
\$\begingroup\$

Both can be used to generate arbitary PWM outputs.

The main difference is MCPWM has SYNC inputs to feedback a motor position, and thus adjust the phase of the PWM outputs (to match the actual rotor position).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.