How to Implement Filtering in Control Circuits

Control Circuit and PCB Design / Visits:21

In the world of precision control, from animatronic puppets to robotic arms and RC aircraft, the micro servo motor reigns supreme. These compact, integrated packages—combining a DC motor, gear train, potentiometer, and control circuitry—are marvels of accessible motion. Yet, anyone who has deployed one in a sensitive application knows a hidden truth: the path to buttery-smooth, accurate, and reliable performance is often littered with jitters, oscillations, and unexplained twitches. The culprit? Almost invariably, it's electrical noise. This blog dives deep into the art and science of implementing filtering in control circuits, using the micro servo as our central, practical case study.

Why Your Micro Servo Jitters: The Noise Problem

Before we fix a problem, we must understand it. A micro servo operates on a Pulse Width Modulation (PWM) signal. The control circuit inside the servo interprets the pulse width (typically 1.0ms to 2.0ms) to determine the target position. This is a low-power, analog-friendly process. However, the environments we place servos in are electrically hostile.

Common Sources of Noise in Servo Circuits: * Power Supply Ripple: Switching regulators or inadequate filtering on battery leads introduce alternating current (AC) ripple on the supposed direct current (DC) supply line. * PWM Signal Integrity: Long, unshielded wires from the microcontroller (like an Arduino or Raspberry Pi) to the servo act as antennas, picking up electromagnetic interference (EMI). * Back-EMF and Brush Noise: The DC motor inside the servo generates back-electromotive force (back-EMF) spikes every time it starts, stops, or changes load. Brushed motors (common in cheaper servos) also create significant electrical noise through arcing. * Shared Power Bus Noise: Other components on the same power rail—especially other motors, solenoids, or wireless modules—can induce large transient currents and voltage dips. * Digital Crosstalk: Fast-switching digital lines running parallel to servo control wires can capacitively couple noise into the signal path.

This noise manifests as an erratic signal at the servo's control IC or superimposed on its power supply. The result? The servo's internal feedback loop gets confused. It "sees" a jittery target position or experiences power fluctuations that affect its internal comparator, causing it to constantly hunt for a position that doesn't exist. The output is that frustrating jitter, buzz, or reduced holding torque you observe.

The Filter Toolbox: From Passive to Active

Filtering is the process of selectively allowing certain electrical frequencies to pass while attenuating others. For servos, we generally want to pass our low-frequency DC power and slow-changing PWM signal, while blocking high-frequency noise.

Passive Filters: The Simple Saviors

Passive filters use only resistors (R), capacitors (C), and inductors (L). They require no external power and are excellent for broad-spectrum suppression.

1. The Bypass/Decoupling Capacitor (Your First Line of Defense)

This is the most critical and simplest filter. A ceramic capacitor (typically 0.1µF to 10µF) placed physically close to the servo's power pins, between VCC and GND. * How it Works: It provides a very low-impedance path to ground for high-frequency noise on the power line, preventing it from entering the servo. It also acts as a tiny local energy reservoir for instantaneous current demands. * Implementation: Solder a 0.1µF ceramic capacitor and a 100µF electrolytic capacitor in parallel directly at the servo's connector leads. The ceramic handles very high frequencies, the electrolytic handles lower-frequency ripples.

2. The RC Low-Pass Filter on Signal Lines

If your PWM signal is noisy, a simple resistor-capacitor (RC) filter can smooth it. * Design: Place a small resistor (e.g., 100Ω to 1kΩ) in series with the PWM signal line, right before the servo. Add a capacitor (e.g., 0.1µF to 1µF) from the servo-side of the resistor to ground. * The Trade-off: Bandwidth vs. Stability. The filter's cutoff frequency (f_c = 1/(2πRC)) must be higher than your PWM signal's fundamental frequency (usually 50Hz or 60Hz for servos) to avoid distorting the pulse itself. A 1kΩ resistor with a 0.1µF capacitor gives a cutoff of ~1.6kHz, which passes the PWM but filters much higher noise. Warning: Too much filtering will round the PWM edges, potentially causing the servo to misinterpret the pulse or respond sluggishly.

3. Ferrite Beads: The Frequency-Dependent Resistor

A ferrite bead is a component that acts as a high-frequency resistor (inductor). It presents low impedance at DC (so your power passes freely) but high impedance at RF frequencies, choking the noise. * Implementation: Thread the servo's power or signal wire through the bead several times, or use a bead with integrated leads. Place it close to the servo or the noise source.

Active Filters and Advanced Techniques

For more demanding applications, active components can provide sharper filtering.

1. Voltage Regulators with Good PSRR

Power your servo from a dedicated low-dropout (LDO) linear voltage regulator, not directly from a noisy switching supply. Choose an LDO with a high Power Supply Rejection Ratio (PSRR), which specifies how well it rejects input ripple. This provides a clean, stable voltage rail.

2. Signal Buffering and Isolation

Sometimes the best filter is isolation. Using a separate microcontroller pin buffered through a simple op-amp circuit or a dedicated logic buffer IC (like the 74HC125) can prevent digital noise from the MCU's internal switching from reaching the servo line. For extreme isolation, opto-isolators break the direct electrical connection entirely.

A Step-by-Step Implementation Guide for a Micro Servo Project

Let's walk through a practical scenario: You're building a pan-tilt camera head using two micro servos (SG90 type). The servos are jittery when the camera module and WiFi are active.

Step 1: Diagnose the Noise Source

  1. Power the servos from a clean, bench power supply or a fresh battery pack, separate from your microcontroller. If the jitter stops, the issue is power supply noise or a weak supply.
  2. If jitter persists, disconnect the PWM signal wire and see if the servo holds still (under no load). If it still moves/jitters, the noise is entering via the power line or is internally generated (back-EMF).
  3. Use an oscilloscope if available to look at the VCC line at the servo and the PWM signal. Look for ripple or spikes.

Step 2: Implement a Robust Power Filtering Stage

  1. At the Power Source: Use a linear regulator (e.g., LM7805 for 5V servos) for the servo power rail, separate from your digital logic power.
  2. At the Servo Connector: For each servo, create a small "filter pod." Solder a 100µF electrolytic capacitor (positive to VCC, negative to GND) and a 0.1µF ceramic capacitor in parallel directly across the servo's plug leads. Use heat shrink tubing.
  3. On the Power Wires: Add a ferrite bead on the VCC wire, about an inch from the servo connector.

Step 3: Clean Up the Signal Path

  1. Keep PWM wires as short as possible and route them away from power lines and other noise sources.
  2. Implement a mild RC filter. For a 50Hz PWM signal, try R = 220Ω, C = 0.047µF (cutoff ~15.4kHz). This will soften but not destroy the pulse edges. Test the servo's response time to ensure it's still acceptable.
  3. In your microcontroller code, ensure the PWM frequency is set correctly for servos (usually 50Hz). Avoid using digitalWrite() loops for servo control; use the hardware PWM timers, which produce cleaner signals.

Step 4: System-Wide Best Practices

  • Star Grounding: Run a thick, common ground wire from your main power source to a central point. Connect the grounds from your microcontroller, regulator, and servo filters to this point. Avoid daisy-chaining grounds.
  • Physical Layout: Keep high-current servo power wires and low-current signal wires physically separated. If they must cross, do so at a 90-degree angle.
  • Shielding: In electrically noisy environments (e.g., near brushless drone motors), use shielded cable for the PWM signal, connecting the shield to ground only at the microcontroller end.

The Limits of Filtering: When Hardware Meets Software

Even the best hardware filtering has limits, especially with low-cost servos that have minimal internal filtering. This is where software filtering becomes a powerful co-pilot.

  • Command Smoothing: Instead of sending a raw target angle from a sensor (like a potentiometer or IMU), implement a software low-pass filter or a moving average filter on the value before converting it to a PWM pulse width. This smooths out abrupt changes and high-frequency noise in the command signal itself. cpp // Simple moving average filter pseudo-code const int numReadings = 10; int readings[numReadings]; int index = 0; int total = 0; int average = 0;

    int getFilteredCommand(int rawCommand) { total = total - readings[index]; readings[index] = rawCommand; total = total + readings[index]; index = (index + 1) % numReadings; average = total / numReadings; return average; }

  • Deadband Implementation: Program a small "deadband" around the target position where no new corrections are sent. This prevents the system from constantly reacting to infinitesimal, noise-induced errors.

By combining robust hardware filtering—focused on clean power and a clean signal—with intelligent software techniques, you can transform a jittery, unreliable micro servo into a precise, silent, and trustworthy actuator. The journey from erratic movement to smooth, controlled motion is a fundamental engineering challenge, and mastering filtering is the key that unlocks professional-grade results in your projects.

Copyright Statement:

Author: Micro Servo Motor

Link: https://microservomotor.com/control-circuit-and-pcb-design/implement-filtering-control-circuits.htm

Source: Micro Servo Motor

The copyright of this article belongs to the author. Reproduction is not allowed without permission.

About Us

Lucas Bennett avatar
Lucas Bennett
Welcome to my blog!

Tags