Sync LEDC and MCPWM?
Posted: 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.
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.