Go Down

Topic: [Solved] Noise and low volume Issues with audio amplifier. (Read 30430 times) previous topic - next topic

raschemmel

 https://www.sparkfun.com/products/9816  

It's plug and play so you don't have to worry about not knowing anything about op amps.
This is a mono amp so you need one for each channel but the best part is it has a potentiometer to allow you to adjust the gain.
It is set up as a gain of 100 but by turning the pot down you can adjust it to anything less than that. I would order one and if it works , get another one. Or just order 2. Heck , they're only $5 /each so you can't go wrong.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Jiggy-Ninja

100x gain is rather excessive, I wouldn't bother using that board. Just get some 358s from Mouser/Digikey and some resistors to wire up your own amplifier. Sparkfun sells it too (https://www.sparkfun.com/products/9456) but it, like most components on SF, is way overpriced.

There's lots of information available about op amps. Your power gain is less than 10, so your voltage gain should be about 3 or slightly less to avoid overdriving your speaker.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

raschemmel

You can reduce the gain as much as you want because the pot is an attenuator.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Jiggy-Ninja

Reducing the gain from 100 to 3 is going to be quite touchy. Best to just choose your own resistors and wire up your own circuit.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

raschemmel

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Snowman815901

Thanks for the suggestions!

I ended up buying a couple of each on Monday so, in theory, I'll be receiving them this Saturday.

I'm glad I picked up the 358s as well. They seemed appropriate and from the discussion it sounds like they'll be the best fit. I'm sure I'll find uses for the break out down the line too.

I'll report back, hopefully with no further issues, after I try it out in a couple days. Thanks for all the help.

Snowman815901

Got my op amps a day early.

I read up on how to achieve the the gain I want and determined the resistor values I would need to wire a 358 up for a voltage gain of 3.

-I don't fully understand the difference between inverting and non-inverting so I just picked one: non-inverting.
-I used a 15k resistor for the feedback between the output and the non-inverting input and a 7.5 k resistor between the inverting input and ground.
-I used a potentiometer to give the input 500mv and read 1.5v on the output.

So far so good so I tried adding it to my test project.

-I wired the (L) output from the musical instrument shield to the input of one channel of the op amp and the (R) output to the input of the other channel.
-I then connected the output of the (L) channel of the op amp to the (L) input of the amplifier and the (R) to the (R).
-I connected the (-) of the instrument shield to the (-) of the amplifier.
-I then powered up the amp, powered up the micro controller and the instrument shield and... Screeching sounds. Entirely noise without any sort of recognizable note. Not the result I was hoping for.

I'm now thoroughly confused. As far as I can tell, I've wired everything correctly.

Two of the things I'm not certain of:

A) Inverting VS. non-inverting. Perhaps I should be using an inverting setup. And,
B) The value of the resistors I'm using. From what I read, the ratio is the important part. Values between 1k - 100k can be used, with higher values being noisier for some reason.

I've attached a diagram of how I have the whole test project wired and a diagram of just the 358.

I'll be doing plenty of fiddling throughout the weekend, first trying different resistor values and an inverting setup. I'll also play around with the op amp breakouts I got from Sparkfun to see what happens with those (as long as I can get them down to a gain of 3).

Any suggestions would be highly appreciated and thank you everyone involved again for all of the support thus far.

raschemmel

There's two things you need to try next. First, put 1uF caps in series with  the signal from the Midi Shield to the Op Amps .
Second , Put 10k Potentiometers on the inputs of the two op amps. You can test one channel first before adding it to the second channel. The output of the Midi should connect to one side of the pot. The other terminal of the pot goes to ground . The wiper of the pot goes to the input of the op amp. This will allow you to reduce the input volume. (essentially a variable attenuator). This will give you control of the amplitude of the signal going to the op amp. The cap will make sure the signal is ac coupled  since audio is ac.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Snowman815901

I tried both of your suggestions raschemmel.

