0

I’m trying to build a wireless stepper motor controller using an ESP32 with a TMC2240 driver. I came across this reference design: Wireless Stepper Motor Controller with ESP32 and TMC2240 https://www.pcbway.com/project/shareproject/Wireless_Stepper_Motor_Controller_with_ESP32_and_TMC2240_007de61a.html

, which looks quite close to what I want to achieve.

So far, I’ve managed to:

Get the ESP32 running with basic stepper control using the AccelStepper library (with a simpler driver like A4988).

Interface the ESP32 with SPI successfully (tested with another peripheral).

Power the ESP32 and stepper motor driver from a common supply (with separate regulators for logic and motor voltage).

The reference project uses SPI communication with the TMC2240, but the library support for this chip on Arduino seems very limited. Is there any way to use the TMC2240 with Arduino (ESP32) using an existing library that supports features like stall detection and current control, or do I need to implement SPI communication from scratch?

#include <AccelStepper.h>
// Define stepper motor connections
#define STEP_PIN 18
#define DIR_PIN 19
// Create an instance of AccelStepper
AccelStepper stepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);
void setup() {
 Serial.begin(115200);
 
 // Set max speed and acceleration
 stepper.setMaxSpeed(1000); // steps per second
 stepper.setAcceleration(500); // steps per second^2
}
void loop() {
 // Move to a target position
 stepper.moveTo(2000); // move 2000 steps forward
 // Run the motor toward the target
 if (stepper.distanceToGo() != 0) {
 stepper.run();
 }
 // Once reached, move back
 if (stepper.distanceToGo() == 0) {
 stepper.moveTo(-2000); // move back
 }
}
jsotola
1,5342 gold badges12 silver badges20 bronze badges
asked Aug 24 at 14:12
0

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.