Help with Arduino UNO and DRV8825

My name is Falcon.

I am using Arduino UNO microcontroller and LCD Keypad shield, connected with the A4988 stepper motor
driver carrier’ to control Nema23 (#1477) in full step resolution .
http://www.dfrobot.com/index.php?route=product/product&keyword=lcd%20keypad%20shiel&product_id=51#.U9AbX_l_tyU
https://www.pololu.com/product/1477
Regarding 6 wire motors , I’m using the red-blue pair and the black-green pair .
I’m using an AC/DC Switching Power Supply and a capacitor .
Here are some of the power supply’s features:

  • Input : 100-200 VAC 0.7 A 50/60 Hz
  • Output: +24V 1.1 A
    Here are the capacitor 's features:
  • 35 V
  • 100 µF

I attach the link of the video that shows how the softavare, controls a stepper motor with Arduino and Pololu Allegro A4988 driver

https://www.youtube.com/watch?v=ZSu9wiRPqHU

Code and project description are available on Luca Dentella’s blog.
http://www.lucadentella.it/en/category/a4988-arduino/

When I use these components , I have no problem to control the stepper motor (Nema 23-#1477).

I would replace the Pololu A4988’s with Pololu DVR8825 boards, because I can use the DVR8825 without a
heat sink or forced air flow.
When I use Pololu DVR8825 board , I have a big problem , because the stepper motor (#1477) has
no vital signs .
I have measured the voltage on the “ref” pin into full-step mode, and then I have calibrated the
adequate voltage (0.5 A) with the trimmer potentiometer.
I attach copy of the software.

[code]#include <LiquidCrystal.h>
#include <TimerOne.h>

// buttons code
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5

// directions
#define FORWARD HIGH
#define BACKWARD LOW

// debounce time (milliseconds)
#define DEBOUNCE_TIME 200

// PINs for Pololu controller
#define PIN_STEP 2
#define PIN_DIR 3

// lookup table speed - ticks (interrupts)
const int speed_ticks[] = {-1, 600, 300, 200, 150, 120, 100, 86, 75, 67, 60, 55, 50, 46, 43};

// global variables
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int actual_speed;
int actual_direction;

int ticks;
int tick_count;

int button;
boolean debounce;
int previous_time;

// custom LCD square symbol for progress bar
byte square_symbol[8] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
};

// string constants
char forward_arrow[] = “–>”;
char backward_arrow[] = “<–”;

void setup() {

// init the timer1, interrupt every 0.1ms
Timer1.initialize(100);
Timer1.attachInterrupt(timerIsr);

// init LCD and custom symbol
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.createChar(0, square_symbol);

// pins direction
pinMode(PIN_STEP, OUTPUT);
pinMode(PIN_DIR, OUTPUT);

// initial values
actual_speed = 0;
actual_direction = FORWARD;
tick_count = 0;
ticks = -1;
debounce = false;

digitalWrite(PIN_DIR, actual_direction);
updateLCD();
}

void loop() {

// check if debounce active
if(debounce) {
button = btnNONE;
if(millis() > previous_time + DEBOUNCE_TIME) debounce = false;
} else button = read_buttons();

// if a button is pressed, start debounce time
if(button != btnNONE) {

previous_time = millis();
debounce = true;  

}

// check which button was pressed
switch(button) {

case btnUP:
  increase_speed();
  break;
case btnDOWN:
  decrease_speed();
  break;
case btnLEFT:
  change_direction(BACKWARD);
  break;
case btnRIGHT:
  change_direction(FORWARD);
  break;
case btnSELECT:
  emergency_stop();
  break;

}

// finally update the LCD
updateLCD();
}

// increase speed if it’s below the max (70)
void increase_speed() {

if(actual_speed < 70) {
actual_speed += 5;
tick_count = 0;
ticks = speed_ticks[actual_speed / 5];
}
}

// decrease speed if it’s above the min (0)
void decrease_speed() {

if(actual_speed > 0) {
actual_speed -= 5;
tick_count = 0;
ticks = speed_ticks[actual_speed / 5];
}
}

// change direction if needed
void change_direction(int new_direction) {

if(actual_direction != new_direction) {
actual_direction = new_direction;
digitalWrite(PIN_DIR, actual_direction);
}
}

// emergency stop: speed 0
void emergency_stop() {
actual_speed = 0;
tick_count = 0;
ticks = speed_ticks[actual_speed / 5];
}

// update LCD
void updateLCD() {

// print first line:
// Speed: xxxRPM --> (or <–)
lcd.setCursor(0,0);
lcd.print("Speed: ");
lcd.print(actual_speed);
lcd.print("RPM ");

lcd.setCursor(13,0);
if(actual_direction == FORWARD) lcd.print(forward_arrow);
else lcd.print(backward_arrow);

// print second line:
// progress bar [##### ]
// 15 speed steps: 0 - 5 - 10 - … - 70
lcd.setCursor(0,1);
lcd.print("[");

for(int i = 1; i <= 14; i++) {

if(actual_speed > (5 * i) - 1) lcd.write(byte(0));
else lcd.print(" ");

}

lcd.print("]");
}

// timer1 interrupt function
void timerIsr() {

if(actual_speed == 0) return;

tick_count++;

if(tick_count == ticks) {

// make a step
digitalWrite(PIN_STEP, HIGH);
digitalWrite(PIN_STEP, LOW);

tick_count = 0;

}
}

// read buttons connected to a single analog pin
int read_buttons() {

int adc_key_in = analogRead(0);

if (adc_key_in > 1000) return btnNONE;
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
}[/code]
Please, can you help me to solve this problem? :question:

Thank you very much

Hello, Falcon.

There are a few things I noticed from your description that might be causing a problem.

Did you set VREF to a voltage that would give a current limit of 0.5A or was that a typo and you were trying to say that you set the VREF to 0.5V? Could you measure the voltage at VREF and double check what it is set to? Also, please note that the formulas for setting the current limit are different for the A4988 and DRV8825.

Depending on what your current limit is set to, you might need to use a power supply rated for at least 2A (since the #1477 NEMA 23 stepper motor is rated for 1A per phase and has two phases).

Also, the RESET and SLEEP pins on the DRV8825 function differently than they do on the A4988. Could you double check that you are either driving these pins high, as shown on the minimal wiring diagram located in the “Using the driver” section of the DRV8825 product page, or connecting the driver as shown in the alternative minimal wiring diagram at the bottom of the same page?

By the way, the A4988 should be able to handle approximately 1A per phase without additional cooling, so unless there are other factors in your system causing it to heat up, you might not need to switch (although, the DRV8825 might run cooler at that current).

-Brandon

Hello, Brandon.

Excuse me for my delay in reply , but I had suspect that my board (DRV8825) was damaged, thus I have bought 2 new boards.
Yesterday, I received these boards.

I set the trimmer at 0.5V on the basis of the following formula:
Current Limit = VREF × 2
Current = 8.6 V / 8.6 Ω =1A
VREF = Current / 2 = 1A/2 = 0,5 V

I have consulted the “minimal wiring diagram and for connecting a microcontroller to an DRV8825 stepper motor driver carrier (full-step mode)”.
According to this diagram I have connected my Arduino Uno to DRV8825 stepper motor driver carrier, but my motor (Nema 23 - # 1477) is still not started .
In contrast when I have connected the driver as shown in the alternative minimal wiring diagram, the motor not responds to commands , because the motor’s rotational shaft rotates, alternating the rotation in clockwise and anti clockwise direction.
Please, Can you help me?
Thank you.
Falcon

From your description of the stepper motor’s behavior, it sounds like it could be a power issue. As I mentioned in my previous post, you will probably need to use a power supply rated for at least 2A to meet the current requirements of the #1477 stepper motor. Could you try replacing your supply with one that can handle at least 2A?

If changing to a more appropriate power supply does not work, could you try simplifying your system down to just the Arduino and DRV8825 carrier? Also, you might try simplifying your code to something that just steps at a specific rate and holds the direction constant.

-Brandon

Yes, I can change my power supply; in contrast , I can’t simplify my system.
Can you suggest me an appropriate power supply?

You should use a power supply that is rated for at least 2A, greater than your stepper motor’s rated voltage (8.6V), and within the DRV8825 carrier’s operating voltage range (8.2V to 45V). For example, we carry a 9V, 3A wall power adapter and a 12V, 3A wall power adapter; either of which should work to power your stepper motor and controller.

-Brandon

Thank you very much for your help.
Unfortunately , your power supply has an USA power plug , but I live in Italy and here we have a different socket.
https://imageshack.com/i/exJzD2g1j
Thus I have need of a power supply with an italian power plug.
https://imageshack.com/i/p9aDGONqj
Have you a power supply with italian power plug?
Please, help me.

No, we do not carry wall power adapters with Italian-style plugs. However, you might be able to find an appropriate one at a local electronics or hardware store.

-Brandon

Ok.
Thank you