# Ground loop? Switch mode power supply noise

I have a single 12V supply powering a 12V class D audio amplifier (Tripath TA2020 based, model 'SMSL SA-36') (C) and a very cheap 12V to 5V 2A rated switch mode converter (A). The 5V is used to power a small computer that generates audio (B). The 12V and 5V grounds are tied together at the 12V input socket. The total 12V current draw is 0.5A-1.0A.

When I connect the audio from computer (B) to amp (C) (stereo mini-jack on the computer side, unbalanced RCA inputs on the amp side) I hear a tonne of switching noise (sounds like CPU/RAM/etc activity) on the speakers connected to the amp. If I connect a pair of headphones (D, only one channel shown) in parallel with the amp inputs, I hear switching noise on the headphones; if I disconnect the amp on one channel, then in the headphones (still connected to the computer) the switching noise goes away on that channel.

What's going on here? Do I have a ground loop? How do I get rid of it? Cut the ground wire to the RCA connectors? Use isolating transformers on the audio? Filter something? Throw out the 12V to 5V convertor and get a better one?

edit added amp details, unbalanced input, description of switching noise, diagram.

• Can you draw a block diagram or schematic? I assume the inputs and outputs are both unbalanced? (Signal on one pin, ground on the other.) I bet the class D amp has balanced inputs, but the board you are using ties one to ground and doesn't expose them to the outside world? – endolith Jul 26 '11 at 11:11
• Do you have control over the switching frequency of the power supply? What does the "switching noise" sound like? Are you sure it's from the supply and not the computer? Normally power supplies operate far above audio frequency. – endolith Jul 26 '11 at 11:17
• The amp inputs are unbalanced, as are the outputs from the computer (it's simply a headphone socket); the 'switching noise' sounds exactly like CPU/RAM/* bus activity. – damian Jul 26 '11 at 23:05
• Ok, the diff amp or transformer solutions will fix that. – endolith Jul 27 '11 at 0:23

Basically you want to do this:

The computer output is probably unbalanced, connected to the computer's ground, which has a lot of spiky noisy currents going through it (hard drive heads seeking, display refreshes, memory access bursts, etc). Due to the (very small, but finite) resistance of the ground traces, this means the computer's ground is at a noisy voltage relative to the power amp's ground. If the power amp measures the computer signal relative to its own ground, it will see that noisy ground difference superimposed on the signal. The power amp probably has a differential input (please specify what you're using for the power amp), which you can use to cancel that noise out.

You want the negative input of the power amp completely isolated from the power amp ground. It should connect directly to the output ground of the computer instead. That way the power amp is measuring the difference between the computer's output and the computer's ground, which will be noise-free. The grounds of the power amp and computer should otherwise be isolated from each other and connected together only at a star ground point near the power supply. You definitely don't want the ground currents from the computer going past a ground that's used as a reference by the preamp.

If the class D amp doesn't provide a differential input, you can make one with an op-amp in the differential amplifier configuration.

Rg will be connected to the ground of the power amp, V1 to the ground of the computer, V2 to the signal from the computer, and Vout to the input of the power amp.

Not shown on Wikipedia:

• You should have a compensation capacitor in parallel with Rf to avoid oscillation.
• You should add an identical capacitor in parallel with Rg to keep the common-mode rejection good at all frequencies.
• Use 1% or better resistors.
• This is the spot on issue, when the signal comes over if you are not referencing the ground of the signal when amplifying you are going to have a ground loop that goes to the wall outlet and back to your device. The reference of the other ground and using a differential amplifier is a pretty great idea. I would not that driving your signal into the non-inverting side of an op-amp is not my favorite as it saturates easily and has large leakages, but it will get the job done. Good job endolith. – Kortuk Jul 26 '11 at 14:24
• @Kortuk: What do you mean by "saturates easily and has large leakages"? I did that to keep the polarity the same, but you could invert by putting ground to V2 and signal to V1. I know there are differences in distortion between configurations that keep the op-amp input at a virtual ground and configurations that apply a changing voltage to the input, but in this configuration both inputs have the same changing voltage signal regardless of which input is signal and which is ground. – endolith Jul 26 '11 at 15:14
• in my experience a non inverting amplifier would often have bad distortion but unlike some of my other areas of expertise I often build it and test it to learn how well something works. I would have used dual inverting stages if I cared to stop inversion, but inversion should not matter in an audio signal, right? – Kortuk Jul 26 '11 at 15:30
• Thanks Endolith. Your drawing is more or less exactly what I'm doing now, except that the amp does not have differential inputs, just plain unbalanced audio line-in. – damian Jul 27 '11 at 0:01
• IT WORKS!!! thank you so much, and apologies for being such a noob :-) – damian Jul 27 '11 at 21:39

