I think I've got a ground loop messing up my audio. Help!

I'm having a serious problem with the audio in my circuit and I don't know how to solve it.

I've got my board hooked up to an amplifier, like so:

What you see there is an 11V LiPo battery powering a Lepai2020a+ amp and a 5V switching regulator which supplies power to my board. (The Mighty)
The Mighty has a line-out connection, and the (unshielded) RCA cable connected to that is attached to the amplifier.

When powering the amplifier from a wall socket, or when powering the Mighty from it's own battery, everything works fantastic. But as soon as I try to power both from the same battery, all hell breaks loose, and the only thing that can be heard is a loud buzzing noise coming from the data being transmitted to some LED modules attached to my board. Said modules are connected by a couple ribbon cables.

Here is the schematic of my audio circuit. The amp is connected to the line out, not the speaker connection:

Any idea how I can fix this?

Pull the Y cable out and plug your 'line out' cable directly into each side of your power amplifier input individually to isolate. Work backward from the speakers to inputs(audio and power). Try it without the charger in the circuit. Try shielding the audio inputs.

Pull the Y cable out and plug your 'line out' cable directly into each side of your power amplifier input individually to isolate.

I've tried that. No change. But I'll make sure it's set up that way for future tests.

Try it without the charger in the circuit.

Charger isn't in the circuit except when charging.

Try shielding the audio inputs.

How? Use shielded RCA cable? I've taken apart two RCA cables and only one had any kind of a braided shield, and that also functioned as the ground connection. I'm aware I'm supposed to only ground the shield on one side, but I don't see how I can accomplish that with a standard RCA cable.

Work backward from the speakers to inputs(audio and power).

What should I be looking for?

These all seem like good suggestions for isolating noise from the circuit, but even if I succeed in removing the noise by adding shielding, seeing as the Mighty and Amp work fine together when they don't share the same power source, correcting the issue with more shielding somehow doesn't really seem like it's getting down to the root of the problem, which the evidence seems to be indicating is the result of a ground loop. But I don't have a clue how to break said ground loop.

I found this document by TI with circuits for breaking ground loops:

...and it seems to indicate that a 5 ohm resistor on the ground of the RCA cable should do the job. And I found some suggestions elsewhere that a 10-100 ohm resistor there would work. I didn't have any 5 ohm resistors, so I tried the 100 ohm which I assume should work but might act as a filter for some of the signal I want to keep, but that didn't make a dent in the noise.

Now that I look at the "Ground Loop Noise Reduction at an Output" section again though, that doesn't seem to match the schematic I got from the other site. I put Rgbk where Zc is. It appears though that Rgbk is actually connected between the ground of the device and the ground of the RCA output. So if I connect a 5-20 ohm resistor between the Mighty ground and the ground pin on my RCA output...

But looking at my own schematic again, the ground pin on the line out goes directly to device ground. And their schematic seems to show an op amp whereas my output is from a dac. So I don't know what I should actually be doing here.

It occurred to me that my searches for methods to avoid ground loops were bringing up lots and lots of results on how to do so with AC powered amps and audio equipment, but not much in regards to DC powered amps. I then realized that I was a dummy and I'm using car speakers and a motorcycle amp and that I should be looking for solutions for ground loops in car audio applications. Bingo! I found this page right away:

I also found out these things exist:
http://www.parts-express.com/pe/showdetl.cfm?partnumber=265-012

In addition, I have seen a suggestion to try grounding the RCA plug's sleeve at the amp, which seems like it might work. I'll have to try that.

A ground loop is a difference in potential between two objects. Where did you read to only ground one end of the shielded cable? That's wrong. Both ends grounded will eliminate the loop. Another thing to consider is ground straps. Grab yourself a 6 foot length of coax. It doesn't matter if it's RG-58, RG-59, or RG-62. Actually RG-8 is the best, but can be a little unruly to work with. Anyway, carefully cut off the outer jacket of the coax (it actually can be shorter or longer than 6'). You should just see the copper braid. Now, like a chinese finger puzzle, push the braided shield together and then start pulling the center conductor and insulation out. When your done, you should have some great ground strap material. This works great for eliminating ground loops in audio and RF devices. With only one end of your existing cable tied to ground, you have basically built an 'antenna' to pick up spurious noise signals.

