Hi
I'm new in the forum and I'm industrial designer.
I'm trying to make tmc2208 control a 5v 338ma Haydon Kerk 19000 series external stepper actuator with arduino Uno for automation process, but the tmc 2208 library examples seem not to work. Trinamic has lots of info for engineers and there's a lot of info on how to use Marlin and Ramps to make it work, but none for arduino Uno.
I've started by using my previous code which I was using with the A4988/Easy in legacy mode and it didn't do anything and then I've tried the examples in the library and the only thing that happens to the motor is to be energized but it doesn't move.
To work with uart I've put jumper connecting the pdn/uart instead of soldering the pads on the bottom of the driver (I don't know if I can do this) and I'm using 1k res between RX/TX.
Because of the issues with usb upload and rx/tx connected with the driver I'm using SoftwareSerial.h.
In this moment I just won't to see the stepper moving because I need to put to buttons (left/right) and Hall sensor to allow the buttons to take action or wait for the hall to lower the values and then take action on the code.
If the tmc2208 doesn't give more power to the motor even in spreadcycle then A4988, I'll have to put an AM256D01_13 RLS encoder on the motor to close loop it, because I'm loosing steps at the velocity I need it to work in the automation process.
The code is from the library with some changes:
Software serial multple serial test
Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.
The circuit:
- RX is digital pin 2 (connect to TX of other device)
- TX is digital pin 3 (connect to RX of other device)
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
// Define pins
#define EN_PIN 10 // LOW: Driver enabled. HIGH: Driver disabled
#define STEP_PIN 9 // Step on rising edge
#define RX_PIN 2 // SoftwareSerial pins
#define TX_PIN 3 //
#include <TMC2208Stepper.h>
// Create driver that uses SoftwareSerial for communication
TMC2208Stepper driver = TMC2208Stepper(RX_PIN, TX_PIN);
bool dir = true;
void setup() {
Serial.begin(9600);
while(!Serial);
// set the data rate for the SoftwareSerial port
mySerial.begin(38400);
mySerial.println("Hello, world?");
driver.beginSerial(115200);
// Push at the start of setting up the driver resets the register to default
driver.push();
// Prepare pins
pinMode(EN_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
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, 0.5 multiplier for hold current and RSENSE = 0.11.
driver.toff(2); // Enable driver in software
uint32_t drv_status;
driver.DRV_STATUS(&drv_status);
Serial.print("drv_status=");
Serial.println(drv_status, HEX);
switch (driver.test_connection()) {
case 1: Serial.println("Connection error: F");
case 2: Serial.println("Connection error: 0");
default: Serial.println("Connection OK");
}
digitalWrite(EN_PIN, LOW); // Enable driver in hardware
}
void loop() {
//if (mySerial.available())
//Serial.write(mySerial.read());
// if (Serial.available())
//mySerial.write(Serial.read());
digitalWrite(STEP_PIN, HIGH);
delay(1);
digitalWrite(STEP_PIN, LOW);
delay(1);
uint32_t ms = millis();
static uint32_t last_time = 0;
if ((ms - last_time) > 2000) {
if (dir) {
Serial.println("Dir -> 0");
driver.shaft(0);
} else {
Serial.println("Dir -> 1");
driver.shaft(1);
}
dir = !dir;
last_time = ms;
}
}