closed loop stepper won't move more than 1 step

I have a Nema 34 closed loop stepper controlled by an HBS86 clone driver and a teensy 4.0. I am trying to use the accelstepper library but the stepper won’t move more than 1 pulse. I tried to use the example constant speed and bounce scripts, and I changed the code to acknowledge that I have an external driver. When I upload the code or power on the teensy, I can hear and feel the motor move 1 pulse, then nothing. I have also tried turning the pin high and low with a delay - same result. I’ve switched pins, switched the order, tried sinking and sourcing the pulse and direction pins. No change. Any advice?

Without seeing your program or your connection diagram .... how can we have any idea what the problem might be.

...R
Stepper Motor Basics
Simple Stepper Code

I tried a couple of scripts. The first were from the accelstepper eamples:

#include <AccelStepper.h>

AccelStepper stepper(1,6,7); 

void setup()
{  
   stepper.setMaxSpeed(1000);
   stepper.setSpeed(50);        
}

void loop()
{  
   stepper.runSpeed();
}

and:

#include <AccelStepper.h>

// Define a stepper and the pins it will use
AccelStepper stepper(1, 6, 7);

void setup()
{  
  // Change these to suit your stepper if you want
  stepper.setMaxSpeed(400);
  stepper.setAcceleration(20);
  stepper.moveTo(500);
}

void loop()
{
    // If at the end of travel go to the other end
    if (stepper.distanceToGo() == 0)
      stepper.moveTo(-stepper.currentPosition());

    stepper.run();
}

When those did not work i tried just pulsing the pin high and low, because if i connect a button the the pulse pin and gnd, I can manually pulse it.

#include <Arduino.h>

const int pulPin = 6;  // PUL
const int dirPin = 7; // DIR

void setup() {
  // put your setup code here, to run once:
  // Setup the pins as Outputs
  pinMode(pulPin,OUTPUT); 
  pinMode(dirPin,OUTPUT);

  //digitalWrite(enaPin,HIGH); 
  //delayMicroseconds(5);
  digitalWrite(dirPin,HIGH); 
  delayMicroseconds(5);
}
void loop() {
  // put your main code here, to run repeatedly:
  analogWrite(pulPin,HIGH); 
  delayMicroseconds(20);
  analogWrite(pulPin,LOW); 
  delayMicroseconds(2000);
}

The driver is wired like this:

Please make your image visible in your Post. See this Simple Image Posting Guide

To start with always use a very slow step rate. Maybe just 2 or 5 steps per second.

A link to the datasheet for your driver would also be a good idea - it is not one that is commonly mentioned on the Forum.

...R

Here is the link to the manual for the driver. The wiring diagram is on page 5: HSS86 User manual.pdf - Google Drive

Also, while i was messing with the wiring something strange occured. I was holding the pulse (-) line coming from the driver in one hand, and I touched the motor with the other, and it started spinning. So thge current was going out of the 5v, into the pul (+), out of the pul (-), into my right index finger, out of my left index finger, and into the motor shaft. The same thing happened when I touched the motor body. I'll try to diagram it out. I had the bounce sketch running and the motor was changing direction correctly - ie the dir pin was wired to the teensy as normal. Perhaps the motor is faulty?

Edit: seems like pictures aren't posting so here is another link: Imgur: The magic of the Internet

UPDATE:

I write ran a simple

analogWrite(pulPin, 50);

and the motor spins!

so now I at least know the motor, driver and pins are working (am I correct in thinking this?). Am I implementing accelstepper incorrectly then?

So update to the update: no matter what I set the value to, the motor speed does not change :frowning:

I went back and tried the the code that sets the pin high, delay, low, delay, etc... and used a digitalwrite instead of analog, and it worked. I was able to change the speed based on the delay.

So now I think it may be something I am doing wrong with my implementatin of accelstepper.

The wiring connections in your linked document seem to be simple, and the same as regular stepper drivers.

It would be a big help if you can make a simple drawing showing how YOU have everything connected and post a photo off the drawing. I suspect you may be missing something.

The analaogWrite() command is not relevant for a stepper motor.

...R

Here is how I have it wired. When I used the 5v rail as the (+) i put resistors after the diode to reduce the voltage for the 3v tolerant pins on the teensy.

jacksonl17:
Here is how I have it wired.

That illustrates the problem very clearly. There needs to be more than one connection between the Arduino and the stepper driver.

And the diode may be the wrong way round - but I can't tell because I don't know what is at each end of the line in the diagram.

...R

Robin2:
There needs to be more than one connection between the Arduino and the stepper driver.

I think in my effort to simplify my wiring diagram I over did it. I do have multiple connections. I also tried to label them better here. The diode is part of the driver.


jacksonl17:
I think in my effort to simplify my wiring diagram I over did it. I do have multiple connections. I also tried to label them better here. The diode is part of the driver.

I would like to help but you seem determined not to respond to my request in Reply #7

simple drawing showing how YOU have everything connected

And the drawing should NOT show components that are internal to the devices.

...R

The diagram in reply #10 is exactly how I have it wired - just minus the diodes internal to the driver. There is nothing else connected right now. Sorry if I'm not understanding what you're asking for.

Here is another diagram which shows exactly how it is wired up.

jacksonl17:
The diagram in reply #10 is exactly how I have it wired - just minus the diodes internal to the driver.

In that case it seems to me to be wrong. It's not at all like the diagram in the document you linked to in Reply #4.

Also, the diagram in Reply #10 does not identify where the 3.3v comes from or what the pins 6 and 7 are part of. I'm not a mind reader. Neither am I going to indulge in mental gymnastics to imagine what the connections might be like without the diodes.

This correspondence is getting very tedious.

...R

3 volts comes from the teensy and pins 6 and 7 are on the teensy. I also updated the diagram in my last post.

So the wiring comes from the 3v pin on the board to the pulse and direction (+) on the driver, then out of the pulse and direction (-) terminals to pin 6 and 7 on the board respectively.

I'm not familiar with the Teensy, but the 3.3v outputs on an Uno or Mega can provide very little current.

The diagram in the PDF shows 5v connected to the + connections.

The diagram in the PDF shows a connection to the ENA pin of the driver.

...R

I have tried using both the 3v and 5v pins, but neither has worked with accelstepper. Both setups worked when I ran the follwoing code though. The enable terminal is normally closed, so it doesn’t require power.

#include <Arduino.h>

const int pulPin = 6;  // PUL
const int dirPin = 7; // DIR

void setup() {
  pinMode(pulPin,OUTPUT);
  pinMode(dirPin,OUTPUT);

  digitalWrite(dirPin,HIGH);
  delayMicroseconds(5);
}
void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(pulPin,HIGH);
  delayMicroseconds(200);
  digitalWrite(pulPin,LOW);
  delayMicroseconds(200);
}

So the only difference between when the motor turned and when it didn’t was switching to accelstepper.

If the code in your Reply #16 works then I can think of no reason why alternative code with the AccelStepper library would not work if you use the same step rate.

Is it possible you have the step and direction pins mixed up?

...R

I have tried switching the pulse and direction pins, switching between sinking and sourcing, and trying different pins around the board. Nothing.

I'm going to pick up an arduino today to see if maybe it's something with the teensy.

jacksonl17:
to see if maybe it's something with the teensy.

I suppose its possible the AccelStepper library does not work on a Teensy - maybe someone with experience of Teensys can comment on that.

...R