Where did you read to only ground one end of the shielded cable? That's wrong.

I've read that many places.

Here's a mention of it on Wikipedia:

"The common method to wire shielded cables is to ground only the source end of the shield to avoid ground loops."

With only one end of your existing cable tied to ground, you have basically built an 'antenna' to pick up spurious noise signals.

I've heard that as well.... That it's a trade off between potentially picking up RF and avoiding ground loops.

When your done, you should have some great ground strap material.

What exactly do I do with this ground strap once I have it? Do I run the cable through it, or attach it to something? And how is that braided material better than say, a copper wire to ground?

By the way, my friend, who has the equipment I'm trying to fix in his possession at the moment, is going to pick up a "ground loop filter" today at a car audio shop. We're gonna pop that onto the RCA cable and see if that has any effect. I'll keep you posted.

The buzzing is presumably the PWM signal to the LEDs. You haven't said how the LEDs are connected, but you need to be make sure they don't share a common ground wire with the output signal or power supply. If the Mighty has 3 ground pins, then use one for the power in, one for the LED grounds or LED driver grounds, and one for the audio out. You also need good decoupling of the power to the LEDs, to decrease the amplitude of the LED switching current in the ground side of the power input.

Other options include:

  • Increase the PWM frequency you are using for the LEDs to more than 20KHz.

  • Add an audio transformer between the line output of the Mighty and the amp. You can get these from the major component distributors. A standard 600 ohm 1:1 transformer should do the job.

dc42:
The buzzing is presumably the PWM signal to the LEDs.

Oh, I'm fairly certain of that. The sound goes away if you disconnect the ribbon cable going to the LED modules.

You haven't said how the LEDs are connected

The LEDs are driven by a couple of TLC5947 LED drivers on individual modules which are chained to the main board using a couple of 6 conductor ribbon cables. One is around 6in long, the other is around 8ft long. I've been told disconnecting the 8ft one, or the board attached to that module with most of the leds on it makes the noise go away. So rather than the data or clock causing the issue, it may be the current draw.

but you need to be make sure they don't share a common ground wire with the output signal or power supply. If the Mighty has 3 ground pins, then use one for the power in, one for the LED grounds or LED driver grounds, and one for the audio out.

I'm not sure I understand. There's a power connector on the board for 5V and ground in. The ribbon cable connector for the LED modules has a ground pin to get ground to the LEd modules. And the Line-Out connection has a ground pin as well. Both the Line-Out and LED grounds are connected to the ground on the main power connection which then goes to the battery ground via a 5V regulator. I have included my schematic and layout below.

You also need good decoupling of the power to the LEDs, to decrease the amplitude of the LED switching current in the ground side of the power input.

Each LED module has a 10uf and .1uf cap between VCC and GND. These were what were recommended in TI's datasheet. I don't know if you consider that sufficient or not.

Other options include:

  • Increase the PWM frequency you are using for the LEDs to more than 20KHz.

I am already sending data to the LED modules at 8mhz, it's impossible to send the data any faster. I am only sending an update 60 times a second though. The noise doesn't seem to be some kind of 60hz hum though.

Now that you mention it though, I seem to recall in testing that the sound went away when I set the LEDs to a 100% duty cycle. Which indicates to me that the noise may be generated by the LED driver chip itself, and I have no control over its speed.

  • Add an audio transformer between the line output of the Mighty and the amp. You can get these from the major component distributors. A standard 600 ohm 1:1 transformer should do the job.

This is what the ground loop isolator my friend is picking up today has inside it. I have a feeling it will solve my problem, since the noise does go away when you power the amp and Mighty from separate power sources.

Anyway, as I mentioned above, here is the layout of my main PCB:
http://mightymicrocontroller.com/mighty-layout.png

And here is the full schematic of my board:
http://mightymicrocontroller.com/Mighty-schematic-full.png

I'm not sure if I should have put an inductor or voltage regulator between the analog and digital portions of my circuit. Someone suggested a regulator, but that alone would not seem to isolate the ground, and one article I read said they typically don't reject noise over 100hz. If that's true then it seems like a regulator would be useless. As for an inductor, I didn't really have the space for one, and I didn't know if it was necessary, and I didn't know if I should use one for power, or ground, or both.

