Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

square wave -->sine using passive bandpass filter

Status
Not open for further replies.

windell747

Mechanical
Jun 16, 2005
64
0
0
US
Hi,

I'm designing a circuit that will take a square wave generated by a microprocessor and feeds it through a bandpass filter to get a sine wave. The application will be to provide a tone for morse code to a handheld ham radio on board a small satellite. Right now im considering remaining simple by using a 1st order passive bandpass filter that uses a capacitor and inductor in series. Assuming this I have a few questions.

1) How should I choose the impedance of the bandpass filter? I do not know the impedance of the GPIO of the microprocessor. Does this impedance matter much?

2) What is the difference between the parallel and series configuration for the passive 1st order bandpass filter?

3) Should I filter more to get a truer sine wave? Any experienced hammers out there? I will be transmitting the morse code tone from a ham radio from a 400km orbit (LEO). I will then feed the tone through a morse decoder to convert the morse to text using a freeware program.

4) Finally, I wanted to use a passive filter to save power, however, I'm open to an active filter that uses an opamp. Are there any advantages to this?

Any guidance would be greatly appreciated!

Thanks,
Windell

4)
 
Replies continue below

Recommended for you

Using an LC filter is not very practical. It will surely get you a clean nice sine. But the gain will be very dependent on the exact frequency of the square wave and the LC components. Also, the L is usually clumsy at these frequencies.

The standard method is to use a two-stage RC low pass filter. One stage will produce audible distortion but two stages usually is fine.

The GPIO (assuming you are referring to I/O on the micro) usually has something like a few tens of ohms internal resistance. So, using kiloohms in the filter is OK.

Assuming (again) that you are going to use 400 Hz, you can use two 2.2 k resistors in series and drop a .47 uF capacitor to gnd fom first junction and from output. That will give you an effective filter that is a little against the school-books, but works.

I/O---2.2k---2.2k---audio out
| |
.47uF .47uF
| |
------------------------ gnd

Increasing .47 uF will make signal cleaner, but also reduce signal strength.

Gunnar Englund
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
 
Thank you for the reply! In using your suggestion, how to I filter out the higher harmonics? Could you direct me to a resource showing me what the cutoff frequencies are for your circuit? Also...what is the gain after the cutoff frequency?

thanks,
windell
 
Hello!

I have used this circuit in a telephone terminal that responds to calls and sends a set of tones to tell things like temperatures and general status in summer houses.

The response is "almost" classical two-pole low pass. I.e. the roll-off is fourty dB/decade. Each section has around 75 Hz -3 dB point and the gain is (75/f)^2. At 400 Hz, that means G=0.035. A 2 V RMS signal in will give you around 70 mV RMS out. That is usually OK as a modulating signal, but it depends on your circuit. A transistor stage may be needed to amplify the signal. Of course, you can also make a two-pole active filter, but that usually is more complex and I got the feeling you wanted to KIS.

The -40 dB/decade means that higher harmonics get attenuated very effectively. There will be only 1/10000th of the 40 kHz and corresondingly less the higher you go in frequency.

Gunnar Englund
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
 
Look at some of the switched capacitor filters from the likes of National or Maxim. With a low frequency of interest like 400Hz you should be able to get a good response with low component count and a really steep rolloff outside the pass band. Here's a couple to get you started:


The Maxim part is limited to quite low frequencies but has a steep 8th order rolloff and uses next to no power from a 5V supply. The National part has much higher maximum working frequency and broader supply range but 'only' a 4th order roll off.


----------------------------------
image.php

If we learn from our mistakes I'm getting a great education!
 
Should I not pass the single through a band pass or is a low pass filter enough? The frequency of interest is 1020Hz or about 1kHz.
 
A low pass is entirely sufficient. There are no frequency components below your 1020 Hz. So no need to filter there. BTW, with 1020 Hz, you should substitute 1 k for 2.2 k.

If anyone wonders, the "raw" circuit does not eliminate parasitic interaction between the two filter sections. So, the filter characteristics are not as taught in school-books. But close enough for this application. The actual characteristics are shown in attached pdf.

Gunnar Englund
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
 
This is wonderful! This might seem a little dumb, but is there a way I can see that there is no components lower than the fundamental frequency of the square wave?

I see the that first couple terms of the fourier transform of the square waves is ....

((4k)/pi)*(sinx+0.33sin3x+0.20sin5x...)

Can the nonexistence of the lower components below 1020Hz be seen by looking at the first term and seeing a coefficient of 1 before the x? Where x =omega=2pi(fundamental frequency)?

And if the coefficient was lower than 1 then there would be lower frequency components?

I apologize, I need to make sure that I can show that a low pass filter is sufficient. I really appreciate your patience!
 
I'll be putting a noninverting amplifier at the end of the double stage filter do make use of the high output impedance of the opamp. Do you think that that will solve the parasitic effects? Also I think you 1000k value isn't correct if a 0.47uF capacitor is used.

Are there any advantages to increasing the resistance vs increasing the capacitance...vice versa?
Thanks
 
Yes, your reasoning regarding the lowest frequency component is correct. There are no components with multipliers below 1.

The parasitic effects have nothing to say in this application. Also, the non-inverting amplifier (if used) shall be between the filter sections. But, as I said, you don't need it.

Attached a version with that buffer amplifier added. As you can see, there's not much difference between the two sets of curves. (Compare to earlier set).

It is wise - if not always necessary - to let the filter work into a high-impedance sink. Like that opamp you are going to add.

