Electronic – How to control a speaker

function generatoroscillatorspeakers

We are trying to produce a sound wave with speaker. We also need to be able to control the frequency (we don't have specific numbers, about 50-500Hz).

As far as we are concerned we are looking for a function generator or a VCO (voltage-controlled oscillator).
We would love to know which specific component we need.

We will synchronize this sound wave's frequency with another timer controlling an electromagnet; information about this connection will also be helpful.

Please take into mind that I don't have much electronic knowledge (learning physics in school, including electromagnetism).

EDIT:
What we are actually trying to achieve is to make two sine sound waves. One is constant and the other can be changed by hand with a potentiometer or so. For example if the constant is 440Hz, the other can be changed between 170Hz to 270Hz or something similar. Another timer will turn on and off an electromagnet, it will be turned on and off with a frequency linear to the changing sound wave's frequency.

Thank you

Best Answer

For a low distortion audio sinewave, the Wien Bridge oscillator is widely used:

Wien Bridge Oscillator

The RC filters provide a 0 degree phase shift at the desired frequency providing positive feedback to keep the oscillation going. You can think of them like a high pass filter followed by low pass filter to give a bandpass response.

The negative feedback needs an exact gain of 3. Since component values vary in practice, we can't just use two resistors, we need an AGC (automatic gain control) In the circuit shown this is achieved using the lamp as the bottom of the resistive divider. The lamp is like a resistor with a PTC (positive thermal coefficient) or a PTC thermistor. So when the voltage rises on the output, the lamp heats up and the resistance rises. This causes the voltage drop across it to rise and more negative feedback to be applied to the opamp inverting input, therefore reducing the gain and keeping the circuit stable.

The frequency is controlled with a dual gang pot (VR1A and VR1B)
The circuit shown should give from ~145Hz to ~1590Hz. Obviously you can adjust the component values to give different ranges. The formula is: f = 1/(2 * pi * R * C) with R1 = R2 and C1 = C2.
So for the pot at max (100k + 10k) we get:
1 / (6.28 * 10e-9 * 110e3) = 144Hz
and with the 100k pot at minimum (10k) we get:
1 / (6.28 * 10e-9 * 10e3) = 1592Hz

ESP has a some good info on audio oscillators and plenty of example circuits.

The other option if you are familiar with microcontrollers is digital synthesis. You can get far more control but you need a quality DAC to give comparable THD to the circuit above.
I made a little audio test oscillator which gave excellent results from a dsPIC33FJ64GP802 which has 2 good quality 16-bit audio DACs onboard. Simply feed the outputs into an opamp (and write the code of course)
There are also function generator ICs out there that could do the job, have a look on Mouser, Farnell, etc. You could also add a (preferably quite sharp) low pass filter to Russell's 555 circuit to give you your sine wave if you don't mind a bit of extra distortion.