Wien bridge oscillator math - diyAudio
Go Back   Home > Forums > Design & Build > Equipment & Tools

Equipment & Tools From test equipment to hand tools

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 20th February 2013, 12:27 AM   #1
diyAudio Member
 
Join Date: May 2011
Location: Charlotte NC
Default Wien bridge oscillator math

Hi all,

I am working on a function generator circuit which will do sine, square and triangle waves at audio frequencies to be used for testing amplifier circuits and similar. I don't need to get to .0000000000000000002% or anything like that as this is just a hobby project but I would like to get it as clean as possible, of course. Perhaps 0.01% distortion would be a good target. Additionally, I don't have a distortion analyzer, just an old analog scope, so I have to rely on coming up with a good circuit design without actually being able to measure the result.

This is my core oscillator circuit:
http://en.wikipedia.org/wiki/File:We...Oscillator.png

though, on my breadboard, I currently have this one wired up:
http://www.4qdtec.com/sinz/invwein.gif

(discussion is here: 4QD-TEC: Audio signal (sinewave) generators)

I want to run this off a single supply of either 9 or 12 volts and that's why I'm using the 4qdtec circuit currently. The plan is to use the standard circuit (as in the wikipedia link) but use another op amp to provide a 1.5V voltage reference by, basically, detaching R1 and C1's left connections from the wikipedia diagram and connecting them to the 1.5V reference.

The only other twist that makes my circuit different than the standard one is that I would like to use the resistor side of optocouplers in place of R1 and R2 (see 1st diagram link). I'll be using Silonex NSL-32H-101 parts since I just bought 100 of them on the cheap. The goal in this is that I'm wanting to use a microcontroller with an output PWM voltage to control the frequency of the circuit... but this is just for overview, not really part of my question except for the fact that A) optocoupler LDRs do add their own distortion compared to actual resistors and B) the resistors will be mismatched fairly poorly compared to precision resistor values.

I've been studying up on the Wien Bridge circuit math and there are a few questions I haven't been able to find an answer to.

A) if I mismatch the two legs of the wien bridge circuit (the series RC versus the parallel RC) does that add distortion? Or does it just change the oscillation frequency? Simulating it, I only see that the frequency changes if I randomly change the 4 R and C values, but I don't see any misshaping of the waveform.

B) Where does the amplitude or midpoint voltage come from in the standard circuit (see link 1)? I know the frequency is 1/(2 Pi R C) if R and C are matched but I don't know what determines the final amplitude. When I experiment with a variable resistor in place of the two R's I see the amplitude seems to change (randomly?) at some frequencies but there's no overall decrease or increase across the frequency spectrum that I can see.

C) Why do most circuits use multiple switched values for their capacitors, one per decade or what have you? With a value of, say, C=100nF and R=82 to 10082 I've gotten a frequency span of about 200 Hz to 20K Hz and the circuit oscillates throughout and the amplitude is similar. Is it just because it's too hard to adjust a knob to that level or is there a distortion factor? My goal is to use a feedback loop with the microcontroller so it would be doing the minute frequency adjustments, checking the resulting frequency then readjusting until the desired frequency is obtained. Is there anything wrong with using a single C value along with an R value swing of this magnitude?

D) This is extra credit (lol) but in the 4QD circuit (link 2), I had wired up the original circuit with ceramic, cheap caps and it handled the frequency range of 200Hz-20kHz without ceasing to oscillate at any point in the range and without any obvious clipping; then I bought a bunch of polyester film caps and used those; then, suddenly, adjusting the 500R resistor (see link 2) became a very, very sensitive chore where the high frequencies would stop oscillating unless I reduced the 500R knob a bit but then, when I'd lower the frequency back to 200Hz, it would be clipped a bit (over-amplified). The end result was that I couldn't really tweak the circuit to handle the full frequency range with the polyester caps, but could with the ceramic caps. Please ignore this one unless I'm missing something obvious

E) Is using PWM to control the two R's of a Wien Bridge a bad idea? It would run at maybe 40kHz or 100kHz, run through a low pass filter for smoothing then finally control the two opto couplers which represent the two resistors of the Wien Bridge. (This one can be extra credit too )

If anyone has any input into any of these questions, it would be greatly appreciated! I've been mulling over this project for like two months now and really need to just build something. A sanity check on any of these thoughts would be most helpful!
  Reply With Quote
Old 20th February 2013, 08:40 PM   #2
richiem is offline richiem  United States
diyAudio Member
 
richiem's Avatar
 
Join Date: Sep 2010
Location: Grapeview, WA
Your first link is incomplete, so it goes nowhere.

As to your questions:
A) Mismatching changes both the frequency and the attenuation of the Wien bridge circuit, which means that the level control (the 6V lamp in the 4QD circuit) has insufficient range of level control given a wide range of mismatch.

B) In a perfectly matched Wien bridge, the AC output from the bridge will be exactly 1/3 of the AC input to the bridge. Mismatching changes this attenuation factor which has consequences for the level control circuitry, and that is what keeps level constant and distortion low.

