Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Converting square to sine

Status
Not open for further replies.

etla

New Member
Hello.
I have bought a 8MHz Oscillator with square wave signals. In order to make my application work, i need the signals in the circuit to be sine. To manage this, I have used a filter found in Horowitz&Hill "Art of electronics", se attached figure. Both the testing on a a breadboard/ simulating in PSpice works out fine, and the signals become nice and smooth sinewaves. Altough the amplitudevoltage are higher than the +5 that comes from the oscillator. I believe this is because of the resonance from the filter.

Because I don\t exactly know what my filtercircuit does to the squaresignals, I would be grateful I would be grateful if anyone could be able to answer the two following questions:

1- What kind of filter have I used for converting the square to sine, and how exactly does it work in order to do so?

2- Are there any better solutions?

Best regards
Tony L
 

Attachments

  • filter.GIF
    filter.GIF
    2.4 KB · Views: 256
Without component values, it's hard to answer your questions about the performance of the filter.
You really only need a circuit with a series R and a parallel LC, and maybe a buffer (voltage follower). What are you going to do with the sine wave?
The circuit I described will have a sine wave output that is somewhat higher in amplitude that the square wave. If this is a problem, another resistor will solve it. We can give you a schematic if you can tell us what the source and load are, and the amplitude required.
All this assumes your frequency isn't going to change.
 
What you have is a PI filter, it can have higher or lower output compared to the input, depending on component values. You could look up Butterworth 3 element low pass filter for more information.
 
etla said:
Hello.
I have bought a 8MHz Oscillator with square wave signals. In order to make my application work, i need the signals in the circuit to be sine. To manage this, I have used a filter found in Horowitz&Hill "Art of electronics", se attached figure. Both the testing on a a breadboard/ simulating in PSpice works out fine, and the signals become nice and smooth sinewaves. Altough the amplitudevoltage are higher than the +5 that comes from the oscillator. I believe this is because of the resonance from the filter.

Because I don\t exactly know what my filtercircuit does to the squaresignals, I would be grateful I would be grateful if anyone could be able to answer the two following questions:

1- What kind of filter have I used for converting the square to sine, and how exactly does it work in order to do so?

2- Are there any better solutions?

Best regards
Tony L

ANY filter will. The way it works is that a square wave is rich in harmonics but a sine wave has non.

If you want something predictable and readily adjustable just double integrate it. The integral of a square wave is a triangle and the integral of a triangle is a sine.

D.
 
Last edited:
Ron H said:
Without component values, it's hard to answer your questions about the performance of the filter.
You really only need a circuit with a series R and a parallel LC, and maybe a buffer (voltage follower). What are you going to do with the sine wave?
The circuit I described will have a sine wave output that is somewhat higher in amplitude that the square wave. If this is a problem, another resistor will solve it. We can give you a schematic if you can tell us what the source and load are, and the amplitude required.
All this assumes your frequency isn't going to change.

Thank you for the replies, and sorry for the lack in given information.
The values for the filter I used, is computed from the LP scaling rules and Butterworth LP filter-table given in Horowitz-hill p. 654. I have supposed I need only 3 poles (don't know if this is enough, but want the filter to be easy to implement and with few components). I have a load on 100 :eek:hm: and with a frequency at 8MHz, according to the LP scaling rules this will give the following values:
C10=C20=200pF
L2=4uH.

The frequency will not change throughout the circuit.
 
etla said:
Thank you for the replies, and sorry for the lack in given information.
The values for the filter I used, is computed from the LP scaling rules and Butterworth LP filter-table given in Horowitz-hill p. 654. I have supposed I need only 3 poles (don't know if this is enough, but want the filter to be easy to implement and with few components). I have a load on 100 :eek:hm: and with a frequency at 8MHz, according to the LP scaling rules this will give the following values:
C10=C20=200pF
L2=4uH.

The frequency will not change throughout the circuit.
Well that is a bit high for generic opamps :) Most hobbyists would not have access to the >50MHz ones that would be required for my suggestion.

D.
 
cadstarsucks said:
Well that is a bit high for generic opamps :) Most hobbyists would not have access to the >50MHz ones that would be required for my suggestion.

D.

Yes, I suppose the high frequency will disqualify most opampcircuits. Anyway, I will continue with the showed LP-filter, but have changed the values to
C10=C20=150pF
L20=3.3uH

The reason is I only have a 3.3uH inductor. When simulating with this values in PSpice, the circuit work fine, altough I am not sure why and I dont know how to calculate the exact amplitude. I find this unsatisfying.
 
cadstarsucks said:
ANY filter will. The way it works is that a square wave is rich in harmonics but a sine wave has non.

