TMC260 Stepper Motor Driver Shield SKU: DRI0035
Contents
1 Introduction
2 Specification
3 Board Overview
o 3.1 TMC260 Control Mode Selection
4 Tutorial
o 4.1 Requirements
o 4.2 Sample Code
4.2.1 SPI Sample Code
4.2.2 STEP/DIR Sample Code
5 Protocol/Library Explantion
Introduction
Do you want to do some projects with stepper motors? A pair of automatic curtains? An XY
Plotter? A 3D printer? Generally, it's not been easy to find a powerful stepper motor driver for
Arduino, but now this has changed! DFRobot presents the TMC260 Stepper Motor Driver
Shield. This shield allows your Arduino to easily drive stepper motors (up to 2A per motor coil,
40V max).
Specification
Basic Features
Compatible with two‐phase
stepper motors
Compatible with Arduino
Up to 2A motor current drive
capability
Up to 40V DC
Simplified communication with
standard SPI™ and STEP/DIR
interfaces
Up to 256 microsteps per full
step
Key Features
StallGuard2™: high precision sensorless motor load
detection
CoolStep™ load dependent current control for energy
saving up to 75%
microPlyer™ : Microstep interpolator for increased
smoothness of microstepping over a STEP/DIR
interface
SpreadCycle™ High‐precision chopper algorithm
available as an alternative to the traditional constant
off‐time algorithm
Protection & Diagnostics: overcurrent, short to
GND,overtemperature & undervoltage
Low Power Dissipation, low RDSON and synchronous
rectification
Board Overview
NOTE: We have already lead out some necessary pins on the chip and use mini
jumpers to avoid a jumble of cables.
Label
Name
Description
DIR(D4)/1
DIR
Connect with D4 pin directly
STEP(D5)/2
STEP
Connect D5 pin directly with a jumper
3
EN
Enable
4
SG
Status value output of motor load detection
CS(D9‐D6)/5 CS
Chip Select. You can choose D6, D7, D8 or D9 to be the CS pin in SPI
mode
SPI
Serial peripheral interface
ICSP
Power Supply VIN
Voltage in. Voltage range 7~40V DC, 2A max
TMC260 Control Mode Selection
SPI mode: SDOFF bit is set, the STEP/DIR interface is disabled, and DRVCTRL is the interface for
specifying the currents through each coil.
STEP/DIR mode:SDOFF bit is clear, the STEP/DIR interface is enabled, and DRVCTRL is a
configuration register for the STEP/DIR interface.
Tutorial
Requirements
Hardware
o Arduino UNO (or similar) x1
o TMC260 Stepper Motor Driver Shield x1
o Hybrid Stepper Motor for 3D Printer (3.5kg) x1
Software
Arduino IDE V1.0.6 (link)
http://arduino.cc/download.php?f=/arduino-1.0.6-windows.zip
Sample Code
Please Download Library First: Download Link
https://raw.githubusercontent.com/CainZ/TMC260-Stepper-Motor-DriverShield/master/TMC26XStepper%20Libraries.zip
SPI Sample Code
You need to give a “sine” a value in SPI mode using function
(tmc26XStepper.SPI_setCoilCurrent(200))
#include
#include
//we have a stepper motor with 200 steps per rotation,CS pin 6, dir pin 4,
step pin 5 and a current of 800mA
TMC26XStepper tmc26XStepper = TMC26XStepper(200,6,4,5,800);
void setup() {
Serial.begin(9600);
Serial.println("==============================");
Serial.println("TMC26X Stepper Driver Demo App");
Serial.println("==============================");
//set this according to you stepper
Serial.println("Configuring stepper driver");
//char constant_off_time, char blank_time, char hysteresis_start, char
hysteresis_end, char hysteresis_decrement
tmc26XStepper.setSpreadCycleChopper(2,24,8,6,0);
tmc26XStepper.setRandomOffTime(0);
tmc26XStepper.SPI_setCoilCurrent(100);
tmc26XStepper.setMicrosteps(128);
tmc26XStepper.setStallGuardThreshold(4,0);
Serial.println("config finished, starting");
Serial.println("started");
tmc26XStepper.SPI_setSpeed(80);
//Set speed at 80 RPM
tmc26XStepper.SPI_step(-200);
//set step at -200 steps,
to say stepper will turn a circle reverse
tmc26XStepper.spi_start() ;
//start stepper
delay(2000);
//delay 2s
tmc26XStepper.SPI_step(200);
will turn a circle forward
tmc26XStepper.spi_start() ;
delay(2000);
// set step at 200 steps,
that is
stepper
tmc26XStepper.SPI_setSpeed(100);
// Set speed at 100 RPM
tmc26XStepper.SPI_step(-300);
// stepper will turn 1.5 circles
reverse
tmc26XStepper.spi_start() ;
delay(2000);
tmc26XStepper.SPI_setSpeed(120);
tmc26XStepper.SPI_step(400);
forward
tmc26XStepper.spi_start() ;
delay(3000);
// Set speed at 120 RPM
// stepper will turn 2 circles
}
void loop() {
//you can put stepper control code in loop{} to make stepper works
circularly
}
STEP/DIR Sample Code
#include
#include
//we have a stepper motor with 200 steps per rotation, CS pin 2, dir pin 6, s
tep pin 7 and a current of 800mA
TMC26XStepper tmc26XStepper = TMC26XStepper(200,6,4,5,800);
int curr_step;
int speed =
0;
int speedDirection = 100;
int maxSpeed = 1000;
void setup() {
Serial.begin(9600);
Serial.println("==============================");
Serial.println("TMC26X Stepper Driver Demo App");
Serial.println("==============================");
//set this according to you stepper
Serial.println("Configuring stepper driver");
//char constant_off_time, char blank_time, char hysteresis_start, char hyst
eresis_end, char hysteresis_decrement
tmc26XStepper.setSpreadCycleChopper(2,24,8,6,0);
tmc26XStepper.setRandomOffTime(0);
tmc26XStepper.setMicrosteps(128);
tmc26XStepper.setStallGuardThreshold(4,0);
Serial.println("config finished, starting");
Serial.println("started");
}
void loop() {
if (!tmc26XStepper.isMoving()) {
speed+=speedDirection;
if (speed>maxSpeed) {
speed = maxSpeed;
speedDirection = -speedDirection;
} else if (speed