Stepper Motor Driver TMC2208¶
About¶
Mode¶
-
Mode 1: Standalone STEP/DIR Driver (Legacy Mode)
- Replacement for A4988
- Manual Vref/Stepper Current
-
Mode 2: Standalone STEP/DIR Driver with OTP pre-configuration
- OTP (One Time Programming)
-
Mode 3: STEP/DIR Driver with Full Diagnostics and Control
- pin PDN_UART is connected to the CPU UART interface
Set up as Mode 1¶
Mode select¶
- Mode 1: no jumber (default)
Stepper Motor¶
- Rated voltage: 12V
- Rated current: 0.55A
Vref formula¶
RMS Current¶
- Root Mean Square (二乗平均平方根)
RMS Current = MAX CURRENT / 1.41
VREF = (RMS Current x 2.5)/1.77)
value | formula | 42SHD4002-24B | Safer use 90% of VREF |
---|---|---|---|
RMS Current | MAX Current / 1.41 | 0.55[A] / 1.41 = 0.39 | - |
VREF | (RMS Current x 2.5)/1.77 | (0.39 x 2.5)/1.77 = 0.55 | 0.55 x 0.9 = 0.495[V] |
test 1¶
SilentStepStick TMC2208 Stepper Motor Driver
Ref. GitHub project page
Download TMC220X.ino from here
/*
SilentStepStick TMC2208/TMC2209 Example
Rsense: 0.11 Ohm
Other examples/libraries can be found here:
https://github.com/teemuatlut/TMCStepper
https://github.com/trinamic/TMC-API
https://github.com/manoukianv/TMC2208Pilot
Example source code free to use.
Further information: https://learn.watterott.com/license/
*/
// Note: You also have to connect GND, 5V/VIO and VM.
// A connection diagram can be found in the schematics.
#define EN_PIN 7 //enable (CFG6)
#define DIR_PIN 8 //direction
#define STEP_PIN 9 //step
void setup()
{
//set pin modes
pinMode(EN_PIN, OUTPUT);
digitalWrite(EN_PIN, HIGH); //deactivate driver (LOW active)
pinMode(DIR_PIN, OUTPUT);
digitalWrite(DIR_PIN, LOW); //LOW to CCW
//digitalWrite(DIR_PIN, HIGH); //HIGH to CW
pinMode(STEP_PIN, OUTPUT);
digitalWrite(STEP_PIN, LOW);
digitalWrite(EN_PIN, LOW); //activate driver
}
void loop()
{
//make steps
digitalWrite(STEP_PIN, HIGH);
delay(2);
digitalWrite(STEP_PIN, LOW);
delay(2);
}
Connection¶
Connect to | LEFT | TMC2208 | Right | Connect to |
---|---|---|---|---|
Uno_7-----Uno_8Uno_9 | EnMS1MS2UARTPDNCLKStepDir | VMGNDM2BM2AM1AM1BVIOGND | Supply(12V(+)) & CAP100uF(+)Supply(-) & CAP(-)Moter(Blue)Motor(Red)Motor(Green)Motor(Black)Uno_5VUno_GND |
Result¶
Worked!
Test 2¶
Library¶
New: TMCStepper
Old: TMC2208Stepper
Sketch -> Include Library -> Library Manager -> Search “tmc” -> install both libraries
sample Sketch¶
File -> Examples -> TMC2208Stepper -> TMC2208_Simple
// Author Teemu Mäntykallio, 2017-04-07
// Define pins
#define EN_PIN 38 // LOW: Driver enabled. HIGH: Driver disabled
#define STEP_PIN 54 // Step on rising edge
#include <TMC2208Stepper.h> // Include library
TMC2208Stepper driver = TMC2208Stepper(&Serial1); // Create driver and use
// HardwareSerial0 for communication
void setup() {
Serial.begin(9600);
Serial.println("Start...");
Serial1.begin(115200); // Start hardware serial 1
driver.push(); // Reset registers
// Prepare pins
pinMode(EN_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
digitalWrite(EN_PIN, HIGH); // Disable driver in hardware
driver.pdn_disable(true); // Use PDN/UART pin for communication
driver.I_scale_analog(false); // Use internal voltage reference
driver.rms_current(500); // Set driver current 500mA
driver.toff(2); // Enable driver in software
digitalWrite(EN_PIN, LOW); // Enable driver in hardware
uint32_t data = 0;
Serial.print("DRV_STATUS = 0x");
driver.DRV_STATUS(&data);
Serial.println(data, HEX);
}
void loop() {
digitalWrite(STEP_PIN, !digitalRead(STEP_PIN));
delayMicroseconds(100);
}
Last update:
March 18, 2022