I should note that it's much too late to change the design of these board I have now, but I hope to do a second batch soon, so any suggestions for improvements would be appreciated. I do have an issue with servo noise getting into the audio circuit I need to deal with at some point as well.

scswift:
What exactly do I do with this ground strap once I have it? Do I run the cable through it, or attach it to something? And how is that braided material better than say, a copper wire to ground?

It does a much better job of dissapating 'rf' to ground. You would put it between the DC ground (chassis) and frame ground of your vehicle or water pipe ground in a house. The braided wire is much more flexible as well. 8 MHZ is 'RF', just above the 40 meter band.

As the other gentleman suggested, a transformer will help. An inductor (sometimes called a 'choke') between the amp and supply may also help. Use the formula 6.28 * Frequency * L (inductance in Henrys) to calculate XL (Inductive Reactance) in ohms. Of course the higher the XL, acts just like resistor in your circuit. As frequency drops, so to does the XL.

OK, what you need is serious decoupling on the LED modules. On each one, connect a 100uF or greater electrolytic in parallel with 0.1uF or greater ceramic between the +ve feed to the LEDs and the ground pin of the TLC5947. Preferably, also connect an inductor between the incoming LED power feed and the junction of those capacitors with the +ve side of the LEDs. As an alternative to an inductor, you could use a low value resistor, if you can afford the voltage drop it will introduce. The idea is to get the LED switching current circulating around the capacitor, instead of feeding down the power and ground lines.

dc42:
OK, what you need is serious decoupling on the LED modules. On each one, connect a 100uF or greater electrolytic in parallel with 0.1uF or greater ceramic between the +ve feed to the LEDs and the ground pin of the TLC5947. Preferably, also connect an inductor between the incoming LED power feed and the junction of those capacitors with the +ve side of the LEDs. As an alternative to an inductor, you could use a low value resistor, if you can afford the voltage drop it will introduce. The idea is to get the LED switching current circulating around the capacitor, instead of feeding down the power and ground lines.

How would I go about selecting an inductor for this purpose?

Also, do you have any suggestions as to how I could isolate the audio portion of my circuit better? The noise from the LED modules when running the amp on it's own power source is nothing compared to the noise generated when I connect servos to my circuit without powering them from their own battery. My board is very small and I can't go attaching huge capacitors to every IO port. Is there some combination of voltage regulator, capacitors, and inductors that I could put in the audio circuit that would minimize the noise from the servos, and presumably take cake of the noise from the LEDs as well?

I don't think a voltage regulator alone would cut it because I've read they don't typically reject noise over 100hz, and the ground would still be connected and I suspect noise would get in there.

Btw, in case you're interested, here's a video of the board in action. You won't hear the LED noise because in this demo the board was being powered by a battery and the amp from a wall socket. It was only a few days ago I learned of this issue when powering them both from the same battery:

So today I had the bright idea of having my friend touch the battery ground to the collar around the RCA connector on the amp to see if that made the hum go away. It did, but it also made the sound really quiet, so it didn't solve the problem.

I'm wondering though, what caused this behavior? I thought it might remove the hum because of a ground potential difference causing the ground loop, so I figured the battery ground would bring the ground at the RCA input up/down to where it should be, but I can't explain why this would make all the sound, rather than just the hum, go away. Any ideas?

I also had the bright idea this evening to have him try a "ground lift", and simply disconnect the ground on the RCA cable. Without a shield in place this might cause it to be more susceptible to RF but right now I'm just hoping to get something resembling normal audio out of the thing. I'll have him try that in the morning.

And of course the ground loop isolator is in the mail so that will be getting here tuesday and we can try that.

But if the ground lift works, that would be pretty sweet, since that's a cheap solution. I am afraid it won't though given the lack of any success so far. I had him try a "partial ground lift" before with a resistor on the negative RCA input and it did nothing. I am also afraid that if that doesn't work, how can the ground loop isolator?

scswift:
How would I go about selecting an inductor for this purpose?

