Hello, I'm trying to phase shift two PWM pins on the same timer, but also I need to have high frequency PWM (60 -140 kHz) and to be able to vary duty cycle. For now I just need phase shift of 180° but it would be also nice if i could control angle. Any ideas? Thanks in advance!
The toneAC library uses Timer1 and pin 9 and 10 for an Arduino Uno. It can easily do 140kHz. It is a normal signal 50% PWM with normal and inverted signal.
I think that for a phase shift and adjustable PWM you have to do that in software in a interrupt. I'm not sure about it. The 140kHz and adjustable PWM and phase shift will not work with an Arduino Uno. You probably need extra hardware for that. Perhaps someone else has a good idea how to do that.
You don't tell which arduino board you are actually using. If you consider an arduino DUE, you can easily have 2 synchro PWM,phase shifted of 180°,and vary constantly their duty cycle.
Sorry, I forgot to mention that I'm using Arduino UNO.
Arduino Uno has 3 timers. I think it is impossible to have phase shift between 2 channels of the same timer unless you want to do it via interrupts. If you can afford to use one timer for each channel it is possible.
(Using "toggle on compare match" feature of a non-PWM mode will give you selectable angle but only 50% duty of the signals).