Close

The "Twitchy Leg Syndrome" and the Op-Amp Solution

A project log for TNY-360: High-Speed Closed-Loop Quadruped Platform

The best Open-Source quadruped robot for learning AI and robotics.

paul-loisilPaul LOISIL 04/23/2026 at 10:312 Comments

When I started designing the TNY-360, I knew I wanted closed-loop control. "Blind" PWM servos just don't cut it if you want to do real robotics (calculating inverse kinematics, detecting terrain, auto-calibration). But spending $50+ per smart servo for a 12-DOF quadruped wasn't an option.

So, I did what every budget-conscious maker does: I bought a bunch of $5 digital MG996R servos and decided to hack them to read their internal potentiometers.

The internet makes it sound so easy: "Just solder a 4th wire to the middle pin of the servo's potentiometer and plug it into your ESP32's ADC!"

So I did exactly that. I wired up all 12 legs, powered up the robot, and... it was a disaster. The limbs were shaking uncontrollably, the robot looked like it was having a seizure, and the position readings were clearly unusable.

What went wrong? Physics.

After pulling my hair out, I realized the problem wasn't my code, it was the electrical reality of a fully assembled robot:

I realized I couldn't just read the potentiometer directly. I needed an intermediary. Enter the Operational Amplifier (Op-Amp)!

Instead of a simple RC filter (which wouldn't solve the current-draw issue), I designed a tiny custom PCB that fits completely inside the MG996R's casing. On this board, I put an Op-Amp configured as a voltage follower (buffer).

The Result

Combined with a software low-pass filter on my ESP32's "Reflex Core", I can now poll the exact position of all 12 motors at a blistering 200Hz, with zero twitching and buttery smooth movements.

We turned a $5 dumb servo into a high-speed, closed-loop actuator!

If you want to see the exact schematic of this micro-PCB, or if you want to mod your own servos for your projects, I’ve documented the entire step-by-step process on the project's website:
See the servo mod

Discussions

dekutree64 wrote 04/27/2026 at 20:40 point

Eliminating the current draw on the potentiometer makes sense, but why is the antenna effect not still a problem?

  Are you sure? yes | no

Paul LOISIL wrote 04/28/2026 at 06:43 point

The wires still act as antennas (there's a noise of about 4 to 6mV), but because the OP-AMP is wired as a voltage follower, it blocks this noise from going back to the potentiometer's wires (by moving it to the GND or VCC pins, kind of like a Schottky diode I guess).

The goal was to avoid the noise from disrupting the internal controller, not to remove the noise completely. On the other side (were the ESP32 is) we can still use a small capacitor or a software low-pass filter to get rid of that noise in the readings. (I used a capacitor first, and switched to a software filter later, both methods work fine)

  Are you sure? yes | no