# Controlling sounds volume

Hi,
Last year I put a 5 zone sound system into my house using a 5.1 surround sound kit. Just little speakers in key places so that I can have music throughout the whole house.

Now I want to be able to control the zones independently - I am thinking relays, which are easy now that I’ve figured out how to use a transistor on the arduino to turn higher loads on and off, but it would be nice if I could control the volume independently - I think I would need to use a digital potentiometer - anyone had any experience with one that would work on speaker wire/sound signal :s

Well I have my arduino powering 5 mechanical relays via a transistor, and it works great.

But
When I connect the same circuit to the parallel port of my computer, the relays have a very faint click. It is like there is more resistence in the transistor, when less voltage (2v?) is applied to it via the computers parallel port, rather than 5v from arduino?

(The external power source that powers the relays stays the same - a 9v battery)

The collector-emitter resistance RCE is controlled by the base current IB:

Which makes sense I guess.

I have a 1k resister between the parallel SIG pin and the BASE pin of the transistor. Perhaps this needs to be reduced to make this work on a low voltage parallel port? I only have 330 ohm resistors at my disposal… will this burn anything out if I was to use it again with the arduino later?

Right, Well I thought instead of waiting for an answer, I’d just try it and risk breaking something - well with less of a resister (330 ohm) works well with the parallel port!

I don’t think I’ll try it with the arduino, but I’d say it will work without breaking anything.

I’m a bit disappointed since I soldered 5x 1k ohm resistors onto this circuit of mine that now all have to be replaced with 330ohm ones

you are right about the base current... but have you checked the current abailable to the relays? I would check that first.
If there is sufficient current, you can calculate the collector current in the following way:

base current = V/R= 5V- .6V /330R = about 15 ma ( the .6 is for the voltage drop across the B-E junction)

and collector current = HfE * Ibe

So if your transistor has a gain (HfE) of 100, then the 330R with 5V applied would produce 100 * 15ma= 1500 ma through the collector....

make sense? You can find the HFE in the datasheet for the transistor.

D

I’m currently away from home at the moment and forgot to bring my multimeter!

It could have saved me a bit of fuss. Oh well - thanks for the explanation there!

You can only draw very little current from the parallelport. I build a kit once that had tha datapins of the par. port connected to 100R resistors which connected to optocouplers and then to a 2003 darlington array which in turn controls realys. This was designed to work with the parallelport. This way the optocouplers protect the par. port by isolating it from the rest of the circuit.

Right, well I got home and hooked it all up to the computer, got out a sample VB program and started playing with it - I could hear the relays clicking, but it wasn’t turning the speakers on.

I did a few tests before realising I had actually soldered one speaker wire to the NO pin on the relay, and the other to the NC pin. What I hadn’t done was solder one to the actual switching pin - duh!

I felt like such an idiot and had to de-solder and re-solder that part.

Now everything works really well, but there is one problem - when I turn a relay off, there is kind of a popping noise on the speaker. But, when I just disconnect one wire on the speaker manually, there is no pop. Is the magnetic field in the relay causing this pop? There is no pop when the speaker turns on. Hrm…

By the way, I don’t have a parallel port connector, so I am using sparkfun jumper cables plus a breadboard to interface to the parallel port (and it works surprisingly well!)

I don’t really have a solution to your popping sound. But what I would try is to isolate the output of the relay so that you don’t switch your speaker cables directly with the relay. Like I said, no idea what I’m doing but this is what I would try. (ignore if this sounds totally stupid)

I have a different question about controlling volume. I’m working on a video/sound installation and I’m using a sonic rangefinder to input the distance a person is from the sensor. What I’m attempting to do is have the volume for the video that is playing to get louder as they get closer. (it will be over powering another stream of audio from another piece of video) Now most likely the audio will be playing from a MAC computer that the video is running off of so I think I need some kind of software that will read the input from the arduino and make the changes on the computer, if it would be easier to hook it up somehow to a seperate audio source that is looping with the video then I might go that route. The only programming I really know is how to make an led pin flash on and off, and I’ve hooked up motion sensors and touch sensors, but this project is new territory and I’m a bit confused. Thanks!!

See http://sound.westhost.com/project53.htm which has a great way to control volume from one of the arduino’s PWM outputs

Hi,

See http://sound.westhost.com/project53.htm which has a great way to control volume from one of the arduino’s PWM outputs

The circuit on this page is a volume-limiter. It is used to protect to your speakers from overloading (or in other circumstances) for changing the dynamic of an electric guitar. You can’t control the volume with this circuit.

Eberhard

Hi,

I have a different question about controlling volume. I’m working on a video/sound installation and I’m using a sonic rangefinder to input the distance a person is from the sensor. What I’m attempting to do is have the volume for the video that is playing to get louder as they get closer.

You might be interested in this: http://www.arduino.cc/en/Tutorial/SPIDigitalPot
That basic idea is to put a small audio-preamp that is controlled by on of these digital pots, between the MAC and the power Amp.

I could not find a complete circuit but you might want to try these keywords on Google
“spi controlled potentiometer preamp”
That should give you a few hints.

Eberhard

Hi,

See http://sound.westhost.com/project53.htm which has a great way to control volume from one of the arduino’s PWM outputs

The circuit on this page is a volume-limiter. It is used to protect to your speakers from overloading (or in other circumstances) for changing the dynamic of an electric guitar. You can’t control the volume with this circuit.

Eberhard

Umm can’t control volume with a circuit that controls volume? what planet are you from? just hook the led to pwm with an rc filter instead of the peak detector…

Hi,

Umm can’t control volume with a circuit that controls volume?

what planet are you from? just hook the led to pwm with an rc filter instead of the peak detector…

PWM frequency on the arduino is at 500Hz. You will have a really hard time filtering this nice square-wave noise from you audio signal.

Eberhard

why 500hz? I haven’t used the IDE, but the chip itself can do 62.5KHz with 8 bits of precision.

Also, cadmium sulfide is usually quite slow, with a time constant of some 10mS. enough to greatly attenuate (but not completely filter) even 500Hz.

Oh, and that circuit limits by cutting volume down when peaks are detected. It works in a completely different way to a couple of diodes. If you supply a constant current to the led, you get constant attenuation to all parts of a signal.

Hi,

why 500hz? I haven’t used the IDE, but the chip itself can do 62.5KHz with 8 bits of precision.

Its just that way with the arduino. If you use the Arduino analogWrite() function the PWM is at 500Hz. This is not a question of using the IDE or an external Editor, its in the libraries.
(Could be changed, but thats off topic)

Oh, and that circuit limits by cutting volume down when peaks are detected. It works in a completely different way to a couple of diodes. If you supply a constant current to the led, you get constant attenuation to all parts of a signal.

Diode-Limiters are usually sold under the name FuzzBox, MegaDistortion at shops for guitar gear.

Its true that using a combination of Led/LDR for volume-control is common practice (for instance the old-school “Tremolo” guitar-effect works that way), but just not adviseable with the PWM-noise coming from the Arduino. I can’t recommend that for a good quality audio solution.
Eberhard

I have my arduino putting out 6 channels of PWM at 62.5KHz at the moment. If the libraries are the problem, don't use them

Agreed that 500hz is far too low for audio use.. the time constant you'd need on the rc filter would be many seconds.

I got some PGA2320 samples from TI the other day. that's a stereo digital volume control with SPI interface, which should suit nicely.