Using Arduino 5V Pro Mini to send signals to closed loop stepper servo drive

Hi, I'm trying to verify if my wiring is correct that is going to my 5V Arduino pro mini from the control signal terminal block of a closed loop stepper servo drive. I am confused by the schematic shown below and what I've read elsewhere on the forum.

The load I'm going to be moving is light ~1.5kg.
I'm using a NEMA17 sized motor with a .68NM stall torque rating I believe.

I am trying to spin my motor 180 degrees and testing out the code below, but it's not spinning:

/*
  Stepper motor rotates 180 degrees
*/

// defines pins numbers
const int stepPin = 3;
const int dirPin = 4;
const int enaPin = 5;

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

  // Sets the two pins as Outputs
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(enaPin, OUTPUT);
}

void loop()
{
    digitalWrite(enaPin, HIGH);
    digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction
    
    // Makes 100 pulses for making half cycle rotation
    for (int x = 0; x < 100; x++)
    {
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(500);
      digitalWrite(stepPin, LOW);
      delayMicroseconds(500);
    }
}

Link to motor and drive:

The wiring from the servo drive to motor was straightforward based on the manual directions that I've attached. The wiring from the servo drive to the Arduino is what I'm unsure of.

The schematic says this:

I'm unsure if:
ena+ (pin 5) , dir+ (pin 4), pul+ (pin 3) should be going to digital output pins on the Arduino
and if
ena-, dir-, pul- should be going to Gnd

(This is how I currently have it wired).

or is it the other way around?

HBS57 Manual.doc (251 KB)

Wire the + to output pin, - to ground, HIGH activates input.
Wire the + to Vcc, - to output pin, LOW activates the input.

I have it wired the first way that you mentioned.

The code did have everything enabled as HIGH.
There was a LOW digitalWrite command but I took it out and it still remains still.
I've attached a picture below showing the Pulse/Rev Table and I have it set to default
(which I believe is set to 400 steps based on the increments)

/*
  Stepper motor rotate 180 degrees
*/

// defines pins numbers
const int stepPin = 3;
const int dirPin = 4;
const int enaPin = 5;

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

  // Sets the two pins as Outputs
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(enaPin, OUTPUT);
}

void loop()
{
    digitalWrite(enaPin, HIGH);
    digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction
    
    // Makes 200 pulses for making half cycle rotation
    for (int x = 0; x < 200; x++)
    {
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(500);
    }
}

You never set stepPin LOW.

On most motor drivers, steps are triggered by the LOW to HIGH transition on the input pin. OBEY the input timing restrictions!

    for (int x = 0; x < 200; x++)
    {
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(500);
    }

Okay, I just took the example from this site and modified it:

You never set stepPin LOW.

Not sure if you are saying not to put it in there or if you thought that I didn't put it in there.

I had it in the first example, but it still didn't work.
I also tried to set the enaPin (enable pin) to LOW and it still didn't work.

I've tried to find examples on the forum where there is an enable, step, and direction situation, but
all of the ones I'm finding are dealing with step and direction only.

After uploading this code, all I hear is a humming sound from the driver:

/*
  Stepper motor rotate 180 degrees
*/

// defines pins numbers
const int stepPin = 3;
const int dirPin = 4;
const int enaPin = 5;

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

  // Sets the two pins as Outputs
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(enaPin, OUTPUT);
}

void loop()
{
  digitalWrite(enaPin, HIGH);
  digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction

  // Makes 200 pulses for making half cycle rotation
  for (int x = 0; x < 200; x++)
  {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);
  }
}

Here is the connected 5V Arduino Pro Mini
(3.3V Arduino Pro Mini might not work since it only accepts 5-24V signals)
for others to see:
The yellow, blue, and white wires are going from ENA+, DIR+,PUL+ into the Arduino Pro Mini in pins 5,4,3 respectively.

This should work.

   for (int x = 0; x < 200; x++)
    {
      digitalWrite(stepPin, HIGH);
      delay(10);  //START SLOW!
      digitalWrite(stepPin, LOW);
      delay(10);
    }

If it doesn’t, your wiring is incorrect or your logic values on the ENABLE pins is incorrect.

I can’t make any sense of the photos, so hand draw and post a schematic diagram of exactly how you wired it, with every pin labeled and every component value identified.

There must be a current limiting resistor of proper value in series with the input LED on the optocouplers. What is that value (it may be internal to the motor driver)?

I tried it but still getting same humming sound.
I tried the latest updated delay timing below and I even tried 500 ms and still got no response from the motor.

I double checked connections for the motor encoder, and motor.
The only thing that was weird based on the manual was the color on one of the windings (phase A+) was labelled as yellow (since it was the only different color and the rest were the same colors mentioned in the manual) I put the only wire left (black) into that port.

I also checked my voltage from my power supply which is still at 24.5 volts

