Stepper Won't Reverse, Instead Cooks Eggs

esdraelon

Member
Sorry if this a repeat question. I spent a good portion of the last couple evenings trying to figure out what I'm doing wrong, searching thither and yon.

Virtually all of the hits on Google refer to specific issues with CNC controller kits, voltage being too low, or programming errors.

Background: I'm the Jon Snow of electronics
More background: I have what I believe to be a fairly simple setup:

  1. Small stepper motor (https://www.omc-stepperonline.com/n...ncm-22-6oz-in-1a-3-7v-42x42x20mm-4-wires.html, https://www.omc-stepperonline.com/download/17HS08-1004S-.pdf)
  2. 3.3V to 5V Level Shifter
  3. Teensy 3.5
  4. Digital Stepper Driver (https://www.omc-stepperonline.com/d...2a-18-30vdc-for-nema-17-23-stepper-motor.html, https://www.omc-stepperonline.com/download/DM332T.pdf)
  5. 24V x 15A Power Supply

Code and schematic follow. I'm a programmer but I am very new to electronics. I learned KiCAD just to make this post so I didn't waste anyone's time if possible. The issue is as follows:

  1. The code runs and happily rotates the motor in one direction.
  2. When the code flips to reverse direction, it instead stands still.
  3. It happily rotates/stands still until it makes a buzzing noise and gets hot (this is the point I gave up and started learning KiCAD).

Validation Steps:
  1. Checked and re-checked the Red, Green, Blue, Black wires to A+/-, B+/- until my eyes crossed
  2. Validated that the code only sends the reverse signal once per second (during inversion).
  3. Put a multimeter on the level shifter to validate that the output for PUL and DIR is changing from 200mV to 4.8V in time with the serial output of the code.

Code:
/*
  Stepper Motor Test
  stepper-test01.ino
  Uses MA860H or similar Stepper Driver Unit
  Has speed control & reverse switch
  
  DroneBot Workshop 2019
  https://dronebotworkshop.com
*/
 
// Defin pins
 
int driverPUL = 7;    // PUL- pin
int driverDIR = 6;    // DIR- pin
int ledPin = 13;
 
// Variables
 
int pd = 500;       // Pulse Delay period
boolean setdir = HIGH; // Set Direction
int reverse = 0;
 
// Interrupt Handler
 
void setup() {
  Serial.begin(9600);
  pinMode (driverPUL, OUTPUT);
  pinMode (driverDIR, OUTPUT);
  pinMode (ledPin, OUTPUT);
  digitalWrite(driverDIR, setdir);
  digitalWrite(ledPin, HIGH);

  delayMicroseconds(1 * 1000000);
  Serial.println("Validate LED");
  delayMicroseconds(1 * 1000000);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1 * 1000000);
  digitalWrite(ledPin, HIGH);
}
 
void loop() {
  reverse++; 
  if (reverse >= 1000) {
    Serial.printf("Reverse loop: %d to %d\n", reverse, setdir);
    setdir = (setdir == LOW) ? HIGH : LOW;
    digitalWrite(driverDIR, setdir);
    digitalWrite(ledPin, setdir);
    reverse = 0;
    delayMicroseconds(pd);
  }
  digitalWrite(driverPUL, HIGH);
  delayMicroseconds(pd);
  digitalWrite(driverPUL, LOW);
  delayMicroseconds(pd);
}

"Schematic" to follow. I screwed up the drawing. Not pictured is the Neutral wire on the power supply connected to Neutral on the digital stepper driver. I'm tired and I just can't go back and open up the library definition and rewire the drawing.

Thank you for any advice or help.

EDIT: I screwed up the drawing. Uploading another one in just a moment.
 

Attachments

  • tutorial.pdf
    51.1 KB · Views: 67
You are stepping this motor without acceleration at 1kHz. Depending on your microstep setting on the driver this might be borderline. If you reverse the direction while the motor runs at this speed it needs to fully stop and start in the other direction in 500µs. I would be surprised if the motor can folllow this rapid change. From your description I assume it looses sync with the rotating magnetic field (aka steploss). Usually a stepper can't recover from this and just stalls which gives the noise you hear.

For a quick check, reduce the step frequency to, say, 100Hz. In the long run I suggest to use one of the available stepper libraries (accelStep, TeensyStep or similar)
 
Last edited:
Indeed you'll never get a stepper to jump to high speed from standstill without speed ramping, unless its a really tiny motor.
 
100stp/sec should not be a problem for this motor. (I assume there is no load on it?)

One more (unlikely) idea: your software is a bit unusual in that it generates a square wave instead of the usual pulses. Can you change that? E.g generate a 15µs pulse for each step. Maybe the driver has some issues with that. You can also try to make the delay after switching the directions longer, say some 10ms.

Not related to your problem: the driver you are using is a bit oversized for the motor. The smallest current setting it provides is 1A. A small step stick (e.g. drv8825) would be absolutely sufficient. You don't need to run the stepper at its rated current some 30-50% are usually just fine.

What microstepping mode did you select?
 
That's not a small motor. This is the small type of stepper: https://www.hackster.io/news/drive-a-tiny-stepper-directly-with-arduino-911571f8cd0e

Try with AccelStepper library and 1000 steps/sec/sec.

Or try 5Hz

Check both windings are intact and correctly wired. Yes, check it again, carefully. (ie check continuity end-to-end of
every wire and connector). Another possibility is a fried driver if you ever hot-plugged the motor (this is a no-no).

OK, it appears to just be a bad driver. I turned it down to 1HZ, and I can see that it pulses in the HIGH direction, but not in the LOW direction.

Thank you for helping. I have ordered another driver, hopefully it will work.
 
100stp/sec should not be a problem for this motor. (I assume there is no load on it?)

One more (unlikely) idea: your software is a bit unusual in that it generates a square wave instead of the usual pulses. Can you change that? E.g generate a 15µs pulse for each step. Maybe the driver has some issues with that. You can also try to make the delay after switching the directions longer, say some 10ms.

Not related to your problem: the driver you are using is a bit oversized for the motor. The smallest current setting it provides is 1A. A small step stick (e.g. drv8825) would be absolutely sufficient. You don't need to run the stepper at its rated current some 30-50% are usually just fine.

What microstepping mode did you select?

I just went with the driver recommended on the site at checkout. I don't believe sending a non-square wave will improve matters, since it is a digital stepper driver - I think it just monitors edges.

I reduced the stepping time to 100hz (as above), with the same results. I put a multimeter on the wires from the driver to the motors, slowed the timing down to 1Hz, and the issue appears to be that the driver doesn't send signals to the motor when DIR is LOW. It does send signals when DIR is HIGH.
 
Hmm, perhaps that level shifter isn't able to drive the opto-coupler LEDs properly - can't see any
datasheet for it. Opto coupled inputs probably want 15mA or so, which is more than some logic
devices can output.

I'd start measuring the voltages at the opto-coupled interface of the driver in case there's an
issue with this.
 
Sorry if this a repeat question. I spent a good portion of the last couple evenings trying to figure out what I'm doing wrong, searching thither and yon.

Virtually all of the hits on Google refer to specific issues with CNC controller kits, voltage being too low, or programming errors.

Background: I'm the Jon Snow of electronics
More background: I have what I believe to be a fairly simple setup:

  1. Small stepper motor (https://www.omc-stepperonline.com/n...ncm-22-6oz-in-1a-3-7v-42x42x20mm-4-wires.html, https://www.omc-stepperonline.com/download/17HS08-1004S-.pdf)
  2. 3.3V to 5V Level Shifter
  3. Teensy 3.5
  4. Digital Stepper Driver (https://www.omc-stepperonline.com/d...2a-18-30vdc-for-nema-17-23-stepper-motor.html, https://www.omc-stepperonline.com/download/DM332T.pdf)
  5. 24V x 15A Power Supply

Code and schematic follow. I'm a programmer but I am very new to electronics. I learned KiCAD just to make this post so I didn't waste anyone's time if possible. The issue is as follows:

  1. The code runs and happily rotates the motor in one direction.
  2. When the code flips to reverse direction, it instead stands still.
  3. It happily rotates/stands still until it makes a buzzing noise and gets hot (this is the point I gave up and started learning KiCAD).

Validation Steps:
  1. Checked and re-checked the Red, Green, Blue, Black wires to A+/-, B+/- until my eyes crossed
  2. Validated that the code only sends the reverse signal once per second (during inversion).
  3. Put a multimeter on the level shifter to validate that the output for PUL and DIR is changing from 200mV to 4.8V in time with the serial output of the code.

Code:
/*
  Stepper Motor Test
  stepper-test01.ino
  Uses MA860H or similar Stepper Driver Unit
  Has speed control & reverse switch
  
  DroneBot Workshop 2019
  https://dronebotworkshop.com
*/
 
// Defin pins
 
int driverPUL = 7;    // PUL- pin
int driverDIR = 6;    // DIR- pin
int ledPin = 13;
 
// Variables
 
int pd = 500;       // Pulse Delay period
boolean setdir = HIGH; // Set Direction
int reverse = 0;
 
// Interrupt Handler
 
void setup() {
  Serial.begin(9600);
  pinMode (driverPUL, OUTPUT);
  pinMode (driverDIR, OUTPUT);
  pinMode (ledPin, OUTPUT);
  digitalWrite(driverDIR, setdir);
  digitalWrite(ledPin, HIGH);

  delayMicroseconds(1 * 1000000);
  Serial.println("Validate LED");
  delayMicroseconds(1 * 1000000);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1 * 1000000);
  digitalWrite(ledPin, HIGH);
}
 
void loop() {
  reverse++; 
  if (reverse >= 1000) {
    Serial.printf("Reverse loop: %d to %d\n", reverse, setdir);
    setdir = (setdir == LOW) ? HIGH : LOW;
    digitalWrite(driverDIR, setdir);
    digitalWrite(ledPin, setdir);
    reverse = 0;
    delayMicroseconds(pd);
  }
  digitalWrite(driverPUL, HIGH);
  delayMicroseconds(pd);
  digitalWrite(driverPUL, LOW);
  delayMicroseconds(pd);
}

"Schematic" to follow. I screwed up the drawing. Not pictured is the Neutral wire on the power supply connected to Neutral on the digital stepper driver. I'm tired and I just can't go back and open up the library definition and rewire the drawing.

Thank you for any advice or help.

EDIT: I screwed up the drawing. Uploading another one in just a moment.

the link doesn't work now,i find these product the same as the above, i can open the following link:

Small stepper motor (https://www.oyostepper.com/goods-82...Nema-17-23-Stepper-Motor-10-32A-10-30VDC.html, https://www.oyostepper.com/images/upload/File/DM332T.pdf)
3.3V to 5V Level Shifter
Teensy 3.5
Digital Stepper Driver (https://www.oyostepper.com/goods-99...tor-13Ncm184ozin-Insulation-Class-H-180C.html, https://www.oyostepper.com/images/upload/File/17HS08-1004S-H.pdf)
24V x 15A Power Supply
 
Back
Top