PWM signals with 90° phase shift

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi,

   

i am trying to build an encoder signal generator, with A-, B-, and Z- signal.

   

The square wave frequency of the the A-, B- signals should be adjustable while running the signal generator (max. 1MHz).

   

My problem is to create square waves, that are shifted 90° degrees to each other.

   

I tried it with two PWM UDB blocks:

   

PWM block 1: I configured a dual Output PWM, where the first output is a 50% duty cycle PWM (A-Signal) and the second output a 75% duty cycle PWM. 

   

PWM block 2: Configured as 50% duty cycle PWM (B-Signal). The start trigger input of PWM Block 2 is connected to the second output of PWM block 1 (75% duty cycle).  

   

When i measure the phase shift between A- and B- Signal it will be near 90° (frequencies lower than 100kHz), but when i increase the frequency (1MHz) the phase shift between A- and B- signal drifts away to 100°.

   

 

   

By the way:

   

i read in the values of a qudrature encoder, these values are used to set the periods of the PWM blocks, so i can adjust the PWM frequencies. 

   

For example:

   

quadrature encoder value: 32

   

PWM block 1 period: 32

   

PWM block 1 compare value 1: 16

   

PWM block 1 compare value 2: 24

   

PWM block 2 period: 32

   

PWM block 2 compare value 1: 16

   

 

   

Does anyone know why the phase shift between A- and B-signal increases with higher frequencies?

   

Is there a better way to implement a encoder signal generator, maybe without PWM? 

   

 

   

Sincerly,

   

manuel

0 Likes
1 Solution
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

manuel, try DDS24 signal generator to make arbitrary frequency and phase:

   

http://www.cypress.com/forum/psoc-community-components/dds24-24-bit-dds-arbitrary-frequency-generato...

Alternative simple method to produce quadrature signals is here: https://youtu.be/OL52f-k3iIE   

View solution in original post

0 Likes
2 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

manuel, try DDS24 signal generator to make arbitrary frequency and phase:

   

http://www.cypress.com/forum/psoc-community-components/dds24-24-bit-dds-arbitrary-frequency-generato...

Alternative simple method to produce quadrature signals is here: https://youtu.be/OL52f-k3iIE   
0 Likes
Anonymous
Not applicable

I used a single PWM block with double output, and adjusted the compare to "Equal" for both. The invert was done by two additional flip-flow blocks. See screenshot.

   

 

   

Regards,

   

Matija