Hi all
I'm looking to build a system to control the electronics for recycling plastic bottles into filament, the project can be found here Though I'm struggling to communicate with the TMC2209 driver, and could really use some help.
The issue I currently have is communicating with a TMC2209 via a 1 wire serial connection.
The board I'm trying to use is a BigTreeTech EBB42 v1.1
Schematic can be found here
Product link can be found here
The code I'm currently trying based on another post on this forum
#include <TMCStepper.h> // TMCstepper - https://github.com/teemuatlut/TMCStepper
#define LED_PIN PA13 // Visual feedback; onboard LED
#define EN_PIN PB5 // Enable pin
#define DRIVER_ADDRESS 0b00 // TMC2209 Driver address
#define R_SENSE 0.11f // SilentStepStick series use 0.11
#define SW_RX PA15 // TMC2208/TMC2224 SoftwareSerial receive pin
#define SW_TX PA15 // TMC2208/TMC2224 SoftwareSerial transmit pin
//#define SERIAL_PORT Serial // TMC2208/TMC2224 HardwareSerial port
#define RMS_CURRENT 600 // Motor RMS current in mA
#define MICROSTEPS 8 // Microsteps; note that MicroPlyer will interpolate to 256
#define SPREADCYCLE false // Spreadcycle can have higher RPM but is louder
TMC2209Stepper driver(SW_RX, SW_TX, R_SENSE, DRIVER_ADDRESS); // Create TMC driver
void setup() {
pinMode(EN_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
//SERIAL_PORT.begin(115200);
driver.beginSerial(115200); // SW UART drivers
digitalWrite(EN_PIN, LOW); // Enable TMC2209 board
driver.begin();
driver.toff(5); // Enables driver in software
driver.rms_current(RMS_CURRENT); // Set motor RMS current (mA)
driver.microsteps(MICROSTEPS); // Set microsteps
driver.en_spreadCycle(SPREADCYCLE); // Toggle spreadCycle on TMC2208/2209/2224
driver.pwm_autoscale(true); // Needed for stealthChop
}
int32_t curr_speed = 0;
int32_t dest_speed = 1000 * MICROSTEPS;
int32_t acceleration = 10 * MICROSTEPS;
void ramp() {
digitalWrite(LED_PIN, dest_speed > 0);
while ((dest_speed > 0 && curr_speed < dest_speed) || (dest_speed < 0 && curr_speed > dest_speed)) {
curr_speed += acceleration;
driver.VACTUAL(curr_speed);
delayMicroseconds(100);
}
}
void loop() {
ramp();
delay(1000);
dest_speed *= -1;
acceleration *= -1;
}
Any help and pointers are greatly appreciated.