stepper motor won't rotate

Hello everyone I am trying to run NEMA 17 Stepper Motor 4 Wire Bipolar connected to the X axis of cnc board.I am using a REES52 GRBL CNC Shield Expansion Board V3.0 +UNO R3 Board + A4988 Stepper Motor Driver powered by a DC OUTPUT 12V 1Amp power supply. Power supply is working and connection is also ok .
To drive the motors I load up GRBL code into Arduino Uno with 'Arduino Create WEB IDE'.

#define EN        8  

//Direction pin
#define X_DIR     5 
#define Y_DIR     6
#define Z_DIR     7

//Step pin
#define X_STP     2
#define Y_STP     3 
#define Z_STP     4 


//DRV8825
int delayTime=30; //Delay between each pause (uS)
int stps=6400;// Steps to move


void step(boolean dir, byte dirPin, byte stepperPin, int steps)

{

  digitalWrite(dirPin, dir);

  delay(100);

  for (int i = 0; i < steps; i++) {

    digitalWrite(stepperPin, HIGH);

    delayMicroseconds(delayTime); 

    digitalWrite(stepperPin, LOW);

    delayMicroseconds(delayTime); 

  }

}

void setup(){

  pinMode(X_DIR, OUTPUT); pinMode(X_STP, OUTPUT);

  pinMode(Y_DIR, OUTPUT); pinMode(Y_STP, OUTPUT);

  pinMode(Z_DIR, OUTPUT); pinMode(Z_STP, OUTPUT);

  pinMode(EN, OUTPUT);

  digitalWrite(EN, LOW);

}

void loop(){

  step(false, X_DIR, X_STP,stps); //X, Clockwise
  step(false, Y_DIR, Y_STP,stps); //Y, Clockwise
  step(false, Z_DIR, Z_STP,stps); //Z, Clockwise

  delay(100);

  step(true, X_DIR, X_STP,stps); //X, Counterclockwise
  step(true, Y_DIR, Y_STP,stps); //Y, Counterclockwise
  step(true, Z_DIR, Z_STP,stps); //X, Counterclockwise

  delay(100);

}

However, when I run it, the steppers will not rotate.

I get this message everytime

System wide configuration file is "C:/Users/MODHU BAGANI/.arduino-create/arduino/avrdude/6.3.0-arduino17/etc/avrdude.conf"

Using Port : COM4

Using Programmer : arduino

Overriding Baud Rate : 115200

AVR Part : ATmega328P

Chip Erase delay : 9000 us

PAGEL : PD7

BS2 : PC2

RESET disposition : dedicated

RETRY pulse : SCK

serial program mode : yes

parallel program mode : yes

Timeout : 200

StabDelay : 100

CmdexeDelay : 25

SyncLoops : 32

ByteDelay : 0

PollIndex : 3

PollValue : 0x53

Memory Detail :

Block Poll Page Polled

Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack

----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------

eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff

flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff

lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00

signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : Arduino

Description : Arduino

Hardware Version: 3

Firmware Version: 4.4

Vtarget : 0.3 V

Varef : 0.3 V

Oscillator : 28.800 kHz

SCK period : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)

avrdude: safemode: lfuse reads as 0

avrdude: safemode: hfuse reads as 0

avrdude: safemode: efuse reads as 0

avrdude: reading input file "C:/Users/MODHUB~1/AppData/Local/Temp/arduino-create-agent235966744/Blink.hex"

avrdude: writing flash (924 bytes):

Writing | ################################################## | 100% 0.16s

avrdude: 924 bytes of flash written

avrdude: verifying flash memory against C:/Users/MODHUB~1/AppData/Local/Temp/arduino-create-agent235966744/Blink.hex:

avrdude: load data flash data from input file C:/Users/MODHUB~1/AppData/Local/Temp/arduino-create-agent235966744/Blink.hex:

avrdude: input file C:/Users/MODHUB~1/AppData/Local/Temp/arduino-create-agent235966744/Blink.hex contains 924 bytes

avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.12s

avrdude: verifying ...

avrdude: 924 bytes of flash verified

avrdude: safemode: lfuse reads as 0

avrdude: safemode: hfuse reads as 0

avrdude: safemode: efuse reads as 0

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done. Thank you.

I used this website for reference though : Click here

Please help , Thank you

Increase your delayTime by a lot. Like 10ms per step for testing. 60us per step is asking the motor to accelerate from 0 to 16K steps per second immediately (with no acceleration). Not happening.

If you need high speeds, the AccelStepper library uses acceleration.

I have an identical setup and, with the following code and only the X motor, the motor works. It did not work with the original code. The only change is to the delay time.

#define EN        8

//Direction pin
#define X_DIR     5
#define Y_DIR     6
#define Z_DIR     7

//Step pin
#define X_STP     2
#define Y_STP     3
#define Z_STP     4


//DRV8825
int delayTime = 3000; //Delay between each pause (uS)
int stps = 6400; // Steps to move


void step(boolean dir, byte dirPin, byte stepperPin, int steps)

{

   digitalWrite(dirPin, dir);

   delay(100);

   for (int i = 0; i < steps; i++)
   {
      digitalWrite(stepperPin, HIGH);
      delay(10);
      //delayMicroseconds(delayTime);
      digitalWrite(stepperPin, LOW);
      delay(10);
      //delayMicroseconds(delayTime);
   }
}

void setup()
{
   pinMode(X_DIR, OUTPUT); pinMode(X_STP, OUTPUT);
   pinMode(Y_DIR, OUTPUT); pinMode(Y_STP, OUTPUT);
   pinMode(Z_DIR, OUTPUT); pinMode(Z_STP, OUTPUT);
   pinMode(EN, OUTPUT);
   digitalWrite(EN, LOW);
}

void loop()
{
   step(false, X_DIR, X_STP, stps); //X, Clockwise
   step(false, Y_DIR, Y_STP, stps); //Y, Clockwise
   step(false, Z_DIR, Z_STP, stps); //Z, Clockwise

   delay(100);

   step(true, X_DIR, X_STP, stps); //X, Counterclockwise
   step(true, Y_DIR, Y_STP, stps); //Y, Counterclockwise
   step(true, Z_DIR, Z_STP, stps); //X, Counterclockwise

   delay(100);

}

You won't get anything like sensible stepper behaviour without ramping the step rate - check out
AccelStepper examples in the first instance perhaps?

Aim for 100 steps a second or less initially, and 1000 steps/s/s acceleration or less.

An mechanically unloaded stepper motor is very likely to exhibit torsional resonance and miss-step
due to this, you can defend against this somewhat by selecting some microstepping, x8 or x16 perhaps.

I am using A4988 motor diver instead of DRV8825 is that can be problem for not working?

No. The A4988 and DRV8825 work the same. You do have to be careful when installing either one to orient the driver properly in its socket. And, with both, you must set the coil current to match the motor.

Did you try the code that I posted? What is the result?

Yes I tried the code you posted it gave me the same message. I even ran the code by orienting the A4988 driver in the opposiste direction, but it didnt worked there also.

Have a look at this Simple Stepper Code. Always start testing a motor with a very slow step rate - maybe just 2 or 4 steps per second.

...R
Stepper Motor Basics

I used that code given in the Simple Stepper Code but it also didnt worked.

modhu_54:
I used that code given in the Simple Stepper Code but it also didnt worked.

Please post the actual code that YOU uploaded to your Arduino and also a photo of a drawing showing how you have everything connected. See this Simple Image Posting Guide

...R

code

byte directionPin = 9;
byte stepPin = 8;

byte buttonCWpin = 10;
byte buttonCCWpin = 11;

boolean buttonCWpressed = false;
boolean buttonCCWpressed = false;

byte ledPin = 13;

unsigned long curMillis;
unsigned long prevStepMillis = 0;
unsigned long millisBetweenSteps = 500; // milliseconds

void setup() {

     Serial.begin(9600);
     Serial.println("Starting Stepper Demo with millis()");

     pinMode(directionPin, OUTPUT);
     pinMode(stepPin, OUTPUT);
     pinMode(ledPin, OUTPUT);
     
     pinMode(buttonCWpin, INPUT_PULLUP);
     pinMode(buttonCCWpin, INPUT_PULLUP);
     
}

void loop() {
   
    curMillis = millis();
    readButtons();
    actOnButtons();
   
}

void readButtons() {
   
    buttonCCWpressed = false;
    buttonCWpressed = false;
   
    if (digitalRead(buttonCWpin) == LOW) {
        buttonCWpressed = true;
    }
    if (digitalRead(buttonCCWpin) == LOW) {
        buttonCCWpressed = true;
    }
}

void actOnButtons() {
    if (buttonCWpressed == true) {
        digitalWrite(directionPin, LOW);
        singleStep();
    }
    if (buttonCCWpressed == true) {
        digitalWrite(directionPin, HIGH);
        singleStep();
    }
}

void singleStep() {
    if (curMillis - prevStepMillis >= millisBetweenSteps) {
            // next 2 lines changed 28 Nov 2018
        //prevStepMillis += millisBetweenSteps;
        prevStepMillis = curMillis;
        digitalWrite(stepPin, HIGH);
        digitalWrite(stepPin, LOW);
    }
}

Connection image

Please see the connection image

Please make your image visible. I already gave you a link to the instructions.

Also small image files are kinder to those of us with slow or expensive internet connections. 640x480 is usually sufficient.

...R

You have the Y axis motor connected. The step pin is 3 and dir is 6. You must also make the enable pin [pin 8] an output and write it low. And verify that the A4988 is inserted right.

image connection

The A4988 driver is inserted backwards and is probably dead if it was powered like that. Inserted correctly, the pot will be toward the center line of the board (x and y axes). Observe the markings on the underside of the A4988 board. The motor pins 1B, 1A, 2A, 2B should align with the motor output header.

Here is the CNC shield pin out on the Uno.
cnc shield Uno pins.jpg

cnc shield Uno pins.jpg

modhu_54:
image connection

In Reply #8 I specifically asked you to post a drawing showing the wiring connections. Photos of the hardware are too easy to misunderstand.

And be sure to include details of the power supply in your drawing.

...R

PS ... for the future if you are taking technical photos you should use a plain background.