Loading...
Pages: [1]   Go Down
Author Topic: Phase shift PWM signals  (Read 396 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it possible to phase shift two PWM signals 90 degrees, without using delays?

Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I had thought about this a few days ago, in some context that might sound very idiotic,

But i think, if we have 2 separate microcontrollers, or arduinos, communicating through serial or through some other interface like I2C,
we can have a phase shift between the PWM signals.

I havent actually tried doing this, and i just *think* this might work. It might also sound idiotic, but i am kinda new here.

Regards
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 269
Posts: 25392
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I havent actually tried doing this, and i just *think* this might work
No way can you make that work.

As the PWM is based on the timers if you take two timers and set them to run at the same frequency then it might be possible. However setting the initial offset could be tricky.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I succeed. In datasheet: .
Set two PWM signals:
- First PWM channel CALG = 0 (left aligned) with freqA (running on CLKA)
- Second PWM channel CALG =1 (center aligned) with freqB (running on CLKB)

The center aligned period is twice as long as the left aligned. If we take freqB = freqA *2 we get a phase shift of 90 degrees. Note: This works a duty cycle of 50% only ( I use it to generate encoder pulses).


Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 71
Posts: 6806
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The SAM also has a PWM engine that will (I think) produce synced waveforms out of phase. As I understand it any PWMLx and PWMHx pair will do this but it's not supported by the Arduino libraries so you'll have to cut your own driver code.

______
Rob
Logged

Rob Gray aka the GRAYnomad http://www.robgray.com

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 269
Posts: 25392
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Note: This works a duty cycle of 50% only ( I use it to generate encoder pulses).
Yes it is easy to do things when you do not do them correctly or only approximate what is being asked for.
Logged

Pages: [1]   Go Up
Print
 
Jump to: