In this post I go over how to use the TMC2208 Stepper Motor Controller. We will learn the basics, how to use microstepping, how to set the current limit to avoid exceeding your motor current limit, how to connect to Arduino, and we will go over several examples which will show how quiet the TMC 2208 runs.
Example
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
#include <AccelStepper.h> // Define stepper pins #define STEP_PIN 3 // Step pin #define DIR_PIN 2 // Direction pin // Microstepping control pins #define MS1_PIN 7 #define MS2_PIN 6 // Steps per revolution for the motor const float stepsPerRevolution = 200; // Microstepping multiplier (1, 2, 4, 8, 16, or 32) int microstepSetting = 2; // AccelStepper instance in driver mode AccelStepper stepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN); void setup() { // Set microstepping pins as outputs pinMode(MS1_PIN, OUTPUT); pinMode(MS2_PIN, OUTPUT); // Set microstepping mode (adjust as needed: HIGH or LOW) digitalWrite(MS1_PIN, HIGH); // Set to LOW or HIGH for desired microstep setting digitalWrite(MS2_PIN, LOW); // Set to LOW or HIGH for desired microstep setting // Set the desired RPM and the max RPM float desiredRPM = 120; // Set the desired speed in rpm (revolutions per minute) float MaxRPM = 300; // Set max speed in rpm (revolutions per minute) // Calculate and set the desired and max speed in steps per second float speedStepsPerSec = (microstepSetting * stepsPerRevolution*desiredRPM) / 60.0; float Max_Speed_StepsPerSec = microstepSetting * stepsPerRevolution * MaxRPM / 60; // Specify max speed in steps/sec (converted from RPM) stepper.setMaxSpeed(Max_Speed_StepsPerSec); stepper.setSpeed(speedStepsPerSec); } void loop() { // Run the motor at constant speed stepper.runSpeed(); } |
Where to Buy:
Where to buy [Amazon Affiliate]:
DRV8825 Stepper Motor Driver: https://amzn.to/3YUF6pp
Arduino UNO: https://amzn.to/3U7xAoT
NEMA 14 – 14HS10-0404S Stepper Motor: https://amzn.to/4aKwQgD
