Square wave to psuedo-sine wave?

I'm trying to come up with a filter or converter that takes a square wave input and outputs something closer to a sign wave (varying between ~1.9kHz and 2.1kHz). It can have some distortion, but I'm trying to eliminate the sharp leading and trailing edge. One option I'm pursuing is a bandpass filter (2 caps and 2 resistors), which looks to give a reasonable output, but still not quite as smooth as I'd like. I've also considered using a counter feeding a bank of resistors, but finding a method for it to start counting up with it hits 0 and down when it hits the high value might be more difficult.

Originally, I had used a wein-bridge oscillator with op-amps to make the sine wave, but due to the environment, EMI was a problem and it damped out the oscillations (even with ferrite beads and modest shielding). So I'd like to avoid using op-amps (since they are apparently sensitive to EMI) if possible.

Any suggestions?

Thanks in advance! Dave

Reply to
dave.harper
Loading thread data ...

Use a 4017 counter, plus resistors.

Or, there are some nice 5-pole analog filters out there. Not cheap, but they'll do ya.

You could implement an up/down counter in a PAL. Doing it so that it up/down counts properly shouldn't be too hard.

Or use one of the myriad itty bitty processors out there -- PIC, AVR, whatever.

--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
Reply to
Tim Wescott

A lowpass filter is appropriate. You're trying to kill the higher (odd) harmonics but there's no signal below the fundamental, excepting DC maybe.

A dual-stage RC lowpass would be pretty good, if you set the -3 dB point around 2 KHz. A higher-order filter, active or LC, would be even better. An LC filter isn't unreasonable at 2 KHz.

John

Reply to
John Larkin

Start with a triangle wave, there are less harmonics to filter out. How bad is the EMI? I like the Wein-bridge. Try using an FET opamp for it. The only problem I've had with the wien bridge was motor- boating of the frequency. This was finally solved by using good low dissipation caps. (Ohh I have seen EMI fuzz.. but only with BJT opamps.)

George H.

Reply to
George Herold

One possibility is to use a digital filter. These have very sharp roll-offs (e.g. 8th order for MAX292), you basically feed the clock of the filter with a multiple of the fundamental frequency of the filter (say 64x), and the output is a very pure sine wave. The beauty of this is the amplitude of the output is independent of frequency and you don't have to change filter components:

formatting link

Another solution is using a multiplexor to create an approximate sine wave using an 8x clock followed by a filter (the example below uses a pair of cascaded 2nd order filters). This may suit you better:

formatting link

Mark.

Reply to
markp

Function generator. Integrate square wave to get triangle wave. Shape triangle wave to sine wave using a couple of diodes. See

formatting link

Dan

Reply to
dcaster

Function generator. Integrate square wave to get triangle wave. Shape triangle wave to sine wave using a couple of diodes. See

formatting link

** Contrary to the OP's wishes, that POS uses op-amps.

Have you seen the ugly " sine" wave it produces ??

The diodes will rectify the RF energy.

Not even a starter.

... Phil

Reply to
Phil Allison

Think "Johnson counter" or "switchtail counter". CD4018 IIRC for example.

Also you can use the counter to drive a 4051 analog MUX. This way you can pick off the voltages at points on the sine curve to make a step like sine function. With the MUX method you can get the 3rd and 5th harmonics down to near zero. Stripping out the 7th is a lot easier than the

3rd.

Reply to
MooseFET

formatting link

--
Many thanks,

Don Lancaster                          voice phone: (928)428-4073
Synergetics   3860 West First Street   Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml   email: don@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com
Reply to
Don Lancaster

Contrary to what you think, the OP seems like he would be happy with a sine wave with only 1% distortion. The diodes will rectify RF but at the output the signal level should be several orders of magnitude higher than the RF. So would not expect that to be a problem. The reference to the kitsrus was to show one implementation that had an explanation of the circuit.

=20 Dan

Reply to
dcaster

I would make a five pole elliptic low pass active filter breaking at about 3 kHz with a deep 80 dB notch at the third harmonic of 6 kHz. This is a dual op amp (2 section) solution and uses a small number of resistors and caps. You should be able to attenuate all of the harmonics at least 80 dB leaving a pretty good sine wave.

Reply to
Bob Eld

dave.harper schrieb:

Hello,

a Wien-Robinson bridge oscillator needs a good amplitude stabilisation. If the amplification is to low, the oscillations will damp out. I guess there was something wrong with your amplitude stabilisation.

Bye

Reply to
Uwe Hercksen

Parallax invented the ultimate in mind-numbingly simple sinewave generators many years ago. SIX BYTES !!! of working code on a PIC!!!!

Start with page 85.3 of

formatting link

--
Many thanks,

Don Lancaster                          voice phone: (928)428-4073
Synergetics   3860 West First Street   Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml   email: don@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com
Reply to
Don Lancaster

Here is minimal solution:

formatting link

This filter makes for about 0.65% of THD; it is probably as good as it could be done in reality with this number of components.

Vladimir Vassilevsky DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

No, I used non-linear feedback (diodes) and it worked like a champ. O- scope showed a nice, rounded, stable wave with no clipping. It was only when the nearby transmitter was turned on, the oscillations damped out.

Dave

Reply to
dave.harper

I modeled a few low pass filters, and think this is the best solution. I have 3 RC low-pass filters and the output looks relatively sine-like. Thanks to everyone that provided good suggestions! Here's the schematic in LTSpice (comments appreciated):

Version 4 SHEET 1 1476 680 WIRE 592 -608 0 -608 WIRE -80 -528 -160 -528 WIRE -80 -496 -80 -528 WIRE -160 -464 -160 -528 WIRE 464 -368 32 -368 WIRE 144 -304 80 -304 WIRE 80 -256 80 -304 WIRE 144 -240 144 -304 WIRE 160 -240 144 -240 WIRE 416 -240 416 -256 WIRE 416 -240 384 -240 WIRE -160 -176 -160 -400 WIRE 0 -176 0 -608 WIRE 0 -176 -160 -176 WIRE 160 -176 0 -176 WIRE 464 -176 464 -368 WIRE 464 -176 384 -176 WIRE -592 -144 -592 -192 WIRE -544 -144 -592 -144 WIRE -432 -144 -464 -144 WIRE -352 -144 -352 -192 WIRE -352 -144 -432 -144 WIRE -352 -112 -352 -144 WIRE 160 -112 96 -112 WIRE 592 -112 592 -608 WIRE 592 -112 384 -112 WIRE -592 -96 -592 -144 WIRE -432 -96 -432 -144 WIRE 32 -96 32 -368 WIRE 32 -96 -160 -96 WIRE 160 -48 144 -48 WIRE 448 -48 384 -48 WIRE -592 16 -592 -16 WIRE -432 16 -432 -16 WIRE -352 16 -352 -48 WIRE 448 16 448 -48 WIRE -160 32 -160 -16 WIRE 144 32 144 -48 WIRE 144 32 -160 32 WIRE 144 80 144 32 WIRE 208 80 144 80 WIRE 448 128 448 80 WIRE 96 160 96 -112 WIRE 96 240 -64 240 WIRE -64 256 -64 240 WIRE 96 288 96 240 WIRE -64 336 -224 336 WIRE -224 352 -224 336 WIRE -64 384 -64 336 WIRE -224 432 -384 432 WIRE -224 480 -224 432 FLAG -592 16 0 FLAG 80 -256 0 FLAG -592 -192 +5V FLAG 416 -256 +5V FLAG -352 16 0 FLAG -432 16 0 FLAG -352 -192 +2.5V FLAG 448 128 0 FLAG -80 -496 0 FLAG 208 80 +5V FLAG -64 448 0 FLAG 96 352 0 FLAG -224 544 0 SYMBOL voltage -592 -112 R0 WINDOW 123 0 0 Left 0 WINDOW 39 0 0 Left 0 WINDOW 0 -66 54 Left 0 WINDOW 3 47 51 Left 0 SYMATTR InstName V1 SYMATTR Value 5 SYMBOL res -560 -128 R270 WINDOW 0 32 56 VTop 0 WINDOW 3 0 56 VBottom 0 SYMATTR InstName R6 SYMATTR Value 1k SYMBOL res -448 -112 R0 SYMATTR InstName R7 SYMATTR Value 1k SYMBOL polcap -368 -112 R0 SYMATTR InstName C3 SYMATTR Value 10=B5 SYMBOL Misc\\NE555 272 -144 R0 SYMATTR InstName U1 SYMBOL cap 432 16 R0 SYMATTR InstName C1 SYMATTR Value 10nF SYMBOL res -176 -192 R0 SYMATTR InstName R2 SYMATTR Value 33500 SYMBOL res -176 -112 R0 SYMATTR InstName R1 SYMATTR Value 1000 SYMBOL cap -176 -464 R0 SYMATTR InstName C2 SYMATTR Value .01=B5F SYMBOL cap -80 384 R0 SYMATTR InstName C4 SYMATTR Value .08=B5F SYMBOL res -80 240 R0 SYMATTR InstName R3 SYMATTR Value 1000 SYMBOL cap 80 288 R0 SYMATTR InstName C10 SYMATTR Value .08=B5F SYMBOL res 80 144 R0 SYMATTR InstName R8 SYMATTR Value 1000 SYMBOL cap -240 480 R0 SYMATTR InstName C11 SYMATTR Value .08=B5F SYMBOL res -240 336 R0 SYMATTR InstName R12 SYMATTR Value 1000 TEXT -648 -472 Left 0 !.tran 0 5ms 0 1u TEXT -648 -432 Left 0 !.ic V(in1)=3D2.7 TEXT -648 -512 Left 0 ;555 Radio Modem

