Jitters and Negative Speed Not Working - AccelStepper - Arduino - TMC2209 - No UART

Hi!

I've been working on a project for several months and recently hit a road block with motors.
The motors can turn CW but with visible jittering at most speeds and are unable to run CCW at all when using negative speeds.

Its an Arduino UNO R3 based project using Nema 8HS11-0204S Bipolar motors:

Specs: https://www.omc-stepperonline.com/download/8HS11-0204S.pdf

Using BIGTREETECH TMC2209 drivers:
https://www.amazon.ca/dp/B09YNFBGKJ?psc=1&ref=ppx_yo2ov_dt_b_product_details
Specs: https://zco.ro/media/documente/TMC2209-V1.2-manual.pdf

Library to handle driver: AccelStepper

Powered by a 12V 30A 360W AC to DC Adapter:
https://www.amazon.ca/gp/product/B07TZMMZ66/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

I've been digging many threads in several forums talking about similar issues for a couple of days.
While threads like these were very helpful:

none of them are using exactly the same setup and most of them are going all in on using UART which require at least 4 wires where I'm hoping to be able to keep using the simple step and direction pins approach where only 2 pins are required to the Arduino board.

There are many ways to achieve this but I initially followed the Mechatronics documentation, here is the final customized schematics that represent my current hardware setup and wiring:

Side note; the Arduino board is powered up via USB since I'm in the middle of developing but in the end it will be powered by a dedicated 5V power supply.
As we can see I'm only using the Step and Dir pins to drive the motor which is very light in connection requirements on the board.
Going the UART route would be my last resort only if I have no other option.

Schematics are essential guides but here is that setup in reality and because an image is worth a thousand words, here are a couple of pics.
To help with clarity I'll try to proceed incrementally instead of showing the spaghetti of a fully wired system in only one pic:

Here is how the 12V30A power supply is hooked to the TMC2209:


As we can see there is a 10V100uF Capacitor between them where the live wire is plugged in the VM pin and the Ground wire in the GND pin of the TMC2209:

Arduino To TMC2209:


TMC2209 Dir pin in the Arduino pin 2
TMC2209 Step in in the Arduino pin ~3

TMC2209 Enable pin in TMC2209 GND pin (to enable the driver):


Nema 8HS11-0204S Bipolar wires:


The spec sheet (link at the beginning of thread) show:
Black: A+
Green: A-
Red: B+
Blue: B-

TMC2209 to Nema 8HS11-0204S Bipolar wires:


Nema 8 Black to TMC2209 A2
Nema 8 Green to TMC2209 A1
Nema 8 Blue to TMC2209 B1
Nema 8 Red to TMC2209 B2

Here is the bare bone version of the code I'm testing with:

#include <AccelStepper.h>
#define STEP_PIN 2
#define DIR_PIN 3
AccelStepper stepper01(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);
void setup()
{
    // Initialize serial and wait for port to open:
    Serial.begin(115200);
    stepper01.setMaxSpeed(10000);
    stepper01.setSpeed(1000); // Using -1000 here doesn't work but it should!
}
void loop()
{
    stepper01.runSpeed();
}

About the Voltage:
The motors are hosted in 3D printed socket where temperature is the main constraint (the goal is to have the motor to heat as less as possible).
But the motor's job is only to rotate a very light propeller (don't need much torque) at low and medium speeds (1 to 200 rpm).
In many places I've been reading a similar tip about using the potentiometer on the driver to lower the voltage as much as possible (and investigate stall limits) to reach the lowest voltage while everything is still working and ultimately avoid heating as much as possible.
If I want to provide 0.2A (or less) of current to the motor I'd need to provide 0.282V since the TMC2209 VREF is equal to current * 1.41, but I believe I'm missing the 24Ohms resistance of the motor in that calculation?

But the motor seem to be able to run with very low voltage and around 0.16V it doesn't heat at all (important parameter) and still able to rotate the small propeller a low and medium speeds:

The motor is at least able to rotate when positive values are set on the speed (up to a certain speed of course where it start skipping most steps).
BUT, even with the "working" positive values there are subtle but noticeable jittering that feels like its frequently skipping steps even it it does manages to rotate (which show its not working smoothly even with positive values):

And the fact that the motor doesn't move at all with any negative values in (setSpeed(-1000) for example) show there is something fundamentally wrong in my setup.
When setting a negative speed touching the motor I can feel its actively trying to step but all it does is vibrate.
I have 6 of these motors and some 2 of them are even yelling when I attempt to run them with a negative value!:

Closeup:

I tried the whole range of voltage between 0.1 and 0.9V on the driver but negative speed values just don't work.
I also tried permuting the motor wires (I didn't try mixing A and B wires, just permuting the positive and negative on each sides) but all that does is inverse the rotation of positive speed values (which then rotate CCW) and negative speed values still don't produce any movements.

At this point I'm kinda stomped, does anybody have an idea what I'm missing to make this simple setup work with no jitter and able to reverse direction with negative speeds?

Any advice on this will be greatly appreciated!

I also tested a moveTo approach with the following code:

#include <AccelStepper.h>

#define STEP_PIN 2
#define DIR_PIN 3

int motorMaxSpeed = 11000; //maximum steps per second (about 3rps / at 16 microsteps)
int motorAccel = 80000; //steps/second/second to accelerate

AccelStepper stepper01(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);

void setup()
{
  // Initialize serial and wait for port to open:
  Serial.begin(115200);

  stepper01.setMaxSpeed(motorMaxSpeed);
  stepper01.setAcceleration(motorAccel);
  stepper01.moveTo(32000);
}

void loop()
{
  //if stepper is at desired location
  if (stepper01.distanceToGo() == 0)
  {
    //go the other way the same amount of steps  <= "go the other way" sounds like a direction change to me.
    //so if current position is 400 steps out, go position -400
    stepper01.moveTo(-stepper01.currentPosition());
  }

  //these must be called as often as possible to ensure smooth operation
  //any delay will cause jerky motion
  stepper01.run();
}

This produce the following behavior where it rotate correctly the positive values (up to 32000) but when it reach its destination and attempt to reverse (move backward) its obviously not happy:

Hoping it will provide the needed details an expert can use to point me in the right direction.

I don't see any ground connection between your Uno and the driver board. You need to have your grounds tied together so everything has a common reference.

1 Like

Power shouldn't be a problem, a 360W power supply for a 2W motor. Maybe you could connect your project's driveshaft to the power supply's cooling fan.
But seriously, @blh64 has your answer. :grin:
Connect a wire from TMC2209 GND to Arduino GND.

Uno pin 0 is the hardware serial RX pin. I suggest that you use a different pin for step.

As @blh64 says, the TMC2208 ground pin should connect to Uno ground.

do you know if arduino get damaged by marking it with sharpie at the back of the board?

Never heard a report of that, I'd say "not likely".
Make a strong black line on paper with the Sharpie, let it dry, then test it for conductivity with your Ohmmeter.

1 Like

Thkx a lot @blh64 it worked!

I'm amazed, a little pissed and very happy at the same time :wink:

I'm amazed by the simplicity of the fix but a little pissed since I knew we needed to have common ground reference.

Still learning and I thought the ground wire from the power supply to the driver was enough and didn't needed to also provide the same ground to the Arduino.

And I was under the impression the driver was handling everything regarding current control to the motor and the Arduino handling the logic call of the direction and step sequence without needing a ground common reference.

But it turn out @blh64 was right and providing the common ground reference to the Arduino from the TMC2209 driver is essential!

The "fixed" schematics:

Here you can see the "brown" wire which spawn from the wire "bridge" between the GND and EN pins on the TMC2209 and is then connected to the GND pin of the Arduino:


The back view showing the wire connection linking the TMC2209 GND and EN pins to the Ardhuino GND pin:

I knew I was missing something fundamental in my setup for negative speeds to fail completely like that.

Here is the fix in action:

Hoping the detailed rundown we went over will help the next person hitting a similar issue!

Thkx again @blh64, I'll be able to push the project forward now!

@JCA34F That project started a year ago and I was gathering some components without exactly knowing which type of motors and how many I would end up using.
Turn out the power supply I got back then was overkill for the very small motors I'm glad I found on Stepperonline.
But yeah, it could have gone down in many different ways.

@groundFungus The schematic was a bit misleading about where the pins from the driver were actually connected to.
I provided the details in the post above the picture showing the connection between the TMC2209 and the Arduino (TMC2209 Dir pin in the Arduino pin 2 / TMC2209 Step in in the Arduino pin ~3).
But yeah, every details count so thkx for checking!

@sof_7 I hope you marking your board with a sharpie work your way, whatever you are trying to achieve.

I'm glad I asked for help on this forum, have a good day everyone! :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.