Personal build
Cycloidal Stepper Actuator

01 / Overview
I'm building a robot actuator from the motor up. A NEMA 17 stepper runs closed loop with field-oriented control (FOC). It drives a 3D-printed 25:1 cycloidal gearbox, and a 14-bit magnetic encoder on the back of the motor closes the loop, all on an STM32.
Two of these will drive the shoulder and elbow of a roughly 5 DOF desk arm that picks up and organizes small objects. The actuator is the part I care most about, so it gets the detail here.
Where it is today: actuator v2 is assembled, runs closed loop through the gearbox, and has its first no-load test data. Torque and backlash aren't measured yet.
02 / Scope
What it had to do
The numbers came from the arm. Holding 200 g at 50 cm puts about 5 N·m on the shoulder once the arm's own mass is counted. With the L298N driver capped at 2 A, 25:1 gives a ceiling of roughly 7.9 N·m on paper. That's an estimate, not a measurement yet.
- Ratio
- 25:1, one stage
- Ring pins
- 26 × Ø3 on Ø50
- Housing
- Ø69 mm (v2)
- Motor
- NEMA 17, closed-loop FOC
- Encoder
- 14-bit AS5047P
- Arm target
- 50 cm reach, 200 g
03 / My contribution
What I did
This is a solo project. I set the requirements and made the design decisions (each one is logged with the options I rejected). I did all the CAD in SolidWorks and tuned the print fits. I also built and wired the hardware and ran and diagnosed the tests.
I used Claude, an AI assistant, a lot along the way. It tutored me through the theory and helped with part sourcing. It also helped me write all of the code: the firmware on top of the SimpleFOC library and the Python test GUI.
How a cycloidal drive works

The motor shaft turns a cam with two lobes, each offset 0.72 mm from the axis and 180° apart. Each lobe carries a 6801 bearing, and each bearing sits in a cycloid disc. As the cam spins, each disc’s centre orbits the motor axis without the disc spinning freely, because its 25 lobes are trapped by 26 fixed ring pins.
There is one more pin than lobes, so every full orbit rolls the disc back by one lobe. That’s 1/25 of a turn in the opposite direction: a 25:1 reduction in one stage.
Six steel output pins pass through holes in both discs. The holes are sized at roller diameter plus twice the eccentricity, so the pins ride the wobble and only pick up the slow rotation. The pins are fixed to the output carrier, which runs on a spaced pair of 6808 bearings. A 688 bearing in the carrier supports the far end of the cam so the motor shaft doesn’t take the side load.
Two discs instead of one balance the eccentric mass and split the load.


System architecture

A NUCLEO-G474RE runs SimpleFOC in voltage mode. The L298N driver has no current sensing, so torque is commanded as a q-axis voltage (Uq) rather than a current. The bench supply sits at 6 V and the firmware is told 4 V, which accounts for the L298N’s roughly 2 V drop. That way a commanded voltage is close to what the coil actually sees. A 2.5 V limit keeps coil current around 1.7 A, under the motor’s 2 A rating.
The AS5047P reads a magnet on the motor’s rear shaft over SPI. The stepper has 50 pole pairs, so any mechanical angle error is multiplied by 50 in electrical angle. That’s why the encoder mount became a mechanical design problem of its own (see Encoder and electronics bring-up).
Today the PC talks to the board over USB serial through a small line protocol with a 1 s watchdog. The CAN parts are on hand (SN65HVD230 transceivers and a USB-CAN adapter) and will replace serial before the arm, so every joint shares one bus.

Key design decisions
Every row is in my notebook’s decision log.
| Decision | Picked | Over | Why |
|---|---|---|---|
| Gearbox | Cycloidal, one stage | Planetary | I already knew planetary from lab work. A cycloid gets a high ratio in one stage, and it was the new challenge |
| Motor | NEMA 17 stepper, my own closed loop | BLDC (T-Motor MN5008) | BLDC was too expensive for now. FOC on a stepper is its own problem to solve |
| Ratio | 25:1 | 20:1 | The L298N’s 2 A cap makes torque the limit. 25:1 gives about 7.9 vs 6.3 N·m on paper |
| Discs | Two, 180° apart | One | Balances the eccentric mass and splits the load |
| Output rollers | Sintered bronze bushings, 3×5×8 | Bare pins, PTFE sleeves, MR63 ball bearings | Drops contact stress on the PETG hole wall from about 50 to 32 MPa at 5 N·m, with no CAD change |
| Output bearings | Two 6808ZZ, spaced pair | One 6808 | One deep-groove bearing acts like a pivot under tilt. A spaced pair turns the moment into a force couple (F = M/d) |
| Output pins | 3×28 steel in a 12 mm socket | The 3×19.6 pins I had, about 4 mm deep | Socket pressure scales with 1/L²: about 80 MPa down to about 8 MPa |
| Encoder link | SPI | ABI | With 50 pole pairs, SPI resolves about 1.1° electrical per count vs 4.4° on ABI |
| Command link | CAN | USB serial per joint | One bus for every joint, with IDs, CRC and arbitration. The G474 has FDCAN built in |
| Driver | L298N | MOSFET drivers, MKS SERVO42D | Cheapest. I accepted the heat and the 2 A cap. It turned out to be the bottleneck (see the driver deadband) |
Printing to bearing tolerances
Every bearing seat in this actuator is printed PETG, so the fits had to be measured rather than guessed. Before printing any actuator parts, I printed coupon plates that sweep each bearing bore and boss in 0.05 mm steps and tested them against the bearings.

What I found on the Bambu A1 with Elegoo PETG HF:
- Holes printed on size at Ø16 to Ø21 and about 0.15 to 0.2 mm small at Ø52.
- Bosses printed 0.2 to 0.3 mm small at every size.
- Press fits landed at nominal + 0.10 mm for the 688 and 6801 bores and + 0.20 mm for the 6808.
Then the actuator parts printed differently from the coupons. The output housing bore came out 51.9 where the coupon gave 52.1. A press fit that felt right over a 5 mm coupon was far too tight over the carrier’s 16 mm boss, and the first 6808 stuck halfway down. The fix was a stepped boss: press fit only on the first bearing’s 7 mm seat, slip fit above it.
Some fits are tradeoffs. Ø3 pin holes vary print to print by as much as the sweep step, so I settled on 3.25. The disc roller holes went to 6.70 (minimum 6.44). That leaves about 0.11 mm of clearance, roughly 0.4° of output backlash on paper, but holes that are too tight would bind the gearbox, which is worse.


Encoder and electronics bring-up
The AS5047P boards ship in 5 V mode, where the chip’s input threshold is 3.5 V. That can’t work with 3.3 V logic. I traced both boards against the schematic and bridged R2 to convert them to 3.3 V.
The motor’s rear shaft is non-magnetic stainless, so the encoder magnet jumped to the motor body instead of sticking. It now sits in a printed holder.
With the board held by hand, the reading wobbled ±250 counts once per turn. That’s about 5.5° mechanical, or about 275° electrical after the 50× pole-pair multiplier: far past the point where FOC torque drops to zero. So I designed a two-piece cage. Corner arms locate on the motor body (0.2 mm offset after a test print), two M2.5 screws into the motor’s rear tapped holes clamp it, and the chip sits 1.5 mm from the magnet.


Other bring-up lessons:
- One of my two L298N modules had a dead channel. The rotor buzzed and rocked until I single-stepped and measured each output. Test the driver before trusting it.
- A wiggle test on the SPI jumpers found intermittent CSn and MOSI wires. A fake 250° jump times 50 pole pairs would have been a violent kick under FOC.
- SimpleFOC 2.4.0 didn’t build on the newest STM32 Arduino core, so I pinned core 2.12.0 in PlatformIO.

Closing the loop

On Nov 12 the bare motor ran closed loop: initFOC passed on every boot, then torque, velocity and angle modes all tracked.
- Zero electrical angle spread over 4 boots: 0.42° at the shaft.
- Angle moves up to 9.3 rad: final error 0.001 to 0.02 rad at the motor, about 0.05° at the output after 25:1.
- Pushed 0.22 rad off target, it pushed back and settled within 0.01 rad.
One thing already showed up here: in torque mode the motor didn’t move below about 1.5 to 2 V. I parked that until the gearbox was on. It became the main finding in the first powered tests.
First assembly, then v2

The first full gearbox went together on Nov 19 and turned on the first try. It also showed three problems.
- Two bearing spacers were designed outside the assembly, so they fit nowhere.
- The cam rubbed the PETG disc bore beyond the bearing. PETG on PETG at input speed means heat and dust.
- The screw patterns of the adapter plate, housing, output housing and cover didn’t line up. Only 2 cover screws went in.
The v2 fixes went into CAD the same evening:
- Outer diameter went from 66 to 69 mm, because the insert holes sat too close to the ring pins. Every mounting screw is now on one Ø60 circle, into heat-set inserts.
- The cover now clamps the outer 6808’s outer race, with a spacer between the outer races so the clamp force doesn’t go through the balls.
- The disc lip hole opened to Ø16.5 so it only touches the bearing’s outer race.
- The housing was reprinted with larger ring pin holes after warping made some pins lean inward. The discs push the pins out into the wall, so a slip fit still locates them.


First powered tests and the driver deadband
Nov 22, no load, logged at 200 Hz through the new test GUI.

What worked
- Position steps of 10° and 45° overshoot about 0.3% and settle within 0.01 to 0.02° at the output, almost identical every repeat. Moves are speed limited to 10°/s.
- Holding still, the jitter is 0.002° (standard deviation).
- Averaged over each motor turn, the voltage needed stays flat within about ±3% across a full output turn in both directions. No tight spots from the carrier, the output bearings or the slip-fit ring pins.


What didn’t
Moving slowly used most of the 2.5 V limit. The fit was about 1.68 V + 0.167 V per motor rad/s, so at 10°/s at the output it was already at the cap.
- Fit: 1.68 V + 0.167 V·s/rad
- Logged runs (approximate)
- 2.5 V limit
My first guess was gearbox friction. The data pointed elsewhere:
- The bare motor needed about 2 V on Nov 12 too, before any gearbox.
- In breakaway runs the output stuck at points exactly 0.288° apart. That’s one electrical cycle, so the torque dip was electrical, not mechanical.
- Stalled supply current at 1.5 V was about 20% of what an ideal driver would give, and almost nothing flowed below 1 V.
- The second L298N behaved the same, and initFOC alignment repeated within 0.06 rad electrical. That ruled out a bad module and bad alignment.
- Ideal driver, U²/(4R), R = 1.48 Ω
- L298N module A (range over 3 rotor positions)
- L298N module B

The cause is the L298N itself. During each PWM off-time, coil current freewheels through a diode and a bipolar transistor. That puts about 1.2 V backwards across the coil. The loss scales with (1 − duty), so it’s worst at low duty, which is exactly the low-speed region FOC cares about. MOSFET drivers avoid it with low on-resistance and synchronous rectification.
I’m keeping the L298N for now and adding deadband compensation in firmware. Then I’ll rerun the sweeps to see what the gearbox really costs. The driver choice gets revisited when the arm design starts.
What’s next
First powered tests
No-load steps overshoot about 0.3% and holding jitter is 0.002°. The low-speed voltage turned out to be L298N deadband, not gearbox friction.
Actuator (Phase 1, running about a week behind and expected to spill into the December exam buffer):
- Stall torque on a printed lever arm (r = 100 mm) and a kitchen scale, at 2 to 3 voltage limits.
- Backlash from load against displacement at the lever, both directions.
- Deadband compensation in firmware, then rerun the sweeps and breakaway.
- CAN link between the Nucleo and the PC.
- Build actuator #2.
Arm (Phase 2, Dec 21 to Feb 7): arm CAD, forward and inverse kinematics derived by hand, all joints under software control, then Cartesian moves. Shoulder and elbow use this actuator. Base, wrist and gripper use smart servos.
Task (Phase 3, Feb 8 to Mar 31): scripted pick-and-place that organizes small objects on my desk, a final demo video, and a write-up. Stretch goal: learn the pick from demonstrations with a desk camera (ACT via LeRobot).
What I learned
- Design parts in the assembly, not on their own. Both the spacer and the screw-hole problems came from parts drawn in isolation.
- Coupons give the size, but big parts and long press fits print differently. Leave margin on large bores and only press where the bearing sits.
- Test a driver before trusting it. It cost me a dead channel on Oct 31 and explained the deadband on Nov 22.
- Pole pairs multiply everything. With 50 of them, encoder mounting is as much a mechanical problem as an electrical one.
- Logging every session paid off. The same 2 V on the bare motor 10 days earlier is what pointed away from the gearbox.
14 / A closer look
Photos and clips








Photos are from my bench. CAD renders are from SolidWorks. The diagrams are drawn from my design numbers.
15 / Where it stands
Actuator in testing
- Actuator v2 assembled, closed loop through the gearbox
- First no-load data: precise positioning, driver deadband diagnosed
- Not measured yet: stall torque and backlash
- Next: torque and backlash on the lever arm, CAN, unit #2
Keep exploring
All projectsTendon-Driven Robotic Gripper
A 3-finger gripper prototype: an adapted open-source finger design for rubber-band and string tendons, with a 3-servo palm and one finger opposing two.


