TMC2130 Stepper Motor Driver Working, Circuit & Arduino Example Code

Arduino RGB Sensor Guide

TMC2130 Stepper Motor Driver with Arduino | Complete Tutorial & Working Explained

HLearn how to use the TMC2130 Stepper Motor Driver with Arduino for smooth and silent motor control. This tutorial covers wiring, SPI configuration, code examples, and working principles for your next robotics or CNC project.

TMC2130 Stepper driver

Introduction

In today’s tutorial, we’re going to explore one of the most advanced stepper motor drivers — the Trinamic TMC2130. This powerful driver module is designed to deliver precise, smooth, and silent motion control, making it ideal for applications where accuracy and performance really matter.

The TMC2130 integrates a complete stepper motor driver and controller in one compact package. It usesTrinamic’s advanced StealthChop™ and SpreadCycle™ technologies, which ensure ultra-quiet operation and smooth current control — perfect for 3D printers, CNC machines, robotic arms, camera sliders, textile sewing machines, and even medical equipment.

In this tutorial, we’ll learn how the TMC2130 works, how to connect it with an Arduino, and how to write the Arduino code to control a stepper motor efficiently. Whether you’re a beginner trying to understand stepper motor drivers or an engineer building precise motion systems, this guide will help you master the working principle and practical setup of the TMC2130.

⚙️ Key Features of the TMC2130 Stepper Motor Driver

The Trinamic TMC2130 is a feature-packed stepper motor driver designed for smooth, silent, and efficient motion control. It combines high-performance hardware with intelligent control features, making it perfect for precision-based applications such as 3D printers, CNC machines, and robotics projects.

Let’s look at some of its key features:

    🔹 Integrated Microstepping Indexer – Supports up to 256 microsteps per full step, providing ultra-smooth motion and high positioning accuracy.

    🔹 High Current Capability – Drives 2-phase stepper motors up to 2.0A RMS (2.5A peak) per coil, ensuring powerful motor control.

    🔹 Wide Operating Voltage – Works reliably within a voltage range of 4.75V to 46V DC, suitable for various embedded and industrial setups.

    🔹 StealthChop™ Technology – Enables extremely quiet and smooth motor operation, ideal for noise-sensitive applications.

    🔹 StallGuard2™ Sensorless Load Detection – Accurately detects motor load and stall conditions without using external sensors.

    🔹 CoolStep™ Smart Current Control – Adjusts motor current automatically depending on load, saving up to 75% of energy consumption.

    🔹 SpreadCycle™ Chopper Control – Delivers highly dynamic and precise motor control, improving torque and response.

    🔹 Flexible Interface Options – Supports both Step/Direction control for simple operation and SPI communication for advanced configuration.

🔌 TMC2130 Pinout and Connection with Arduino

Before connecting the TMC2130 stepper motor driver to an Arduino, it’s important to understand its pin configuration. The module provides a mix of power pins, motor output pins, control inputs, and SPI communication pins. Let’s go through them one by one so you can wire it correctly and safely.

TMC2130 Stepper Driver Pinout
Pin Name Description
GND Motor power supply input (4.75V–46V DC)
VM GND
OA1 / OA2 Output for Motor Coil A
OB1 / OB2 Output for Motor Coil B
EN Enable pin to activate or disable the driver (Active Low)
DIR Direction control input (High/Low to change rotation direction)
STEP Step pulse input for motor movement

TMC2130 Standalone Mode (SPI jumper closed)

Pin Name Description
CFG0 hopper Off Time TOFF (GND=140tclk, VIO=236tclk, OPEN=332tclk)
CFG1 Step-Configuration
CFG2 Step-Configuration
CFG3 Current Setting (GND=int, VIO=int, OPEN=ext)
DIAG0 Diagnostics Output 0 (50k pull-up to 2.5V)
DIAG1 Diagnostics Output 1 (100k pull-down to GND)
VREF Snalog Reference Voltage

TMC2130 SPI MODE (SPI jumper open)

Pin Name Description
SDO/CFG0 MISO - Serial Data Output
SDI/CFG1 MOSI - Serial Data Input
SCK/CFG2 SCLK - Serial Clock Input
CS/CFG3 SS - Chip Select Input
DCO DC Step Ready Output
DIAG0 Diagnostics Output 0 (50k pull-up to 2.5V)
DIAG1 Diagnostics Output 1 (100k pull-down to GND)
VREF Analog Reference Voltage

STEP CONFIGURATION

TMC2130 Step Configuration

Required Components

  • Arduino Board (Arduino Uno, Mega, Nano)
  • TMC2130 Breakout Board
  • Jumper Wires (Male-to-Female)
  • USB Cable ( Arduino connection)

Interfacing TMC2130 Stepper Motor Driver with Arduino

After learning the pinout, it’s time to interface the TMC2130 stepper motor driver with Arduino. This step will help you understand how to control a stepper motor efficiently using the Step/Dir signals or the SPI communication mode for advanced control.

The TMC2130 is highly versatile and can work in two different modes depending on your project requirements:

    🔹 Step/Direction (Standalone) Mode

    🔹 SPI Mode (Advanced Configuration)

TMC2130 Library Install

1Download TMC2130 Library

To get started, you need to download the TMC2130 Stepper Motor Driver library for Arduino, called TMC2130Stepper. You can download it from the official source using the link below 👇

🔗 Download TMC2130Stepper Library

2Install TMC2130 in Arduino IDE

After downloading the .ZIP file, open your Arduino IDE, go to Sketch → Include Library → Add .ZIP Library, and select the downloaded file to install it.

TMC2130 Library for Arduino

3Example TMC2130

After installation, the library will appear in your Arduino IDE under File → Examples → TMC2130Stepper

📘 Understanding the TMC2130Stepper Library Functions

The TMC2130Stepper library is a powerful Arduino library that makes it easy to control and configure the Trinamic TMC2130 stepper motor driver through the SPI interface. It allows you to access advanced features such as StealthChop™, CoolStep™, SpreadCycle™, and StallGuard2™ — all through simple function calls.

Let’s go through the most commonly used functions and understand what they do 👇

    ⚙️ 1. begin():

    This function initializes communication between Arduino and the TMC2130 driver via SPI. It must be placed inside the setup() function before using any other commands.

    driver.begin();


    ⚙️2. rms_current(value):

    Sets the RMS current (in milliamps) for the motor. For example, 600 means 0.6A. Adjust this according to your stepper motor’s rating. 🔹 Lower current = cooler operation 🔹 Higher current = more torque but more heat

    driver.rms_current(600);


    ⚙️ 3.microsteps(value):

    Defines the number of microsteps per full step. The TMC2130 supports up to 256 microsteps, allowing for smooth and precise movement. Common values: 1, 2, 4, 8, 16, 32, 64, 128, 256

    driver.microsteps(16);


    ⚙️ 4. en_pwm_mode(true/false):

    Enables or disables StealthChop™ mode, which ensures quiet and smooth motor operation — perfect for 3D printers and camera sliders. true → Enables StealthChop™ (silent mode) false → Uses normal chopper mode

    driver.begin();


    ⚙️ 5.pwm_autoscale(true/false):

    Automatically adjusts PWM amplitude for smoother motion and better current control when StealthChop is active.

    driver.pwm_autoscale(true);


    ⚙️ 6. SG_RESULT():

    Reads the StallGuard2™ load value. This gives feedback about how much mechanical load is on the motor — useful for detecting stalls or end stops without using physical sensors.

    int load = driver.SG_RESULT();


    ⚙️ 7. TCOOLTHRS(value):

    Sets a threshold speed below which CoolStep™ and StallGuard2™ are active. Higher values keep these features enabled over a wider speed range.

    driver.shaft(true);


    ⚙️ 8. shaft(true/false):

    Controls the rotation direction of the stepper motor electronically. true → Clockwise (CW) false → Counterclockwise (CCW).

    driver.shaft(true);


    ⚙️ 9.diag1_stall(bool):

    Enables stall detection output on the DIAG1 pin. When the motor stalls, the pin changes state — useful for sensorless homing or limit detection.

    driver.diag1_stall(true);


    ⚙️ 10.chm(true/false):

    Switches between SpreadCycle™ (for torque and performance) and StealthChop™ (for quiet motion). false = SpreadCycle mode (default) true = Constant off-time chopper mode

    driver.chm(false);


    ⚙️ 11.toff(value):

    Sets the off time of the chopper control. This parameter fine-tunes how the motor current is regulated. Typical value: toff(4) to toff(8) for stable operation.

    driver.toff(5);

0 comments:

Post a Comment