Author Topic: ESP32: LEDC PWM or MCPWM when doing simple motor speed control?  (Read 867 times)

0 Members and 1 Guest are viewing this topic.

Offline rolerozTopic starter

  • Supporter
  • ****
  • Posts: 8
  • Country: us
Hi all

I'm using an ESP32 to control a mecanum wheel chassis, and for that I need to control the speed of the 4 motors (each connected to one of the wheels). I'm using Toshiba's TC78H620FNG as an H-Bridge to control each motor (2 motors per IC), and 2 GPIO pins per motor (direction + enable). The plan is to have the direction (PHA_x) pin directly set with digitalWrite(), and use PWM on the enable pin to control speed. I have no feedback signal from the motors

I see that I have 2 ways of doing PWM in ESP32, and in case this is important I'm using the ESP32-S3, I can go with the LEDC PWM or the MCPWM modules:
- The LEDC PWM module seems simpler to use, is the most widely used system out there to control motors, and according to the data sheet is used to control LEDs and "other uses", whatever that means
- MCPWM is harder to use, and has fewer examples out there, but it's specifically designed to control motors

What would I be missing if I used LEDC PWM instead of MCPWM for this application?

My motors are currently 6V 250mA, but I foresee them potentially growing up to 12V 1A in the future, but that is handled by the H-Bridge, not the ESP32. I do have separate power rails for motors and the electronics
 
The following users thanked this post: DarkMode

Offline ArdWar

  • Frequent Contributor
  • **
  • Posts: 721
  • Country: sc
Re: ESP32: LEDC PWM or MCPWM when doing simple motor speed control?
« Reply #1 on: July 02, 2023, 05:10:20 pm »
LEDC outputs a single PWM signal. You can use this if you use motor control IC with its own dead time generation.
MCPWM outputs two (or more) PWM signal with matched phases, programmable dead time, etc. Use this if you want to directly control the switch timing of each MOSFET in a half bridge for example.
 
The following users thanked this post: DarkMode

Offline rolerozTopic starter

  • Supporter
  • ****
  • Posts: 8
  • Country: us
Re: ESP32: LEDC PWM or MCPWM when doing simple motor speed control?
« Reply #2 on: July 07, 2023, 07:39:41 am »
It works, thanks
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf