simple volume control using floating pins

hax

New Member
Hi all,

I am thinking of ways to implement digital volume control on a microphone amplifier in the simplest way possible.

I am thinking of using say 4 or 5 picaxe pins, and connecting them DIRECTLY to the DC biased low line level audio signal through various resistor values.

The program would bring the pins low, thereby attenuating the audio signal through the resistor, or the program would set the pins as inputs, thereby essentially floating the analog signal for max volume.


I appreciate that mixing digital signals and analog signals like this is unconventional and usually a bad idea, but will it work?!

If I ensure the audio signal is never above 5V or below 0v, I'm sure the picaxe won't be damaged. I just wonder if there are any other drawbacks that I can't think of, before I breadboard it and find out!
 

techElder

Well-known member
I sure hope you aren't looking for a hi-fidelity audio system! You didn't say where the microphone amplifier was headed.

I would look for a more isolated attenuator if I was going to get a microprocessor that close to a low line level audio signal.
 

hax

New Member
It's a two transistor preamplifier for an electret mic, which goes in to a 5W amplifier. Not Hi-Fi at all!

I would be tapping the connection between the preamp and the amp. The preamp is powered by a 5V supply, and the output is positively DC biased by about 2V (before the decoupling capacitor of the amplifier), so the audio signal is within the voltage range of the picaxe.

I know it's unconventional, I just wanted to see if anyone has done it before and if they had any luck!

I guess I could use transistors to isolate the picaxe, but if I can keep it as simple as possible, why not just use the outputs directly!
 

hippy

Technical Support
Staff member
Does it work as desired when you pull the signal down to 0V via resistors ?

I suspect it would work but the only way to say for sure is to try it. It will depend on the circuit because, if you cannot create a potential divider, you are simply putting a load on the signal, not actually reducing it. It may be better to use Analogue inputs rather than floating inputs.
 

AllyCat

Senior Member
Hi,

What attenuation range do you want to achieve and with which PICaxe? The "D-A converter" in most PICaxes is actually a tapped string of 32 x 5k resistors, with pin access to the Top (Reference+), "Wiper" (DAC output) and perhaps the lower end (Reference-) on some (otherwise grounded).

It might be possible to implement the volume control with just two capacitors, to ac couple the audio signal in and out of the PICaxe. On some chips, it's even possible to "bias" the top end of the resistor chain using the pin's internal "Weak Pullup" resistor. ;)

Cheers, Alan.
 

Pongo

Senior Member
Does it work as desired when you pull the signal down to 0V via resistors ?

I suspect it would work but the only way to say for sure is to try it. It will depend on the circuit because, if you cannot create a potential divider, you are simply putting a load on the signal, not actually reducing it. It may be better to use Analogue inputs rather than floating inputs.
If Haxby adds a series resistor before the point where the picaxe resistors-to-ground are connected then there would be a potential divider, but the real issue will be noise, both injected by the switching of the volume control and just general hash from the digital circuitry. Fun to try but most unlikely to be an acceptable solution IMHO.
 

hax

New Member
Sounds like it's worth a try. Will report back. (I haven't built any of the circuit yet, hence can't (quickly) test Hippy's suggestion yet)

And thanks AllyCat for the idea of using the DAC. Very clever! Will give it a go!
 

nekomatic

Member
If digital noise turns out to be an issue you could use optoisolators with open-collector outputs in a similar way, which should still be a low cost solution - say an ISQ74 or equivalent for 4-bit resolution.
 

fernando_g

Senior Member
One thing to remember is that for audio use, one must use an "audio taper" control, which means that the required steps are log and not linear.
 

John West

Senior Member
You might also consider a quad analog switch to isolate any micro-controller noise from the switched resistors. They are inexpensive and readily available.
 

hax

New Member
Hi all,

I breadboarded the DAC command volume control as suggested by AllyCat above: Using an external audio reference as the V+ reference, I get very very good results. No digital hash issues at all.

There is a roll-off of low frequency audio due to all the decoupling capacitors, but for my purposes it will be a great result.

Thanks all to your help!
 
Top