- 1. Introduction
- 2. Credits
- 3. Technical Specifications
- 4. PCB & Hardware Revisions
- 5. CAD & Mechanical Design
- 6. Firmware & PlatformIO Environments
- 7. Additional Tools
- 8. Changelog
The N20 Servo is an affordable, high-performance(?) closed-loop actuator system built around the WCH CH32V003 RISC-V 32-bit microcontroller. The project was created from my dissatisfaction of the SG90 servo performance: lots of backlash and weak torque, and the failed attempt when trying and modify the servo with the DIY solution (link in Credits) but found it rather hard to properly install the very thin metal wiper and secure the potentiometer body onto the metal surface of the motor. Therefore, I set my goal on creating a better alternative.
This project contains the firmware, CAD assemblies, PCB views, and debugging utilities required to build, test, and tune.
If there's anything wrong, you can raise an issue and let me know. Thank you for your help.
This project is designed, developed, and maintained by: imdolce (aka dolce_st, hovietkien49).
Important
Code base development is assisted by OpenAI Codex. On my side, I try to read and comprehend the functions used on this chip or the whole CH32 family in general, as it is my first time working with this chip.
Other sources and ideas:
- DIY Servo Modding Guide: How to convert an N20 gear motor into a servo using SG90 parts — by JANIUL HAQ
- Angle Sensor Adapter: N20-Servo-Module (3D print + N20 motor + angle sensor = servo motor) — by jkugalde
- N20 DC Motor CAD Model: N20 DC Gear Motor | GrabCAD Library — by RamBros 3D
- SG90 CAD Model: SG90 Micro Servo 9g | GrabCAD Library — by Mattheus Frasson
The following table outlines the hardware and software specifications of the N20 Servo:
| Parameter | Specification | Notes |
|---|---|---|
| Microcontroller | WCH CH32V003J4M6 (RISC-V 32-bit Core @ 48 MHz) | Dirt cheap 5 cents MCU. |
| Operating voltage | 5V | Shared power bus with motor driver. |
| Actuator | N20 Geared DC Motor | High torque, compact size. |
| H-bridge chip | RZ78xx, SA8301, DRV8210, DRV8837 | RZ78xx driver series include: RZ7888, RZ7889, RZ7899. Currently the RZ7888 and SA8301 are used because it's cheap. |
| H-Bridge Output | Dual-PWM control on PC1 and PC2 |
Drives motor direction and speed using TIM2. |
| PWM Frequency | 2.0 kHz | Adjustable via MOTOR_PWM_HZ in config. |
| Position Feedback | SV01A103AEA01R00 10K (or similar clones) angle position detector (Wiper input pin PA2) |
Read via ADC1 Channel 0, 10-bit resolution.. |
| Traverse range | Up to 330° (-165° to +165° symmetrical) mechanical travel | To make the servo safely accomodate within the wiper track of the angle detector, the traverse angle is limited to 320° (-160° to +160° symmetrical). |
| Input Signal | 50 Hz RC Servo PWM, PC4 |
Captured via TIM1 Channel 4 (1000µs to 2000µs, 0° angle at 1500µs). |
| Polling rate | 500 Hz (2 ms) | Position feedback and control loop. |
| Telemetry UART | 921600 baud on PD5 (UART1 Remap 2 TX) |
CSV telemetry output for live tuning. |
Tip
You can view & get the PCB schematic and designs in this repository, or visit my post on OSHWLAB (coming soon).
Important
It is not recommended to order PCB of the initial version 1D2 (1Д2), as it requires good soldering skill to install components on both sides and wiring up the angle detector with bodge wires. The 1D3 (1Д3) version aims to resolve both issues. More details will be added as soon as I can get my hands on the new 1Д3 PCB.
The electronics are designed to fit directly on top of the N20 motor. The enclosure is designed specifically for the first revision 1Д2
In this new version, it aims to resolve the difficulty of populating the PCB and wiring the angle detector. Currently I have not tested the design myself, so documentation is limited. There are 5 different PCB designs, 1Д3-1/2/3/4 incorporates 4 different designs of 4 different motor drivers, it was made to avoid ordering multiple PCB revisions. The remaining 4 designs 1Д3-1, 1Д3-2, 1Д3-3, 1Д3-4 are standalone boards, using the SA8301, RZ7888, DRV8210DRLR, DRV8837DSGR respectively to each design.
| View | Image | Description |
|---|---|---|
| PCB View | ![]() |
Coming soon. |
| Top populated view | ![]() |
Coming soon. |
| Bottom populated view | ![]() |
Coming soon. |
The enclosure is designed using Onshape. The link is included here: CAD Design
Important
Use 4x M1.4x6 Self-tap SHCS and a 1.3mm Allen key or T4 Torx screwdriver bit to close and secure the top cover. The same screw size will persist across all future releases.
The firmware is written in C, using WCH Standard Peripheral Library (StdPeriphLib) aka noneos-sdk. The project is managed using PlatformIO.
To compile and upload the default firmware environment using a WCH-LinkE programmer, run:
platformio run -e genericCH32V003J4M6_servo_control -t uploadOr click the Upload button
The environment for this project is defined in platformio.ini:
| Environment Name | Description | Build Configurations |
|---|---|---|
genericCH32V003J4M6_servo_control |
Production Closed-Loop Servo: Primary operational environment. Telemetry output is disabled to prevent UART TX blocks and ensure minimum control loop jitter. | TEST_MODE_SERVO_CONTROLSERVO_CONTROL_TELEMETRY_ENABLE=0 |
genericCH32V003J4M6_servo_control_debug |
Debug Closed-Loop Servo: Enables high-speed CSV telemetry output via UART for visualization and tuning. | TEST_MODE_SERVO_CONTROLSERVO_CONTROL_TELEMETRY_ENABLE=1 |
genericCH32V003J4M6 |
Motor Sweep Test: Periodically drives the motor from limit to limit. Useful for verifying gear engagement, mechanical tolerances, and limits. | TEST_MODE_MOTOR_SWEEP |
genericCH32V003J4M6_adc_only |
ADC Calibrator: Reads the position potentiometer raw values and displays computed angles. Essential for finding POT_ADC_AT_NEG160 and POT_ADC_AT_POS160 parameters. |
TEST_MODE_ADC_ONLY |
genericCH32V003J4M6_rc_input_capture |
PWM Signal Capture Monitor: Measures the pulse width and period of incoming RC PWM signals without driving the motor. Used for verifying receiver compatibility. | TEST_MODE_RC_INPUT_CAPTURE |
To facilitate tuning and development, the project includes desktop tools located in the tools/ folder. Precompiled executables are included alongside their source Python implementations.
Refer to Tools guide
- File:
tools/python/serial_dashboard.py(Executable:tools/serial_dashboard.exe) - Description: Reads the high-speed UART telemetry stream and plots real-time curves showing command target vs. measured position, error metrics, motor duty cycle, and signal validity.
- Usage:
python tools/python/serial_dashboard.py --port COM5 --baud 921600 - Test / Demo Modes:
(This will be removed in the next release).
Or use the included executeable.
python tools/python/serial_dashboard.py --demo --demo-mode servo python tools/python/serial_dashboard.py --self-test
- File:
tools/python/servo_configurator.py(Executable:tools/servo_configurator.exe) - Description: A graphical user interface using Tkinter for inspecting and editing the configuration header
include/servo_config.h. It automatically checks configuration boundaries, performs self-tests, and saves a timestamped backup before modifying the file. - Usage:
Or use the included executeable.
python tools/python/servo_configurator.py
- v1.1.0: Added precompiled executable for
serial_dashboard.pyandservo_configurator.py, released new PCB version1Д3-1/2/3/4and its standalone variants. - v1.0.0: Initial release, no documentation available..











