Phase Shifter for square wave..!!

Thread Starter

naren_iisc

Joined Jan 13, 2015
21
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.
 

MrChips

Joined Oct 2, 2009
30,712
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.
 

JWHassler

Joined Sep 25, 2013
306
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.
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.
 

crutschow

Joined Mar 14, 2008
34,284
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.
 

Thread Starter

naren_iisc

Joined Jan 13, 2015
21
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.
 

Thread Starter

naren_iisc

Joined Jan 13, 2015
21
@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?
 

bertus

Joined Apr 5, 2008
22,270
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
 

GopherT

Joined Nov 23, 2012
8,009
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.
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.

http://ww1.microchip.com/downloads/en/AppNotes/00000893B.pdf
 
Last edited:

cmartinez

Joined Jan 17, 2007
8,220
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.
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.
 
Top