If you want something predictable and readily adjustable just double integrate it. The integral of a square wave is a triangle and the integral of a triangle is a sine.

D.
Pay no attention to this nonsense. The integral of a triangle is most definitely not a sine wave. It is a spikey looking animal with piecewise continuous segments that look like parabolas.

Quiz question: what's the derivative of a sinewave? A triangle ? I think not.
 
Papabravo said:
Quiz question: what's the derivative of a sinewave? A triangle ? I think not.
Derivative of Sine wave is Cosine Wave which Sine wave phase shifted by 90 degrees.

So derivative filter does not change shape of the wave but only causes phase shift.
 
C10 = C20 and 100 ohm load implies that the source is 100 ohms. that is unlikely, an 8 mHz generator would probably have 50 ohms output impedance. The calculation of output is a math problem; if you are not able to do the math, spice will give the correct output if the parameters are correct. If you don't know the correct parameters, you could not do the math anyway.
 
etla said:
Hello.
I have bought a 8MHz Oscillator with square wave signals. In order to make my application work, i need the signals in the circuit to be sine. To manage this, I have used a filter found in Horowitz&Hill "Art of electronics", se attached figure. Both the testing on a a breadboard/ simulating in PSpice works out fine, and the signals become nice and smooth sinewaves. Altough the amplitudevoltage are higher than the +5 that comes from the oscillator. I believe this is because of the resonance from the filter.

Because I don\t exactly know what my filtercircuit does to the squaresignals, I would be grateful I would be grateful if anyone could be able to answer the two following questions:

1- What kind of filter have I used for converting the square to sine, and how exactly does it work in order to do so?

2- Are there any better solutions?

Best regards
Tony L

Have you considered using a switched capacitor filter? Linear tech & maybe National Instruments make these.. They are easy to setup to do a high Q bandpass filter. Not sure if they operate up to 8MHz but it may be worth a look.
 
etla said:
Yes, I suppose the high frequency will disqualify most opampcircuits. Anyway, I will continue with the showed LP-filter, but have changed the values to
C10=C20=150pF
L20=3.3uH

The reason is I only have a 3.3uH inductor. When simulating with this values in PSpice, the circuit work fine, altough I am not sure why and I dont know how to calculate the exact amplitude. I find this unsatisfying.

It is not the circuit but the opamp that would be the problem.

D.
 
What's wrong with a reasonably high Q parallel resonant tank, possibly followed by a voltage follower?
 
kinjalgp said:
Derivative of Sine wave is Cosine Wave which Sine wave phase shifted by 90 degrees.

So derivative filter does not change shape of the wave but only causes phase shift.
QED. A cosine function is NOT a triangle as cadstarsucks would have everyone believe.
 
I hate to rain on some peoples' parades, but here are the results of integrating a triangle. The "sine" wave still has a lot of harmonics, because the integrator is just single pole lowpass filter with the pole (ideally) at zero frequency. Still, it looks pretty good, at least visually.
EDIT: Oops, forgot to post the time domain waveforms! It will be done shortly.
EDIT: OK, they've been added. I changed the cap from 1uF to 0.25uF to get the peak to peak amplitudes approximately the same, so the FFT scaling of the sine wave will be different, but the relative harmonic content will be the same.
EDIT: Note that a simple RC integrator, with the pole (corner frequency) a couple of octaves past the fundamental, also makes a good-looking sine wave. It is severely attenuated, though, compared to the operational integrator, which has adjustable gain (just vary the R or C). Note that, in the real world, you need a big (value) resistor across the cap to keep the op amp from going to one of the rails, and a cap in series with the resistor is also useful, and generally OK for this application.
I still think a simple series resistor and an LC tank is the way to go.
 

Attachments

  • tri to sin sch.PNG
    tri to sin sch.PNG
    12.2 KB · Views: 661
  • triangle fft.PNG
    triangle fft.PNG
    24.1 KB · Views: 446
  • sine fft.PNG
    sine fft.PNG
    20 KB · Views: 436
  • tri to sin waves.PNG
    tri to sin waves.PNG
    17.1 KB · Views: 464
Last edited:
Convert from 2 alternating distinct frequency square waves, using passive components

Greetings all,

I know this thread is old, but I believe I'm on topic:
(MOD/OP: if this reply should be on another thread, please advise)

I'm using the VCO (Voltage Controlled Oscillator) of On Semi's MC74HC4046A (CMOS(Complementary metal–oxide–semiconductor) 4046) PLL (Phase-Locked Loop) as an AFSK (Audio Frequency Shift Keying) modulator to communicate over low power (maximized unlicensed radiated power according to FCC (Federal Communications Commission)) FM (Frequency Modulation) radio w/ carrier frequency centered at 107.9MHz. The input to the AFSK modulator is a TTL(Transistor-to-Transistor Logic)-level signal (5V HI, 0V LO)

