5

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.

diagram

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.

endolith
  • 28,494
  • 23
  • 117
  • 181
damian
  • 343
  • 2
  • 3
  • 12
  • 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 00:23

3 Answers3

5

Basically you want to do this:

enter image description here

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.

enter image description here

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.
endolith
  • 28,494
  • 23
  • 117
  • 181
  • 1
    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](http://www.sg-acoustics.ch/analogue_audio/ic_opamps/index.html) 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
  • @Kortuk: Specifically, I'm talking about the "Common-Mode Linearity" and "Input Impedance Linearity" mentioned in that paper. For a diff amp these should be the same regardless of polarity of the input, though. Remember this is not an inverting or non-inverting amp, it's a combination of the two. No, inversion itself isn't audible, but it's definitely audible when you combine two signals with opposite polarity and the bass disappears, so I always try to keep polarity consistent throughout. – endolith Jul 26 '11 at 15:33
  • A diff amp could work, but also might have problems. Common mode rejection may be fine at low frequencies, but at high frequencies it might not be so good and also cause cross-modulation products. Since the noise seems to be due to switching power supplies, which can have spikes with high frequency content, a diff amp may not attenuate the noise satifactorily. Signal to noise ratio needs to be quite high in audio circuits. The ear is annoyingly good at picking up small noise signals. Try the diff amp and see what it does, but don't be surprised if it's not a complete solution. – Olin Lathrop Jul 26 '11 at 15:41
  • @Olin: True. I suspect the noise is due to the computer, not the SMPS though. SMPS would indeed be above audio frequencies and would only show up due to subharmonics or aliasing or stuff like that. – endolith Jul 26 '11 at 15:50
  • @endolith, I was just adding minor notes, I got to be your first upvote so do not fret to much about my feedback, just trying to give you all of the information I can to help you improve explanation on your answer! – Kortuk Jul 26 '11 at 15:51
  • @Kortuk: I'm not complaining! I just want to know everything there is to know about op-amps. – endolith Jul 26 '11 at 16:14
  • @endolith, yes, and 4 years ago I could have gone into detail as to why this was. – Kortuk Jul 26 '11 at 16:17
  • 1
    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 00:01
  • @damian: Oh, I see you've added the amp to the question. I guess you're right; the TA2020 has an inverting unbalanced input. I don't see any schematics for the SA-36. If it has an op-amp at the input you can probably hijack it and turn it into a diff amp. – endolith Jul 27 '11 at 00:22
  • ... So, having never worked with op-amps before, I tried to build this. It cut out the switching noise completely, but (and this is obvious when I think about it now) I'm using a rail-to-rail op-amp, the rails are 0V and 12V, and so of course it distorts since the input goes below 0V. I've ordered a couple of audio transformers, but is there any way I can trick the op-amp into reading signal 0V as 6V? – damian Jul 27 '11 at 20:08
  • @damian: Yes, of course. See "2.4 Difference Amplifier" of http://www.eng.yale.edu/ee-labs/morse/compo/sloa058.pdf and http://electronics.stackexchange.com/questions/14404/dc-biasing-audio-signal/14416#14416 for how to DC offset a signal, and I'll try to draw a complete circuit later – endolith Jul 27 '11 at 20:23
  • 1
    IT WORKS!!! thank you so much, and apologies for being such a noob :-) – damian Jul 27 '11 at 21:39
3

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.

Added:

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.

Added 2:

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.

Olin Lathrop
  • 310,974
  • 36
  • 428
  • 915
  • 1
    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
  • 1
    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
  • 1
    **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 00:20
1

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.

Olin Lathrop
  • 310,974
  • 36
  • 428
  • 915
Tim Williscroft
  • 1,702
  • 11
  • 11
  • `@` before a user name only has a function in comments, in an answer it doesn't do anything. – stevenvh Jul 26 '11 at 05: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 00:38
  • @damian: I'm not an expert in audio transformers (diff amps are cheaper in mass production), but I'm imagining something like these: http://www.jameco.com/webapp/wcs/stores/servlet/StoreCatalogDrillDownView?langId=&storeId=10001&catalogId=10001&categoryName=cat_2040&category=204060 Maybe you could ask a separate question about what to look for. – endolith Jul 27 '11 at 00:46
  • @endolith One of those would probably work just fine. – Tim Williscroft Jul 27 '11 at 03:28