I'm getting a lot of static when driving servos.

My board is designed to output audio and control servos, and I've just found that when driving a medium sized servo I get a lot of static on my audio output every time it changes direction, and some static when it's just turning as well. Even with a tiny servo, I can hear static if I'm preventing it from turning.

I thought the servos would have a reverse protection diode built in as well as some capacitors to reduce noise since noise on the data lines could potentially result in crashed airplanes, but if they're in there, they don't seem to be doing a very good job.

I also don't seem to have done a very good job at isolating my audio from this sort of noise in my circuit. I did make sure to have only one entry and exit point for the current into the audio portion of the circuit, and it's on the other side of the board from the servo ports, and the power source is between the two, so I thought that would be sufficient to avoid this issue, but apparently my efforts were either insufficient, or the noise is being radiated from the servo line and the audio line is picking it up or something. But I suspect it's direct transfer on the board itself.

You can see the layout of my board here. The servo is attached to port 9. So the current for the servo either flows in from the top of the board from the mosfet on the top right, or under the microcontroller and past the switch, I'm not sure. The audio portion is in the lower right, and there is a fairly straight line for the positive plane to the mosfet, but the ground plane current has to go around the LED pins:

This was as good as I could get it, and as far as noise from other sources goes, like a vibration motor I've got attached via a mosfet and with a protection diode... That works just fine. I don't hear any noise at all from it. And I'm switching it on and off rapidly. It's just these darn servos, which are plugged into the same ports that are the issue.

Is it perhaps just the servos are inadequately noise protected? I mean I hardly did anything for my vibration motor other than that diode. Might there be some way to modify a servo cable to reduce the noise? Put a choke on it for example?

scswift:
My board is designed to output audio and control servos, and I've just found that when driving a medium sized servo I get a lot of static on my audio output every time it changes direction, and some static when it's just turning as well. Even with a tiny servo, I can hear static if I'm preventing it from turning.

Most hobby servos used brushed DC motors, and brushes create electrical noise both onto the DC and ground wires and admitted as low level RF noise. Filtering of the servo wires and your audio signals may be the only solution. Running the servos on a separate voltage source from the arduino and audio stuff might help also.

I thought the servos would have a reverse protection diode built in as well as some capacitors to reduce noise since noise on the data lines could potentially result in crashed airplanes, but if they're in there, they don't seem to be doing a very good job.

Servo motor using brushed DC motors will create some level of noise. R/C receivers are designed to work with servos so they have the proper internal noise filtering not to be effected by servo generated noise.

I also don't seem to have done a very good job at isolating my audio from this sort of noise in my circuit. I did make sure to have only one entry and exit point for the current into the audio portion of the circuit, and it's on the other side of the board from the servo ports, and the power source is between the two, so I thought that would be sufficient to avoid this issue, but apparently my efforts were either insufficient, or the noise is being radiated from the servo line and the audio line is picking it up or something. But I suspect it's direct transfer on the board itself.

Hard to say, a good oscilloscope can be used sometimes to identify the noise which is the first step to identifying the best method of filtering/protecting something from it.

You can see the layout of my board here. The servo is attached to port 9. So the current for the servo either flows in from the top of the board from the mosfet on the top right, or under the microcontroller and past the switch, I'm not sure. The audio portion is in the lower right, and there is a fairly straight line for the positive plane to the mosfet, but the ground plane current has to go around the LED pins:
http://shawnswift.com/arduino/mighty-layout.png

This was as good as I could get it, and as far as noise from other sources goes, like a vibration motor I've got attached via a mosfet and with a protection diode... That works just fine. I don't hear any noise at all from it. And I'm switching it on and off rapidly. It's just these darn servos, which are plugged into the same ports that are the issue.

Is it perhaps just the servos are inadequately noise protected? I mean I hardly did anything for my vibration motor other than that diode. Might there be some way to modify a servo cable to reduce the noise? Put a choke on it for example?

Vibration motors generally are much lower current then the DC motors used in servos so maybe that would account for your observations?