The 1uf caps in series between the midi shield and the input of the op amps had strange results. This is with a test tone (piano key stroke) being played at max volume at 1 seconds intervals with the 20w amp gain set to max. With 15k and 7.5k resistors.

-Without the potentiometers in series between the midi shield and the op amps, all I get is noise. An ugly high pitched hum and static sounds.

-With the potentiometers, I get the same thing. Here's the strange part though. If the pots are set just just a little below max, I can hear the first piano stroke then it fades into noise. I can then sort of "chase" the piano stroke by turning down the pots slowly. After about 10 seconds I have to have the pots almost completely off to hear the note then it fades away to noise no matter where the pot is set.

Just because, I tried putting the caps in series with the output of the op amps and the input of the 20w amp.

- Without the pots, it's only noise.

- With the pots added and adjusted just below max, I can hear the notes again. The volume is louder than it was without the op amps but still just above the threshold of acceptable. There's a bit of a high pitched hum as well that I can alter by touching and moving around the wiring. There's also a bit of low static like sound that I can't seem to influence the same way. I tried checking the AC voltage as this setup was running and measured 4v at the point where I could hear the notes again. With the pots all the way up I read ~4.3v. This makes sense as the 20w amp is rated to accept up to 4Vpp.

I wasn't expecting that high of a value since I only read 200mv before but perhaps my crappy meter is just unreliable at that low of a voltage and in reality it was more like 1.2v.

In conclusion, with a slightly lower gain of the op amps to remove the need for the pots and if I can eliminate the noise I'm getting now I could call this acceptable and move on. I still don't know why the volume is, at least apparently, greater when the input is an iPod vs the midi shield though. Perhaps it just seems louder vs the single note being played.

Also, I bought an oscilloscope last night and should be getting it on Tuesday so I'll really be able to dig into this and understand what's happening.

raschemmel

Try the scope on AC Cpupling and DC Coupling.
Post your problem on ghe Adafruit Tech Support forum.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Jiggy-Ninja

You haven't biased the op amp properly.  The output of the music instrument shield doesn't look like it has any DC-blocking caps from what I could see on the schematic, and it doesn't have a negative supply, so the audio output is likely biased at 1.65 V. Your op amp configuration has DC gain, so it will multiply this bias voltage to 4.95 V, which is above the output swing of the 358. This will severely distort the signal. In order to properly amplify the signal, you need a pair of DC blocking caps (one on the input and one on the output) and proper biasing.

Follow the schematic I have attached. This will properly bias the op amp for AC gain, and is the exact same setup I use for my audio project and it works just fine. The value of the output cap will depend on the input impedance of the power amplifier, though in general the larger the better. Note that if you use an electrolytic cap for this, make sure it is hooked up the right way.

Finally, you mention pots and caps being hooked up "in series" in your last post. This is rather ambiguous, so post of schematic of how they are connected. This should give some insight into what is causing your symptoms.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

Snowman815901

Jiggy-Ninja:

So I followed your drawing to the letter and got pretty much identical results. Improved volume but not very and lots of noise.

I didn't know what value to use for the caps on the output so I used the largest ceramic I had (.47uF). I wasn't entirely sure about the polarity if I were to use an electrolytic. I would guess that the positive would go to the output of the op amp and the negative to the input of the 20w amp?

When I said "series" regarding the capacitor/pot I meant it exactly as you have drawn above. With the caps, in one leg, out the other.

I was able to reduce the noise significantly but not fully by placing the largest capacitor I had on hand across the 5v and Gnd of the breadboard I'm using (470uF). Maybe I'll pull a 1000uF cap out of another project to try.

The noise is heavily influenced by touching and moving around the wiring, particularly wires connected to ground, so I think I could reduce it further by making a small circuit board for the op amp either on copper clad or some perf board to reduce the "antenna" effect of the wires and remove any weak connections due to the breadboard. Though, solving it without that would be preferred.

