Arduino Forum

Using Arduino => General Electronics => Topic started by: Palmiche on Nov 03, 2018, 03:35 am

Title: Volume knob from Arduino signal to LM386 amp circuit (too loud)
Post by: Palmiche on Nov 03, 2018, 03:35 am
Hello,

I've been struggling with this for a bit.

I built an amp circuit based on the LM386-1  I'm powering it with DC12V. It's conected to a small speaker of unknown characteristics because it's salvaged.

I have it connected to an arduino program outputting some synth sounds on digital pin 9. I can input audio signal from my smart phone and it sounds really good.  I measured the voltage and it was about .6V coming out of the phone.

The Arduino however outputs about 2.4V when sound is playing (my multimeter is not very good though) and the volume pot only seems to work in an area around the middle of the sweep and it goes from nothing to way too loud in no time. I tried a voltage divider manually with resistors to bring it down to under .5V but it seems to sound just as loud? as if the amp was just adaptively increasing the volume. I used a 10KΩ and a 1KΩ which brought down the voltage but it still sounds too loud from the arduino as opposed to the phone.


So I have two related ( I think) problems:

1 What should I do to make it sound quieter like the phone?

2 Why is the volume potentiometer wonky (I've tried a few, from a slide pot, to a couple of shaft pots)
This is the schematic and components I'm using:

thanks!!



Title: Re: Volume knob from Arduino signal to LM386 amp circuit (too loud)
Post by: polymorph on Nov 03, 2018, 04:58 am
Are you using an audio taper pot? How is the pot wired up?

An Arduino is outputing a PWM signal, a square wave from 0 to 5V. On your meter, it will read the AC voltage as 1/2 of Vcc, because the signal is 5Vpp but it measures rms, however a 5Vpp square wave will read about 2.5Vrms because it is 2.5Vpp.

An LM386 has a gain designed to amplify a MUCH smaller signal. Do you have an isolating capacitor in between?

We really need a schematic, that would answer a LOT of questions.
Title: Re: Volume knob from Arduino signal to LM386 amp circuit (too loud)
Post by: Grumpy_Mike on Nov 03, 2018, 10:10 am
This is the OP's circuit
(https://forum.arduino.cc/index.php?action=dlattach;topic=577302.0;attach=280430)

It looks fine but as polymorph said you need an audio taper pot, sometimes called just a log pot to make the adjustment sound right. I guess you have been using linear pots so far.

If you want to cut it down further place a 10K resistor or so between the top end of the pot and the capacitor. Experement with the value of this resistor until you are suited.
Title: Re: Volume knob from Arduino signal to LM386 amp circuit (too loud)
Post by: hammy on Nov 03, 2018, 06:48 pm
Or even 100k.
Title: Re: Volume knob from Arduino signal to LM386 amp circuit (too loud)
Post by: rtek1000 on Nov 04, 2018, 05:11 am
Hello,

I believe this problem is due to PWM, because the square wave generates many harmonics, maybe it is interesting to make a low pass filter before sending the signal to the potentiometer.

(http://elasticsheep.com/wp-content/uploads/2010/06/PWM.png)

Source: Teensy2 USB WAV player - Part 2 (http://elasticsheep.com/2010/06/teensy2-usb-wav-player-%E2%80%93-part-2/)
Title: Re: Volume knob from Arduino signal to LM386 amp circuit (too loud)
Post by: Grumpy_Mike on Nov 04, 2018, 11:45 am
I believe this problem is due to PWM, because the square wave generates many harmonics, maybe it is interesting to make a low pass filter before sending the signal to the potentiometer.
No nothing to do with it. Second post you have got wrong today, not having a good one are you.
If your theory was correct the OP would get a lot of distortion not excess volume.
Title: Re: Volume knob from Arduino signal to LM386 amp circuit (too loud)
Post by: TomGeorge on Nov 04, 2018, 12:18 pm
Hi,


Quote
2 Why is the volume potentiometer wonky (I've tried a few, from a slide pot, to a couple of shaft pots)
This is the schematic and components I'm using
Explain wonky?

Can you get zero output volume with the pots you have tried?

Thanks.. Tom.. :)

Title: Re: Volume knob from Arduino signal to LM386 amp circuit (too loud)
Post by: Palmiche on Nov 05, 2018, 01:39 am
Thank you all for answering! I shouldn't have posted this before going out of town, now I'll have to wait to try changing it.

I'll try to find a logarithmic pot. And play with higher Ohm resistors.

Tom, I do remember getting zero volume with the pots I tried. If I visualise the pot sweep action as a timeline it went something like this:

000000000138!!000000

Where ! = Really loud and 0 = no sound

I'll report back soon.
Title: Re: Volume knob from Arduino signal to LM386 amp circuit (too loud)
Post by: TomGeorge on Nov 05, 2018, 02:20 am
Hi,
Something not right with those findings, even with the wrong taper pot, you should have no sound at one end and full sound at the other.
With full sound in the middle, is showing a wiring fault.

When you get back can you post a picture of one of the pots connected to you project, so we can see your component layout?

Thanks.. Tom... :)
Title: Re: Volume knob from Arduino signal to LM386 amp circuit (too loud)
Post by: MarkT on Nov 05, 2018, 02:34 am
Missing dc-blocking capacitor?
Title: Re: Volume knob from Arduino signal to LM386 amp circuit (too loud)
Post by: TomGeorge on Nov 05, 2018, 02:47 am
Hi,
(http://forum.arduino.cc/index.php?action=dlattach;topic=577302.0;attach=280651)

Tom... :)
Title: Re: Volume knob from Arduino signal to LM386 amp circuit (too loud)
Post by: Palmiche on Dec 12, 2018, 03:31 am
Thanks to all who replied!  It ended up being the log pot. I was trying to use linear pots. Using a log pot fixed it. I did have to ad a voltage divider of fixed value (two resistors) to lower the overall volume a bit. In theory this didn't make sense to me because the pot should change the volume as a ratio? but in practice it helped. Perhaps I had the wrong amount of K ohms pot.

Ty