C) Most circuits use a narrower range of adjustment in order to control the size of the loads from both the level control and the Wien bridge on the output of the oscillator amplifier. A 50 ohm total load will be hard for many circuits to drive, so the caps are switched to keep the resistor values in a reasonable range -- typically from several kilohms to tens of kilohms.

D) Cheap ceramic caps are piezoelectric generators, so it is possible that they are contributing some voltage that keeps everything working -- or more realistically, maybe their tolerance spread and resulting mismatch as frequency varies is such as to offset the level effects of the resistive mismatches. Don't really know. The Poly caps are likely to have a much lower spread of values -- ie, tighter tolerance, which may make the effects fo the existing resistor mismatch worse.

E) PWM is OK but be prepared for some distortion; but given your level of test gear, you won't likely be able to see it. I can visually see about 1-2% THD on a scope, but I've had lots of practice.

As to your general desire for having multiple waveforms, you can use a squaring circuit (Google Schmitt trigger) to transform the sine wave into a square wave, and then another circuit (integrator) to convert the square waves into triangle waves.

Function generators start with a square wave generator, then convert to triangle, and then use a special series of resistors and diodes on the triangle wave to generate more-or-less sine-shaped waves. They generally have THD well above 0.1% -- typically 0.5 to 1%.
__________________
...................
Dick Moore
  Reply With Quote
Old 20th February 2013, 09:59 PM   #3
diyAudio Member
 
Join Date: May 2011
Location: Charlotte NC
Thanks for the insightful answers! That's an enormous help and lots to ponder on. And I was planning on doing the sine to square to triangle wave path, though the triangle wave is a bit wonky at his point. I have purchased some op amps with a higher slew rate which I'm hoping will help.

I can't seem to edit my first post so I'll repost the missing link:
Wein Bridge Oscillator - Wikipedia, the free encyclopedia

Thanks again!
Patrick
  Reply With Quote
Old 23rd February 2013, 03:22 PM   #4
PChi is offline PChi  United Kingdom
diyAudio Member
 
Join Date: Jan 2012
Location: Staines, UK
My guess of a possible answer to question D) is that the cheap capacitors were ceramic and the capacitance changed with voltage which helped control the feedback. The large value multilayer type can have a large reduction in capacitance with voltage.

I have found Oscillators difficult to stabilize because the amplitude change with time is an exponential of the Oscillation frequency x gain error.
  Reply With Quote
Old 23rd February 2013, 10:59 PM   #5
richiem is offline richiem  United States
diyAudio Member
 
richiem's Avatar
 
Join Date: Sep 2010
Location: Grapeview, WA
Hi Patrick -- the Wikipedia file shows the simplest form of a Wien bridge oscillator, and this form can be found in a Linear Technology App Note on oscillators and bridges, although I can't at the moment remember the number.

The reactive legs of the bridge (assuming equal Cs and equal Rs) results in an AC attenuation of 3, while the resistor + lamp leg has to have approximately the same attenuation -- this means for a lamp, which is not intended to run at full operating voltage, but rather at around 10% of rated voltage, that has an operating resistnace in circuit of say 150 ohms, the resistor will have to be 2x that value or 300 ohms.

If you're using an opamp like the LM49710 or LT1037, then I suggest using the 1869 type lamp, available from Mouser. The reactive feedback path blocks the DC from the output, while the resistive feedback path sets the DC output level of the amp. If you want the oscillator output to be zero volts DC, then use an opamp with split power supplies. To use the single-ended version and get maximum output swing, return the bulb to a low impedance voltage divider at half the positive supply which is bypassed at the bulb by a large electrolytic cap for low AC impedance to ground.

Use a pot in series with the feedback resistor to adjust for lowest THD and best stability.

See my webpage on lamps for oscillators -- www.moorepage/Lamps.html
__________________
...................
Dick Moore
  Reply With Quote
Old 24th February 2013, 09:24 PM   #6
diyAudio Member
 
Join Date: May 2011
Location: Charlotte NC
Quote:
Originally Posted by PChi View Post
I have found Oscillators difficult to stabilize because the amplitude change with time is an exponential of the Oscillation frequency x gain error.
Thank you for your input. I definitely concur! I am trying to calibrate the oscillator to handle a range of about 200Hz to 20 kHz and it's not easy task. Probably a strong argument for using multiple switched capacitors, however...

Quote:
Originally Posted by richiem View Post
If you're using an opamp like the LM49710 or LT1037, then I suggest using the 1869 type lamp, available from Mouser. The reactive feedback path blocks the DC from the output, while the resistive feedback path sets the DC output level of the amp. If you want the oscillator output to be zero volts DC, then use an opamp with split power supplies.
I am using a Radio Shack lamp rated at 5V, 25mA. I can see the "bounce," it's definitely doing something, so I'm not sure if it's part of the problem. I also have a 12V version which I haven't tried yet. My supply is currently 12V, single-ended.

I have rewired the circuit using the op-amp version instead of the 4QD version. My first observation is... it doesn't really work! I think I failed to consider the amount of current the op amp has to drive due to the lamp. My first try was with a LM833 and that does oscillate and the wave looks very clean, but it's only oscillating at about 2V p-p; that wouldn't really be a big problem except that I feel I'm overloading it. I also tried an NE5532 and a TLC2272; neither of those oscillated at all with the lamp. If I removed the lamp and put in place a 10K resistor and a pot for the feedback resistor it oscillated just fine. That makes me think it's a current issue.

So I don't know at the moment if I'll buy some higher current op amps, perhaps those Dick suggested, or if I'll go back to the 4QD circuit. Just thinking out loud here (so to speak) but I guess two other avenues would be using one of my life-time-supply of Silonex optocouplers in place of the lamp or some hybrid solution with some kind of transistor buffer between the output and the resistive leg of the feedback loop. Don't know if the latter's possible but I seem to remember seeing something like that.

As far as the single supply goes, I'm mimicking the circuit in figure 15-10 in this link:
http://www.ti.com/lit/an/slod006b/slod006b.pdf

I'm using a second op amp to generate a 2V reference voltage in place of "Vref." This is supposed to bring my output's midpoint to 6V.

Quote:
Originally Posted by richiem View Post
To use the single-ended version and get maximum output swing, return the bulb to a low impedance voltage divider at half the positive supply which is bypassed at the bulb by a large electrolytic cap for low AC impedance to ground.
I like this idea better because it's based on half the supply, but I can't get it to simulate correctly. I attached the circuit I _think_ you were describing but I may have gotten something wrong

Thanks for all the input guys!
Attached Images
File Type: gif Wien_OpAmp_1sply.gif (12.8 KB, 151 views)
  Reply With Quote
Old 27th February 2013, 08:55 PM   #7
diyAudio Member
 
Miguel Lopez's Avatar
 
Join Date: Feb 2012
Location: Havana, Cuba
I built this one. It only needs one pot to change frequency. Don't know the amount of distortion, and have to say that amplitude varies with frequency.
Attached Images
File Type: jpg Generador de Audio.jpg (51.1 KB, 134 views)
  Reply With Quote
Old 27th February 2013, 09:39 PM   #8
diyAudio Member
 
Join Date: May 2011
Location: Charlotte NC
Thanks for posting the circuit; that looks great! I'm kind of set on using the lamp, but this might work well too.

I attached my current circuit for the oscillator core. I added a transistor buffer past the op amp and it's helping a whole lot with the calibration. It's a lot more stable within a pretty large frequency range. It doesn't do well past about 12k so I'm thinking that has to do with current delivery from the voltage reference op amp as the resistors get small -- I've seen some voltage sag.

I'm really hoping to get this working without switching any caps, though, as I want to control the frequency with optocouplers driven by a microcontroller (see attached). I'm going to set up an AGC the same way, too, but that will be _after_ the selected waveform (square, sine or triangle) is switched into the next stage of the circuit.
Attached Images
File Type: gif WienCore_bufferedOut.GIF (5.1 KB, 127 views)
File Type: jpg micro.jpg (151.9 KB, 125 views)
  Reply With Quote
Old 6th March 2013, 06:53 PM   #9
paba is offline paba  Canada
diyAudio Member
 
Join Date: Sep 2004
Location: Montreal
a google search produced this nice read and circuit...

http://www.janascard.cz/PDF/An%20ult...0-140%20dB.pdf

/paba
  Reply With Quote
Old 7th March 2013, 01:02 AM   #10
diyAudio Member
 
Join Date: May 2011
Location: Charlotte NC
You read my mind. I was just thinking about that! I have tweaked and calibrated my circuit to where I am now getting my full target range of 100Hz-20kHz without cap-switching. This is using two optocouplers in the wien bridge sharing a current source and attached to a pot. But the last couple days I've been thinking about how I might go about swapping the lamp out for a third optocoupler. Especially, I'm thinking if I could reduce the output level to a smaller value, that would be better for overall distortion caused by the optocouplers; then re-amplify with an op amp. With a lamp, it has some pretty fixed properties and you have to work around that but optocouplers seem much more controllable as far as how sensitive you want them to be, what kind of time constant you want them to have, etc., since one piece is completely isolated from the other. I've only found one other similar circuit to this so this is a great find that I will definitely check out further.
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple wien bridge oscillator with temperature compensation akis Equipment & Tools 10 18th October 2012 09:15 AM
Use of a Ribidum Oscillator as refrence oscillator in a DAC Mark A. Gulbrandsen Digital Line Level 18 2nd January 2009 09:57 PM
Wien Bridge, I HATE YOU mod_evil Equipment & Tools 42 5th July 2008 05:17 PM
repairing adjust Thorens TD125 wein bridge oscillator pjpoes Analogue Source 15 27th December 2006 05:10 PM


New To Site? Need Help?

All times are GMT. The time now is 09:12 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2