3
\$\begingroup\$

I'm using 2 x 1.8-Degree Nema 14, 35 BYGHW Stepper Motors with a DRV8825 Stepper Motor.

I have tried all 24 combinations of wiring the damn 4 wires but it won't work. I am using a 9v battery as the motor power source, which is fine.

It sometimes turns when I have 3 wires connected??

I can guarantee the wiring is correct, and this is the sketch. enter image description here

Here is the code, which I am almost certain is correct too, I just started this project and I can't even get a damn motor to work!

/* stepper motor control code for DRV8825
 * 
*/

// define pin used
const int stepPin = 9;
const int dirPin = 8;

void setup() {
  // set the two pins as outputs
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);

}

void loop() {
  digitalWrite(dirPin,HIGH); //Enables the motor to move in a perticular direction
  // for one full rotation required 200 pulses
  for(int x = 0; x < 200; x++){
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
 }
 delay(1000); // delay for one second


  digitalWrite(dirPin,HIGH); //Enables the motor to move in a opposite direction
  // for three full rotation required 600 pulses
  for(int x = 0; x < 600; x++){
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
  delay(1000); // delay for one second
}
\$\endgroup\$
  • 1
    \$\begingroup\$ First thoughts were to give the motor the power and/or time to actually make the step, i.e more current and/or try slower step frequency/mode. \$\endgroup\$ – Lamar Latrell Mar 13 at 19:11
  • 1
    \$\begingroup\$ Make sure you haven't accidentally swapped the DIR and STEP wires. It's a silly thing, yes, but double checking it can't hurt. \$\endgroup\$ – computercarguy Mar 13 at 20:22
  • 1
    \$\begingroup\$ Have you measured the voltage at the battery when it is running? It is probably a lot less than 9 volts. Get a good voltmeter. \$\endgroup\$ – whitegreg56 Mar 13 at 22:22
7
\$\begingroup\$

There was no need to try 24 wiring combinations.

Your schematic shows that you have a two-coil motor. You identify the two coils with your multimeter and connect one coil to A1 - A2 and the other to B1 - B2. The motor should now run if you are using full-step mode. If using half-step mode (where more than one coil is on at time) you may need to reverse one of the coils.

A 9 V battery may not be adequate. Measure the battery voltage while trying to run the motor.

You can also increase the step delays by a factor of 100 and see if the motor turns slowly and whether or not you can feel any torque.

For further help please edit your question and add a link to the motor datasheet.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Yep, as long as the motor coil wire pairs go to the same pair of outputs on the driver, it should work, even if it's going the "wrong" direction. And to get it to go the "right" direction, you just have to swap the wires on one pair of coils. \$\endgroup\$ – computercarguy Mar 13 at 20:37
6
\$\begingroup\$
  1. 9V batteries are very weak. When I was a kid, they were sometimes called transistor batteries, since that is all they were good for, powering low-power transistor radios.

  2. Is the enable_n pin low by default? You may need to drive it low.

  3. Use full step mode until you get it to work.

  4. Try longer delays. If you want to run the motor fast, you need to accelerate gradually. There are drivers to help you for some MCUs.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ +1 on the ENABLE_N pin. Inputs do not usually float low - if anything, they'll usually float high. That would be my top bet. \$\endgroup\$ – Graham Mar 13 at 17:55
  • 2
    \$\begingroup\$ The gradual acceleration is an important point also. The current code basically assumes the motor will go from 0 to 300 RPM in 1 millisecond. And while being powered by the very limited current of 9V battery. \$\endgroup\$ – jpa Mar 13 at 19:25
  • \$\begingroup\$ DRV8825 datasheet specifies that enable pin has internal pulldown, so that should be fine. Same for the mode inputs. \$\endgroup\$ – jpa Mar 13 at 19:41
  • 2
    \$\begingroup\$ These motors require 1.2A, and a 9V can really only do 0.5A. geeetech.com/nema-14-35-byghw-stepper-motor-p-909.html \$\endgroup\$ – computercarguy Mar 13 at 20:29
  • \$\begingroup\$ @computercarguy The motors do not require 1.2A, they just promise to not overheat when you stay below 1.2A. They will likely even work at 0.12A, but provide only one tenth of the rated torque. The actual current delivered to the motor depends on the trimmer setting on the Pololu driver board, (the rotational speed - if the motor would rotate) and of course the current capability of the power source. 9V batteries are (as others already commented) notoriously weak. \$\endgroup\$ – Michael Karcher Mar 14 at 0:39
1
\$\begingroup\$

If I had to guess and the motor is really rated at 1.2 Amps, you are fighting a losing battle! There's no way in the world you can suck 1 Amp out of a 9 volter! You basically need to start with a beefier power supply, say 3 Amps or so and you possibly may have to put transistors between the motor and the controller.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Two things: Steppers have a lot of mass in the rotor and thus high inertia. Your 1-millisecond initial move may cause it to bounce between one step behind / one step ahead, which would be similar to the buzzing and vibrating you see. You need to allow it time to spin-up or by having longer delays initially. You can try one of the microstepping modes of the 8825 (the Mx inputs) this will allow a more gradual move between poles.

The 9v battery might be too weak. As a rule of thumb, to move fast, you want high voltage, for greater torque, you want high amperage.

I can recommend a library called "AccelStepper" for controlling if you aren't determined on writing your own. It's always fun and full of important learnings to write it yourself.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.