Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

N20 Servo CAD Assembly

N20 Servo

A CH32V003-powered small size closed-loop actuator

PlatformIO CH32V003J4M6 Language C License


Table of Contents


1. Introduction

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.


2. Credits

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:


3. Technical Specifications

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.

4. PCB & Hardware Revisions

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.

1. Initial version 1D2 (1Д2)

The electronics are designed to fit directly on top of the N20 motor. The enclosure is designed specifically for the first revision 1Д2

View Imagew Description
PCB View PCB View Bare PCB appearance, top and bottom view.
Top populated view Top Populated PCB Fully populated top view of the PCB.
Bottom populated view Bottom Populated PCB Partially populated bottom view of the PCB, bottom 2 22uF capacitors are removed due to their interference with the motor below.
Angle sensor and adapter collet Angle Sensor Top and bottom view of the angle sensor, with the adapter collet installed, the standalone collet (second to the left side) the 3D printed custom fixture to easily print the adapter collets (white rectangle on the left side)
Test setup Test Setup Consists of: Partially assembled N20 Servo assembly (to make space for the Outcoming UART TX telemetry), WEMOS D1 Mini for PWM output, WCH-LinkE for UART telemtry reading and MCU programming.

2. Second version 1D3 (1Д3)

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 PCB View Coming soon.
Top populated view Top Populated PCB Coming soon.
Bottom populated view Bottom Populated PCB Coming soon.

5. CAD & Mechanical Design

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.

Isometric View
Isometric View
Front View
Front View
Side View
Side View
Rear View
Rear View
Top View
Top Down View

6. Firmware & PlatformIO Environments

The firmware is written in C, using WCH Standard Peripheral Library (StdPeriphLib) aka noneos-sdk. The project is managed using PlatformIO.

Build & Uploading

To compile and upload the default firmware environment using a WCH-LinkE programmer, run:

platformio run -e genericCH32V003J4M6_servo_control -t upload

Or click the Upload button

PlatformIO Environments

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_CONTROL
SERVO_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_CONTROL
SERVO_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

7. Additional Tools

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

1. Serial Dashboard

  • 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).
    python tools/python/serial_dashboard.py --demo --demo-mode servo
    python tools/python/serial_dashboard.py --self-test
    Or use the included executeable.

2. Servo Configurator

  • 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:
    python tools/python/servo_configurator.py
    Or use the included executeable.

8. Changelog

  • v1.1.0: Added precompiled executable for serial_dashboard.py and servo_configurator.py, released new PCB version 1Д3-1/2/3/4 and its standalone variants.
  • v1.0.0: Initial release, no documentation available..

About

SG90 servo alternative using the popular N20 geared DC motor.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages