Phase Shifter for square wave..!!

Discussion in 'General Electronics Chat' started by naren_iisc, Mar 19, 2015.

  1. naren_iisc

    Thread Starter New Member

    Jan 13, 2015
    Hello all,

    I have a square wave signal of 50% duty cycle (duty cycle will remain unchanged at any time), but frequency is variable. I want to generate a 90 degree phase shifted output for this square wave. So that I can use these signals (original and phase shifted) as quadrature encoder and measure the frequency of input signal using STM32 discovery board.
    How to do this?
    Thanks in advance.
  2. t_n_k

    AAC Fanatic!

    Mar 6, 2009
    Perhaps a phase locked loop.
  3. MrChips


    Oct 2, 2009
    You didn't state the frequency range.

    Use the STM32DISCOVERY to trigger on the reference signal and measure the frequency (actually measure the period).
    Then use an internal timer to generate the new signal with desired period and phase.
  4. DickCappels


    Aug 21, 2008
    BR-549 likes this.
  5. JWHassler


    Sep 25, 2013
    What's your application, frequency range and jitter tolerance?
    There are many ways to do this, with outcome/effort products ranging from impossible to unnecessary.
  6. crutschow


    Mar 14, 2008
    It's difficult to do a 90 degree phase shift of a variable frequency square-wave.
    The easiest way is to generate a 2X frequency square-wave and use a digital technique for the shift, such as Dick showed.
  7. naren_iisc

    Thread Starter New Member

    Jan 13, 2015
    Thanks for your replies.

    Actually I want to measure the speed of an DC motor. The motor controller IC gives the Tacho output in the form of variable frequency square wave with 50% duty cycle. The frequency range is from 0Hz to 10KHz.

    Problem with using STM32 discovery timer in counter mode is that, for lower freq timer gets overflowed.
  8. naren_iisc

    Thread Starter New Member

    Jan 13, 2015
    @DickCappels thanks for your great idea, but frequencies lower than 270 Hz are also very important for lower speed control. I can not ignore them. Can the frequency range of this be expanded?
  9. bertus


    Apr 5, 2008

    What frequency range would you need?
    In the schematic Dick posted the range of 270 - 4000 is given.
    By changing the capacitor the range can be shifted.

  10. GopherT

    AAC Fanatic!

    Nov 23, 2012
    Just use your ACD and measure the motor's back emf during the zero output on the Pwm. That bEMF will be proportional to rpm.

    See page 4 of this microchip application note.
    Last edited: Mar 19, 2015
    cmartinez likes this.
  11. cmartinez

    AAC Fanatic!

    Jan 17, 2007
    First, you need to define a minimum RPM to be calculated. For instance, if RPM<5 then RPM=0
    The reason for this is that any counter that you use for your application is always going to eventually overflow. After this, you have to select a counting technique. Say for instance, that you choose to use an 8 bit number to define the RPMs being measured, then you can state that your result will have a 0 to 255 range, and since the lowest RPM's that you will measure is >=5 RPM, then if counter=255 then RPM=(256 - 255)*5=5, if counter overflowed to zero, then RPM = 0
    Normally then you would measure any decrements in that integer counter as 5 RPM increments, so that a value of 1 will represent RPM = (256 - 1) *5 = 1,275 . The problem with this technique, is that you will make an incorrect measurement if your motor is going faster than that. But then again, all techniques have that limitation.