4 PWM signals of 20kHz frequency

I want to generate 4 PWM signals of 20kHz and 50% duty cycle, at four different pins . There should be a controllable phase shift or delay between two of them. I am attaching a pic of the required signals for better explanation. I am using arduino nano.
The process as I see it, first we have to generate 2 PWM signals of 20kHz and 50% duty cycle. Next we have to introduce a phase shift between them.
Then complimentary PWM signals can be taken from the original and the delayed signal.
Thanx in advance. Any help is much appreciated.

You'll need a more advance MCU than the Atmega328P on the Arduino if you want to do this in hardware

You'll want something with advanced timers with the following features

  • dead-time insertion
  • complimentary outputs

I think the SAMD21 on the Arduino Zero can do it. You might have to write the driver for it...

I dont want arduino to generate the dead band. And for the complimentary signals, i can make do without that as well. I can use normal inverter ic to get the complimentary signal.
But what i do want is two square pulses with some phase differences between them. If i can adjust the phase difference that is even better.
See the picture of required waveform.

Thanks a ton for helping.

Pwm.pdf (152.1 KB)

Which Arduino do you have? You might be able to get away with a Mega but not an R3. There's just not enough timers on the R3 to do this reliably

I have arduino nano. I can make do if i can generate just two square waves with some phase difference between them.

The thing is, you need two timers to create a PWM signal independently with a phase difference. You can't use two channels on the same timer since you wont be able to implement a phase shift.

The Nano only has three timers

8 bit TIM0
16 bit TIM1
8 bit TIM2

I suppose you can disable millis() use use TIM0 and TIM2

If ATmega328 is just for those signals, maybe its possible with uses of only 1 timer interrupt and software generated signals with port manipulation. Its just idea.