Here is an overall view of the HBS57 connected to the Arduino:

So I just checked the windings for continuity on my multimeter.

The vendors manual that I attached in the first post for this specific motor is wrong I believe.

Black wire plugged into A+ had continuity with the green wire in B-.
Blue wire plugged into A- had continuity with red wire in B+.

:confused:

Another large view of setup:

It's weird I had a little bit of movement (it only happened once) with this setup but it's not repeatable. Will keep on trying different combinations. At least I know which two pairs are the respective phases. I also contacted the vendor, no response yet.

A+ (green)
A- (black)
B+ (red)
B- (blue)

I tried to increase delay timing as well but no luck.

So I went back to vendor site in the link below and found the correct sequence.
Still no response just a little bit of clicking.
I'm hoping I won't have to program the drive via the RS232 port.

Got it working. Thanks!
Had to change Enable pin to LOW.

It’s overshooting though after each 180 degree spin. That may be just my design. The GT2 belt is not catching onto the pulley at times. I may have to change design up a bit.

/*
  Stepper motor rotates 180 degrees
*/

// defines pins numbers
const int stepPin = 3;
const int dirPin = 4;
const int enaPin = 5;

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

  // Sets the two pins as Outputs
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(enaPin, OUTPUT);
}

void loop()
{
    digitalWrite(enaPin, LOW);
    digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction
   
    // Makes 400 pulses for making half cycle rotation
    for (int x = 0; x < 400; x++)
    {
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(500);
      digitalWrite(stepPin, LOW);
      delayMicroseconds(500);
    }

    delay(2000);
}

jremington:
You never set stepPin LOW.

On most motor drivers, steps are triggered by the LOW to HIGH transition on the input pin.

On all drivers I've ever seen its the LOW->HIGH transition - the other transition is irrelevant.

The step happens on the LOW->HIGH step transition and the direction pin is sampled at the
same instant.

So you normally you use code like:

  digitalWrite (direction_pin, direction) ;   // direction must change first if necessary
  delayMicroseconds(10) ;  // to allow for slow opto couplers
  digitalWrite (step_pin, HIGH) ;   // everything happens here.....
  delayMicroseconds(10) ;  // to allow for slow opto couplers
  digitalWrite (step_pin, LOW) ;  // release it for next time.

If directly talking to a chip the delays can be removed or reduced to 1 µs.

The way I see that diagram, the inputs are sourcing (LOW true).
Are the encoder signals push-pull, open collector or differential line driver?

Link to motor and drive:

The way I see that diagram, the inputs are sourcing (LOW true).

I believe you are correct. I have it the other way around.

Honestly I'm still familiarizing myself with closed loop systems.
I'm not sure what type of encoder signal it is.
It's a 1000 line encoder. There are no labels on it.

My CAD software gave me an incorrect belt length ~400 mm, so I ordered some GT2 400 mm belts but they were loose. Even after putting the belt in tension it looses its grip on the pulley teeth. My gear ratio is 20 to 28 teeth (1.4).

I'm going to try to see if I can get more torque from the motor via the software settings.
The software the vendor provided is in Chinese.
It seems like a Leadshine software interface.
I think I will have to install Chinese fonts properly on Windows 7 for it to display properly.

Here is a the setup view from the bottom of the machine:

Or maybe I'll ask the vendor if they have an English version of the software I can download.

I have this USB to RS232 (RJ-12) cable plugged in to communicate with the driver:

Well I talked to the vendor, they don't have an english version of the software.
I will try to install Chinese fonts on Windows 7 so that other menu options can show up properly and hope fully a friend can translate.

I can't fine tune it yet without knowing what the menu options mean and some GUI options showing up with ???? and other weird characters.

I somewhat got rid of my locating/overshooting problem.
I removed one roller bearing that was in the way of the belt.
I also shimmed the spacers that the roller bearings are mounted to by ~.3 mm.
So now I've got less contact between my rotating metal plate that the roller bearings come into contact with.

The nut at the top of the plate is unwinding itself regardless of which way I rotate.

  1. I will first try some thread locking adhesive to prevent it from loosening.
  2. Use the set screw option coming in from the side of the plate and locking onto a d-cut shaft that is
    rotating it if the first option doesn't work.

Next time maybe I'll go with a more reputable brand even thought it's more expensive.
I've heard good things about:

http://www.dmm-tech.com/index.html

I had a friend help me translate things a bit for the software, hope it helps others:

Hello, for a prosthetic arm project that uses 5 servo motors ( tower pro SG90 micro servo 5V operating voltage) i have a 12V 2400mah Li-ion battery how can i use it to power all 5 servo motor. Can i use the same battery to power all my servos along with my arduino uno board or i need a seperate power supply for it ? If in case i can use the same battery how long would it last?
Someone kindly reply ASAP its quite urgent.
thankyou.