# 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
21
0
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?

2. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
783
Perhaps a phase locked loop.

3. ### MrChips Moderator

Oct 2, 2009
12,635
3,454
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 Moderator

Aug 21, 2008
2,772
669
BR-549 likes this.
5. ### JWHassler Member

Sep 25, 2013
204
34
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 Expert

Mar 14, 2008
13,501
3,375
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
21
0

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
21
0
@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?

Apr 5, 2008
15,802
2,388
Hello,

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.

Bertus

10. ### GopherT AAC Fanatic!

Nov 23, 2012
6,312
4,031
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.