ESP32(-S3) LEDC komplementärer Ausgang mit programmierbarer Totzeit-Beispiel
Auf der ESP32-Plattform können Sie den LEDC-PWM-Treiber verwenden, um programmierbare Totzeit zu erzeugen, indem Sie duty (d.h. Impulslänge) und hpoint (Zeitversatz des Impulses) entsprechend setzen.
esp32_ledc_complementary.cpp
#include <driver/ledc.h>ledc_complementary_deadtime_config.cpp
ledc_timer_config_t ledc_timer = {
.speed_mode = LEDC_LOW_SPEED_MODE,
.duty_resolution = LEDC_TIMER_8_BIT,
.timer_num = LEDC_TIMER_0,
.freq_hz = 100000,
.clk_cfg = LEDC_AUTO_CLK
};
ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer));
uint32_t deadTime = 20; // Large value to show clearly on the oscilloscope
ledc_channel_config_t ledc_noninverted_channel = {
.gpio_num = GPIO_NUM_10,
.speed_mode = LEDC_LOW_SPEED_MODE,
.channel = LEDC_CHANNEL_0,
.intr_type = LEDC_INTR_DISABLE,
.timer_sel = LEDC_TIMER_0,
.duty = 127-deadTime/2, // Set duty to 50%
.hpoint = 0
};
ESP_ERROR_CHECK(ledc_channel_config(&ledc_noninverted_channel));
ledc_channel_config_t ledc_complementary_channel = {
.gpio_num = GPIO_NUM_11,
.speed_mode = LEDC_LOW_SPEED_MODE,
.channel = LEDC_CHANNEL_1,
.intr_type = LEDC_INTR_DISABLE,
.timer_sel = LEDC_TIMER_0,
.duty = 127-deadTime/2, // Set cycle to start just after 50%
.hpoint = 127,
};
ESP_ERROR_CHECK(ledc_channel_config(&ledc_complementary_channel));
Check out similar posts by category:
ESP8266/ESP32
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow