Sync LEDC and MCPWM?

michamorg
Posts: 2
Joined: Fri Mar 01, 2024 3:30 pm

Sync LEDC and MCPWM?

Postby michamorg » Fri Mar 01, 2024 4:42 pm

Hi
I consider using esp32 as a MC for a new project. I've never used esp32 before. I've used arduino before and I'm pleased to find a MC that seems to be so similar to arduino, while having so much better specs in every aspect.

However I'm not sure if the esp32 will fill my needs for this project. What I need is to control a motor, while generating pulses to trigger samples from sensors that are phase shifted from the motor control signals. The esp32 has a MCPWM that seems to be perfect for the motor control (6 pwm signals). And it has the LEDC that seems to be perfect to trigger sampling from the sensors (needs 3 pwm signals). From documentation I've found that LEDC pwm signals can be phase shifted by changing the Hpoint value. Also the 6 (3 pairs) pwm signals from MCPWM are easily phase shifted.

What I haven't been able to figure out is: is there some sort of synchronization / phase shift ability between the MCPWM and LEDC signals? From the documentation it looks to me that MCPWM and LEDC cannot use the same timer. But MCPWM does have a sync signal input. Could one of the LEDC signals be used as a sync-input to the MCPWM timer? If so, how would that work out when the motor speed (pwm frequency) is changed? Is there a way to update frequency of both MCPWM and LEDC at the same time?

Expected pwm frequency is in the range 500-2000Hz under normal operation, and 0-2000Hz during start/stop.

lbernstone
Posts: 673
Joined: Mon Jul 22, 2019 3:20 pm

Re: Sync LEDC and MCPWM?

Postby lbernstone » Sat Mar 02, 2024 4:41 pm

I can't directly answer your question, as I have never done what you are asking. But I will ask why you would change the frequency to control the speed? The idea of PWM is to change the duty cycle (the number of pulses sent per timer cycle), rather than the frequency of the carrier signal.

michamorg
Posts: 2
Joined: Fri Mar 01, 2024 3:30 pm

Re: Sync LEDC and MCPWM?

Postby michamorg » Sat Mar 02, 2024 7:21 pm

Because it's 3-phase. Both frequency and duty cycle will be adjusted in order to control speed and torque. For the same reason it's important to know/adjust the phase offset between all 9 signals.

In case the answer to the question about sync LEDC to MCPWM is a no, is there any way to sync MCPWM to MCPWM on another esp32? (Could I utilize the MCPWM on two ESP32's to get a total of 9 pwm signals with a known/adjustable phase offset?)

Who is online

Users browsing this forum: No registered users and 122 guests