Looking for help with SparkFun AutoDriver (Stepper Driver)

Greetings all,

Our team has been having trouble getting this driver to work, and the tutorial that SparkFun provides is not working as specified. I don’t suppose any users are out there with experience with this device? I’ve attached our code and the SparkFun Fritzing Diagram. We’ve hooked it up exactly as shown by SparkFun.

Potential problems we see, but don’t know how to troubleshoot:

  1. In all of the SparkFun Sketches, Pin 6 is referred to as the reset pin, yet pin 6 on the Arduino is never hooked up in any of the Fritzing Diagrams.
  2. Where are pins 11 and 12 initialized for SPI communications? 13 for SCK? Is this handled internally by calling ‘include AutoDriver.h’ ?
  3. Doesn’t the Board need another Power Source for the Motor itself? We weren’t under the impression that the motors could draw power from the Arduino.

Any assistance would be greatly appreciated - For our code, we took the ‘essential’ components of the example and tried to make a simple piece of code that would turn at 20 Steps per second forward, wait 1s, then backward, wait 1s, and loop.

#include <AutoDriver.h>

AutoDriver boardA(10, 6);

void setup()
  Serial.println("Hello world");

void loop()
 boardA.run(FWD, 20);
 boardA.run(REV, 20);

void dSPINConfig(void)
  boardA.configSyncPin(BUSY_PIN, 0);// BUSY pin low during operations;
                                    //  second paramter ignored.
  boardA.configStepMode(STEP_FS);   // 0 microsteps per step
  boardA.setMaxSpeed(10000);        // 10000 steps/s max
  boardA.setFullSpeed(10000);       // microstep below 10000 steps/s
  boardA.setAcc(10000);             // accelerate at 10000 steps/s/s
  boardA.setSlewRate(SR_530V_us);   // Upping the edge speed increases torque.
  boardA.setOCThreshold(OC_750mA);  // OC threshold 750mA
  boardA.setPWMFreq(PWM_DIV_2, PWM_MUL_2); // 31.25kHz PWM freq
  boardA.setOCShutdown(OC_SD_DISABLE); // don't shutdown on OC
  boardA.setVoltageComp(VS_COMP_DISABLE); // don't compensate for motor V
  boardA.setSwitchMode(SW_USER);    // Switch is not hard stop
  boardA.setOscMode(INT_16MHZ_OSCOUT_16MHZ); // for boardA, we want 16MHz
  boardA.setAccKVAL(255);           // We'll tinker with these later, if needed.
  boardA.setHoldKVAL(32);           // This controls the holding current; keep it low.

I see connection points on your picture of the board marked motor power !!!

Yes the motor needs a separate power source - the Arduino can't supply enough power to run a motor.

You haven't described what actually happens? - perhaps nothing if there is no power for the motor?


In this case, even when hooking up 12V / 330 mA to power the stepper Motor, nothing happens. We're wondering if maybe their Fritzing diagram is incorrect, as the Chip Select Pin looks to hook up to something other than that the diagram shows.

330mA seems very little power from a power supply. What motor are you using? The motor I have needs 330mA on each coil and I would expect losses between the power supply and the motor.

You should be able to get the motor to move with a short sketch that puts the step pin high for 1 millisec at a time. Repeat as needed with a short delay (perhaps 100msecs to start with) between steps. Then experiment with different timings.

I think that board defaults to 1/16th microsteps and if so it will need 16x200 steps for a revolution.

Robin2: 330mA seems very little power from a power supply. What motor are you using? The motor I have needs 330mA on each coil and I would expect losses between the power supply and the motor.

You should be able to get the motor to move with a short sketch that puts the step pin high for 1 millisec at a time. Repeat as needed with a short delay (perhaps 100msecs to start with) between steps. Then experiment with different timings.

I think that board defaults to 1/16th microsteps and if so it will need 16x200 steps for a revolution.

I'm using the exact same stepper motor and power supply (turns out it's 600mA) that SparkFun uses for their example.

There is no 'step' pin with this driver. The driver is delivered commands using the AutoDriver.h library using SPI serial communication.

The driver itself doesn't default to any sort of stepping, the setting must be specified in the code, as is with ours -


Sorry, I didn't realize it uses SPI. All red boards are not the same :)


geeze - got my boards (qty 2) just today and have them all soldered up & ready to go - i was going to use my Uno or Mega 2650. now i'm a bit concerned. very excited to get these going for my robot project - have you any further info on this?

I was looking on the SpF site for the BOB-11611 and in the comments there was mention of a "little bug" in the AutoDriverConfig.cpp code: where it says: stepModeConfig |= (stepModeConfig&0x07); it should read: stepModeConfig |= (stepMode&0x07);

