0

I tried running Nema 17 stepper motor using the drive in the pic below (not the basic L298N drive, which BTW I successfully used to rotate the motor) .

Could any of you review my existing connections and guide me to complete the remaining ones?

Existing Arduino Uno, Nema 17 motor and drive setup:

Existing Arduino Uno, Nema 17 motor and drive setup

Existing connections to Drive from left to right:

  1. Thick yellow wire (0v) from power adapter along with a thin black wire (Ground) from Arduino
  2. Thick red wire (12v +) from power adapter
  3. Green wire (A+) from stepper motor
  4. Black wire (A-) from stepper motor
  5. Red wire (B+) from stepper motor
  6. Blue wire (B-) from stepper motor

What I am missing is connections to PUL, DIR, VCC and ENA. I could put the 4 wires from Arduino D8 to D11 respectively but is that enough? Is there an Arduino sketch I could refer to after the connections are ready?

2 Answers 2

-1

Here is the user manual for the BH-MSD-2A Micro stepping driver.

Page 5 shows the two tables giving the connections:

Connection table

You have already connected P2, and that leaves P1 remaining.

The timing diagram below shows the state of the, PUL, DIR and ENA signals required

Timing diagram.

So, the ENA input can either be held high, by connecting to VCC or connected to a digital output pin of the Arduino, to provide basic ON/OFF control.

This thread, arduino uno with stepper motor, the OP is using a very similar controller to yours, except that theirs is the 6 A version (BH-MSD-6A). Their code, in the thread has a lot of unnecessary code, and apparently has a number of issues. A stripped down version, of the same code, is as follows:

//arduino code
//
#include <TimerOne.h>
#include <EEPROM.h>

int rpm;
int initial_rpm;
int dutycycle_time=0;
int stepper_Enable=5; //STEPPER MOTOR  ENABLE PIN : PUL- 
int stepper_Pulse=6;  // STEPPER MOTOR PULSE PIN :  PUL-

int address_eeprom=0;


void displayNumber(int);
void lightNumber(int);



void setup() 
{                



  Timer1.attachInterrupt( timerIsr ); // attach the service routine here
  pinMode(stepper_Pulse,OUTPUT); // Analog pin A2 is used for ENABLING the steeper motor
  pinMode(stepper_Enable,OUTPUT); // Analog pin A2 is used for DIRECTION the steeper motor
  digitalWrite(stepper_Pulse,HIGH);
  digitalWrite(stepper_Enable,LOW);

  rpm=EEPROM.read(address_eeprom);
}

void loop() 
{


  while(digitalRead(stepper_Enable)==HIGH){
     int cycle_freq=(1600/60)*rpm;
     int dutycycle_freq=2*cycle_freq;
     int dutycycle_time=1000000/dutycycle_freq;
      Timer1.initialize(dutycycle_time); // set a timer of length 100000 microseconds (or 0.1 sec - or 10Hz => the led will blink 5 times, 5 cycles of on-and-off, per second)
      if(analogRead(A3)==LOW )  // STOPPING THE STEPPER MOTOR
       {
         digitalWrite(stepper_Enable,LOW);

       }

  }

  while(digitalRead(stepper_Enable)==LOW)
  {
    int initial_rpm=rpm;
     EEPROM.write(address_eeprom,rpm);

      if(analogRead(A0)==LOW && rpm<300 ) ///increasing speed of stepper motor
    {
          rpm=rpm+1;
         // delay(100);
     }
    if(analogRead(A1)==LOW && rpm>0) ///decreasing speed of stepper motor
    {
          rpm=rpm-1;
         // delay(100);
    }
    if(analogRead(A2)==LOW ) //STARTING THE STEPPER MOTOR
    {
     digitalWrite(stepper_Enable,HIGH);
    }
  }
  if(initial_rpm!=rpm){
    address_eeprom=address_eeprom+1;
  }

}

void timerIsr()
{
  // Toggle LED
  digitalWrite( stepper_Pulse, !digitalRead( stepper_Pulse ));
}

Note that while this should get you started, as the OP states in the thread there are issues with it, that will need fixing.


(I have to go now to fix some Marlin firmware, but I'll come back to this answer later)

-1

Connect:

  • VCC to Arduino 5 V
  • ENA either directly to VCC or to an Arduino pin (for optional enable driver software control - active high).

Pulse (steps) and direction to Arduino GPIO.

Have a look here Arduino forum Simple Stepper Program - I think you will find what you are looking for.

1
  • Ok... been abused by « enable signal negative » in the chart page 5...
    – Bouc
    Aug 13, 2018 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.