Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15427

UART Interface, TMC2208 and Arduino Nano

$
0
0

Hi All,

I'm trying to run a NEMA17 stepper motor at a low constant speed and need maximum torque from the stepper engine. Currently, the stepper motor is running with the wanted rpm, however, it seems that the serial connection (UART) is not established since spreadCycle and the defined microstep are ignored.
The connections between the TMC2208 v3.0 and Arduino Nano are as follows (in respective order):

  • VI0 to 5V
  • GND to GND
  • OB2, OB1, OA1, OA2 to stepper motor
  • GND and VM to 20V external power supply
  • DIR to D5
  • STEP to D2
  • PDN/UART split into two where 1k resistor is added before TX and the other to RX
  • EN to GND

The jumper on the driver board is soldered to enable the UART communication (According to the datasheet of the driver board)

The code in Arduino IDE is as follows:

// Defining
#define StepPin     2
#define DirPin      5
#define SERIAL_PORT Serial

#define InvertDir   HIGH
#define Current     1200
#define MicroStep   16
#define R_Sense     0.11

// Including library
#include <TMC2208Stepper.h>                       // Include library
TMC2208Stepper driver = TMC2208Stepper(&Serial, R_Sense);  // Create driver and use

// Setup
void setup() {
  SERIAL_PORT.begin(9600);
  Serial.begin(9600);             // Init used serial port
  while(!Serial);                 // Wait for port to be ready

  // Prepare pins
  pinMode(DirPin, OUTPUT);
  pinMode(StepPin, OUTPUT);

  driver.pdn_disable(1);              // Use PDN/UART pin for communication
  driver.I_scale_analog(0);           // Adjust current from the registers
  driver.rms_current(Current);        // Set driver current 500mA
  driver.toff(0x2);                   // Enable driver
  driver.en_spreadCycle(1);
  driver.shaft(InvertDir);
  driver.microsteps(MicroStep);

  digitalWrite(DirPin, InvertDir);         // Invert direction
}

// Looping
void loop() {
  digitalWrite(StepPin, !digitalRead(StepPin)); // Step
  delay(4);
}

I strongly suspect that there is something in the code that I'm missing since I don't have great knowledge of Arduino coding.

I've looked everywhere on different forums, videos and library documentation, but it doesn't seem to work. Please, if you have any comments that might be helpful, I would appreciate it!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 15427

Trending Articles