Go Down

Topic: Digital volume control (Read 2090 times) previous topic - next topic

GrahamB

Hi,
Using an LM386 amplifier, got access to lots of useful circuits, but what I want is a digital volume control.

Why the LM386, simple it's what I have.

Yes I could modify the amplitude of the output, but a separate digital volume control would be easier. I do also have the MCP4725 DAC which I was hoping would be of use.

I am a programmer with a rudimentary knowledge of electronics.

Graham
The art of answering a question is to understand what the question actually is.

DVDdoug

#1
Jan 29, 2018, 06:47 pm Last Edit: Jan 29, 2018, 06:48 pm by DVDdoug
If you are already using a DAC then you simply multiply the sample values by a factor to adjust the volume.  For example, multiplying all of the samples by 0.5 (before sending the data to the DAC) will cut the volume in half (-6dB).   If you multiply by zero, you get silence.    That's how the volume control in your phone or computer works.    (But if you are not using the DAC...  if you have an analog signal...  you'd need an ADC in front of the DAC and that wouldn't make much sense.)

Otherwise you can use a digital potentiometer.   Usually they are 8-bits.   There are (at least) 3 different kinds of digital pots.   The "simplest" has up/down inputs where you step the volume up or down by one-step with each pulse.    There are also parallel (i.e. 8-inputs) and I2C controlled pots.   I2C seems to be the most common. 


artisticforge

Hi,
Using an LM386 amplifier, got access to lots of useful circuits, but what I want is a digital volume control.

Why the LM386, simple it's what I have.

Yes I could modify the amplitude of the output, but a separate digital volume control would be easier. I do also have the MCP4725 DAC which I was hoping would be of use.

I am a programmer with a rudimentary knowledge of electronics.

Graham
Which Arduino board are you using?
Which version of the Arduino IDE are you using?
What operating system are you using?
Linux, MacOSX, MS Windows, other

i ask these questions in the event that I may have to replicate your environment.

Do you have a wiring diagram?
><>

GrahamB

Thank you DVDdoug.

A digital potentiometer is exactly what I am looking for. I was just using the wrong terminology and looking in the wrong places I was mainly looking for a shield or small board, but I see the chips are so simple even I can just use them as they stand.

Now I just need to pick the right one for my purposes.

Problem solved!
The art of answering a question is to understand what the question actually is.

ian332isport

Graham,

Have a look at the PGA2311. This device is specifically designed to be a volume control chip, and a very good quality one too.

Ian.

GrahamB

Thanks for the suggestion, but a bit too complex and upmarket for my current needs.
However I have filed it, maybe sometime in the future.

I am making a theramin with my grandson as part of his IT instruction, at the moment we only have 2 8ohm 0.5W speakers, but it seems the cheesier the sound the more he likes it.

Next lesson, which is well in hand is how we can produce a sine wave.

The ultimate goal is a theramin using 2 ultrasonic sensors for volume and tone using a variety of waveforms. Maybe a third ultrasonic sensor detecting pelvic thrusts to add a bit of Bass.

He's 12 so it's not the end result, but the journey that is important to me.

Graham
The art of answering a question is to understand what the question actually is.

Bugiroff

Wow, for once I actually have applicable and (some what) timely knowledge of a recent subject...

I bought a few X9C103P chips a couple weeks ago just for this topic!  I've got two LM386s on a board I drew up and had fabricated.  One LM386 handles each channel, going out to a couple of ceiling mount speakers (that I recovered from a job) that are mounted in my walls.

Right now, I've got them running on 12 volts and they work great, but they're either on full blast, or off.  So, I bought the X9C103Ps to try and put a volume control on these suckers.  I was actually doing a Google search trying to figure out how to put them in when I found this. 

So, X9C103P are available on eBay, el cheapo.  I got 25 of them for $9.  Yeah, I expect to blow a few of them up during testing.  I burned several LM386s up before I realized that I reversed the power pin on my circuit board (oops...)  I'm planning on designing a board with an ATtiny85, an RF sensor, and the LM386s on 1 board to handle the volume control and a few other little things that I like to control by remote (yeah, like my LED lights around my room)


Any ways, I'd love to hear how your designs turn out.  Let us know!

Go Up