I've done some sums, and from the datasheet I think the PWM frequency of the TLC5947 should be around 1kHz (based on 4MHz nominal internal clock and 4096 clocks per PWM cycle). If you use a 100uF decoupling capacitor, that will give an impedance of 1.6 ohms to ground. To get a 10-fold reduction in the amplitude of the unwanted signal, the impedance of the inductor should be 16 ohms, which implies an inductance of about 3.3mH. The inductor needs to be rated at the maximum current drawn when all the LEDs are on. The resistance of the inductor needs to be small enough not to cause an unacceptable voltage drop.

You could also use a larger decoupling capacitor (say 1000uF), which would all9ow you to use a smaller inductor (e.g. 330uH for the same 10-fold reduction at 1KHz).

it is probably the high frequency harmonics that are causing most of the problem, so this L-C combination may be rather more effective than the calculation implies.

Thanks for the assistance!

I really hope I don't actually need to put this information to use to solve my problem, because the boards have already been produced and I don't want to have to solder 300 inductors onto them. Plus I'm not sure I could afford all those inductors at this point.

But could you show me how you dd the math so that I can learn how to do this sort of calculation myself in the future?

Also, let's say I have my friend hook up his iPod to the amp with the Mighty drawing power from the same battery as the amp, but the RCA cable from the Mighty disconnected. And let's say he doesn't hear any of this noise. Would that then mean that the problem is not the power draw of the LED drivers? I have not actually had him do this test yet, it's something I just thought of this evening. I'll have him try it today.

I'm going to have him try "lifting the ground" of the RCA cable as well. Ie: disconnect it completely. If that doesn't do something then it will seem unlikely at that point that a ground loop is the culprit. I'm really hoping the problem is a ground loop and not the issue with the power draw as you suggested because the ground loop is an easy fix, but adding inductors and capacitors to all my boards will neither be easy nor cheap.

Even if I do ultimately solve the problem by eliminating a ground loop, your suggested changes will still come in handy if/when I'm able to redesign my LED modules, because even if a ground loop is at fault, I do still get a little noise when the amp is on a separate power source, and I doubt fixing a ground loop will fix that. For now, that noise is something I can tolerate though if it means I don't have to do an expensive fix.

I only found one viable option for a 3.3mH inductor on Digikey. That's this one here:

Most 3.3mH inductors were really expensive, like $4-$5. That one is $0.44. They've only got 930 of them though, that's not a large enough supply to ensure it would be available when I need it.

The 330uH inductors on the other hand are much more common. I found this one for example:

A bit more expensive than the above, but still affordable. Thousands in stock. And the resistance is 3x lower than the other one.

So I guess using the larger capacitor with the smaller inductor would be the way to go.

[edit]

Actually, this one:

...can handle almost twice as much current, has half the resistance of the 330uH above, is half as expensive, and is a through-hole part making it easier to use for a patch job. So I guess that's what I'll use if I have no other option than to add these things to all my LED modules.

I just noticed you said I could use a low value resistor instead of an inductor. What exactly do you mean by low value? 1 ohm? 330 ohm? I assume this has an effect on the frequencies that would be filtered? I guess the idea is to create a low-pass filter?

It looks like the LED drivers can run at a minimum of 3V. But I'm driving some white LEDs, so the minimum actually needs to be more like 4V. And my power supply is typically 5V, but could be as low as 4.5V if running on 3 AA's. So I guess to be on the safe side I would need to the voltage drop to be less than 0.5V.

This is the first time you mentioned using AA cells to power the lights. Please update your original diagram to include the light modules and the power to them. Also post a schematic of the light modules.

dc42:
This is the first time you mentioned using AA cells to power the lights.

Oh, no that's not something I'm doing right now. This board is designed to be used in lots of different props. It has a built in 3W amp for small props. In those props the board would be powered by AA's. There's no noise issue when I run the board that way. But I do need to make sure if I make any changes to the LED modules that they will still work when the board is powered from batteries.

Please update your original diagram to include the light modules and the power to them. Also post a schematic of the light modules.

Here's the schematic for those:
http://mightymicrocontroller.com/Mighty-TLC5947-schematic.png

These modules are connected to the LED port on the Mighty via ribbon cables of varying lengths. They get both data and power over the ribbon cable, and multiple modules can be chained together. In this particular prop, there are two modules. The first is attached via a 6" ribbon cable, the second via an 8.5' ribbon cable.

OK so if the LEDs are running from the same +5V source as the TLC5947s then you should increase the 10uF caps to more like 1000uF.