Electronic – the difference between MCPWM and LEDC PWM

microcontrollerpwm

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?

Best Answer

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