square wave -->sine using passive bandpass filter
square wave -->sine using passive bandpass filter
(OP)
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)
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)





RE: square wave -->sine using passive bandpass filter
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
www.gke.org
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
RE: square wave -->sine using passive bandpass filter
thanks,
windell
RE: square wave -->sine using passive bandpass filter
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
www.gke.org
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
RE: square wave -->sine using passive bandpass filter
http://www.national.com/mpf/LM/LMF100.html
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1957
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.
----------------------------------
If we learn from our mistakes I'm getting a great education!
RE: square wave -->sine using passive bandpass filter
RE: square wave -->sine using passive bandpass filter
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
www.gke.org
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
RE: square wave -->sine using passive bandpass filter
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!
RE: square wave -->sine using passive bandpass filter
Are there any advantages to increasing the resistance vs increasing the capacitance...vice versa?
Thanks
RE: square wave -->sine using passive bandpass filter
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
www.gke.org
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
RE: square wave -->sine using passive bandpass filter
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
RE: square wave -->sine using passive bandpass filter
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
RE: square wave -->sine using passive bandpass filter
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
www.gke.org
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
RE: square wave -->sine using passive bandpass filter
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
www.gke.org
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
RE: square wave -->sine using passive bandpass filter
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
RE: square wave -->sine using passive bandpass filter
RE: square wave -->sine using passive bandpass filter
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
www.gke.org
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
RE: square wave -->sine using passive bandpass filter
RE: square wave -->sine using passive bandpass filter
RE: square wave -->sine using passive bandpass filter
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.
RE: square wave -->sine using passive bandpass filter
Thanks,
windell
RE: square wave -->sine using passive bandpass filter
TTFN
FAQ731-376: Eng-Tips.com Forum Policies
RE: square wave -->sine using passive bandpass filter
Right now my circuit looks like the following.
two passive low pass filters cascaded (thanks Skosgurra)...
then a voltage divider at the end to attenuate the signal down to 5mV
then a voltage follower
then a capacitor in series with the output of voltage follower.
I have a couple questions...
1) would it be fine to put a capacitor with a really small capacitance at the output of the opamp to filter out the DC components? Does the value of the capacitor matter much?
2)What would be the best way to determine the values for the components in the lowpass filters? I know that the equation is f0=1/(2piRC) but that leaves a large number of combonations for R and C.
3) The impedance requirement for the mic specifided by the radio's documentation is 2000ohms. How do I maintain this requirement with the capacitor at the end of the voltage follower? I do know the impedance of the output of the opamp and it is about 30ohms.
I appreciate the help!
Thanks,
Windell
RE: square wave -->sine using passive bandpass filter
You do not need the attenuator to get the right output level (the 5 mV). Just make your low pass filter (the two RC links) output that voltage. You do that by adjusting the f0 to get the right output level. That gives you optimum filtering action as well.
You do not need the opamp or voltage follower. It is possible to select components in the filter so that your output impedance is around 2 kohms. An exact fit is not necessary. Usually, anything "kilohmish" will work.
We have been doing this for quite a while now and I appreciate the way you try to grasp the material. So, I have made a short run with data that should satisfy your requirements. Input is 3.3 V 50 % 1020 Hz square from a micro. Output is around 6 mV at around 2 kohms (a little lower actually, because of source impedance being quite low).
Gunnar Englund
www.gke.org
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
RE: square wave -->sine using passive bandpass filter
windell
RE: square wave -->sine using passive bandpass filter
Instead of using a square wave out of your microprocessor at the desired fundamental frequency, try PWM'ing a higher frequency pulse output with a modulation of the desired sinewave. This will help reduce the amount of effort requried by the filter. As I understand it, the technique is commonly used in PWM inverters to generate a low frequency sinewave.
RE: square wave -->sine using passive bandpass filter
A much better approach
Gunnar Englund
www.gke.org
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
RE: square wave -->sine using passive bandpass filter
http://w
RE: square wave -->sine using passive bandpass filter