NEMA17 stepper motor oscillating back and forth with DRV8825 driver

Customer:

I purchased 5 NEMA17 stepper motors and a Dasduino Connect Plus. The driver was sourced separately - a DRV8825. I connected everything in a basic configuration following the setup described at Pololu - DRV8825 Stepper Motor Driver Carrier, High Current (Using the driver).

I used this basic example:

#define stepPin 2

void setup() {
  pinMode(stepPin,OUTPUT);
}

void loop() {
  for(int x = 0; x < 800; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(100000);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(100000);
  }
}

The step pin of the DRV8825 is connected to PIN IO2 of the Dasduino. The stepper motor has its own separate power supply (12V), with a 100 uF capacitor between the power and ground. The Dasduino is powered via USB. The GND of the stepper motor and Dasduino are connected together. The wiring follows the standard recommendations for getting started with stepper motors.

Unfortunately, instead of rotating in one direction, the motor behaves like a metronome - one pulse left, one pulse right.

I configured VREF to 175mV to limit the maximum current to 350mA according to your documentation. Do you have any ideas where the problem might be?

Original message (Croatian)

Nabavio sam kod vas 5 komada NEMA17 stepper motora te Dasduino Connect Plus. Driver za taj motor niste imali pa sam ga nabavio iz drugog izvora. U pitanju je DRV8825.

Sve skupa sam spojio u nekoj osnovnoj konfiguraciji kako je to opisano npr. na Pololu - DRV8825 Stepper Motor Driver Carrier, High Current (Using the driver).

Koristio sam osnovni primjer:

#define stepPin 2

void setup() {

pinMode(stepPin,OUTPUT);

}

void loop() {

for(int x = 0; x < 800; x++) {

digitalWrite(stepPin,HIGH);

delayMicroseconds(100000);

digitalWrite(stepPin,LOW);

delayMicroseconds(100000);

}

}

Step pin od DRV8825 spojen je na PIN IO2 Dasduina

Stepper motor ima svoje posebno napajanje (12V), stavio sam 100 uF izmedju njegova napajnja. Dasduino se napaja iz racunala (USB kabelom). GND stepper motora i Dasduina je takodjer spojeno.

Pojednostavljeno receno spojeno je kako to predlazu i opisuju svi portali za pocetak rada sa stepper motorima.

Nazalost umjesto da se okrece u jednom te istom smjeru motor radi kao “metronom” – jedan impuls lijevo, drugi desno.

Prema naputku za DRV8825 sam podesio VREF (da bude 175mV) da se maksimalna struja ogranici na 350mA (prema specifikaciji na vasoj stranici).

Imate li vi neku ideju gdje bi mogao biti problem?

Originally submitted via email support on 27 January 2025. Migrated to the forum for community visibility.

Soldered Support:

My opinion is that everything is connected correctly except for the 4 pins that connect to the stepper motor coils - there may be a mismatch there. Try different combinations of how these pins are connected to the motor. This oscillating motion is characteristic of that kind of problem, which I’ve also encountered in servo motor projects.

Also, in the code try increasing the step speed - set delayMicroseconds(2000); instead of 100000 to get 10 steps per second.

On the DRV8825, try explicitly connecting the DIR pin to GND.

These are some things that come to mind - try them and report back. I think it’s just a small detail remaining but everything should work :slight_smile:

Original message (Croatian)

moje mišljenje je da je sve dobro spojeno osim 4 pina koji trebaju ići u stepper, koji su spojeni na navoje NEMA17. Tu može biti neki mismatch, treba provjeriti hoće li neka različita kombinacija spajanja ovih pinova proraditi. Takvo kretanje motora me asocira na taj problem, koji se i meni događao u projektima sa servo motorima.

Također, u kodu probaj povećati brzinu od10 stepova u sekundi, stavi npr delayMicroseconds(2000); umjesto 100000.

Na drv8825 ne vidim točno ali probaj DIR pin spojiti na GND eksplicitno.

To su neke stvari koje padaju na pamet, probaj pa javi rezultate. Mislim da je samo još neka sitnica u pitanju ali da bi sve trebalo raditi :slight_smile:

Customer:

Thank you for the reply. I’ve tried all possible combinations of connecting the motor coils. Your website states:

Coil 1: yellow and red wire, Coil 2: green and brown wire

However, the cable that came with the motor has the following colors (from left to right looking at the motor connector): black, green, red, blue.

The motor connector has 6 pins, and pins 2 and 5 are not connected when the cable that came with the motor is inserted.

Could you please check which pins should actually be used and which pin corresponds to which motor coil?

Original message (Croatian)

Hvala na odgovoru. Sve moguce kombinacije spajanja na stepper sam probao (ako imate neku shemu koju mozete predloziti rado cu i to probati).
Na vasoj stranici objavili ste sljedece:

Coil 1: yellow and red wire, Coil 2: green and brown wire

medjutim uz motor je dosao kabel sljedecih boja (s lijeva na desno gledajuci u konektor na motoru): crna, zelena, crvena, plava
Na konektoru motora postoji 6 pinova … 2 i 5 nisu spojeni kada se utakne kabel koji je dosao sa motorom.