You are generating audio only? In that case the chief suspect is the supply rail - you should power audio DAC + amps from a separate power
rail with its own regulator and at lots of decoupling (0.1iF + 10uF + 100uF for instance). Separate voltage regulator is vital if your
DAC's reference voltage is the supply rail (and it needs to be linear, not switch-mode).

The layout looks good and you don't appear to have low-level audio signals that could be picking up RFI.

MarkT:
You are generating audio only?

What do you mean?

I am reading audio from an SD card, updating LEDs, reading inputs, and turning pins on and off for a strobe and vibration motor, but none of that generates any noise in the line. I only get noise when I have a servo plugged in and I'm actively moving it.

In that case the chief suspect is the supply rail - you should power audio DAC + amps from a separate power
rail with its own regulator and at lots of decoupling (0.1iF + 10uF + 100uF for instance). Separate voltage regulator is vital if your
DAC's reference voltage is the supply rail (and it needs to be linear, not switch-mode).

Hm, well it's far too late for that, but I'll keep it in mind in the future. What about the ground though? Even if I have it on a separate 5v rail, the grounds must still be shared.

The layout looks good and you don't appear to have low-level audio signals that could be picking up RFI.

I'm not sure what you mean by this either.

In RC-model air planes we often use these ferrit rings on the servo leads, close to the receiver to avoid noise problems.

You can get the as clip-on too

I just remembered something.

My boards don't have an onboard voltage regulator. I use an external regulator or USB power to supply the 5V I need. Or I power it directly from 3 AA batteries. This means I couldn't add a linear regulator for my audio, because to supply 5V to the audio circuit I'd need to supply the regulator with more than 5V.

I suppose I could create a servo control module of some kind which uses an external power source, but the whole point of this board is to be as small as possible and be a light, sound, and motion controller. A separate servo module would likely not fit in a small handheld prop with servos.

Any other ideas for how I could prevent noise from getting into my audio circuit? Inductors where the digital power and ground planes connect to the analog ones perhaps? I've seen inductors in some papers I've looked at. But my budget and space constraints didn't really allow for them at the time and I thought I could get away without them. Is it possible to get really tiny inductors?

Oh, and the reason I used an external regulator was because late in my design process I discovered the linear regulator I was going to use wasn't going to be able to supply more than 2A without melting my board down and I didn't have space for a heat sink, or the money, space, or time to add a switching regulator, so I ended up purchasing a bunch of fixed 5V switching regulators to get the job done.

Well, I just did a couple tests with some interesting results.

First, I discovered that my cheap chinese switching regulators which are supposed to supply up to 3A seem to fail when I use them as my power source and try to drive a servo. Mostly I've been running off USB power when doing my tests, and I know that can only supply up to 500mA. So something weird is going on. I know the switching regulators can actually supply up to 5A peak because I tested them with my multimeter.

So perhaps the issue is the switching regulator is unable to supply power quickly. There's some 220 ohm caps on the input and output of the regulator though, so I'm not sure what more could be done there. The regulator on these boards is the LM2596S: LM2596 data sheet, product information and support | TI.com

Or, maybe the problem is the power source itself, which is six C cells of unknown age. I don't have any LiPoly batteries to test with though. I suppose I could try fresh C cells.

Anyway, the other test I did was to run the main board on USB power, power the servo with the voltage regulator, and connect the grounds. This worked like a charm. The huge amounts of static I was getting disappeared. So I know the static isn't coming from the servo's signal line, or from emf getting into my audio lines. It must be from the power. Perhaps an inductor or some caps would help there, but until I know the voltage regulator can even power the servo at the same time as the board with an adequate power source, I'm not gonna mess around with that.

At least I know now I can drive servos without noise if I use a separate power source. That at least is a workable solution.

Oh, and I did finally test the vibration motor going with a quiet sound effect going and I do notice that I can hear some quiet pops with that. So even the vibration motor isn't immune from causing noise. I guess I should have used an inductor on that, but it's not really a major concern since the only time you really use the vibration normally is with loud sound effects.

Just a quick update to mention that I found one of those clip-on ferrite things on a spare cable I had and stuck it on the servo wire to see if that would have any affect on the noise, but it didn't make any difference.