Op-Amps as Sine wave generator

my apologies for straying off the Arduino reservation, but this is on-topic of "General Electronics", so i hope you guys don't mind.

i have been dabbling a bit with circuits sans micro-controller and marvelling at what is already possible with simple electronic basic circuits (my topic on low-pass filters last week was my first !)

playing with a 555 timer chip was simple enough and the square wave generator was well comprehended, along with trying various R(es) and C(ap) combinations to get the desired frequencies for LED blink speeds.

now; a rather big step up, is to this sine wave generator circuit - and into the audio realm !
haven't fully mastered the various op-amp circuits, but i think i know what is going on the with non-inverting amplifier and the comparator setups.

this sine wave generator is quite complicated because they look like the're looping feedbacks; anyway, for now - i just want to get a sine wave and have it realized audibly.

so; i tried to copy the circuit example below (on the left) except i used a 5V unregulated power supply (i've measured 6V from it before).

the schematic on the right is how i actually rigged it up - please excuse the messy layout - i wanted to ensure it was as close as possible to the actual physical connections so that it might highlight any wrong connections i might have made.

the problem now is - i don't hear anything; not from a speaker (which might be designed to expect more power though) nor some small earphones.

that "Quadrature oscillator" circuit is supposed to give a 1.5 kHz sine wave - so it should be within normal hearing range.

did the change from 9V to 5V change this frequency ? - i'm not sure how to calculate it, but i thought it is dependent on the R and C combinations. (and in this complicated circuit, i'm not sure which to use, although it's obviously 10k Ohm and 10 nF ! [and using f = 1.4/((R1 + 2*R2) * C) would give 4.8 Hz (??)]

would appreciate if anyone could give some pointers what to look for in trouble-shooting why nothing is happening with the circuit i built.

EDIT:
sorry - that ACTUAL SETUP is missing a 10k resistor from "2" to "7" - but it's there on the breadboard though, also as a potentiometer to play with the sine wave.

Hi,
Check the number of connections to each of the op-amps pins.

The original has two connections to pin2, you have 1.
The original has two connections to pin7, you have 1.

Component count, the original has 5 resistors, you have 4.

Its a good idea to give resistors designators like R1, R2 etc, capacitors C1 C2 etc

That will help.

Tom... :slight_smile:

TomGeorge:
Its a good idea to give resistors designators like R1, R2 etc, capacitors C1 C2 etc

That will help.

yes, there are on the schematic i did on the right.

i've now updated the omitted error (on the diagram) - and cleaned it up to minimize the diagonal headache inducers ! :stuck_out_tongue:

Does this work? Have you built it ?

There is no method of amplitude control and the LM324 has nowhere near enough power to drive a loudspeaker.

There are various ways of doing this - see NatSemi's biquad or the classical Wein bridge.

Allan

did the change from 9V to 5V change this frequency ?

No. When dealing with analogue electronics you have to make a different circuit that will change frequency with voltage. You will get what is known as a frequency controlled oscillator. While at University I did come across an old article about such a circuit. It was a modest little article by a Robert Moog, it went on to make him a millionaire.

It is notoriously difficult to get this type of oscillator to work. There is an old adage:-

If you want to build an oscillator, build an amplifier and if you want to build an amplifier build an oscillator.

You are really in the sort of territory where you need an oscilloscope to see what happens. I would remove the speaker and see if it oscillates, because sometimes such a load on some low current op-amps stop them from working.

Hi,
Okay.
Now measure the voltage on Pin3, it should be 1/2 of the 5V supply, 2.5V. Using 1K instead of 2k2 shouldn't make a difference.

Also put a 10nF cap across pins 4 and 11 to bypass the supply.

With your DMM on AC, see if you can measure any AC on the output pin1.

What is the resistance of the speaker.

You may need to use a higher supply for the circuit, try 6V if you can or the 9V suggested
The specs say the LM324 is good to 3V, but this circuit may need more.

Hope it helps.. Tom... :slight_smile:

allanhurst:
Does this work? Have you built it ?

yes, built and it doesn't work - which is why i seek assistance in trouble-shooting.
the example circuit is supposed to work - i'm copying it from this video;

allanhurst:
There is no method of amplitude control and the LM324 has nowhere near enough power to drive a loudspeaker.

hmm, so that 9V changed to 5V could be the issue for this particular circuit ?

a frequency controlled oscillator.

?? What's that ??

It is notoriously difficult to get this type of oscillator to work.

Not at all - mine worked 'out of the box' having done the sums.

I designed biquad oscillators when I worked for Neve many years ago, and obtained a 20-20kHz range and <0.01% distortion with a dual-ganged pot for frequency control - and needed a seperate amplitude control sidechain for stability. LM324 and their ilk weren't quick enough - I used NE5534's.and a split +/- 15v supply.

It was a bit more complex than the posted circuit.

It probably won't oscillate - 2 integrators in series with 90 degrees phase shift each need an extra invertor to obtain oscillation. And without an amplitude control sidechain you certainly won't get a clean sinewave.

Robert Moog didn't use this as such -and so got funny noises. My work was contemporary and I wish I'd thought of the application. Jfets instead of the integrator resistors would make a voltage controlled oscillator of wide range.

The supply voltage doesn't matter.

google biquad.

A

TomGeorge:
Now measure the voltage on Pin3, it should be 1/2 of the 5V supply, 2.5V. Using 1K instead of 2k2 shouldn't make a difference.

that unregulated supply gave 6V infact - and i measured Pin3 at 3V

TomGeorge:
What is the resistance of the speaker.

it says Impedance 6 Ohms, Output power 1W - it's actually part of a battery-powered active speaker pair so i guess i shouldn't have expected much - but i am monitoring also with a pair of ear-buds.

TomGeorge:
You may need to use a higher supply for the circuit, try 6V if you can or the 9V suggested
The specs say the LM324 is good to 3V, but this circuit may need more.

i've tried half-assed connecting the 9.6V 8xAA NiMh pack instead, and didn't get a squeak (through the ear buds).

Grumpy_Mike:
No. When dealing with analogue electronics you have to make a different circuit that will change voltage with frequency. You will get what is known as a frequency controlled oscillator. While at University I did come across an old article about such a circuit. It was a modest little article by a Robert Moog, it went on to make him a millionaire.

heh-heh, i'm old enough to have heard of that name !! (80s music !!)

Grumpy_Mike:
It is notoriously difficult to get this type of oscillator to work.

sounds like the perfect learning experience then ! :smiley:

Grumpy_Mike:
You are really in the sort of territory where you need an oscilloscope to see what happens. I would remove the speaker and see if it oscillates, because sometimes such a load on some low current op-amps stop them from working.

i guess i should also start investing in a DMM instead of a simple needled-multimeter !

Your post beat mine - see above.

And a 6-ohm load will probably stop any oscillation - you need a seperate power amp.

Don't knock the old meters - that's all I had when I designed this sort of stuff. And a scope, of course.

A

BabyGeezer:
... it's actually part of a battery-powered active speaker pair ...

You could try reducing the load on the opamp circuit and feed the Line In of your active speaker
Diagram:
to_speaker.png
For investigating circuits that should oscillate when they don't (or do oscillate when they shouldn't) there is the old "laying on of hands"... touch GND (or wear an anti-stat bracelet) and prod at the circuit with your finger. A stubborn(*) oscillator may spring into life if you touch across one of the capacitors for example.

A slightly more technical version is prodding around with a 'scope probe, which can often be misleading when the *$&!# circuit oscillates only when the probe is touching it.

This may be of interest: Design of op amp sine wave oscillators

Yours,
TonyWilk

(*) stubborn really means 'not a reliable design'

to_speaker.png

allanhurst:
LM324 and their ilk weren't quick enough
...

It was a bit more complex than the posted circuit.

It probably won't oscillate - 2 integrators in series with 90 degrees phase shift each need an extra invertor to obtain oscillation. And without an amplitude control sidechain you certainly won't get a clean sinewave.

thanks, but it'll take a while for me to understand that sentence.

did you get to see the YouTube video - it seemed to work for that guy.
(perhaps there was something else connected off-camera that made the difference ?)

allanhurst:
The supply voltage doesn't matter.

google biquad.

wow, i sure opened up a whole new can of worms... !!

TonyWilk:
This may be of interest: Design of op amp sine wave oscillators

thanks - looks quite advanced, but a good introduction to oscillator circuits !

so; the circuit i am attempting to reproduce is "not just a Sine Wave generator" but a Quadrature Oscillator.

TonyWilk:
You could try reducing the load on the opamp circuit and feed the Line In of your active speaker
Diagram:
to_speaker.png

fundamental question then - i thought the issue was not enough voltage ?
and your suggestion for the exit at Pin1 is to add a voltage divider to lower the range by a factor of 10 ?
i must not be understanding something basic here.

The circuit you posted has 2 integrators ( quadrature or 90-degree phase shift elements - hence the name biquad ) in series.

Biquad circuits are remarkably versatile, but use several opamps - you'll need at least 3 for it to work as an oscillator - the third as a straight invertor. ( gain = -1 or phase shift 180 degrees ) such that the total phase shift at a given frequency is 360 degrees - ie back in phase and so reinforces itself - so it must oscillate given sufficient gain.

The circuit you posted omits this essential 3rd stage and so cannot (usually) work . Extra phase shift in the opamps may add to the total shift and so work in some circumstances, but is unpredictable.

I'll post a working circuit if you like . a/ in principle or b/ detail - I'll have to figure that out.

Simpler - a Wein bridge which only needs one opamp.

Either needs a sub-circuit to control the gain to obtain a pure sinewave - do you need this?

If any waveform will do and the frequency range limited, a 555 is easier.

