Page 1 of 1

Generate complementary/Interleaved PWM signals.

Posted: Wed Jan 09, 2019 1:14 am
by daviddawe1982
Hello,
I am in the process of getting away from Arduino and have been porting my project to eclipse.
What I am currently stuck on is complementary PWM signals.
What I need is a pair of output's on the same timer but I need them to run opposite to each other.
Image
I'm using it to drive an H-Bridge that's connected to a transformer. DC to AC.
I have it working with the code below, but what I would like is to be able to set the timer to 50Hz then just adjust the duty cycle.
The code below is ugly and would have period drift.
Just looking for some hints and help.
Thank you.

Code: Select all

	gpio_set_level(Apin, 0);
        gpio_set_level(Bpin, 0);
        vTaskDelay(5 / portTICK_PERIOD_MS);
        gpio_set_level(Apin, 1);
        vTaskDelay(5 / portTICK_PERIOD_MS);
        gpio_set_level(Apin, 0);
        gpio_set_level(Bpin, 0);
        vTaskDelay(5 / portTICK_PERIOD_MS);
        gpio_set_level(Bpin, 1);
        vTaskDelay(5 / portTICK_PERIOD_MS);
     

Re: Generate complementary/Interleaved PWM signals.

Posted: Wed Jan 09, 2019 8:34 am
by ESP_Sprite
You may want to look at the MPWM periperial, that should be able to do this entirely in hardware.

Re: Generate complementary/Interleaved PWM signals.

Posted: Wed Jan 09, 2019 8:38 am
by daviddawe1982
I did try the MCPWM but could not figure out how to phase shift the second channel it would be perfect if I could...