Reply to
dave.harper

An inductor really does make a big difference for these kind of jobs and only costs pennies. I've tacked on an LC filter to your drawing. Output is 5Vpkpk sine at very low distortion. (filter is a 3rd order, Chebyshev, low pass, with 6db passband ripple and a Zero notch at 6kHz. Components rounded to preferred values) [replacement for LTlist...]

Version 4 SHEET 1 1748 680 WIRE -80 -528 -160 -528 WIRE 592 -528 0 -528 WIRE -80 -496 -80 -528 WIRE -160 -464 -160 -528 WIRE 464 -368 32 -368 WIRE 144 -304 80 -304 WIRE 80 -256 80 -304 WIRE 144 -240 144 -304 WIRE 160 -240 144 -240 WIRE 416 -240 416 -256 WIRE 416 -240 384 -240 WIRE -160 -176 -160 -400 WIRE 0 -176 0 -528 WIRE 0 -176 -160 -176 WIRE 160 -176 0 -176 WIRE 464 -176 464 -368 WIRE 464 -176 384 -176 WIRE -592 -144 -592 -192 WIRE -544 -144 -592 -144 WIRE -432 -144 -464 -144 WIRE -352 -144 -352 -192 WIRE -352 -144 -432 -144 WIRE -352 -112 -352 -144 WIRE 160 -112 96 -112 WIRE 592 -112 592 -528 WIRE 592 -112 384 -112 WIRE -592 -96 -592 -144 WIRE -432 -96 -432 -144 WIRE 32 -96 32 -368 WIRE 32 -96 -160 -96 WIRE 160 -48 144 -48 WIRE 448 -48 384 -48 WIRE 448 -32 448 -48 WIRE -592 16 -592 -16 WIRE -432 16 -432 -16 WIRE -352 16 -352 -48 WIRE -160 32 -160 -16 WIRE 144 32 144 -48 WIRE 144 32 -160 32 WIRE 848 48 784 48 WIRE 960 48 912 48 WIRE 448 64 448 32 WIRE 144 80 144 32 WIRE 208 80 144 80 WIRE 96 128 96 -112 WIRE 128 128 96 128 WIRE 576 144 560 144 WIRE 640 144 576 144 WIRE 784 144 784 48 WIRE 784 144 720 144 WIRE 832 144 784 144 WIRE 960 144 960 48 WIRE 960 144 912 144 WIRE 1104 144 960 144 WIRE 1152 144 1104 144 WIRE 96 160 96 128 WIRE 1104 224 1104 144 WIRE 96 240 -64 240 WIRE -64 256 -64 240 WIRE 784 256 784 144 WIRE 960 256 960 144 WIRE 96 288 96 240 WIRE -64 336 -224 336 WIRE -224 352 -224 336 WIRE 784 352 784 320 WIRE 960 352 960 320 WIRE 1104 352 1104 304 WIRE -64 384 -64 336 WIRE -224 464 -224 432 WIRE -224 464 -368 464 WIRE -224 480 -224 464 FLAG -592 16 0 FLAG 80 -256 0 FLAG -592 -192 +5V FLAG 416 -256 +5V FLAG -352 16 0 FLAG -432 16 0 FLAG -352 -192 +2.5V FLAG 448 64 0 FLAG -80 -496 0 FLAG 208 80 +5V FLAG -64 448 0 FLAG 96 352 0 FLAG -224 544 0 FLAG 1104 352 0 FLAG 960 352 0 FLAG 784 352 0 FLAG 576 144 Square FLAG 1152 144 Sineout FLAG 128 128 Square SYMBOL voltage -592 -112 R0 WINDOW 123 0 0 Left 0 WINDOW 39 0 0 Left 0 WINDOW 0 -66 54 Left 0 WINDOW 3 47 51 Left 0 SYMATTR InstName V1 SYMATTR Value 5 SYMBOL res -560 -128 R270 WINDOW 0 32 56 VTop 0 WINDOW 3 0 56 VBottom 0 SYMATTR InstName R6 SYMATTR Value 1k SYMBOL res -448 -112 R0 SYMATTR InstName R7 SYMATTR Value 1k SYMBOL polcap -368 -112 R0 SYMATTR InstName C3 SYMATTR Value 10=B5 SYMBOL Misc\\NE555 272 -144 R0 SYMATTR InstName U1 SYMBOL cap 432 -32 R0 SYMATTR InstName C1 SYMATTR Value 10nF SYMBOL res -176 -192 R0 SYMATTR InstName R2 SYMATTR Value 33500 SYMBOL res -176 -112 R0 SYMATTR InstName R1 SYMATTR Value 1000 SYMBOL cap -176 -464 R0 SYMATTR InstName C2 SYMATTR Value .01=B5F SYMBOL cap -80 384 R0 SYMATTR InstName C4 SYMATTR Value .08=B5F SYMBOL res -80 240 R0 SYMATTR InstName R3 SYMATTR Value 1000 SYMBOL cap 80 288 R0 SYMATTR InstName C10 SYMATTR Value .08=B5F SYMBOL res 80 144 R0 SYMATTR InstName R8 SYMATTR Value 1000 SYMBOL cap -240 480 R0 SYMATTR InstName C11 SYMATTR Value .08=B5F SYMBOL res -240 336 R0 SYMATTR InstName R12 SYMATTR Value 1000 SYMBOL ind 928 128 R90 WINDOW 0 5 56 VBottom 0 WINDOW 3 32 56 VTop 0 SYMATTR InstName L1 SYMATTR Value 15m SYMBOL cap 912 32 R90 WINDOW 0 0 32 VBottom 0 WINDOW 3 32 32 VTop 0 SYMATTR InstName C5 SYMATTR Value 47n SYMBOL cap 944 256 R0 SYMATTR InstName C6 SYMATTR Value 680n SYMBOL cap 768 256 R0 SYMATTR InstName C7 SYMATTR Value 680n SYMBOL res 736 128 R90 WINDOW 0 0 56 VBottom 0 WINDOW 3 32 56 VTop 0 SYMATTR InstName R4 SYMATTR Value 330 SYMBOL res 1120 320 R180 WINDOW 0 36 76 Left 0 WINDOW 3 36 40 Left 0 SYMATTR InstName R5 SYMATTR Value 1k8 TEXT -648 -472 Left 0 !.tran 0 50ms 0 1u TEXT -648 -432 Left 0 !.ic V(in1)=3D2.7 TEXT -648 -512 Left 0 ;555 Radio Modem

Reply to
john

If a well-designed Wien bridge oscillator gets hammered by RFI, you're somewhat depending on luck that an active filter doesn't have the same problem.

--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
Reply to
Tim Wescott

You have such a narrow "bandwidth" that you might consider an LC tuned network..

Reply to
Robert Baer

Your RC values could be optimized. Try using successively bigger resistors and correspondingly smaller caps in successive stages. As is, each filter stage heavily loads the previous one.

These RCs each have an unloaded 3 dB point of about 2 KHz, so three in a row will lose about 9 dB. Making the taus a little shorter will increase output at the expense of distortion.

I'd expect a 3-pole LC filter to be a lot better.

John

Reply to
John Larkin

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.