Re. the resistors. I chose kohm range because the micro's output impedance can handle low impedance and because the filter is able to drive some load when resistors are low.

If you go to 1000 k (1 Meg) then you should reduce caps to nanofarads instead of microfarads. The f0 of a single filter section is 1/(R*C*6.28) and you should be a bit down on the slope to have effective filtering. When you are in the 1 Meg range, there's some risk that your circuit picks up stray signals. I would keep impedances low. Not much use going higher.

Oh, yes. There is a DC component equal to half the micro's supply voltage. Use a DC block if needed.

Gunnar Englund
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
 
Thanks! to make ease of calculating the correct values I was thinking about using a 2 pole lowpass butterworth filter. I guess TI's filter pro can come up with convinient component values for you. Do you see any disadvantages to this? You will see that I put up a new post asking about this.

I also realize that if I set my cutoff frequency to 1020Hz exactly i will have a sine wave that has a -3dB attenuation comeing out of the filter. I don't want this attenuation so should I choose the next frequency up in the forier series? So the cutoff frequency would now be 3060Hz?

Thanks,
windell
 
I apologize for making a new thread I thought it was a little bit different of an idea, but after thinking about it, it is pretty much the same.

So I guess to get the unattenuated sine wave at 1020Hz and to filter out the DC component, it would probably be best for me to go with an active bandpass filter like a Sallen Keys filter?

Would a single pole be good enough with a Q=10? I don't really have a feel for the Q factor. I'm not sure if it would be better to go up or down...

Thanks,
windell
 
I think that you are getting into waters that may be a bit too deep for you now. If you are a complete beginner in filters, then keep it simple.

One thing that you may be overemphasising is that attenuation. You can easily get rid of it by adjusting the amplification of your buffer amplifier.

The other ting is that if you set your cut off frequency to three times your fundamental, you will still get lots of the harmonics through your filter. Beginning with about 25 % (off top of head) 3060 Hz.

And third, the simple four.component filter I showed first is nothing but a two-pole Butterworth filter. Admittedly with some very small imperfections. But working - and fool-proof.

Gunnar Englund
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
 
Sallen-Key is fine. But a single-pole will not give you the attenuation you need at 3060 Hz. Are there single-pole Sallen-Key filters? Always thought a SK was two-pole?

The Q is the quality factor of a band-pass filter. It is defined as center frequency divided into the bandwidth. In your case, say, 1020/102 = 10. If Q is chosen higher, like 20, your BW will become 1020/20 = 51 Hz. Higher Q -> narrower BW.



Gunnar Englund
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
 
yeah im sorry, I just want to try to follow the books as much as possible because this circuit is being reviewed by other members on my team and I need to make sure that I can analyze everything and not wing anything.

I really like your 2 pole butterworth filter. To filter out the DC component, should I just use a capacitor in series with the output of the microprocessor? Would the capacitor value matter much? I'm guessing that a lower capacitance would be better so that the capacitor acts as a short sooner.

to figure out the gain for the opamp at the end of the filter, should I to a 3dB gain and convert that into what that means in term of voltages using 20*log(v2/v1) where v1 is calculated by -3dB of the voltage of 4(3.3V)/pi?

I appreciate your patience. They dont teach this stuff in books.

windell
 
I guess i was reading that for active filters the number of opamps usually identify the amount of poles in the filter. And for a single pole filter TI's filter pro only comes up with a single op amp so I assumed that a salleen filter with a single opamp was a single pole filter. Of course I could be wrong.
 
A capacitor in series with the link is OK. But, remember that the DC component has to be getting rid of in a short time. This may actually be the trickiest part of the design. Getting the output settled at 1/2*Vdd in shortest possible time. If you can start the square wave with a "half-pulse", that part of the problem gets a lot easier because the mean value settles at 50 % during the first pulse.

The value of the series capacitor depends a lot on what impedance it sees. The capacitor will always act as a short (more or less) it is the time it takes to reach DC equilibrium that is the problem. But, using the "half-pulse" technique, that problem is more easily solved.

Re. number of poles in a filter: It is the number of reactive components in the signal path that determines the order of the filter. In an SK filter, there are two capacitors. Hence, the order is two. And the slope is -40 dB/decade.

Re. gain of filter. Once you get above the f0 frequency and a bit down the slope, you can use the -40 dB/decade characteristic. Like this (get the diagram I posted earlier): draw a straight line along the slope. You will see that it has a -40 dB/decade slope. That means that your output signal is attenuated 40 dB each time you increase frequency ten times. Or, in other words, reduced one hundredth for each decade. Or, is proportional to 1/(f/f0)^2. It is quite simple - and there are text-books about this in hundreds. I am sure you can find one or two in your organisation.



Gunnar Englund
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
 
would it be better if I put the capacitor at the end of the butterworth filter? or how about at the output of the opamp so that there is more current flowing?
 
Don't forget that your "handheld ham radio" (probably NBFM) almost certainly has some audio filtering in the xmit audio and modulator circuits. It's quite likely to have an audio passband of about 300 - 3000Hz or similar.

From the other aborted thread: "... a 1020Hz 3.3V squarewave... ...I would like this sine wave to be attenuated as little as possible. ..." If you're feeding a microphone input on the handheld, then you'd need to attenuate the signal from volts to mV.

Depending on where you are in the design stage, a simpler (less hardware, software is weightless) approach would be to take advantage of the power of modern processors and have the CPU generate a PWM version of the desired sin wave (as well as on-off for the Morse code). Then the filtering within the handheld would probably be all you need.

 
Status
Not open for further replies.
Back
Top