# High Pass Filter of a square wave

Discussion in 'The Projects Forum' started by cptott, Nov 25, 2008.

1. ### cptott Thread Starter New Member

Nov 25, 2008
2
0
My input is a 0-5V, 5Hz to 1kHz square wave and frequencies less than 300Hz need to be blocked. The frequencies greater than 300Hz need to be latched such that the output is always high while the input frequency is greater than 300Hz. In summary, if the input frequency is less than 300Hz then the output must be 0V and if the input frequency is greater than 300Hz then the output must be 5V.

I am having difficulty filtering the square wave using a low cost solution.

I have tried a Sallen and Key high pass filter, passive high pass filter, and a single non-inverting high pass filter. With all of these filters, the sharp rising edge of the square wave is passed by the filter even when the square wave is at frequencies as low as 5Hz.

I currently am running my input through two active inverting high pass filters in series and that signal is then input into a pulse detector circuit with a 555 timer. This works, but I would like to minimize the number of components in the circuits by using a different filter technique.

Any one have good experience with high pass filters and square waves that could help me out?

Regards,
Chris

2. ### beenthere Retired Moderator

Apr 20, 2004
15,808
295
Ideally, it would be great to just count the square wave and determine the output by the counted frequency. Getting a really accurate filter response to determine above or below 300 Hz with a square wave is a challenge.

3. ### nop New Member

Nov 26, 2008
5
0
Your filters don't work because a square wave is composed of higher frequency components as opposed to a sine wave. Even at lower frequencies, if it is a square wave it will have higher frequency components to it that will pass through the filter; look up Fourier Series. You might be able to do it your way still, but you will have to attenuate your signal through the filter so that the frequency components that do pass through won't trip the detection circuit (that is probably what is happening with you running your signal through two high-pass filters). Or you might consider a circuit that will measure the period of the input or use a microcontroller to detect the signal.

4. ### mik3 Senior Member

Feb 4, 2008
4,846
70
You can use a low pass filter rather a high pass filter to do it. Set the low pass filter at 300 Hz. When the output of the low pass filter low (below a value-high frequencies) then the output will latch and when the output of the low pass filter is high (above a value-low frequencies) the output will reset. You can use a comparator to detect this voltage levels.
By using a low pass filter you eliminate the problem with the high frequency harmonics Nop mentioned.

5. ### SgtWookie Expert

Jul 17, 2007
22,201
1,809
I think I'd use an RC differentiator circuit to just allow the leading edge of the square wave to pass, and then use a missing pulse detector running at 300Hz to determine if the PRT of the leading edge was less than or greater than 300Hz.

From there, run the output of the missing pulse detector through an inverter to trigger a monostable multivibrator (one-shot) that has a 3.4mS pulsewidth output. A 556 timer could likely take care of both the missing pulse detector and the mmv; an NPN transistor could be used for an inverter. The differentiator would be a series input capacitor, then a fairly low-value resistor to ground. A diode clamp will take care of the falling-edge spike. You'll need to know the rise time of your input waveform to figure out the values of R and C, or you could just use a trim pot and "tweak" it in.

Your net propagation delay would be roughly 3.4mS, but you'd probably wind up with that no matter what solution you came up with.

I'm afraid that filters won't get it done for you. Square waves are the sum of all of the odd harmonics of a fundamental frequency. Since your range is 5Hz to 1kHz, your filter would have to have a "brick wall" response. Such filters can be very complex and difficult to tune properly.

Last edited: Nov 26, 2008
6. ### cptott Thread Starter New Member

Nov 25, 2008
2
0
Thank you all for your help. I ended up using Sgt Wookie's suggestion and I am able to get the circuit to work properly in the range of 267 Hz to 330 Hz over temperature using low tolerance components and a PPS capacitor for the timing on the 555 timer.

Works great.