Mozete li molim vas provjeriti kod sebe koji pinovi zapravo trebaju biti u upotrebi i koji pin pripada kojem navoju motora?

[name removed]

Soldered Support:

Yes, pins 2 and 5 are not connected because they are not needed in this mode of operation.

I believe this is the correct pinout for our motor with the supplied cable.

Also, try a different IO pin on the ConnectPLUS - pins 32 and 33 work for virtually all applications.

I would also try the code and go step by step through this article I found: https://www.makerguides.com/drv8825-stepper-motor-driver-arduino-tutorial/

If it still doesn’t work after debugging and following this tutorial, let me know and I’ll take these components myself and test them in a way that I can. Thank you for your patience with the responses.

Original message (Croatian)

da, 2 i 5 nisu spojeni jer oni u ovom modu rada nisu potrebni.

Vjerujem da je s našim motorom kablićem ovo točan pinout.

Također, isprobao bi drugi IO pin sa ConnectPLUS-a, 32 i 33 inače rade za doslovno sve primjene.

Ja bi također probao kod i išao korak po korak iz ovog članka koji sam pronašao: https://www.makerguides.com/drv8825-stepper-motor-driver-arduino-tutorial/

Ako još uvijek ne radi nakon debugganja i praćenja ovog tutoriala, javi pa uzmem osobno ove komponente i isprobam na način koji mogu. Hvala na strpljenju s odgovorima :slight_smile: nadam se da ćemo ubrzo riješiti problem

Attachment omitted in migration: image.png

Customer:

I followed your recommendations but without improvement. I looked at the signals from the driver with an oscilloscope (without the load on them) and they appear to look nominal - I can’t check with the load because I currently don’t have probes with attenuation. The motor also appears to be working correctly. The STEP signal from the Dasduino arrives properly. So individually all the components seem to function as expected, but together not quite.

Is it possible to find the factory specifications for this motor somewhere? Your documentation mentions 12V and 350mA. I’m running out of ideas.

Original message (Croatian)

Poslusao sam vase preporuke medjutim bez pomaka na bolje.
Osciloskopom sam pogledao signale sa driver-a (bez tereta na njima) i cini se da izgledaju nominalno (s teretom ne mogu jer trenutno nemam sonde sa atenuacijom).
Motor mi se takodjer cini u redu.
STEP Signal sa DasDuina dolazi uredno.
Znaci, odvojeno cini se da sve komponente funkcioniraju kako je za ocekivati, medjutim zajedno ne bas.

Je li moguce negdje pogledati tvornicke specifikacije tog motora (na vasim stranicama navodi se 12V i 350mA)?

Ponestaje mi ideja.

[name removed]

Customer:

By pure chance, my power supply for the motor was set to 9V and finally it worked. I then tried:

  • at 7.5V it doesn’t work at all (probably because the DRV8825 operates only from 8.5V)
  • at 12V twitching occurs

So it would definitely be useful to know the factory data for this motor.

Original message (Croatian)

Sasvim slucajno mi je izvor napajanja za motor bio podesen na 9V … i konacno je proradilo. Probao sam nakon toga:

  • na 7.5V ne radi uopce (vjerojatno zbog DRV8825 koji radi tek od 8.5V)
  • na 12V se dogadja “trzanje”

Svakako bi dakle dobro doslo znati tvornicke podatke za predmetni motor.

[name removed]

Customer:

Following up on the previous message: after a series of attempts and trials, it seems that the current limit stated on your website (350mA) is too low. It would really be helpful to get access to more detailed technical specifications for this motor.

  • What is the current limit?
  • What is the maximum speed for a given current?
Original message (Croatian)

Nastavno na prethodni email
Nakon niza pokusaja/promasaja cini sa da ipak da je ogranicenje struje navedeno na stranici (350mA) pre nisko.
Dakle jako bi dobro bilo dobiti pristup detaljnijim tehnickim specifikacijama za taj motor.

  • koje je ogranicenje struje?
  • koji mu je najveci broj okretaja za danu struju?

Soldered Support:

I’m glad it worked. If we don’t have a datasheet on the product page, then we weren’t able to get it from the manufacturer. There are NEMA17 variants that can have different characteristics, including maximum current and speed. Maximum current on all models ranges from 0.5 to 2A, so using 0.5A is safest.

It should really work at 12V through this driver, so unfortunately I’m not sure what exactly happened, but I’m glad you managed to get the motor running.

Original message (Croatian)

drago mi je da je proradilo, ako nemamo datasheet na stranici proizvoda onda ga nismo uspjeli dobiti od proizvođača, a postoje varijante NEMA17 koje mogu imati drugačije karakteristike, u što ulaze maksimalna struja i brzina. Maksimalna struja je na svim modelima u rasponu od 0.5 do 2A, tako da je korištenje 0.5A najsigurnije.

Trebao bi stvarno raditi na 12V preko tog drivera, tako da na žalost nisam siguran što se točno dogodilo ali mi je drago da ste uspjeli u pokretanju motora.