I'll also try powering the shield op amp and controller with something other than USB.

If I could eliminate the noise I'd be willing to settle for what I've got right now.

Jiggy-Ninja

#27
Jun 30, 2014, 12:24 am Last Edit: Jun 30, 2014, 12:42 am by Jiggy-Ninja Reason: 1

Jiggy-Ninja:

So I followed your drawing to the letter and got pretty much identical results. Improved volume but not very and lots of noise.

Odd. I use the same configuration for my project and it works just fine.

Quote
I didn't know what value to use for the caps on the output so I used the largest ceramic I had (.47uF). I wasn't entirely sure about the polarity if I were to use an electrolytic. I would guess that the positive would go to the output of the op amp and the negative to the input of the 20w amp?

That depends on the bias voltage of the input of the power amp. Measure the DC voltage on the input with nothing connected, and the DC voltage of the op amp output with nothing connected (should be 2.5V), and connect the - lead to the lower of the two. If they are about the same, don't use an electrolytic.

Quote
When I said "series" regarding the capacitor/pot I meant it exactly as you have drawn above. With the caps, in one leg, out the other.

That doesn't explain how you had the pots wired.

Quote
I was able to reduce the noise significantly but not fully by placing the largest capacitor I had on hand across the 5v and Gnd of the breadboard I'm using (470uF). Maybe I'll pull a 1000uF cap out of another project to try.

Do you have ceramic 100nF capacitors between power and ground near every chip in your project? You NEED power decoupling caps, especially for digital chips and precision analog stuff like audio.

Quote
The noise is heavily influenced by touching and moving around the wiring, particularly wires connected to ground, so I think I could reduce it further by making a small circuit board for the op amp either on copper clad or some perf board to reduce the "antenna" effect of the wires and remove any weak connections due to the breadboard. Though, solving it without that would be preferred.

Reducing the size of the wire loops will definitely improve the noise situation.
Quote
I'll also try powering the shield op amp and controller with something other than USB.

I actually found in my project that having USB connected reduced the noise in my circuit. Probably because of EARTH ground being connected or something.

EDIT: One thing I just noticed about your hookup after reading the datasheet and doublechecking the schematic for the Music Instrument Shield. It looks like you have the - output of the Shield connected to AGND of the power amplifier. If so, this is BAD. The - output of the shield is connected to GBUF on the chip, NOT GND! The datasheet says that GBUF should never be connected to GND. It looks like the music instrument shield is designed to drive headphones and speakers, not other analog circuitry. Disconnect GBUF entirely and connect AGND on the power amplifier to the proper circuit GND, and see if that makes a difference.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

Snowman815901

Quote
Odd. I use the same configuration for my project and it works just fine.


For your projects, what would you use after the op amp? I'm not laser focused on using these particular components. I just need to be able to adjust the volume digitally which I could probably do with a digital potentiometer or something if I had to. Also, what op amp do you use?

Quote
That depends on the bias voltage of the input of the power amp. Measure the DC voltage on the input with nothing connected, and the DC voltage of the op amp output with nothing connected (should be 2.5V), and connect the - lead to the lower of the two. If they are about the same, don't use an electrolytic.


I will be doing this tomorrow. Any idea how to figure an appropriate value for the caps? Or is bigger better?

Quote
That doesn't explain how you had the pots wired.


I had the (L/R) from the shield to one side terminal, GND to the other side terminal, and the (L/R) to the op amp from the middle (wiper) terminal.

Quote
Do you have ceramic 100nF capacitors between power and ground near every chip in your project? You NEED power decoupling caps, especially for digital chips and precision analog stuff like audio.


At the moment I just have the 470uF across the 5v and GND rails of the breadboard closest to where the rails are fed and the 470uF that's soldered to the 20w amp. I'll try moving the 470uF I added directly across the teensy and adding another cap for the op amp tomorrow.

