Power a Nema17 steppermotor

Hi,

Despite extensive troubleshooting efforts, I've encountered ongoing difficulties in achieving successful stepper motor operation with an A4988 driver and various Arduino boards. Below is a comprehensive summary of the steps taken and observations made during the troubleshooting process:

  1. Arduino Board Testing
  • Tested three "Arduino" Nano boards and one Uno board in an attempt to isolate any potential board-specific issues.
  1. Power Supply Analysis:
  • Utilized a 12V 1A DC power supply for motor operation, but observed that the motor setup consistently drew no current, despite appropriate voltage supply.
  1. Motor Resistance Examination:
  • Conducted resistance measurements on the stepper motor coils, revealing a slightly lower than expected resistance of 3.2 ohms between the red and blue wires and between the black and green wires, should be 3.5 ohm's so 3.2 should be okey.
  1. Direct Power Application Testing:
  • Applied direct power between the green and black wires, as well as between the red and blue wires, resulting in an increase in motor resistance, indicating functional coil behavior.
  1. Vref Adjustment:
  • Set the Vref voltage to 0.6V, for the A4988 driver.
  1. Power Supply Voltage Verification:
  • Confirmed 12V supply voltage between VMOT and ground, as well as 5V supply voltage between VDD and ground.
  1. Sleep and Reset Connection:
  • Bridge the sleep and reset pins.
  1. Pin Configuration for Step and Direction:
  • Programmed the step and direction signals to be driven from pins 2 and 3 on the Arduino board.
  1. Multimeter Measurements:
  • When measuring with a multimeter between ground and pins 2 and 3, no pulsed effect is observed, indicating potential issues with signal generation or transmission.
  1. Voltage Measurements:
  • Observed approximately 2.2V on each cable connected to the motor.
  1. Additional Ground Connection Testing:
  • Tried with and with out bridging the grounds on the A4988

Despite these meticulous efforts and thorough testing, the stepper motor setup continues to exhibit non-functional behavior. Further guidance, insights, or recommendations for troubleshooting would be greatly appreciated to overcome these persistent challenges.

This is the code I'm running:

#define stepPin 2
#define dirPin 3

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

void loop() {
  digitalWrite(dirPin, HIGH);

  for (int i = 0; i < 200; i++) { 
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);
  }

  delay(1000);

  digitalWrite(dirPin, LOW);

  for (int i = 0; i < 200; i++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);
  }

  delay(1000);
}

PS:
Additionally, I attached an ultrasonic sensor to the Arduino to see if the Arduino even worked. However, despite proper wiring and code implementation, the sensor consistently returned a distance reading of 0, indicating a failure in its functionality.

I also conducted a simple LED blink test, wherein an LED connected to pin 13 blinked at a one-second interval. This test revealed that certain basic functionalities of the Arduino are operational, although more complex components, such as the stepper motor and ultrasonic sensor, are encountering issues.

You're asking from the motor to do a full turn in 1/5th of a second.
Do you think your motor is capable to do that, from standstill.

For testing, try increasing delayMicroseconds(500); to 5000.
Leo..

The power supply should cut out from this overload. Else almost the resulting 4 Amps would damage the coils.

How exactly did You find that out?

Would be a more reasonable test. Else the stepper migh stay still and only make some buzzing.

Sorry, should been clearer what I did with this code. This code is basically just to see if I get a pulsating current on the output on pin 2 and 3, not to run the motor properly

#include <AccelStepper.h>

// Steppermotoranslutningar
#define STEP_PIN 9
#define DIR_PIN 10
#define ENABLE_PIN 8 // Om du anvÀnder en ENABLE_PIN

// SteppermotorinstÀllningar
#define STEPS_PER_REV 200      // Antal steg per varv för din stegmotor
#define MICROSTEPS 16          // MikrosteginstÀllning för din driver
#define ML_PER_REV 25          // Antal milliliter per varv (anpassa efter behov)
#define TOTAL_STEPS (ML_PER_REV * STEPS_PER_REV)  // Totalt antal steg för att tömma hela sprutan

// Skapa en AccelStepper-instans
AccelStepper stepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);

void setup() {
  // SĂ€tt upp motoranslutningar
  pinMode(ENABLE_PIN, OUTPUT);
  digitalWrite(ENABLE_PIN, LOW); // Aktivera motorn

  // SÀtt upp motorinstÀllningar
  stepper.setMaxSpeed(1000.0);   // Max hastighet i steg per sekund (anpassa efter behov)
  stepper.setAcceleration(1000.0); // Acceleration i steg per sekund per sekund

  // SÀtt upp mikrosteginstÀllningar för driver
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH);

  // Starta seriell kommunikation
  Serial.begin(9600);
  Serial.println("Tryck 's' för att starta tömningen av sprutan.");
}

