Hello , i'm trying to make a stepper motor run at a constant speed of 60 RPMs.
I'm using a Arduino Uno R3 with a Arduino CNC SHIELD V3 on top, a STEPPERONLINE Nema 17 17HE15-1504S(Website Link) motor and the BIGTREETECH TMC2208 V3.0 UART(Trinamic Datasheet)(BIGTREETECH Documentation) to control it.
From what I understand The TMC2208 has a max 1/16 step using the MS1 and MS2 pins, but using UART mode it can reach 1/256 and also control the steps interpolation.
I don't understand how I enable the UART mode, do i connect the top UART pin of the TMC2208 to the TX pin of the CNC SHIELD V3, or is in other place?
I have seen that both the TMC2208Stepper and the TMCStepper libraries can be both used with code to communicate via UART but most code examples i have seen were for the TMC2209 and using other boards, unfortunately with my small coding knowledge i was not able to adapt the codes for my setup.
Using the UART I just wanted to be able to change the microstep value (0 to 256) and the interpolation (on/off). To move the stepper motor I have seen that the Stepper and the AccelStepper libraries can make it move at 60 rpm, but I don't know if these libraries are needed.
If someone could help me with the code and with the UART pins I would really appreciate it.
The "TX" pin on the CNC shield connects to D1 on the Arduino. Probably best to avoid that pin, since it is used for serial monitor and programming. I would pick another unused pin, and use SoftwareSerial.
Hi @Grumpy_Mike , I'm using a 12V power supply that is plugged to the Arduino CNC SHIELD V3.
I can make it run at the 60RPM, but since my TMC2208 is by default in UART and not in STEP/DIR mode I think my code below is not really correct.
I think I need to use the TMC2208 in UART, but I don't know how to put it in that mode and what code do I need to communicate with it.
Thanks,
Ben
Code:
#include <Stepper.h>
// Define the number of steps per revolution
const int stepsPerRevolution = 1600;
// Define the Stepper motor object
Stepper myStepper(stepsPerRevolution, 4, 7);
// Pin for enabling the stepper motor (needs to be LOW for the motor to work)
const int enablePin = 8;
// Desired RPM
const int targetRPM = 60;
void setup() {
// Set the speed in RPM
myStepper.setSpeed(targetRPM);
// Set the enable pin to OUTPUT and initially set it LOW
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW);
}
void loop() {
// Step the motor one step
myStepper.step(1);
}
Hi @bobcousins , so I can pick another pin on the Arduino CNC SHIELD V3, and use the SoftwareSerial library to send UART commands to the TMC2208? Or do i use it in combination with TMC2208Stepper library, since it has a function for controlling the microsteps and the interpolation?
You have linked to an integrated circuit for documentation. You need to link to the document for the circuit board adapter so we can see how the IC connections were implemented. You are talking to the adapter board,not directly to the IC, I hope!
Hi @Paul_KD7HB , sorry I thought you were asking for the connections of the CNC SHIELD V3. I am not sure if this is correct but the BIGTREETECH Documentation has this image that shows the BIGTREETECH TMC2208 V3.0 UART circuit board layout, is this what is needed?
My BIGTREETECH TMC2208 V3.0 UART also has 3 pins "up" that I'm not sure for what they are used for, the CLK, PDN and UART, like shown in the second image.
Yes, now we can see what you have. The PDF documentation says exactly what those pins are for. The CLK is there for you to add an external clock signal if you want to. The PDN is power down, if you want to use it. And the UART is the bidirectional uart to communicate with the processor in the device.
No! You need to actually print the PDF documentation and study it. It answers your questions. If you are going to use the built-in bidirectional uart, you need to build the recommended interface so your Arduino can both send and receive the configuration information to the controller in the device.
For my need I think I only need to send information to TMC2208, in this case the microstep value (0 to 256) and the interpolation (on/off). If this is the case, do I still need to build the recommended interface or I can use the single wire that came with the BIGTREETECH TMC2208 V3.0 UART?
Hi @Paul_KD7HB , sorry, but i don't see in the BIGTREETECH TMC2208 V3.0 UART documentation , where is written that i can or can not use a single wire for sending UART commands to the TMC2208, nevertheless what i really don't understand is what library do i use to control the UART parameters, since it's also not written in the documentation.
It's also not written in the documentation the code i need to use to start the UART connection with the TMC2208!
I think I would not necessarily need the full 256 microsteps, I just wanted a way to control that value so that I could choose what would be enough for my application.
My TMC2208 is the UART version so I'm not sure if I can use it without being in this mode.
I have seen this YouTube Video showcasing the TMC2208 capability of doing 256 microsteps, I just wanted to test that for my project.
I tried using the code below to use the TMC2208 in step/dir but I'm not sure if is it correct since the stepper motor was not running that smoothly.
I think since my TMC2208 is the UART version it might not be reading the step/dir code correctly, but I'm not sure if that can happen.
The code:
#include <Stepper.h>
// Define the number of steps per revolution
const int stepsPerRevolution = 3200;
// Define the Stepper motor object
Stepper myStepper(stepsPerRevolution, 4, 7);
// Pin for enabling the stepper motor (needs to be LOW for the motor to work)
const int enablePin = 8;
// Desired RPM
const int targetRPM = 60;
void setup() {
// Set the speed in RPM
myStepper.setSpeed(targetRPM);
// Set the enable pin to OUTPUT and initially set it LOW
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW);
}
void loop() {
// Step the motor one step
myStepper.step(1);
}