Quote
EDIT: One thing I just noticed about your hookup after reading the datasheet and double checking the schematic for the Music Instrument Shield. It looks like you have the - output of the Shield connected to AGND of the power amplifier. If so, this is BAD. The - output of the shield is connected to GBUF on the chip, NOT GND! The datasheet says that GBUF should never be connected to GND. It looks like the music instrument shield is designed to drive headphones and speakers, not other analog circuitry. Disconnect GBUF entirely and connect AGND on the power amplifier to the proper circuit GND, and see if that makes a difference.


I just tried this and there's no improvement to the noise or volume which is disappointing because it seemed like this would make a difference.

When there's no op amp in the circuit however, like the early setups I tried,  with the (L) (-) (R) of the midi shield connected directly to the (L) (-) (R) of the 20w amp didn't produce any unwanted noise at all. Just a pathetic volume.

When I tested this, I had nothing connected to the (-) of the midi shield and nothing connected to the (-) of the 20w amp. I could try connecting the AGND of the 20w amp to the (-) of the midi shield or I could try the (-) of the amp to the GND/AGND of the teensy.

Just shootin' in the dark here. That's a task for tomorrow though.

Thanks a lot Jiggy. I really appreciate the suggestions.

Jiggy-Ninja

Quote
For your projects, what would you use after the op amp? I'm not laser focused on using these particular components. I just need to be able to adjust the volume digitally which I could probably do with a digital potentiometer or something if I had to. Also, what op amp do you use?

TL092 currently, but origianlly I had 358s in there, same as the ones you're using. I attached a schematic of my project for you to look at if you want. It's DigitalAmplifier.pdf. The main volume control stage is slightly different than the one I gave you, but the end result is the same.

Quote
I will be doing this tomorrow. Any idea how to figure an appropriate value for the caps? Or is bigger better?

The Cap + Input Impedance in series creates a high pass filter, with a cutoff frequency calculated by the equation 1/(2*PI*R*C). For example, the inverting op amp circuit I gave you has an input impedance of 100K ohms, and a 0.1uF capacitor. Plug those values into the equation ( 1 / (2*3.14159*100000*0.0000001) ) and you get about 15.9 Hz cutoff frequency. You want that frequency to be below 20 Hz, which is the lower limit of human hearing.

I just found the schematic for the Adafruit amplifier (also attached, in case you want it), and it looks like it already has input coupling capacitors, so you don't need to add those onto the output of the amplifier.

Quote
I had the (L/R) from the shield to one side terminal, GND to the other side terminal, and the (L/R) to the op amp from the middle (wiper) terminal.

A description is still not as good as a schematic drawing.

Quote
At the moment I just have the 470uF across the 5v and GND rails of the breadboard closest to where the rails are fed and the 470uF that's soldered to the 20w amp. I'll try moving the 470uF I added directly across the teensy and adding another cap for the op amp tomorrow.

Don't move the 470uF cap, it's in a good place. Just add some 0.1uF caps near the chips power lines.


Quote
When there's no op amp in the circuit however, like the early setups I tried,  with the (L) (-) (R) of the midi shield connected directly to the (L) (-) (R) of the 20w amp didn't produce any unwanted noise at all. Just a pathetic volume.

There is no (-) on the Adafruit amplifier. Do you mean the AGND terminal?
Quote
When I tested this, I had nothing connected to the (-) of the midi shield and nothing connected to the (-) of the 20w amp. I could try connecting the AGND of the 20w amp to the (-) of the midi shield or I could try the (-) of the amp to the GND/AGND of the teensy.

Just shootin' in the dark here. That's a task for tomorrow though.

DO NOT DO THAT. As I said, (-) on the music shield is not GND, it is GBUF. It should not, under any circumstances, be connected to GND or AGND.

Just to be sure, I have attached the setup I want you to make as 2nd Schematic.png. If this does not boost the volume significantly, please post a picture of your setup so we can verify the wirings.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

Go Up