Higher Motor PWM Frequency?
Posted: Tue May 26, 2020 7:29 pm
I need a complementary PWM with dead time generation of 150 kHz.
Here is a quality graph of the PWM Signal I need. Duty Cycle needs to be 50 % and frequency 150 kHz.
So I thought I use the MCPWM module for that, but I recognized that the maximum frequency is about 2 kHz.
When going higher the duty cycle is shrinking smaller and smaller.
At my desired frequency of 150 kHz the duty cycle is only about 10 %.
I guess the timer reaches its end or the bits are not enougth. Can I set up a timer with wider bits or crank up the timer frequency to be able to produce a higher motor pwm frequency?
Here is my code:
Is there any other possibility to produce a complementary pwm with dead time?
Best regards
Chris
Here is a quality graph of the PWM Signal I need. Duty Cycle needs to be 50 % and frequency 150 kHz.
So I thought I use the MCPWM module for that, but I recognized that the maximum frequency is about 2 kHz.
When going higher the duty cycle is shrinking smaller and smaller.
At my desired frequency of 150 kHz the duty cycle is only about 10 %.
I guess the timer reaches its end or the bits are not enougth. Can I set up a timer with wider bits or crank up the timer frequency to be able to produce a higher motor pwm frequency?
Here is my code:
Code: Select all
ESP_LOGI(TAG, "Init MCPWM");
// Link I/Os to MCPWM module channels
mcpwm_gpio_init(MCPWM_UNIT_0, MCPWM0A, HEAT_HS_1);
mcpwm_gpio_init(MCPWM_UNIT_0, MCPWM0B, HEAT_LS_1);
mcpwm_gpio_init(MCPWM_UNIT_0, MCPWM1A, HEAT_HS_2);
mcpwm_gpio_init(MCPWM_UNIT_0, MCPWM1B, HEAT_LS_2);
//2. initialize mcpwm configuration
mcpwm_config_t pwm_config;
pwm_config.frequency = 500; //frequency = 15 kHz
pwm_config.cmpr_a = 0.0;
pwm_config.cmpr_b = 0.0;
pwm_config.counter_mode = MCPWM_UP_COUNTER;
pwm_config.duty_mode = MCPWM_DUTY_MODE_0;
mcpwm_init(MCPWM_UNIT_0, MCPWM_TIMER_0, &pwm_config); //Configure PWM0A & PWM0B with above settings
pwm_config.duty_mode = MCPWM_DUTY_MODE_1;
mcpwm_init(MCPWM_UNIT_0, MCPWM_TIMER_1, &pwm_config); //Configure PWM1A & PWM1B with other duty mode (negation).
mcpwm_sync_enable(MCPWM_UNIT_0, MCPWM_TIMER_0, 1, 200);
mcpwm_sync_enable(MCPWM_UNIT_0, MCPWM_TIMER_1, 1, 200);
MCPWM0.timer[0].sync.out_sel = 1;
vTaskDelay(100/portTICK_PERIOD_MS);
MCPWM0.timer[0].sync.out_sel = 0;
mcpwm_deadtime_enable(MCPWM_UNIT_0, MCPWM_TIMER_0, MCPWM_ACTIVE_HIGH_COMPLIMENT_MODE, 200, 200); //Deadtime of 20us
mcpwm_deadtime_enable(MCPWM_UNIT_0, MCPWM_TIMER_1, MCPWM_ACTIVE_HIGH_COMPLIMENT_MODE, 200, 200); //Deadtime of 20us
mcpwm_set_duty(MCPWM_UNIT_0, MCPWM_TIMER_0, MCPWM_OPR_A, 50);
mcpwm_set_duty(MCPWM_UNIT_0, MCPWM_TIMER_0, MCPWM_OPR_B, 50);
mcpwm_set_duty(MCPWM_UNIT_0, MCPWM_TIMER_1, MCPWM_OPR_A, 50);
mcpwm_set_duty(MCPWM_UNIT_0, MCPWM_TIMER_1, MCPWM_OPR_B, 50);
Best regards
Chris