dunno if this will help.

have you narrowed it down to a code problem or wiring? Please update either way. thanks,

Russ from Coral Springs

So -I got wired up after looking at many sites and checking out the UNO's SPI pins just to make sure. you're sketch is correct and your wiring is correct but for one wire, and you mentioned it in one of your 1st posts - Here's what I think your problem was(is?) When creating the boardA instance:

AutoDriver boardA(10, 6);

The 10 stands for the chip select (CS) as you have it, but the 6 is for defining the "Reset" pin. Pin 6, while it may not be in any of the diagrams you looked at, still needs to be hooked up. I added it when I was going for my 1st try & the system worked right away. Thinking about you & your problem, I then powered down, detached the pin6 >-- Reset wire and powered up again. Nothing happened at all - looked to be dead. So... this is probably where things went wrong - 1 simple (but important) wire. my 1st half hour with the system has been revealing, I'm cautiously pleased. for the 1st time in months (and many stepper drivers later), I'm able to run my wheels continuously without overheating motors and/or drivers. AND, i can change speeds without stopping, AND these commands do not seem to have any effect on processing speed! My robot is an "Inverted Pendulum" robot, which is a fancy name for "2-wheeled balancing robot". My Gyro/Accelerometer module has been chomping at the bit to get moving ahead, and I feel that I may have finally found the right Driver/Controller to get this done.

I'm a little concerned about the speed, but I'm using you "pared-down" version and will now move forward into different stepping modes to see if I can work with that, still @ speed set to 450 (whatever that means) , it's still fast enough to get things going. also, speeds under 100 seem to start introducing a lot of resonance (vibration), I'm hoping to get rid of that.

Thanks for this post, and I'll write back with any positive/negative breakthroughs (hopefully positive).

Russ from Coral Springs, Fl

I must make another notation on this... I wanted to use the Arduino Mega 2560 board for my project, not the UNO... go figure that i got stopped with SPI. now, i'm not sure if my Mega's SPI is broken, but it does not work with using Pin 6 for Reset on the Autodriver. there IS, however a RESET PIN on the Mega 2560, but it does NOT have a pin Number & therefore does not work with the Autodriver library which insists on a pin number.

Unfortunately, of all the devices i have experimented with so far, none of them support SPI and I'm at a loss to test my SPI bus since I do not have a scope or logic probe, yet (looks like it's about time for one)...

so, i either get a device that utilizes SPI to test on both my UNO & Mega, or i get another Mega.

