simplefoc / Arduino-FOC

Arduino FOC for BLDC and Stepper motors - Arduino Based Field Oriented Control Algorithm Library
https://docs.simplefoc.com
MIT License
2.03k stars 521 forks source link

[FEATURE] Centre ESP32 LEDC PWM, add dead time and 6-PWM support #273

Closed runger1101001 closed 2 months ago

runger1101001 commented 1 year ago

Looks like LEDC actually allows setting a centre-aligned PWM. See the ledc_timer_config_t field hpoint field, which defines the point at which the PWM switches on. By setting both duty cycle and hpoint we can centre the signal. https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html#_CPPv421ledc_channel_config_t

See also ledc_set_duty_and_update()

If we can centre the signal, we can also introduce dead-time. We have to consider if this can be done in a safe manner, since the channels are not actually complementary. But it should in the end not be different to the software dead-time of the other drivers.

askuric commented 2 months ago

Done in v2.3.4