Currently, the AFSK-mod outputs a square wave and I'd like to convert it to a sine wave to minimize it's occupied bandwidth. I currently have a MARK (logic one) frequency of 2kHz and SPACE (logic zero) freq. of 1kHz (though I intend to double each proportionately to MARK=4kHz and SPACE=2kHz ... perhaps even higher if a greater element length (minimum duration of a MARK/SPACE condition in seconds) is required).

I simulated in PSPICE the idea from Rott with an LC tank of 120uF and 47uH (f_r=2.119kHz) for MARK with a 10ohm series resistor between the tank and the Square wave. It takes about 3ms to ramp up the amplitude to a relatively stable 2Vpk (square wave simulates incoming TTL-level 5V HI, 0V LO). Upon switching the square wave from 2kHz(MARK) to 1kHz(SPACE) and leaving the conversion circuitry the same, it outputs what looks like BPSK(Binary Phase shift keying) modulation of approx 160mVpk. When the Square wave is high, one sine wave occurs, and when Square is low, a sine wave mirrored over the horizontal axis occurs (shifted by 180degrees or pi radians). I changed the tank to 560uF and 47uH (f_res=981Hz) and the output's amplitude ramps up to a about 1Vpk after about 5.5ms (PSPICE would not let me simulate further, complaining of the capacitor in the tank changing too fast. In output file PSPICE says: "ERROR -- Time step = 14.00E-15 is too small in Transient Analysis at Time = 54.00E-15. Minimum allowable step size = 20.00E-15. The device which is changing too fast is C_C_space.") I did not specify a step this small. I specified 220usec print step, and step ceiling 240usec.

I'm not sure about the choice of the series resistor. I choose 10ohm to maximize the output current of the Square wave.

I created a circuit where the 47uH inductor is centered between the two parallel caps (120uF and 560uF). I rigged up a VPWL_RE_FOREVER source to output 2 cycles of the SPACE freq. then 4 cycles of the MARK freq. and then repeat. The oscillation frequency on the output remains near constant, which is NOT desired. Also, it's amplitude never peaks over 200mVpk. At startup it appears as more of an AM(amplitude modulation) signal, but by 30msec its amplitude stabilizes. PSPICE doesn't complain and lets me run it for 100ms.

Bottom line questions:
What's the best way to convert this square wave AFSK to sine wave AFSK? I tend to use the MAX2606 according to MAXIM's AN1869 as the FM-TX(Transmtter). Or would it be better to originate in sine wave AFSK w/ perhaps the NJM2211D or XR2206CP-F, or in triangular wave AFSK (XR-2209CP-F) The EXAR(XR) chips require higher voltage to operate; XR-2209CP-F 8V min and XR2206CP 10V min. I know there is a frequency offset not requiring a DCV(Direct Current Voltage) offset on the 4046 CMOS. On the EXAR or NJM, I'm not certain of their freq. offset abilities. On the FM-Rx(Receiver), I intend to use TDA7000 from Philips. According to FCC, need to keep Bandwidth of FM-Tx confined w/in 200kHz centered on my operating frequency of 107.9MHz. On the FM-Tx, I intend to keep the MARK freq. below 13.3kHz, to remove the need for pre-emphasis; which I believe amplifies freq. above this threshold on Tx and attenuates them on Rx to improve SNR(Signal to Noise ratio) - please correct me if I'm wrong. I've read that I should keep the shift between MARK and SPACE at an integer multiple of the keying rate (originally 1kBAUD, now 2kBAUD due to Manchester coding). Any opinion on the minimum number of cycles to use for the SPACE frequency? Is one cycle possible? or too idealistic? I've read about MSK (minimum shift keying) which only uses half a cycle (modified version of MSK used in cell phones, I believe).

I'd prefer to use passive components for conversion from square to sine to limit current consumption (intended for 9.6V NiCd 1000mAh battery use).

Let me know if there is any info I can provide to bring clarification to my post. I've uploaded PNGs of the schematic, time domain, and FFT. Also uploaded are the PSPICE files.

Thanks for any input!
 

Attachments

  • FFTSQ2SN.png
    FFTSQ2SN.png
    36.6 KB · Views: 416
  • SQR2SINE.png
    SQR2SINE.png
    20.3 KB · Views: 486
  • TIMESQ2S.png
    TIMESQ2S.png
    49.5 KB · Views: 331
  • Square2Sine_PSPICE.zip
    34.1 KB · Views: 231
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top