void loop() {
  if (Serial.available() > 0) {
    char input = Serial.read();
    if (input == 's') {
      // Starta tömningen av sprutan
      Serial.println("Tömmer sprutan...");
      stepper.move(-TOTAL_STEPS); // Flytta sprutan bakÄt med det totala antalet steg
      stepper.setSpeed(1000.0); // Hastighet i steg per sekund (anpassa efter behov)
      while (stepper.distanceToGo() != 0) {
        stepper.runSpeedToPosition(); // Kör motorn tills sprutan Àr helt tömd
      }
      Serial.println("Tömning av sprutan klar.");
      // VĂ€nta i 10 minuter innan programmet avslutas
      delay(600000); // 600000 millisekunder = 10 minuter
      Serial.println("Programmet avslutas.");
      while (true); // HÄll programmet igÄng tills det stÀngs av
    }
  }
}

Sorry about the notes being in Swedish. I know it's a different output, but I just wanted to test it with the simpler code

Stepper drivers do not do anything useful without the motor windings as loads - the winding inductance is an integral part of the function of the driver.

You have to be careful never to disconnect the motor from the driver when the driver is powered - this will usually fry the driver instantly. This can happen if the motor wiring isn't rock-solid too - the inductive kick-back over the loose connection fries the chip.

1 Like

I have limited the amp to 1 to not cause damage to the engine.

By connecting directly to red and blue wire of the engine.

Sorry for being wage with the code. The code was a simple code to see if there was any pulse in pins 2 and 3.

It's not pretty but should be functional.

Okey. Good.
The easiest way to verify a coil cable pair is to short 2 motor cables and turn the shaft. If it is more difficult, You've found a pair. If turning easy they are not a pair.
A DMM measuring resistance also does the job.

Red and blue, green and black are usual clour codings but it's not a standard!

I've bought and tested lots of steppers and found out that more then 100 steps per second (delay shorter than 10000 micro) often made steppers stall. Too much much acceleration....

Swedish comments is not a problem here but for international forums, English comments are better....

True, but if there was a break while the board was active the coils wouldn't have a resistens of 3.2, right?

Very new to all this so I truly don't know.

Oops. Don't run motor currents through breadboards. They are inrnded for signals and might burn from amps.

Read the schematics for the motor, but also tested it with continuity with my multimeter .
True, but that code with the Swedish comments are the one I'm planing on using, when/if I get it to work :sweat_smile:. The one that I posted in the beginning was mostly to see if I can see anything being outputted on pin 2 and 3, but there ain't.

Even with the maximum amp set to 1 one the DC power supply?
Haven't seen any amp's being pulled.
With the first Arduino - A4988 - Stepper motor combo I did i solder anything together, but still had the same problem, that's why i opted to do this instead to try different combinations.

Yup, the sleep and the reset are bridge. Might be hard to see in the picture, but the white wire is the bridge.

That's what I thought as well, but I've tried 5 A4988 boards now, and it's the same problem on all of them. Sure it could be a manufactory fault but seems unlikely on all 5.
I've contacted the seller, we'll have to wait to see what they say.

Okey. There should be signals but without the entire measuring schematics mistakes could have tricked You.

I'll say no.
12 volt across 3.2 Ohm == 3.73 Amps, without current limiting.

You really need to grab pen and paper and produce schematics. There's a systematic fault somewhere.

Measured again while in circlet the the reading is 3.5 ohms and the continuity is still there between red and blue, and back and green.

The stepper is okey.

This is the A4988 board I'm using.

And these are the motors:

The connection is as follow:
DC: (+) - VMOT
DC: (-) - GRD
2B: Green
2A: Black
1A: Red
2B: Blue
VDD: 4988 - Arduino (5V)
GND: 4988- Arduino (also tried bridging with the other GRD on 4988)
DIRECTION: 4988 - Arduino (pin 2)
STEP: 4988 - Arduino (pin 3)
SLEEP - REST

Looks like the ones I use in the CNC shields.

Please don't referre to sales sites. They never tell what helpers want to know. Datasheets do....

That looks okey but the words don't show missing connections etc.
Words can never replace schematics.
21 posts now and nothing gained.
This kind of conversation can go on for ever.......

Can You test the controller board by compiling and downloading a sketch that prints "Hello world" on serial monitor?