×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

square wave -->sine using passive bandpass filter

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)

RE: square wave -->sine using passive bandpass filter

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
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

(OP)
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

RE: square wave -->sine using passive bandpass filter

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
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

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:

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

(OP)
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.

RE: square wave -->sine using passive bandpass filter

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
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

(OP)
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!

RE: square wave -->sine using passive bandpass filter

(OP)
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

RE: square wave -->sine using passive bandpass filter

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
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

(OP)
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

RE: square wave -->sine using passive bandpass filter

(OP)
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

RE: square wave -->sine using passive bandpass filter

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
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

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
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

(OP)
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

RE: square wave -->sine using passive bandpass filter

(OP)
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.

RE: square wave -->sine using passive bandpass filter

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
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

(OP)
Thanks, I really appreciate it!

RE: square wave -->sine using passive bandpass filter

(OP)
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?

RE: square wave -->sine using passive bandpass filter

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.

 

RE: square wave -->sine using passive bandpass filter

(OP)
Thanks VE1BLL. I was once told about the passband filter within the radio. I wasn't sure if I should just assume that this already exists in the radio. The radio is the VX3R. Is there any way I can look this up for sure?

Thanks,
windell

RE: square wave -->sine using passive bandpass filter

(OP)
is there any freeware that you may know of that I can use to simulate the performance of my filtering circuit? I don't have the radio with me as I'm on vacation from the lab so I don't have a chance to do some testing of the audio quality of sending a square wave into the mic input of the radio. To be safe ill include the lowpass filter just in case. I'll include a bypass in the circuit that can skip over it if it is sufficient to just send the square wave into the mic input.

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

OK. At last, we got something that looks like a specification.

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

(OP)
thanks,

windell
 

RE: square wave -->sine using passive bandpass filter

Here is an idea that might be of benefit that approaches the problem from a different perspective.

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

I second that, Noway!

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

How about a D2A converter, a tone generator from a phone or an oscilator going to an op-amp with an enable?
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources