CLN17: Closed-Loop Driver for NEMA17

A compact, silent, high-performance Closed-Loop (servo) Stepper Motor Driver that supports CAN-FD and USB-C with PowerDelivery

Similar projects worth following
The CLN17 motor driver is an open-source, compact, high-performance closed-loop stepper motor driver designed specifically for NEMA17 form factor motors. The driver offers advanced features such as silent and smooth motion, high-precision position control, and energy-saving capabilities, making it ideal for various applications.

This project wasn't merely born as yet another driver; it was envisioned as a mighty instrument for education, development, experimentation, and the modeling of mechanical systems. Its mission? To resolutely meet every requirement and address all the needs that may arise during the journey with stepper motors, once and for all!

The project is actively evolving and improving! If you wish to be a part of it, ask questions, or simply watch its progress, join the project's Discord server -

Driver development will lead to content updates on this page and the project website - Stay tuned!

Assemly preview

Board Diagram

Key Features | All Features

  • 🕹️ Closed-Loop Control: Enables precise motion in challenging conditions.
  • 💪 Adaptive Torque Control: Optimizes energy efficiency, reduces stress, and extends motor lifespan.
  • 🧩 Reliable Operation and Enhanced Safety: Ensures reliable operation and protects users from potential harm.
  • 🛡️ Modular Concept: Provides flexibility and cost-effectiveness through various configurations and expansion boards.

Key Specs | All Specs

  • 🔌 Wide Input Voltage Range: 5-25VDC with reverse polarity and surge protection
  • ⚡️ Powerful Motor Control: 1.4A RMS current per phase with up to 2.5A peak and up to 1/256 microstepping
  • 🚀 High-Performance MCU: STM32G431CB Arm Cortex-M4 running at 170MHz with Classic EN/DIR/STEP interface, CAN-Bus, I2C, UART and USB Type-C with PD2.0 support,
  • 🔒 Compact and Durable Design: 38x38mm PCB, with optional aluminum housing for heat dissipation and mechanical protection and minimal height of 7.5mm (10mm with connectors)

Applications | In-depth

  • 🎓 Learning Platforms
  • 🛠️ CNC Machines & 3D printers
  • 🤖 Robotics & Automation Systems
  • 🤝 Collaborative Robots
  • 🔭 Camera & Telescope Stabilization Systems
  • 🔬 Laboratory Equipment
  • 🏭 Industrial Motion Control Systems
  • 📳 Haptics & Force Feedback Systems

What is the project's status?

There are numerous updates planned for the documentation, including the publication of articles on related topics. Alsowill be provided insights into development process, announce new versions, introduce new features, and much more. Here's a concise breakdown of major and immediate updates:

✅ Completed:

  • Project Conceptualization: The initial idea and blueprint of the project.
  • First Prototype Development: Crafting the initial version of our product.
  • Design Completion: Finalizing (or nearly finalizing) the product's design.
  • Final Prototype Testing: Evaluating the last prototype to ensure functionality and reliability.
  • Wiki and Specifications: Developing a comprehensive wiki and detailing the product's specifications.

🔜 In Progress:

  • Hardware Documentation: Providing essential information and guides about the hardware components.
  • Library for TMC2209: Developing a STM32 library to manage all TMC2209 registers using UART communication.
  • Library for TLE5012B: Crafting a STM32 library for interactions with TLE5012B registers via SPI.
  • Basic Driver Function Code: Producing the foundational source code for executing the product's essential operations.

📅 Scheduled:

  • PowerDelivery Support Library: Working on a library that will support PowerDelivery functionalities.
  • CLN17 Lite: Simple and cheap version for basic tasks (CAN-FD, IMU excluded)
  • CLN17 Pro: Advanced version with higher currents and voltages (TMC2240 based)
  • CLN234 Version: Developing a variant that can control NEMA23 and NEMA34 motors, supporting up to 55V 10A (TMC5160 based)

Should there be significant interest, the project will establish Kickstarter Campaign and its own store to cater to the entire community's needs!

  • 1 × CLN17 PCBA For control the motor
  • 1 × NEMA17 Stepper Motor The motor as it is
  • 1 × Diametrically magnetized magnet D5xH2mm To determine the shaft orientation with a magnetic encoder
  • 1 × Aluminum enclosure For positioning, securing, protecting and cooling the board
  • 2 × DIN912 M3 For securing to the motor

