R.G.'s Q&D test oscillator + software oscilloscope

Started by mdh, January 23, 2007, 02:06:37 AM

Previous topic - Next topic

mdh

I recently installed a little buffer circuit (schematic here: http://xoscope.sourceforge.net/hardware/hardware.html) in one of my more expendable computers so that I can play around with software oscilloscopes. Tonight I breadboarded R.G.'s quick and dirty test oscillator (http://geofex.com/FX_images/q+dosc.gif) in order to get an idea of how the buffer responds to a relatively clean sine wave. Well, here's what I see in xoscope:



This is with the negative probe connected to the oscillator output, and the positive probe connected to the oscillator ground. If I swap the probes, the clipping shows up on the negative side of the wave. This suggests to me that the buffer isn't at fault, so I'm wondering what might be causing this clipping. In the interest of full disclosure, I subbed 22k resistors in place of the 27k resistors in the twin tee; all other component values are as specified in the oscillator schematic. Other than the oscillator itself, I'm suspicious (or maybe superstitious is the right word) of the "probe" that I have connected between the buffer and the circuit. I'm a cheap bastard, so I took about a meter of RG174/U coax, crimped a BNC connector on one end, and made a Y-shaped "probe" end by separating a few centimeters of shield from the center conductor and tinning both ends. At present, this wonderful probe is connected to the circuit with those little double-ended alligator clip jumpers. Having never owned a real scope, I'm not really sure what to expect from a likely suboptimal probe.

Obviously if my probe/buffer/soundcard combination has assymetrical clipping built into it somehow, I'd like to know (likewise the test oscillator, for that matter), since I intend to use this thing to understand, evaluate and debug effect circuits. Any thoughts on how to track this down?

Cliff Schecht

I would start by using a real probe being that they are designed to not load down the signal at all, but that doesn't seem possible considering you are using a sound card. As to why only one side of the wave is clipping, my guess would be it has something to do with the fact that you are using a cheaper soundcard, they aren't known for their high quality audio properties by any means. From what it sounds like you are doing, I don't think it would matter if you just used 2 pieces of wire for your probe, you would still get the same results. If I'm wrong and the clipping gets worse with even cheaper wire, then my guess would be that the probe itself is loading the signal down.

I have no idea :D.

zpyder

I remember recently reading a thread on this forum about a similar thing.

Found it:
http://www.diystompboxes.com/smfforum/index.php?topic=46885.0

Seljer's reply includes the reference.  He said he didn't use some spec parts, but the way he mentions it kind of sounds like he had asymmetrical clipping.  Perhaps it's a possibility the the oscillator itself is not putting out a perfect sine wave...

zpyder
www.mattrabe.com/ultraterrestrial Ultraterrestrial - Just doing our little part to make new rock go where it should have gone in the late-90's, instead of the bullshit you hear on the radio today.

Paul Perry (Frostwave)

Quote from: mdh on January 23, 2007, 02:06:37 AM
This is with the negative probe connected to the oscillator output, and the positive probe connected to the oscillator ground. If I swap the probes, the clipping shows up on the negative side of the wave.

Do you mean, you see the same as the image above, but inverted?
If so, it IS the buffer.
What happens if you make a voltage divider (couple of 47K resistors say) & run half the previous voltage to the buffer?

R.G.

The reason it's called a quick and dirty oscillator is that it's not perfect - but it is quick.

That circuit does not usually put out a perfect sine wave unless you tweak it a lot. It shares this with most analog sine wave oscillators.

Making a low-distortion sine wave by analog means is complicated. This is because to make a sine wave oscillator, you have to have **exactly** the right amount of gain in the feedback loop. Too little signal being fed back and the sine wave dies out. Too much and it distorts. So the name of the game is to either put in a little too much gain and live with it or to put in some gain-changing circuitry to continuously keep the gain adjusted to the perfect level.

As a matter of historical interest, the use of an incandescent light bulb to automatically adjust the gain of a sine wave oscillator was the the subject of either Hewlett or Packard's master's thesis, and a sine wave oscillator using a light bulb to do this was the product that started Hewlett-Packard.

If you want to get a more perfect sine out of the Q&D, lower the gain. Do this by increasing the emitter resistor while you watch the sine wave on the scope. When you get below unity, the sine will start to die out. When you get above unity, it will distort a little. Set it for whatever level of distortion you can stand.

If you want a very low distortion sine wave, I can show you how to do that as well, but it won't be nearly as quick to get it less dirty.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Joe Viau

FYI

http://en.wikipedia.org/wiki/Wien_bridge_oscillator

Great stuff to read, but I must admit that I feel like a baboon staring at a thesaurus.

mdh

Thanks for the replies, everybody, those were exactly the sort of insights I was looking for.

Quote from: Paul Perry (Frostwave) on January 23, 2007, 09:17:15 AM
Do you mean, you see the same as the image above, but inverted?
If so, it IS the buffer.
What happens if you make a voltage divider (couple of 47K resistors say) & run half the previous voltage to the buffer?

Yes, that's what I mean, Paul. After I wrote the original post, it occurred to me that maybe my reasoning was backwards. I guess my reasoning was that if the buffer (or soundcard) was clipping asymmetrically, it would clip either positive or negative waves, and wouldn't care about the phase of the signal. I'm working from a very tenuous theoretical understanding, though, so if I'm wrong, I'd love to know exactly how I'm wrong. In light of R.G.'s reply and the thread linked by zpyder, though, it seems likely that it really is the oscillator. The other thing I failed to mention is that when I play guitar into the buffer, there doesn't seem to be any indication of asymmetrical clipping, though either the buffer or the soundcard does clip (symmetrically) if I crank up the gain in the buffer.

Thanks for the inside knowledge, R.G., I'll tweak it a bit and report back when I get a chance.

jamtin

phew, glad I found this thread. I was scratching my head having built RG's oscillator as I noticed the output was clipping



I thought I was overloading the soundcard, but does the same thing at lower levels. The waveform at the base of Q1 is distorted ie

.

hey mdh, any luck tweaking values to get a better looking sine wave ? I've used the stock values. I tried increasing the 4K7 to 15K (approx 27K/2 as per most of the twin tee oscillator info I found) and it stopped oscillating.
It's Only Rock and Roll But I Like It

R.G.

The scoop on all phase-shift-oscillators is that they only produce a perfect sine wave at one gain level - that being just as they quit oscillating. This particular result is part of the math of the circuit. To get them to oscillate reliably, you must put in extra gain so they're a bit distorted. The extra gain ensures that they'll start and keep running as voltage, time, moon phase, etc vary.

You can, by careful hand tweaking, get a minimally distorted sine wave. But just as you get a perfect sine, the oscillation will stop.

To do better than this requires a different approach. One way is to build a resonant filter which is tunable, then to take the filter's almost perfect sine wave and run it back into an amplifier that distorts and amplifies it a bit, enough to feed the input to the filter.

In a way, this is what the phase shift, twin t and Wien bridge oscillators do - the "filter" is just not very resonant, so it can't filter out all the distortion the amplifier causes, and the output has to be taken from the amplifier to avoid loading down the filter.

It's easy to do better, but not with phase-filter analog approaches. Generating a triangle wave is easy, and then using either a wave shaper or tracking filter gives you the sine. Wave shapers are what's in all the waveform chips like the ICL8038. MAX038, and 2206. Tracking filters tended to be lab-grade stuff back in the day. Today, no one would mess with that much. You'd either use a wien bridge setup or go digital.

A digital sine generator is easy to do. You use one or more CMOS walking ring counter chips and a CMOS 555, plus some weighting resistors on the outputs of the walking ring. It puts out a stairstepped approximation to a sine wave that looks ugly by itself, but has the property that the lowest harmonics that need to be filtered out to make a sine wave are very far separated from the fundamental sine wave. That means that a simple filter (like one cap!) can suppress the harmonics. What you get out is a good sine wave. You can find much more on this in Lancaster's "CMOS Cookbook". By the way, any effects hacker who doesn't have a copy of the CMOS Cookbook is seriously underinformed.

So - if you need a quick signal source just to see if sound goes through, use the quick and dirty oscillator. But the instant you start thinking "Ugh! I just have to get some of that distortion out...", plan on going to a different oscillator with better performance rather than tinkering the Q&D for better operation.

At work the hard-core lab rats used to use a word which refers to the unit-clump of fecal matter. When they saw someone trying to improve something beyond what it inherently could do, they would say that they were polishing such clumps. You need a huge can of clump-polish to make a low distortion sine oscillator out of a single transistor oscillator. The time you'd spend on it would be better used finding a better clump to start with. Less polish needed.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

gaussmarkov

i have been using VA as well and ran into a problem with looking at LFOs at really low frequencies.  it seems like the inputs on my m-audio 410 have capacitors that filter square waves into curvy triangles. :icon_confused:  i guess there's no substitute for a real oscilloscope for that sort of signal.  or?

R.G.

Yeah, then there's that problem. An input capacitor does integrate the waveform at low frequencies. You need an input cap so big that the input rolloff is at least ten times lower than the waveform being observed. For LFOs that's down around 0.01Hz.

If I were doing this, I'd figure out how to modify the sound card to allow me to put a very high input impedance amplifier ahead of the actual sound card input.

It's not hard, but it does require modding the card.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

mdh

I guess I never made good on my promise to report back.  I seem to recall that I did improve the symmetry of the waveform a bit, and I suspect I did it by tweaking the emitter resistor on the first transistor, which I believe is what R.G. suggested.  I have to get to work soon, but I might have a chance to open it up tonight and see what I did.  As you may have gathered, I don't really use this setup very much any more.  Like GM, I was mostly interested in things like LFOs and envelope followers, and it didn't occur to me at the time that the buffer/soundcard combination wouldn't work out for the reasons that R.G. mentioned in his last post.

One thing that has occurred to me before is to multiply the frequency of the incoming signal before sending it to the buffer.  I guess if you did it digitally, you could sample the wave as it comes in, store up as many waves as you want, and spit out subsamples to get a higher frequency.  I've been meaning to play around with microcontrollers a bit... maybe this would be a fun way to start.  No idea whether this would be practical, and I can see how it might introduce distortion and even aliasing if you weren't careful with the sample rates.

stm

There is a major flaw in the buffer stage of the oscillator that precludes obtaining low distortion, no matter how much you adjust the emitter resistor.  As the output of the first transistor goes below 0.6V, the output buffer is condemned to clip the bottom of the waveform since the emitter follower output will be "Vbe" or approx. 0.6 volts below its input, thus hitting GND during the negative waveform cycle.

If you follow my three-step program the distortion of this oscillator can be reduced from over 15% down to 1% or less, at the expense of two general purpose diodes and one extra 22n capacitor:

1) To get rid of the bottom clipping, you need to add two diodes in series with the 22 ohm emitter resistor, cathodes facing towards GND.  You can use 1N4148's, 1N4001's, etc.  This instantly reduces the distortion level to less than 10% or so.

2) You can add extra filtering by adding another 22n capacitor from the first transistor base to GND.  This cuts down distortion a good deal, to less than 5% or so.

3) You can replace the 22 ohm emitter resistor with a 100 ohm trimmer.  In my case I could raise it up to 43 ohms and distortion was reduced down to 1%.

As a final note, in my case the frequency was 700 Hz, rather than 1 kHz.  I just changed the 10n caps with 6.8n and the 22n with 15n and got pretty close to 1kHz.

Cheers.

jamtin

thanks for the advice R.G, I should have thought about my goals for this little box before wading in. I should've known the good people at AD or Maxim would have a chip for the job.

However I applied a dab of the polish you refer to, thanks for the tips stm, and it buffs up reasonably well. Looks a lot cleaner now, even using brown polish !



It's Only Rock and Roll But I Like It

R.G.

Well, I'll be doggone - that's pretty remarkable. Hats off to stm and jamtin, that's much better than I thought it could get.

I guess I'll have to modify that article with the suggested improvements and a note that it's a quick and not-so-dirty oscillator.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

~arph

Nice!

Would it be possible to make this into a variable frequency oscillator? eg. by replacing the two 27k's with a 50k dual gang pot? (I'm thinking about an LFO). If you replace just one of the 27k's with a pot the sine will become asymmetrical (as in more of a sawtooth) right?
Oh well I'll experiment with it tonight.

R.G.

The quick answer is yes, modifying the resistors in the phase shift network will get you a 5:1 or 10:1 range on the frequency. You can do even better with one Vactec VT54C3/2 replacing two of the resistances as the vactec can make huge changes in resistance. You can actually use a vactec to lower gain when the sine reaches a certain level and get truly low distortion sine waves out of it, especially if you replace the transistor with an opamp, and use and active rectifier to sense level.. and ... and ...

It's easy to get caught up in creeping featurism. I was originally after something that anybody who could solder could make out of a few resistors, caps and a transistor. I'm perfectly willing to toss in a few diodes and a trimpot for a big jump in performance, as it still kinda fits that first objective - quick, simple, build out of what you got.

Any time you get to the complexity of one IC, the MAX038 will run rings around any discrete implementation, as will the 8038, the 2206, and a variety of microcontrollers. It is fairly easy to make a 20Hz-to-20kHz sine wave oscillator out of an LM13700 and a couple of opamps. Shoot, one quad opamp and a grain-of-wheat light bulb and you can replicate the original Hewlett-Packard sine wave oscillator that started the company.

Engineers are (in)famous for wanting to put just one more bell or whistle on whatever is in front of them.  :icon_biggrin:
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

stm

R.G., if you are OK with using a PNP and an NPN transistor (instead of two NPN's) it is possible to get rid of the two extra diodes.  In addition, replacing the ladder at the emitter of the 2nd transistor by an audio pot further simplifies component count while allowing variable output level.

I redrew the circuit and tuned the twin-tee values so as to include these changes and get closer to 1kHz and 1Vrms output level.  Will post at night since firewall at the office won't let me access the layouts gallery or any image hosting site.

I think the modified circuit achieved the best of both worlds: it allows trimming distortion down to 1% or less and uses fewer parts.

~arph

Quote from: R.G. on January 04, 2008, 11:51:07 AM
The quick answer is yes, modifying the resistors in the phase shift network will get you a 5:1 or 10:1 range on the frequency. You can do even better with one Vactec VT54C3/2 replacing two of the resistances as the vactec can make huge changes in resistance. You can actually use a vactec to lower gain when the sine reaches a certain level and get truly low distortion sine waves out of it, especially if you replace the transistor with an opamp, and use and active rectifier to sense level.. and ... and ...

It's easy to get caught up in creeping featurism. I was originally after something that anybody who could solder could make out of a few resistors, caps and a transistor. I'm perfectly willing to toss in a few diodes and a trimpot for a big jump in performance, as it still kinda fits that first objective - quick, simple, build out of what you got.

Any time you get to the complexity of one IC, the MAX038 will run rings around any discrete implementation, as will the 8038, the 2206, and a variety of microcontrollers. It is fairly easy to make a 20Hz-to-20kHz sine wave oscillator out of an LM13700 and a couple of opamps. Shoot, one quad opamp and a grain-of-wheat light bulb and you can replicate the original Hewlett-Packard sine wave oscillator that started the company.

Engineers are (in)famous for wanting to put just one more bell or whistle on whatever is in front of them.  :icon_biggrin:

You're absolutely right. I totally understand the purpose of this oscillator, it was more of a theoretical interest and partly the following: LM13700 are a little more expensive  and harder to find and a bit 'strange' to me (I have some but haven't come around to using one yet). I've seen the light bulb wien brigde too, but using a light bulb seems somewhat odd to me...
I guess with some tweaking this circuit will  end up a bit like the oscillator in the schaller tremolo.

stm

OK, this is the circuit I finally settled for my personal use:



( Added also here http://www.aronnelson.com/gallery/v/STMs-Circuit-Ideas/Quick+and+Dirty+Audio+Oscillator.PNG.html )

Cheers!