2 Replies Latest reply on Aug 11, 2017 4:38 AM by matija.ponikvar_2031061

    PWM signals with 90° phase shift

    manuel.bayer_2286546

      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