Pololu 36v4 to Arduino Uno

Hi,

I’m currently working on a project wherein I want to control a stepper motor using the Pololu 36v4. I’m supplying 8V from an external supply to the Pololu and I’m powering my arduino with USB. I followed the following wiring as stated in the Github Resource:

image

And used this code from github too:

// This example shows basic use of a Pololu High Power Stepper Motor Driver.
//
// It shows how to initialize the driver, configure various settings, and enable
// the driver.  It shows how to step the motor and switch directions using the
// driver's SPI interface through the library's step() and setDirection() member
// functions.
//
// Since SPI is used to trigger steps and set the direction, connecting the
// driver's STEP and DIR pins is optional for this example.  However, note that
// using SPI control adds some overhead compared to using the STEP and DIR pins.
// In addition, since the library caches SPI register values, SPI control is
// more likely to re-enable the driver with the wrong settings (e.g. current
// limit) after a power interruption, although using the verifySettings() and
// applySettings() functions appropriately can help prevent this.
//
// Before using this example, be sure to change the setCurrentMilliamps36v4 line
// to have an appropriate current limit for your system.  Also, see this
// library's documentation for information about how to connect the driver:
//   http://pololu.github.io/high-power-stepper-driver

#include <SPI.h>
#include <HighPowerStepperDriver.h>

const uint8_t CSPin = 4;

// This period is the length of the delay between steps, which controls the
// stepper motor's speed.  You can increase the delay to make the stepper motor
// go slower.  If you decrease the delay, the stepper motor will go faster, but
// there is a limit to how fast it can go before it starts missing steps.
const uint16_t StepPeriodUs = 2000;

HighPowerStepperDriver sd;

void setup()
{
  SPI.begin();
  sd.setChipSelectPin(CSPin);

  // Give the driver some time to power up.
  delay(1);

  // Reset the driver to its default settings and clear latched status
  // conditions.
  sd.resetSettings();
  sd.clearStatus();

  // Select auto mixed decay.  TI's DRV8711 documentation recommends this mode
  // for most applications, and we find that it usually works well.
  sd.setDecayMode(HPSDDecayMode::AutoMixed);

  // Set the current limit. You should change the number here to an appropriate
  // value for your particular system.
  sd.setCurrentMilliamps36v4(2500);

  // Set the number of microsteps that correspond to one full step.
  sd.setStepMode(HPSDStepMode::MicroStep32);

  // Enable the motor outputs.
  sd.enableDriver();
}

void loop()
{
  // Step in the default direction 100 times.
  sd.setDirection(0);
  for(unsigned int x = 0; x < 100; x++)
  {
    sd.step();
    delayMicroseconds(StepPeriodUs);
  }

  // Wait for 300 ms.
  delay(300);

  // Step in the other direction 100 times.
  sd.setDirection(1);
  for(unsigned int x = 0; x < 100; x++)
  {
    sd.step();
    delayMicroseconds(StepPeriodUs);
  }

  // Wait for 300 ms.
  delay(300);
}

My motor has a 3.6 degrees stride angle.

Appreciate if anyone can enlighten me on how to progress with my project.

Hello.

It sounds like you are having trouble getting your stepper motor to move using the High-Power Stepper Motor Driver 36v4 and its BasicSteppingSPI example sketch. Can you post pictures showing how everything is connected in your setup, especially the connections between the stepper motor and driver? Also, can you post close-up pictures showing the soldering on the stepper motor driver board?

- Amanda

Hi Amanda,

Below is the diagram of my setup. I’ll upload close-up photos of the board in a while.

We tried measuring V5 with respect to GND = 1.7V

Your soldering looks good. I don’t see a connection to the !SLEEP pin, which by default the driver pulls low, putting it into low-power mode. You would need to set that pin high as shown in the typical wiring diagrams on the motor driver’s product page. Also, you need to supply the IOREF pin with the logic voltage of your microcontroller. You can find more information and the various ways to connect IOREF on the driver’s product page. Please let me know if it still isn’t working after you make those changes.

- Amanda

Hi Amanda,

We were able to test again yesterday and finally it worked. We misedd out reading some important info in your product page.

However, I still have one query – the program only works whenever I upload it.

Let’s say I uploaded it at 10am and then the motor ran for 1 hour. I turned it off by cutting the power supply to the Pololu and my Arduino.

When I reconnect the power supply at 12pm - I assume the BasicSteppingSPI sketch is still loaded in Arduino. The motor does not automatically run and I have to re-upload this.

Is there something that needs to be modified in the sketch?

Thanks,
Donna

I’m glad your setup is working now.

It sounds like a problem with the order in which you’re applying power; what is your power-up sequence? Reloading the sketch resets the Arduino, and it is probably just the reset step that is doing something meaningful, so you could try just pressing the reset button on your Arduino Uno instead of uploading the sketch again (but the better solution is to get the power-up sequence right since applying power in the wrong order can break things).

- Amanda

Hi Amanda,

Thanks for the info. We’re currently reconfiguring the power sequence. We have another question, we’ve been looking through the datasheets and resources, is there a specific equation that depicts the relationship between the StepPeriodUs and the RPM of the motor?

Yes; there is a relationship between the step period and RPM for the stepper motor. The stepPeriodUs variable in the BasicSteppingSPI example code sets the time in microseconds between each step pulse, and each step pulse corresponds to one step or microstep of the stepper motor. In order to get from the step period to the RPM of the motor, you therefore need to know the number of steps per revolution of your stepper motor (which is the number of full steps per revolution times the number of microsteps per full step for whatever microstepping mode you are using).

RPM\space = \space\frac{60,000,000\space \mu s}{stepPeriodUs \times full\space steps\space per\space rev \times microsteps}

- Amanda