You have a ground offset problem. Basically, you are not distinguishing between power ground and signal ground, so offset voltage due to the power current is added to the signal.

Good grounding is not a trivial subject, and there is often not a simple easy answer, especially after the fact.

It would be difficult to describe exactly what to do, even with good diagrams of your setup. One way or another, you have to keep the power supply return currents from flowing thru the wire that is the 0V signal reference between the computer and the class D amp. One way would be to use a separate isolated supply for each device, then connect the grounds only at the signal feed. Since each side is isolated, there would be no return currents flowing thru the link. If the devices don't have separate signal ground connections and you can't get inside them, then you have to treat them as black boxes and the separate isolated supplies is pretty much the best way.

Sorry to not be more specific, but this is actually a rather complicated problem many more details of the setup would have to be known to offer any better suggestions.

I gave you one answer, but I see you edited your post to basically ask the same thing again.

Let me be more clear: Your setup is fundamentally flawed. Hooking up the power like that was a bad idea, because it leads to exactly the problem you are seeing. Some possible solutions:

• Ditch the whole setup, and do it over right. If you don't understand grounding, get someone to do it that does.

• Use separate power supplies for the computer and amp, then tie the grounds together only thru the single audio cable. This is what I suggested above, but you apparently missed.

• Use a audio transformer between the computer and amp. This was suggested by Tim, but you apparently missed that too.

• Have the computer send the data digitally, which is then easy to opto-isolate. Get a amp that can deal with digital data, or add a D/A in front of the amp. While this would work in theory, it's rather a long way to go to get around something that shouldn't be that way in the first place.

The diagram helps. Your experiment with the headphones proves that some of the 5V power supply ground return currents are running thru the ground of the audio cable. This must be avoided.

Why can't a separate 5V supply be powered from whatever is powering the 12V supply? Splice the two line cords together so you have one power plug if that's what you want. Why does it matter that the 5V is coming directly from the AC power as apposed to the 12V DC power for the amp? The advantage is that 5V DC supplies are plentiful and cheap.

If you really need to run the computer from the 12V DC power, then get a isolated DC-DC converter. Those exist, but aren't as plentiful and cheap.

You can also try Tim's idea and use a audio transformer. Be careful with capacitive coupling, and watch the frequency and impedance specs, but if done right should significantly reduce the noise.

• Ok, first of all I'm coming from Stack Overflow where it's normally the correct thing to do to edit and clarify one's question in response to feedback. Guess that's not done here...? I'm still in the process of edeting/responding to everyone. – damian Jul 26 '11 at 23:46
• So: Thanks for your answer. I've added a diagram. I've also added more details. 1. Given that I designed neither the computer nor the amp nor the 12V to 5V converter -- they're black boxes that i bought from the internet -- I can't easily ditch the whole setup, as there's practically none of my own work there to ditch in the first place. 2. The whole thing needs to be portable; I'd very very much prefer a single power supply. – damian Jul 26 '11 at 23:53
• Commented 2: The 12V supply is just a 12V battery for portability, so yes, I really do need to run the computer from the same 12V supply. I will look into an isolated DC-DC converter -- had never heard of them before today, I guess that's what this place is for... This is for a sound art project so it's important that the noise be reduced as much as possible. – damian Jul 27 '11 at 0:20

Olin is right, your problem is complicated.

A certain answer is not possible but...

Isolating the audio will probably work. That's why professional audio equipment uses balanced signals instead of single ended signals like your PC makes.

An Audio isolating transformer is the first port of call, even a cheap device will probably make a noticeable difference, given that you have so much noise.

If you have an old audio transformer in your junk box, try it.

• @ before a user name only has a function in comments, in an answer it doesn't do anything. – stevenvh Jul 26 '11 at 5:17
• Thanks for the suggestion. I don't have an audio transformer but I will order one and give this a shot. I'd prefer not to have the extra weight if I can help it, though. – damian Jul 26 '11 at 23:54
• @Damian: The weight of an audio signal transformer will be negligible compared to the other components. It doesn't need to handle any power. – endolith Jul 27 '11 at 0:38
• @damian: I'm not an expert in audio transformers (diff amps are cheaper in mass production), but I'm imagining something like these: jameco.com/webapp/wcs/stores/servlet/… Maybe you could ask a separate question about what to look for. – endolith Jul 27 '11 at 0:46
• @endolith One of those would probably work just fine. – Tim Williscroft Jul 27 '11 at 3:28