Stepper motor not moving for small angles (<= 3 degrees)

Hi,

My application involves auto focusing a camera. Thus, I need to move the stepper motor by small angles and hold the motor in that position. However, when I try to move the motor by 1 or 2 steps, it only makes noise and does not move.

I am using DRV8825 driver. I have tried this with motors from three different suppliers.

Here is the code:

#include <Arduino.h>
#include "DRV8825.h"


#define MOTOR_STEPS 200

#define DIR 8
#define STEP 9


// microstep control 
#define M0 10
#define M1 11
#define M2 12

#define slp 5

void setup() {

    pinMode(4, OUTPUT);
    pinMode(slp, OUTPUT);
    digitalWrite(4, HIGH);
    
    stepper.begin(120);
}

void loop() {
    delay(1000);

    stepper.setMicrostep(1);

      digitalWrite(slp, HIGH);
 
      stepper.move(-2);

      delay(100);

      digitalWrite(slp, LOW);
      
}

Hello.

Do you have a datasheet or any detailed specifications for the motor you are currently using? Did you set the current limit on the driver board, and if so, what did you set VREF to? What kind of power supply are you using for VMOT? Does the code you posted compile and load onto the board properly? It appears that you are using a modified version of one of the examples in the “StepperDriver” library by laurb9 we link to in the resources for the driver, but your code is missing the declaration of the “stepper” object. Can you post pictures here that show your board and all of your connections including any soldered connections you made?

-Nathan

Technical specifications of the motor

I have set the Vref to around 0.84V (as per the calculations on the pololu page Pololu - DRV8825 Stepper Motor Driver Carrier, High Current).

I am powering up the using a regulated power supply, 30V, 3A.
(http://www.tme.eu/html/EN/gw-instek-programmable-power-supplies/ramka_13372_EN_pelny.html)

The code is not giving any errors and is loading successfully. And the set up functions properly when it is programmed to move for say 5 steps at a time.

I have not soldered any connection. I have only used Jumper cables.Below is the block diagram for the set up:
IMG_20170913_124507496|281x500

I guess there is some problem with the block diagram image. Below is the image:

Sorry. The code posted above is also incorrect.
Following is the code which I am using:

#include <Arduino.h>
#include "DRV8825.h"

#define MOTOR_STEPS 200

#define DIR 8
#define STEP 9

// microstep control for DRV8834
#define M0 10
#define M1 11
#define M2 12

#define slp 5

DRV8825 stepper(MOTOR_STEPS, DIR, STEP, M0, M1, M2);

void setup() {

    // reset pin
    pinMode(4, OUTPUT);
    digitalWrite(4, HIGH);
        
    pinMode(slp, OUTPUT);

    stepper.begin(120);
}

void loop() {
  
    delay(1000);

    stepper.setMicrostep(1);

    digitalWrite(slp, HIGH);
 
    stepper.move(-1);

    delay(100);

    digitalWrite(slp, LOW);
      
}

Thanks for the additional information. Does that code work OK if you remove the lines that toggle the nSLEEP pin? It is likely that the DRV8825 returns the step indexer to the HOME position (shown in Table 2 of the DRV8825 datasheet) when the driver wakes up, which would just move the motor back to the position it was at previously. If you are trying to save power, you might try toggling the nENABLE pin instead.

-Nathan

Hi Nathan,

I tried out that as well (i.e. keeping nSLEEP = HIGH constantly), but it is still not working.

Can you post pictures here that show how you have everything connected?

-Nathan

Hi,

Sorry for the late response. Here are the images of the connections:

Thank you for posting those pictures. I do not see any specific problems with your connections. You might try microstepping at a higher frequency. Also, adding a load to the motor (which provides some inertia) might help as well.

Please be aware that we recommend using an electrolytic capacitor near VMOT with our DRV8825 carrier boards to prevent damage from LC spikes.

The DRV8825 board you are using does not appear to be one we manufactured. You might try to get in touch with the distributor you purchased the driver from or the board’s manufacturer for additional support.

-Nathan

Hi,

Thanks. We ordered original Pololu board. And now it’s working fine. :slight_smile: