Complementary PWM signals on Timer 0, with dead time

Hi there,

I would like to generate complementary PWM outputs signals (with dead-time) on Arduino Uno, from pin5 and pin6, which are connected to Timer 0.

I am using Matlab/Simulink, and in the Hardware > Hardware settings > Code generation > Custom code > Initialise function, I write:

TCCR0B = TCCR0B & B11111000 | B00000001; // PWM 7812.50Hz on pin 5
TCCR0A = 0b10110000 | (TCCR0A & 0b00001111); // pin 6

this is the simulation

and this is the result I get (which is fine, i.e., frequency is 7.8125kHz and PWM out of pin6 is opposite of pwm out of pin5, but no dead-time between pwm's as yet)

The issue occurs when I try to generate a dead-time between the two pwm signals, i.e., I need them to be both low for a short period of time when their status changes.

To work around this, I setup the model in the following way:

and this is the result I get, where the dead-time is generated, but only on one of the edges (i.e. when blue pwm goes down, yellow pwm goes up immediately with no deadtime):

.

Note that, if I set-up pin 9 and 10 using these lines of code:

TCCR1B = TCCR1B & B11111000 | B00000001; // PWM 31372.55 Hz pin9
TCCR1A = 0b10110000 | (TCCR1A & 0b00001111); // pin 10 inverse of pin9,

and using a similar simulation to get the deadtime generation, where one pwm duty cycle (to pin 9) is slightly lower than the other one (to pin 10), the deadtime generation seems to work fine

In summary, would be good to know if anyone knows a way to generate a PWM signal with dead-time, using pin 5 and 6 connected to timer0, and at 7.8 kHz.

Thanks

1 Like

So what's your problem?

On a real µC you should not touch T0 because it's used for system timing. For deadtime generation use Phase Correct PWM mode.

can any 2 pwm pins generate complementary signals at about 7kHz, and with dead-time? and if so, what is the code to do that? (sorry, I have no experience with writing code to change the register/timer settings, and I thought someone in thus forum could help).
cheers

There is a forum section for paid assistance. If you want to learn about the Arduino hardware then specify which controller and what you already have read about the timer registers.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.