another thing i can do is find out what the Reset function does, and maybe find out how to use it on the Mega, (or again, if it can be just about any digital pin, then maybe it's the Mega board) and it SHOULD be working on pin 6).

I will check back in once I have this resolved. this library is just so perfect for what i need to do, it's worth the extra time to get things done.

Russ from Coral Springs.

Hi Russ,

I spent 12 hours figuring this out so I hope this helps everyone else out there.

If you are using a mega you need to check all the included libraries for hard coded UNO SPI pin values and replace them with the MEGA SPI mapped pins. See the SPI documentation on the Arduino site for standard SPI mappings.

http://arduino.cc/en/Reference/SPI see the connections table.

The wiring diagrams shown on the Sparkfun Learning Autodriver (https://learn.sparkfun.com/tutorials/getting-started-with-the-autodriver/example) are correct but there is one additional wire you need to run which connects the BUSYN to any digital pin you choose otherwise when you run the LibraryTest example it won't run as it does use the busy signal as it has this code:

while (boardA.busyCheck());

I'm using a MEGA so in my case I chose pin 48 for BUSYN.

So if you are going from UNO to MEGA the SPI mapping including user selectable ones would look something like this:

MOSI for UNO = pin 11, MEGA = pin 51 MISO for UNO = pin 12, MEGA = pin 50 SCK for UNO = pin 13, MEGA = pin 52 SS for UNO = pin 10, MEGA = pin 53

User selected BUSYN, for me MEGA = pin 48 User selected RESETN, for me MEGA = pin 49

So you should have 6 signal wires connected plus the additional VCC and GND lines as per the Sparkfun diagram. I grouped mine together so I could use a ribbon cable header for the MEGA.

The main library file you need to edit the hardcoded SPI pins is the AutoDriver.cpp - main library. For the examples I've listed the files below including the obvious ones just for completeness (so people please don't flame me):

[u]dSPIN_example[/u] dSPIN_example.ino - pin definitions dSPIN_support.ino - pinMode change pin assignment from 10 to 53 for MEGA

[u]LibraryTest[/u] LibraryTest.ino - pin definitions and also change AutoDriver boardA(10, 6); to read AutoDriver boardA(53, 49, 48);if you use the MEGA setup above.

Oh you probably also need to glue a small heatsink to the driver IC as it does get hot.

Hope this helps.

Has anyone been able to get this to work by using just the auto driver, Arduino UNO and a stepper motor?

I'm a little lost. At the start of the thread, the wiring diagram has the UNO board, and the last person to post is using something totally different.

This might be a bit late... but yes, just plugging in the AutoDriver with an Arduino, a PSU and a Stepper it works great... I was having trouble initially because I was using an Arduino MEGA... then I used an Arduino Due and it worked like a charm!

And thanks to cybernob, I am in the process of re-wiring my pins on the MEGA to work properly...

This is probably what you'll need to get you started from scratch. The wiring is good, all you need is to tune your driver and stepper.


edit: YES! Thank you cybernob! my MEGA now is able to control my stepper... now on to figure out why It's making a lot of noise but not spinning... It might simply just be the current...

Hi there,

I've got a weird problem with my AutoDriver and Mega2560.

My code waits 500ms, then sets up the driver, next waits 500ms again and then sends a run command.

If I hook up a 12V Lipo battery directly to the autodriver Input and also the Arduino Vin (and GND..), the seem to be doing nothing.

If I hook up the USB on the Arduino AND the 12V Lipo as described above, the autodriver works fine and the motor turns (after arduino reset).

I know, that the Arduino runs through the code, when only on 12V Lipo because I'm using a buzzer to signal the ending code line.

And here comes an even weirder thing: If I hook up both USB and Lipo and then unplug the USB before the run command, the stepper also works fine.

I really hope, anyone knows what to do as my project deadline is coming closer and closer :/

The Uno and Mega each have only one hardware SPI unit, so you don't need to and should not specify the pins other than the chip-select (pin 10 will work for that on both Arduinos). Just be sure to connect to the right pins (on the ICSP header for either board, or 11..13 on Uno and 50..52 on Mega)

If you connect to the ICSP header for SCLK/MOSI/MISO and use pin 10 for select the pinout is identical in fact.

[ I am somewhat assuming Sparkfun used the hardware SPI as is usually done ]

Hi Mark,

I'm using the correct SPI pins for the Mega. Also changed the pin defines in the autodriver library to match Arduino Mega.

I just don't get why everything works only when initially started up with a USB plugged into my laptop.

Okay. I've solved the problem. But don't understand why it happened.

I used the mega's digital pins to provide gnd and 5V to the autodriver board. (D46 HIGH and D44 LOW if that's relevant).

They are being pulled high first thing in the setup function. Afterwards I even used a 500ms delay before setting up the autodriver. When using both digital pins for high and low, I need to reset the arduino after powering up the first time to make the autodrivers work. When using only the digital low and the mega's normal 5V pin however, the autodrivers work properly when powering with lipo only.

Any ideas?

Ok so I am having the same problem as the user who started the thread.

I am using UNO so there is no issue with connections. I have also connected pin 6 to reset.

Even though I only have one board connected, when I try to use the ‘Want You Gone’ example, it partially works as it runs one motor for some time and then goes into infinite wait probably because of busy checks and all.

But my problem is not this. This just proves that my hardware is correct as the motor runs.

I am running this - L6470-AutoDriver/SparkFunLibraryTest.ino at master · sparkfun/L6470-AutoDriver · GitHub

But if I try to replace wantYouGone(); command line with let’s say boardA.run (FWD, 10000); the motor won’t run.

#include <SparkFunAutoDriver.h>
#include <SPI.h>
#include "SparkFunnotes.h"

AutoDriver boardA(0, 10, 6);
AutoDriver boardB(1, 10, 6);

void setup()
  Serial.println("Hello world");  
  // Start by setting up the SPI port and pins. The
  //  Autodriver library does not do this for you!
  pinMode(6, OUTPUT);
  pinMode(MOSI, OUTPUT);
  pinMode(MISO, INPUT);
  pinMode(13, OUTPUT);
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);
  digitalWrite(6, LOW);       // This low/high is a reset of the L6470 chip on the
  digitalWrite(6, HIGH);      //  Autodriver board, and is a good thing to do at
                              //  the start of any Autodriver sketch, to be sure
                              //  you're starting the Autodriver from a known state.

// loop() waits for a character- any character- and then plays the song.
void loop()
  if (Serial.available() !=0)
    Serial.println("Play it!");
    wantYouGone();                // trying to replace this line with any other command let's say 
                                          //boardA.run (FWD, 10000); will not run the motor.
    Serial.println("Done playing!");

Any idea?
Thanks in advance