Generate complementary/Interleaved PWM signals.
Posted: 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.
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.
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.
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);