casete
Posts: 23
Joined: Sun Jun 01, 2014 3:09 pm

PAM8403 Amplifier Audio Hum

Fri Jan 25, 2019 4:08 pm

(I wasn't sure where to ask this... hopefully I got it right)

I'm trying to get my Pi (Model 3) set up with external audio. I bought the following:
I wired the amplifier up to a 3.5mm plug and plug it in directly to the Pi. The amplifier power is connected to the Pi GPIO header. I didn't add any other components.

With this arrangement, there is an audible hum whenever power is applied. I believe this is related to the power and probably something related to grounding based on my reading. However, I'm finding lots of competing information about what I can do to clean up this sound. Can anyone offer specific suggestions to remove the hum?

Thanks!
Craig

User avatar
Imperf3kt
Posts: 2766
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: PAM8403 Amplifier Audio Hum

Fri Jan 25, 2019 9:58 pm

The outputs on a PAM8403 are isolated, make sure not to connect left and right together!

The issue stems from the input, I believe. Try running a wire from the ground pin on the PAM8403 voltage input and the ground pin on the audio out (from the Pi) and twist the Left and Right audio wires together.
55:55:44:44:4C
52:4C:52:42:41

casete
Posts: 23
Joined: Sun Jun 01, 2014 3:09 pm

Re: PAM8403 Amplifier Audio Hum

Fri Jan 25, 2019 9:59 pm

A couple of other things I've noticed.
  • While is is dry and kind of static-y in the house, it seems like I'm getting shocked quite a bit more whenever I touch the Pi (or for instance the amplifier volume control knob)
  • The sound seems to be somewhat related to the activity on the device. If I do something that requires it to do work, I hear the speaker hum/sound change. In some ways, it reminds me of old school disk drive sounds.
I'm kind of at a loss. My electronics background is out of date. I could use some direction from someone that has a better idea what might be going on.

Thanks again,
Craig

casete
Posts: 23
Joined: Sun Jun 01, 2014 3:09 pm

Re: PAM8403 Amplifier Audio Hum

Fri Jan 25, 2019 10:03 pm

Imperf3kt wrote:
Fri Jan 25, 2019 9:58 pm
The outputs on a PAM8403 are isolated, make sure not to connect left and right together!

The issue stems from the input, I believe. Try running a wire from the ground pin on the PAM8403 voltage input and the ground pin on the audio out (from the Pi) and twist the Left and Right audio wires together.
I'm definitely not connecting left and right together. I had read elsewhere that that was a good way to fry the amp.

I'm not sure I understand exactly what you are suggesting relative to the input. You are suggesting wire the ground wire of the 3.5mm jack together with the PAM ground terminal? Is that in addition to connecting it to the GPIO ground? Are you also suggesting I twist the right and left wires coming out of the 3.5mm jack together? If I do that, I assume I lose stereo? What is the primary goal of twisting them together?

Thanks for your thoughts!
Craig

User avatar
Imperf3kt
Posts: 2766
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: PAM8403 Amplifier Audio Hum

Fri Jan 25, 2019 10:14 pm

Not quite, the ground points should all be connected together to eliminate a ground loop except the outputs. The outputs Must NOT be commoned (left ground and right ground must not be connected, despite both being 'ground')

When I mention twisting the left and right audio wires together, I was meaning just the wires. Don't actually connect them to each other.
This is to help reduce the 50/60Hz interference the wires will pick up from electromagnetic interference caused by your household electrical system.
The technique is called "twisted pair"

https://en.m.wikipedia.org/wiki/Twisted_pair
55:55:44:44:4C
52:4C:52:42:41

casete
Posts: 23
Joined: Sun Jun 01, 2014 3:09 pm

Re: PAM8403 Amplifier Audio Hum

Fri Jan 25, 2019 10:20 pm

Imperf3kt wrote:
Fri Jan 25, 2019 10:14 pm
Not quite, the ground points should all be connected together to eliminate a ground loop except the outputs. The outputs Must NOT be commoned (left ground and right ground must not be connected, despite both being 'ground')

When I mention twisting the left and right audio wires together, I was meaning just the wires. Don't actually connect them to each other.
This is to help reduce the 50/60Hz interference the wires will pick up from electromagnetic interference caused by your household electrical system.
The technique is called "twisted pair"

https://en.m.wikipedia.org/wiki/Twisted_pair
Ahh... twisted pair makes more sense (Cat 5, etc).

I'm still not quite sure what I should do with ground. Am I taking the connections to GPIO ground, PAM8403 power ground and 3.5mm jack ground and tying them all together?

User avatar
Imperf3kt
Posts: 2766
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: PAM8403 Amplifier Audio Hum

Fri Jan 25, 2019 10:30 pm

Okay so here is the PAM8403 that I have
Image
On the left is L, ground, R. On the right is 5v +, -

What I am suggesting, is place a wire between 5v - (negative) and ground, the very outer right connection, to the middle connection on the left side of the board.

This is because these points are not connected properly in my opinion. If you run a continuity check with a multimeter, you'll see they are already connected but they have about 50ohms of impedance between them.
Running a second wire to the GPIO ground is likely to create a ground loop.

You do not actually need to connect the ground wire from your axillary 3.5mm trs pole. This is what causes the ground loop on my opinion.
Last edited by Imperf3kt on Fri Jan 25, 2019 10:39 pm, edited 2 times in total.
55:55:44:44:4C
52:4C:52:42:41

casete
Posts: 23
Joined: Sun Jun 01, 2014 3:09 pm

Re: PAM8403 Amplifier Audio Hum

Fri Jan 25, 2019 10:33 pm

Imperf3kt wrote:
Fri Jan 25, 2019 10:30 pm
Okay so here is the PAM8403 that I have
Image
On the left is L, ground, R. On the right is 5v +, -

What I am suggesting, is place a wire between 5v - and ground - the very outer right connection, to the middle connection on the left side of the board.

This is because these points are not connected properly in my opinion. If you run a continuity check with a multimeter, you'll see they are already connected but they have about 50ohms of impedance between them.
Running a second wire to the GPIO ground is likely to create a ground loop
Thanks for the clarification. That is definitely an easy thing to do/test.

In terms of the twisted audio. I typed Cat 5 and then realized I have a boatload of Cat 5 lying around. I assume that would do a good job in this case?

Craig

User avatar
Imperf3kt
Posts: 2766
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: PAM8403 Amplifier Audio Hum

Fri Jan 25, 2019 10:35 pm

For audio, yeah cat5 cable should be adequate. The wires are 26AWG, which should carry the signal well enough.

Note that I edited my post since you replied, and suggest giving the changes a look.
Basically I'm suggesting leaving the 3.5mm jack ground disconnected, and run a wire from the 5v - input in its place so there is only a single path for ground back to the Pi. (the audio ground and all ground points on the Pi are connected, but having two paths to ground from your amplifier makes a ground loop, the cause of the hum)
55:55:44:44:4C
52:4C:52:42:41

casete
Posts: 23
Joined: Sun Jun 01, 2014 3:09 pm

Re: PAM8403 Amplifier Audio Hum

Fri Jan 25, 2019 10:41 pm

Imperf3kt wrote:
Fri Jan 25, 2019 10:35 pm
For audio, yeah cat5 cable should be adequate. The wires are 26AWG, which should carry the signal well enough.

Note that I edited my post since you replied, and suggest giving the changes a look.
Basically I'm suggesting leaving the 3.5mm jack ground disconnected, and run a wire from the 5v - input in its place so there is only a single path for ground back to the Pi. (the audio ground and all ground points on the Pi are connected, but having two paths to ground from your amplifier makes a ground loop, the cause of the hum)
Sounds good. Looks like I have a bit of de/re-soldering to do this weekend.

Thanks for the help. I will let you know how it goes.

Craig

drgeoff
Posts: 9803
Joined: Wed Jan 25, 2012 6:39 pm

Re: PAM8403 Amplifier Audio Hum

Sat Jan 26, 2019 1:06 am

Imperf3kt wrote:
Fri Jan 25, 2019 10:14 pm
The outputs Must NOT be commoned (left ground and right ground must not be connected, despite both being 'ground')
No they are not "both being ground". L+ and L- come from identical output stages which are driven in anti-phase. Neither of them is more or less "groundy" than the other. Same for R+ and R-. The + and - labels are merely so that you can wire the left and right speakers to be in phase with each other.

drgeoff
Posts: 9803
Joined: Wed Jan 25, 2012 6:39 pm

Re: PAM8403 Amplifier Audio Hum

Sat Jan 26, 2019 1:11 am

There is an easy way to determine if the hum is caused by the ground connection wiring or from an unclean power feed to the amplifier. Try a separate power supply for the amplifier.

User avatar
Imperf3kt
Posts: 2766
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: PAM8403 Amplifier Audio Hum

Sat Jan 26, 2019 6:36 am

drgeoff wrote:
Sat Jan 26, 2019 1:11 am
There is an easy way to determine if the hum is caused by the ground connection wiring or from an unclean power feed to the amplifier. Try a separate power supply for the amplifier.
And if that supply has the same problem? How can you be sure what the cause is.?
The audio jack connects the ground to the Pi. Using a separate power supply won't change anything.
drgeoff wrote:
Imperf3kt wrote:
Fri Jan 25, 2019 10:14 pm
The outputs Must NOT be commoned (left ground and right ground must not be connected, despite both being 'ground')
No they are not "both being ground". L+ and L- come from identical output stages which are driven in anti-phase. Neither of them is more or less "groundy" than the other. Same for R+ and R-. The + and - labels are merely so that you can wire the left and right speakers to be in phase with each other.
You know what I meant, in many audio systems, you can common the negative terminal of multiple speakers - an example being the 3.5mm jack - three wires, L, R, ground. Two speakers, four connections, Lin, L ground, Rin, R ground.
With this particular amplifier, you cannot.
55:55:44:44:4C
52:4C:52:42:41

drgeoff
Posts: 9803
Joined: Wed Jan 25, 2012 6:39 pm

Re: PAM8403 Amplifier Audio Hum

Sat Jan 26, 2019 11:33 am

Imperf3kt wrote:
Sat Jan 26, 2019 6:36 am
drgeoff wrote:
Sat Jan 26, 2019 1:11 am
There is an easy way to determine if the hum is caused by the ground connection wiring or from an unclean power feed to the amplifier. Try a separate power supply for the amplifier.
And if that supply has the same problem? How can you be sure what the cause is.?
The audio jack connects the ground to the Pi. Using a separate power supply won't change anything.
casete already wrote: "The sound seems to be somewhat related to the activity on the device. If I do something that requires it to do work, I hear the speaker hum/sound change."

If that noise is getting to the PAM8403 because of the PSU that is powering both the RPI and the PAM8403 then powering them separately will identify that. There might still be a noise/hum if the PSU powering the PAM8403 is not clean but it will not change with the work the RPi is doing.

User avatar
Imperf3kt
Posts: 2766
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: PAM8403 Amplifier Audio Hum

Sat Jan 26, 2019 12:46 pm

Fair enough, although after dealing with this exact issue myself about 8 months ago, I'm fairly sure what I suggested will fix the issue.
55:55:44:44:4C
52:4C:52:42:41

casete
Posts: 23
Joined: Sun Jun 01, 2014 3:09 pm

Re: PAM8403 Amplifier Audio Hum

Sat Jan 26, 2019 5:57 pm

Imperf3kt wrote:
Sat Jan 26, 2019 12:46 pm
Fair enough, although after dealing with this exact issue myself about 8 months ago, I'm fairly sure what I suggested will fix the issue.
An update on things.

I rewired everything and, while it is better, there is still what I would consider a high pitched "whine" when the amp is turned on. Here are some other interesting aspects:
  • I ended up connecting up the ground line from the TRS connection. It didn't seem to make a difference too much when connected to the Pi, but if I connected to my phone I would get a pretty bad buzz. Connecting ground cleaned that up.
  • When connected to my phone and not to the Pi, it is perfectly silent.
In the end, I used twisted pair wire (Cat 5) to connect the 3.5mm plug as suggested and I jumpered the two input ground lines on the Amp board. The question now is whether it is still possible to get rid of this whine? I've read elsewhere about using a capacitor somehow on the power input. Would that help and, if so, how would I connect that up? (across the power input or inline with the power input?)

For what it's worth, this whole thing is an attempt to build a smart bedside alarm clock. That is the reason I'm hyper focused on trying to get things silenced.

Thanks again,
Craig

casete
Posts: 23
Joined: Sun Jun 01, 2014 3:09 pm

Re: PAM8403 Amplifier Audio Hum

Sun Feb 03, 2019 4:43 pm

drgeoff wrote:
Sat Jan 26, 2019 1:11 am
There is an easy way to determine if the hum is caused by the ground connection wiring or from an unclean power feed to the amplifier. Try a separate power supply for the amplifier.
I finally found time to get back to this project today. I just validated that a separate power supply does indeed lead to silence from the audio. Given that I don't really want to have multiple power supplies to drive this project, what are my options to fix this problem using a single power supply?

FWIW, this is the power supply I am using to power the project. I was looking for something with enough power to drive the Raspberry PI, the touchscreen and the amplifier. https://www.amazon.com/gp/product/B01N3 ... UTF8&psc=1

Thanks again,
Craig

DurtVonnegut
Posts: 1
Joined: Wed Oct 09, 2019 2:11 am

Re: PAM8403 Amplifier Audio Hum

Wed Oct 09, 2019 2:13 am

Did you end up finding a solution to this issue without using a separate power supply?

Return to “HATs and other add-ons”