Stepper Driver enable pin has no effect - TMC2208, AccelStepper, Teensy3.2

Hello smart people,

I'm working on a project that uses stepper motors to move something very light very slowly (most of the time - under certain conditions it needs to move faster). It's all working fine except that it uses way, way more power than is necessary, which I understand is normal with stepper motors holding their position.

I thought a good next step would be to periodically enable and disable the drivers, allowing the motors to draw zero current and the machine to freewheel (as it has no load on it, this is fine). However, in trying to use the enable pin as in the modified AccelStepper library example below, the enable pins have no effect - the motors spin continuously.

With this code running running and with the motor power off, I measure the voltage on the enable pin to go from 0 to 3.48V as expected; with motor power on, it goes from -0.78V to 2.7V. EDIT I was referencing something not ground - it always goes from 0-3.5 as expected.

Is there something happening between this library / my driver that I'm not understanding? Is that 2.7V not actually high enough to disable the chip? Or am I supplying the wrong voltage (embarrassingly, I have never know what is a good voltage to give these steppers, but have found that 12V moves nicely)? Am I horribly misguided in general?

Summary:

Thanks in advance,
Sean

Modified example code:

// MultiStepper.pde
// -*- mode: C++ -*-
//
// Shows how to multiple simultaneous steppers
// Runs one stepper forwards and backwards, accelerating and decelerating
// at the limits. Runs other steppers at the same time
//
// Copyright (C) 2009 Mike McCauley
// $Id: MultiStepper.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#define STEP_P_STP 3
#define STEP_P_DIR 4
#define STEP_P_EN  23
#define STEP_Y_STP 5
#define STEP_Y_DIR 6
#define STEP_Y_EN  22

#include <AccelStepper.h>

// Define some steppers and the pins the will use
AccelStepper stepP(1, STEP_P_STP, STEP_P_DIR);
AccelStepper stepY(1, STEP_Y_STP, STEP_Y_DIR);

long currentTime = 0;

void setup()
{
  Serial.begin(115200);

  // set enable pin mode
  pinMode(STEP_P_EN, OUTPUT);
  pinMode(STEP_Y_EN, OUTPUT);

  stepP.setMaxSpeed(100.0);
  stepP.setAcceleration(100.0);
  stepP.moveTo(10000);

  stepY.setMaxSpeed(100.0);
  stepY.setAcceleration(100.0);
  stepY.moveTo(10000);

  currentTime = millis();

}

void loop()
{
  // Change direction at the limits
  if (stepP.distanceToGo() == 0) {
    stepP.moveTo(-stepP.currentPosition());
  }
  if (stepY.distanceToGo() == 0) {
    stepY.moveTo(-stepY.currentPosition());
  }

  stepP.run();
  stepY.run();

  if (millis() - currentTime == 2000) {
    digitalWrite(STEP_P_EN, LOW);
    digitalWrite(STEP_Y_EN, LOW);
    Serial.print("LOW  ");
    Serial.println(millis());
  }
  if (millis() - currentTime == 4000) {
    digitalWrite(STEP_P_EN, HIGH);
    digitalWrite(STEP_Y_EN, HIGH);
    Serial.print("HIGH  ");
    Serial.println(millis());
    currentTime = millis();
  }


}

My guess is that you wired the setup incorrectly. Post a schematic diagram (hand draw is fine).

Are you measuring with a DMM or an oscilloscope? The voltage may not be a steady voltage necessary for a DMM to measure correctly.
Paul

Hi @jremington thanks for getting back to me

I have wired it as in this image:

Not sure if it's useful (is beyond my knowledge ) but here is the schematic for the bigtreetech TMC2208 board:

I double checked that I didn't cross anything, and I did feel confident that the wiring was correct up to the driver enable pin as it did show the voltage from 0 to 3.5V

The motor driver schematic is very helpful, and shows that the Enable pin ENN has a pullup to Vcc, so the micro has to set a LOW signal to disable the motor driver.

BUT the schematic does not seem to show how the ENN connection is brought out (that is, how EN is connected to the driver chip)!

Check that you are sending a LOW and check all connections for continuity, using a multimeter (or redo the wiring).

Edit: I see it now (faint symbol, see below). LOW should do the trick.

Capture

Hi Paul - I'm using a (very cheap) DMM. The sketch I posted alternates between high and low every two seconds, and within a second or so the readout of the DMM did settle to 0 or 3.5V. I checked again, there is actually no negative voltage (I think I was referencing the VREF, or something, will edit original post

Thanks for looking that over! Makes sense re: the schematic, however it still doesn't appear to have any effect. The example should let the motor move for 2 seconds, then disable for 2 (whichever of HIGH or LOW actually enables it) and I can see the voltage on the enable pin alternating between 0 and 3.5V as expected. But it is moving continuously on the desk currently...

any other thoughts? unfortunately I don't have any other of these boards to hand to see if it's a faulty one (but I have ruined some previously, so wouldn't rule it out, i suppose)

As a test, connect the EN pin on the motor driver to motor driver ground with a wire. That should prevent the motor from running. If not, the board might be defective.

If you are doing this on a breadboard, that may be the problem, as breadboards don't always make good connections, and can't handle motor currents (the tracks burn).

Motor driver chips can be instantly destroyed by loose motor connections.

From the data sheet linked in the original post.
EN Enable Motor Outputs: GND=on, VIO=off

Hi,
I think this is the manual for your driver;
TMC2208-V3.0 specification .pdf (1.1 MB)
Here is the relevant part;


You need a pull-up resistor then gnd will enable the driver, Vcc will disable it.

Can you draw a schematic please , with labelled components and pin names, a cut and paste diagram is not the easiest to read.
Hand draw your circuit and post a picture would be fine.

Tom.. :grinning: :+1: :coffee: :australia:

Posted in reply #4

I stand corrected: according to the data sheet, it appears that with no connection to EN (open input), the pullup on the board ensures that motors will not run.

That they do run suggests that you have either a defective board, or a short to ground on EN. Check the board with a magnifying glass, and look for solder blobs shorting pins, etc.

The image has too many coloured and crossed wires, and TWO MCUs!!

The schematic is of the driver, not the complete project.

Tom... :grinning: :+1: :coffee: :australia:

I had no problem understanding that the "second MCU" does not exist, but the diagram is sloppy.

Hi @jremington @TomGeorge @groundFungus thanks for your input! Here is a diagram (still a little sloppy, sorry, but I hope it does the job).

and it looks like this to give you an idea of the construction quality of this prototype... (similarly, a bit sloppy but it has been doing the job!):

Re: wiring and shorting out drivers, it is all done on this protoboard, so the connections should be fairly stable? The motors and drivers perform exactly as expected except for this enable/disable thing, so I am doubtful that they're faulty

I've checked it for shorts and don't see any (see pics in prev post, for reference, although not pretty it seems all good). I have also measured the enable pin going from high to low repeatedly, as expected from the sketch, and not seen the motors/drivers do anything other than run continuously.

I've also confirmed that both the drivers I have show the same behavior - driving perfectly but not enabling/disabling the output. See video here: Img 0734-1.m4v - Google Drive

My only guesses:

  • Do I need some extra circuitry to actually use the pin? pull up or down resistors?
  • Is it possible that the boards work perfectly for driving, but the enable pin/feature (on both boards) is busted?
  • is the AccelStepper library somehow interfering with the enable pin? (seems unlikely but I can test this)

Thanks for all you input, I'm sorry if it's dissolved into a big moan from me.

Hi,
This may help.
I have added R1 and R2 as pullup resistors as I do not know if the Teensy has internal pullup on its A8 and A9 pins.
I have also swapped the Tx and Rx on the GPS as you noted in your diagram
Fell free to find any errors or suggestions.


Have you got a 3V3 supply?

Tom.. :grinning: :+1: :coffee: :australia:
PS. Looking at your board layout, you will need to add some bypass capacitors to your power supply wires at each major component.

wow thanks for this @TomGeorge. I'm using the teensy as 3V3 supply, which is powered by USB (I suppose that should have gone in my schematic too).

I just added R1 as drawn here but no change. I also had a read here: Teensy® 3.2 where it states:

Input Pullup & Pulldown Resistors
All digital pins have optional pullup and pulldown resistors. These are used to keep the pin at logic HIGH or logic LOW when it is not being actively driven by external circuity. Normally these resistors are used with pushbuttons & switches. The pinMode function with INPUT_PULLUP or INPUT_PULLDOWN must be used to configure these pins to input mode with the built-in resistor.

and later

Digital Output Pins
All digital pins can act at output. The pinMode function with OUTPUT or OUTPUT_OPENDRAIN must be used to configure these pins to output mode. The digitalWrite and digitalToggle functions are used to control the pin while in output mode. Output HIGH is 3.3V. The recommended maximum output current is 10mA.

Which perhaps indicates that they do have this resistor already?

As for bypass capacitors, do i need to add one in addition to what's on the breakout boards already? (for example, the GPS board appearss to have one on it's VCC already: https://cdn.shopify.com/s/files/1/0174/1800/files/PA1010D_schematic.pdf?v=1617176686)

resistor I added (covered w heatshrink, you'll have to trust me that it's 4k7 and connected to EN and 3v3):

That they do run suggests that you have either a defective board, or a short to ground on EN.

Use your multimeter to check for a short to ground on the EN pin, right at the motor driver module. After that, I'm out of ideas.

Hi,
What is the output current rating of the Teensy 3V3 pin?
100mA available form 3V3 pin, you need to see if 3v3 is being overloaded.

Can you measure the 3V3 with DMM while operating your project to see if it is stable?

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

A quick update on this:

I ordered new TMC2208 drivers boards from a different manufacturer (https://uk.farnell.com/trinamic/tmc2208silentstepstick/eval-board-stepper-motor-driver/dp/3861298?st=tmc2208) and they work exactly as expected..

So that's that functionally solved, but I don't know why my bigtreetech drivers' enable pins never worked.

(@TomGeorge thanks for your suggestion above - as far as I could tell it wasn't, ie the voltage never dropped while it was running)