Generate complementary/Interleaved PWM signals.

daviddawe1982
Posts: 2
Joined: Wed Jan 09, 2019 12:58 am

Generate complementary/Interleaved PWM signals.

Postby daviddawe1982 » Wed Jan 09, 2019 1:14 am

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);
     

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: Generate complementary/Interleaved PWM signals.

Postby ESP_Sprite » Wed Jan 09, 2019 8:34 am

You may want to look at the MPWM periperial, that should be able to do this entirely in hardware.

daviddawe1982
Posts: 2
Joined: Wed Jan 09, 2019 12:58 am

Re: Generate complementary/Interleaved PWM signals.

Postby daviddawe1982 » Wed Jan 09, 2019 8:38 am

I did try the MCPWM but could not figure out how to phase shift the second channel it would be perfect if I could...

Who is online

Users browsing this forum: No registered users and 131 guests