Arduino DRV8825 StepperMotor code

Hello everyone!

I am having some trouble with the stepper motor. I use a stepper drive, called DRV8825, and this driver is connected like in the picture in the Attachment. For this setup i found an example code (see this page http://mchobby.be/wiki/index.php?title=DRV8825). When i start the stepper motor it vibrates only and won’t turn circles.
What is the mistake i am making?

640px-DRV8825-Montage_Rouge-Bleu-Vert-Noir.jpg

Sounds like either the current limit is set too low for the motor, or more likely you have one of the wires mixed up.

If the wires are mixed up in such a way that a wire from one coil is swapped with a wire from the other, then you will see exactly this.

The other option is if you have a dodgy connection somewhere on your breadboard (no idea as you haven't shown a photo of your setup - nor a proper schematic -- fritzing is not a proper schematic!)

Try this simple stepper code - it does work.

If it does not work for you then the problem lies elsewhere and we can try to help.

Provide a link to the datasheet for your stepper motor Tell us what power supply you are using for the motor (volts and amps) I presume you are following the wiring diagram on the Pololu DRV8825 web page

...R Stepper Motor Basics

Hello everyone!

I am having some trouble controlling the stepper motor. For the setup I’m using the DRV8825. In the attachment you can see how I wired it.

I wired from above; orange, blue, red and yellow (see other attachment). When I used a code to drive this it wouldn’t make circles. Instead it was making noises and holding its position.
Does anyone know what the problem is? It would make my day!
This was the code I was using:

// — Commande d’un StepStick/Driver A4988 ----------------------
// DRV8825_Test.ino
//
// Commande d’un moteur pas-à-pas à l’aide d’un pilote DRV8825 avec
// Arduino.
//
// Un projet www.mchobby.be (vente de kit et composant)
// Meurisse D. - Licence CC-SA-BY
//
// Un tutoriel http://wiki.mchobby.be/index.php?title=DRV8825
// Ou Acheter un StepStick DRV8825
// http://shop.mchobby.be/product.php?id_product=454
//

#define pinEnable 13 // Activation du driver/pilote
#define pinStep 9 // Signal de PAS (avancement)
#define pinDir 8 // Direction

void setup(){
Serial.begin(9600);
Serial.println(“Test DRV8825”);

pinMode( pinEnable, OUTPUT );
pinMode( pinDir , OUTPUT );
pinMode( pinStep , OUTPUT );
}

void loop(){
int i = 0;

digitalWrite( pinDir , HIGH); // Direction avant
digitalWrite( pinStep , LOW); // Initialisation de la broche step

// Avance de 200 pas
for( i=0; i<200; i++){
Serial.println( i );
digitalWrite( pinStep, HIGH );
delay( 10 );
digitalWrite( pinStep, LOW );
delay( 10 );
}

// Changer de direction
digitalWrite( pinDir , LOW); // Direction avant

// Refaire 200 pas dans l’autre sens
for( i=0; i<200; i++){
Serial.println( i );
digitalWrite( pinStep, HIGH );
delay( 1 );
digitalWrite( pinStep, LOW );
delay( 1 );
}

// Pas de step et pas d’ordre…
// l’axe du moteur est donc bloqué
Serial.println(“Axe bloqué + attendre 5 sec”);
delay( 5000 );

// déblocage de l’axe moteur
Serial.println(“Deblocage axe”);
digitalWrite( pinEnable, HIGH ); // logique inversée

// Fin et blocage du programme
// Presser reset pour recommander
Serial.println(“Fin de programme”);
while( true );
}

640px-DRV8825-Montage_Rouge-Bleu-Vert-Noir.jpg

kleuren.png

MihaelR: Instead it was making noises and holding its position.

Often that means that one of your coils is wired backwards. Try swapping orange and blue.

johnwasser: Often that means that one of your coils is wired backwards. Try swapping orange and blue.

There is no "backwards" for coils on a two-phase stepper motor. if one coil is "reversed" the motor will simply turn the other direction. If it's just making noise, and not moving, you're usually either not accelerating gradually enough, the step pulses have too much jitter, or the motor does not have enough torque to move the load.

Regards, Ray L.

Its not about reversing the coil, its about ensuring that the wires are not mixed up so one wire from one coil and one wire from the other coil are connected to the same H-bridge on the driver.

As per my earlier post, have you checked the current limit? Have you ensured the coils are wired up correctly?

MihaelR: I am having some trouble controlling the stepper motor. For the setup I'm using the DRV8825. In the attachment you can see how I wired it.

This quote is from Reply #3.

Did you read Reply #2 ?

...R