A bit of history - Hewlett-Packard's first commercial product was a low distortion widerange audio oscillator ( using valves, of course) in 1947. It used the Wein bridge circuit topology. They used the resistivity change with temperature of tungsten to stabilise the gain. The filament of a light bulb.

Google is your friend.

Allan

BabyGeezer:
fundamental question then - i thought the issue was not enough voltage ?
and your suggestion for the exit at Pin1 is to add a voltage divider to lower the range by a factor of 10 ?
i must not be understanding something basic here.

The voltage divider is there to lower the voltage range to 0.5V to 1V (depending on the voltage you are running the oscillator at).

Since you say you have a powered speaker, then that 0.5V to 1.0V signal could be fed into the input to the speaker amplifier... usually the 3.5mm jack plug that would go into a PC or MP3 player.

Yours,
TonyWilk

Hi,
The link to the YouTube comes back as video unavailable.

Tom.... :slight_smile:

allanhurst:
Don't knock the old meters - that's all I had when I designed this sort of stuff. And a scope, of course.

i wasn't knocking old :wink: - i should've mentioned it's a cheap multimeter. (knock-off brand name even !!)

allanhurst:
The circuit you posted omits this essential 3rd stage and so cannot (usually) work . Extra phase shift in the opamps may add to the total shift and so work in some circumstances, but is unpredictable.

hmm, i'm probably waay out of my depth here, but just out of curiosity, the link that Tony Wilk gave showed this same Quadrature Oscillator circuit with only two op-amps;

allanhurst:
I'll post a working circuit if you like . a/ in principle or b/ detail - I'll have to figure that out.

thanks for the offer, but i have a lot on this plate already, as i said, i barely master single Op-Amp circuit variety, let alone what can be done with several of them in one go !

allanhurst:
Either needs a sub-circuit to control the gain to obtain a pure sinewave - do you need this?

If any waveform will do and the frequency range limited, a 555 is easier.

yes, i've experimented with that already, can a 555 timer do sine wave or is it always square ?

although, i guess even a square wave at audible frequencies should still come out on a speaker, right ?

TonyWilk:
The voltage divider is there to lower the voltage range to 0.5V to 1V (depending on the voltage you are running the oscillator at).

Since you say you have a powered speaker, then that 0.5V to 1.0V signal could be fed into the input to the speaker amplifier... usually the 3.5mm jack plug that would go into a PC or MP3 player.

ahh yes - "lower the voltage range" makes it "more sensitive".

much like adding the sensitivity of an analog sensor, say an LDR (as R2) and increasing the value of R1 (in the voltage divider) to make R2 more sensitive. (ie. tapping the analogRead() in between R1 & R2.)

TomGeorge:
Hi,
The link to the YouTube comes back as video unavailable.

Tom.... :slight_smile:

oh noes - thanks for pointing that out !! (i noticed there should be an uppercase 'E' instead... )

here's the video i meant;

That isn't a Biquad, as it has 3 90 degree phase shifts. Anything above 180 ought to work, though since there is no amplitude control it will be nearer a square than a sinewave output.

You can't make a 555 deliver sinewaves.

Allan

Wien bridge oscillator

allanhurst:
That isn't a Biquad, as it has 3 90 degree phase shifts. Anything above 180 ought to work, though since there is no amplitude control it will be nearer a square than a sinewave output.

You can't make a 555 deliver sinewaves.

hmm, i think my topic title strays from the main intention - i'm getting a lot of good feedback (!) on generating Sine waves (pure even !) but the key issue is trying to hear it !

in other words, even if it wasn't a pure Sine wave, it would be acceptable - i'm really just trying to replicate the example circuit - a Quadrature Oscillator - not a Biquad.

infact, looking closely at the Quadrature Oscillator example from Tony Wilk's link - the values (of Res & Caps) are exactly the same - except the op-amps are not the LM324 - and even the voltage supply is 5V !

so the problem at hand is actually finding the right speaker to realize the "Sine" wave that the Quadrature Oscillator is producing.

anyway, i thought since i can't find a way to hear it, maybe we can just see it.

here's a plot using a "Arduinoscilloscope" (instead of going to the speaker, i fed Pin1 to analogRead(A0); )

that would seem to be a confirmation of oscillation happening, right ?

i tried plotting with finer resolutions, even going all the way down to 20 microseconds, but it just looked random, and perhaps the macro view as shown above is more of a proper picture of the wave being generated.

runaway_pancake:
Wien bridge oscillator

interesting...
allanhurst touched on this too;

i could probably follow this circuit;

i do have an incandescent lamp that can take up to 9V - and that would supply the circuit shown via the op-amp power pins, right ?

btw what does the 's' in C1s and C2s mean ? (is it also the same 's' referenced on the op-amp A0(s)

that would seem to be a confirmation of oscillation happening, right

Yes it would appear so.
Now while it is connected to the analogue input connect the speaker to see if it stops.

You need an amplifier so that you don’t load the circuit. A computer speaker, one that needs a power supply, will be fine.