View all 7 components

  • Note about USB Type-C and board programming

    Anton Khrustalev6 days ago 0 comments

    In many small-scale embedded projects, the Type-C connector has historically seen limited use. However, there's a noticeable shift towards its adoption in recent times.

    For the most part, Type-C acts as an up-to-date substitute for the now-obsolete Mini-USB or Micro-USB connectors. Their primary roles have been to provide 5V power and to function as a USB2.0 interface. Let's sidestep the frequent oversight by some developers who forget to incorporate the 5.1k resistors.

    Yet, the utility of Type-C extends far beyond merely replacing aged connectors!

    Note: This discussion excludes Type-C configurations that necessitate USB3.0 or the 24-pin connector due to their intricate design.

    A popular adaptation of Type-C is the 16-Pin variant:

    • 8 pins are used for power (4 for GND and 4 for VCC to withstand currents up to 3A or 5A - check datasheet for connector)
    • 4 pins are used for orientation-independent USB 2.0 (2 for D+ and 2 for D-)
    • 2 pins, CC1 and CC2 (Configuration Channel), are used for PowerDelivery communication
    • 2 pins, SBU1 and SBU2 (SideBand Use) - are nt used except for 'alternate mode' or 'Audio Accessory Mode'.

    Employing PowerDelivery can yield voltages and currents ranging from:

    • 5-20V at 5A (max 100W) for PD2.0
    • 3.3-21V at 5A (max 100W) with 20mV steps in PPS mode for PD3.0
    • 3.3-48V at 5A (max 240W) with 100mV steps in PPS+EPR mode for PD3.1.

    However, two pins in the connector – SBU1 and SBU2 – often remain untouched. They're designated for 'alternate modes' that rely on USB3.0 signaling lines. Since many projects bypass USB3.0, these pins stay dormant. But consider the potential: what if we repurpose these pins for debugging or programming? Imagine using them for the SWD or UART interfaces, both of which require just two lines! For example

    In terms of compatibility, the Type-C standard dictates that the impedance of inactive SBU lines should exceed 950kOhm. With CMOS-based communications (like UART and SWD), this specification is almost always met. Additionally, if a Type-C cable lacks USB3.0 support, it likely won't carry SBU signal lines, eliminating potential concerns. And given the resilience of UART and SWD protocols, coupled with their data integrity checks, inadvertent mishaps are unlikely.


    • Single connector on the board, ensuring reliable contact.
    • Eliminates the need for bulky programming pads, especially in micro-projects.
    • Debugging flexibility with extended cables.
    • Firmware updates without having to disassemble the device.


    • Mandatory attention to Type-C orientation since signaling is orientation-specific.
    • Programming requires a slightly pricier Full Featured Type-C Cable.
    This is a raw note, will be corrected late

    Linked project: #SWD over USB Type-C: New way of programming boards 

  • Theoretical and real positioning accuracy

    Anton Khrustalev6 days ago 0 comments

    The motor driver allows for position control down to a microstep of 1/256 (<0.01°), while the encoder has a maximum resolution of 15 bits (0.01°). Although theoretical accuracy should be close to 0.01°, it is not achievable in practice due to four factors:

    1. Motor imperfections: The construction of stepper motors commonly causes step size deviations of 2-5% in the degree measure.
    2. Step interpolation non-linearity: Increased difficulty in positioning is caused by a significant torque decrease with interpolation increase, in combination with the mechanical nonlinearities of the mechanical construction.
    3. Encoder imperfections: The effective resolution may be less than 15 bits due to nonlinearity of encoder measurements, variations in operating temperature, or interference with external magnetic fields.
    4. Magnet imperfections: The magnetic field profile created by the magnet may not rotate correspondingly to the encoder's center because of potential misalignment of the magnet and the shaft or manufacturing defects of the magnet itself.

    To achieve optimal motor performance at the maximum effective resolution, it is not recommended to exceed an interpolation of 1/64 of a full step, with an optimal limit of 1/32. Exceeding these limits can lead to a significant loss in torque without any improvement in positioning accuracy, due to mechanical nonlinearities. To maintain the encoder's linearity and minimize noise, the minimum usable resolution should not exceed half of the full resolution, resulting in a maximum resolution of 14 bits.

    As a result, the maximum approximately linear actual positioning resolution is 12,800 positions per revolution, and the actual position control resolution is 16,384 positions per revolution (0.02° step). Assuming this, the closed-loop system operates as expected and is capable of error-free shaft position correction.

    Resolution at high speeds and loads

    For high-speed or high-torque applications, it is not recommended to exceed a positioning resolution of 1/32 of a full step or 6,400 steps per revolution.

  • Power Connectors Interconnection

    Anton Khrustalev6 days ago 0 comments

    The USB Type-C and power connectors (both XH2.5) are connected in parallel. Each XH2.5 connector is equipped only with a protective resettable fuse rated at 2A, while the USB Type-C has only a protective diode. Therefore,

    • The USB Type-C can provide power to the system up to 20V 3ARMS (5A peak).
    • Each one at a time XH-2.5 can provide power to the system up to 25V 2A.
    • Current transit from USB Type-C to any of the XH2.5 connectors is also possible with a current of up to 2A.
    • Current transit from one XH-2.5 to another is possible with a current of up to 2A.
    Simultaneous use of several power sources
    To avoid damaging the power supply, do not connect two different voltage sources to the XH2.5 connectors or apply power to the USB Type-C and XH2.5 connectors simultaneously, if the USB voltage is higher than the XH2.5 connector's voltage (VXH < VUSB).
    The maximum current rating of a fuse
    The maximum current rating of a self-resetting fuse decreases with rising ambient temperature. For example, at 25°C, the fuse can carry up to 2A, but at 85°C, the maximum current drops to 0.8A.

    This power architecture allows flexible and efficient power distribution across a device network. For example, with 7.5W motors (like Nema17 34mm body length), you can power the driver through a USB Type-C 20V 3A connection, and the POWER connector can supply five similar motor assemblies.

    Network driver connection
    When connecting additional drivers, it is crucial to ensure that the total current passing through the connector at any given moment does not exceed 2A. This limitation allows for a greater number of drivers to be connected, as long as they are not all operated simultaneously.
    For powering the network of drivers, it is highly recommended to use a star topology instead of a linear one. Excessive transitions through the drivers should be avoided as they can result in unnecessary heat losses.

  • Driver Powering Options

    Anton Khrustalev6 days ago 0 comments

    The CLN17 operates within a 5-25V range, which is protected by a 26V surge protection TVS diode. While the TMC2209 driver recommends a 6-29V power range, operations with less than 500mA current can work at 5V.

    There are 3 options available for powering the driver:

    1. USB Type-C Connector: Default 5V 3A, can support up to 20V 3A (5A peak) with Power Delivery.
    2. XH2.5 2Pin POWER Connector: Accepts a 5-25V power source, with a maximum 3A (2.5ARMS recommended).
    3. XH2.5 6Pin CONTROL connector with power lines: Accepts a 5-25V power source, with a maximum 3A (2.5ARMS recommended).

    Operating near the lower limit of the supply voltage

    The 5V supply voltage is sufficient for low-power operations with total coil currents lower than 500mA.
    At least a 6V supply voltage is required for safe operation at the maximum permissible currents.

  • Alternative Closed-Loop Drivers

    Anton Khrustalev6 days ago 0 comments

    CLN17 is not the only closed-loop motor driver. There are several alternatives available, which are also closed-loop drivers and designed with a similar architecture. These drivers comprise a microcontroller, an encoder, and a driver, all integrated onto a single printed circuit board placed at the rear side of the NEMA17 motor.

    Quick overview of the alternatives

    A comparative table of thiese drivers can be found here

    Is there anything else?

    There are several other similar products available, but they haven't been described due to the project's confidentiality or lack of information.

  • Design philosophy

    Anton Khrustalev6 days ago 0 comments

    In any project, the philosophy  have a significant impact on its vision and purpose, extending beyond basic functionality. Incorporating design principles into the project can result in a solution that not only fulfills technical requirements but also resonates with users on an aesthetic level.

    • 📖 Open Source and Comprehensive Documentation: Adopting an open-source philosophy invites wide-ranging engagement, making the project versatile and adaptable. Community involvement fosters innovation and knowledge exchange, creating a supportive ecosystem. Clear documentation promotes learning, collaboration, and seamless integration with other projects.
    • 💎 Aesthetic Appeal and Usability: A technical product's aesthetic appeal should be a byproduct of its superior functionality, technological advancement, and usability.
    • 💰 Cost-Effectiveness and Accessibility: Balancing cost and functionality while prioritizing accessibility ensures the project's seamless integration across various sectors.
    • 🚀 Future-Proofing: Incorporating foresight for future improvements while maintaining the core design's integrity streamlines the development of new products. Proactively addressing and accommodating future requirements ensures the project's enduring viability and relevance.

  • Design concepts

    Anton Khrustalev6 days ago 0 comments

    • 💪High Performance: The system should be capable of processing feedback data in real-time and react immediately by controlling the motor based on predefined algorithms. This simplifies the control process and reduces the load on the control device.
    • 💻 Compatibility and Versatility: A wide range of supported interfaces should enable interaction with existing protocols as well as the implementation of new ones. This expands compatibility and facilitates integration of the device into existing systems.
    • 🛡️ Precision and Fault Tolerance: The implementation of feedback control with position and current sensors should ensure precise positioning and mechanical load monitoring. This enables the detection and prevention of abnormal system operation when necessary.
    • 🔧 Adaptability: Evaluating motor operating parameters and system displacement data enables the selection of an optimal motor control profile for the specified task.
    • ⚡️ Reliability and Power Efficiency: Providing protection against electrostatic discharge (ESD), short circuits, and reverse polarity, as well as preventing overheating through reduced thermal losses, improved heat dissipation, and enhanced energy efficiency.
    • 🧩 Customizability and Modularity: The device should accommodate functionality expansion or reduction without necessitating design changes.
    • 🏭 Optimized for Design for Manufacturing (DFM): Complying with manufacturing technology requirements enhances manufacturability while reducing production costs and complexities.
    • ⏳ Longevity Considerations: When choosing project component composition, future availability and support forecasts should be considered.

  • The Journey: Functional Prototype

    Anton Khrustalev09/12/2023 at 13:14 0 comments

    After an extensive development process which involved numerous design iterations and reconsideration of implementation methods, the updated project version that encompasses all concept ideas has been released!

    Compared to the previous version, the PCBA is more:

    • Compact
    • Powerful
    • Functional
    • Equipped with numerous safety features

    It has now evolved from being just another driver to becoming a powerful tool for education, development, testing, and system modeling.

    Does it work? The short answer is yes. However, diving deeper, things get a bit more complicated.

    From a hardware perspective, there are a few minor issues, which fortunately don't have an impact on the primary functionality. These known issues include:

    • Incorrect polarity of the power indicator LED;
    • Not stable behavior of the buck DCDC converter at voltages below 6V

    Apart from these, all other driver functions operate correctly.

    On the code side of things, it's a different story. A vast amount of work is still needed to release the complete driver control library that would unlock its full potential. But there's hope that it's just a matter of time.

  • The Journey: Concept Challenges

    Anton Khrustalev09/12/2023 at 12:03 0 comments

    Based on the experience and ideas acquired during the prototype development, a final vision of the project and its functionalities has been formed. Below are the key challenges:

    1. Quiet yet Robust Driver: Designed to deliver core motor control functionalities unhindered by hardware constraints. This driver is intended to be an off-the-shelf solution to minimize the computational load on the microcontroller and mitigate risks, leveraging the inherent safety features of pre-built solutions.
    2. Support for Standard Interfaces: Incorporates USB for computer connectivity, CAN-Bus for communication within industrial systems, Stepstick for compatibility with legacy systems such as 3D printers, and UART and I2C for interactions in embedded environments.
    3. High-Speed Microcontroller: Equipped to handle concurrent tasks such as position calculations, real-time encoder-based position monitoring, processing of external commands from various interfaces, and other user-defined tasks.
    4. Compatibility with Expansion Boards: Ensures the provision to integrate additional boards to accommodate any functionalities not originally addressed.
    5. Efficient Power Delivery: Guarantees compatibility with widely-used power sources or power banks.
    6. Optimal Protection: Shields against potential hazards like electrostatic discharges, current overflows, voltage spikes, and more.
    7. Integrated IMU: Facilitates the detection and compensation of resonances or vibrations while continuously tracking the current position.
    8. Compact Design: Crafted to seamlessly integrate into devices where space is a constraint.
    9. Cost-Effective and Modular Structure: Tailored for swift customization based on specific requirements.

    There are many other smaller nuances that can be enumerated, but more on that later! You can also read the foundational principles to get a clearer picture.

  • The Journey: Concept Prototype

    Anton Khrustalev09/12/2023 at 10:33 0 comments

    In March 2022, while working on a laboratory robot designed for handling test tubes, the idea of using a closed-loop driver came up. This driver needed to be:

    • Compact
    • Feature minimalistic wiring
    • Offer precise and repetitive positioning
    • Exhibit unwavering reliability

    Sadly, no existing solutions fit the bill. Some were inadequate due to size, others lacked the necessary features or interfaces, some had proprietary code that disallowed modifications, and still, others were either unavailable due to component shortages or had been discontinued. A detailed comparison of these alternatives can be found here.

    Thus, a new vision was formed: To create a universal, powerful, and affordable driver that would address all challenges related to controlling a stepper motor.

    By September 2022, the first prototype driver was born. Key components included:

    • Standard CAN-Bus and USB2.0 with QC support
    • STM32F103 MCU
    • TLE5012B encoder
    • TMC2209 stepper motor driver

    However, there were critical setbacks. While it did feature a Type-C port, it relied on Quick Charge (QC) for power, which hampered its flexibility. Another significant limitation was that the controller could not operate the USB and CAN-Bus simultaneously, leading to developmental troubles. A few minor problems arose but  were quickly fixed with a soldering iron. 

    Predictably, this prototype did not achieve all its intended functions, underscoring the need for a revised driver version. This initial setback only strengthened the determination to design a comprehensive stepper motor control solution.

View all 10 project logs

  • 1
    Complete Project Documentation

    All the latest project documentation can be found at

View all instructions

Enjoy this project?



Petar Crnjak wrote 09/17/2023 at 16:21 point

Hey, great project! Where can I find the code it is not on gihtub.

  Are you sure? yes | no

Anton Khrustalev wrote 09/17/2023 at 16:29 point

Thank you! The project is still in the works, so the release of source files and software is planned after successful tests. Follow updates on this page or in the Discord community!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates