Arduino Nano IoT 33 and A4988 with Nema 17 - can't get it to work

Hello everyone,

I am trying to get into stepper motors and wanted to controll a Nema 17HS4401 with the Arduino Nano IoT 33 and A4988 (clone) from Longruner (Amazon).

I have set the wiring up like the attached picture.
The Power Supply for the motor is a laboratory power supply that I can adjust from 0-15V and 0-2A.
Arduino Nanot Iot 33 is powered fromt the USB connection with my Laptop.

When I power everything up, sadly nothing is happening.

I have tried using the forum to understand what I'm doing wrong but unfortunately I couldn't figure it out.

I have noticed that when I power just the A4988 and increase the current, the coils of the motor should be active, since the motor is harder to turn than when it is not supplied with power. So doesn't that mean that I have wired the coils correctly?

Secondly I made sure, that the Pins D2 and D3 of the Arduino are wokring properly. I have connected D2 and D3 with each other and declared one as input and the other as output. I could receive the signals sucessfully.

I have tried using the 5V output of the Arduino as logic supply for the A4988 but that doesn't make it work.

It would be awesome if you could help me to get this to work. This would mean a big step for me.

Best Regards,
Sevvv

This is the code im trying to run:

const int dirPin = 2;
const int stepPin = 3;
const int stepsPerRevolution = 200;
 
void setup()
{
  // Declare pins as Outputs
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  
}
void loop()
{
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  // Set motor direction clockwise
  digitalWrite(dirPin, HIGH);
 
  // Spin motor slowly
  for(int x = 0; x < stepsPerRevolution; x++)
  {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(2000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(2000);
  }
  delay(1000); // Wait a second
  
  // Set motor direction counterclockwise
  digitalWrite(dirPin, LOW);
 
  // Spin motor quickly
  for(int x = 0; x < stepsPerRevolution; x++)
  {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(1000);
  }
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000); // Wait a second
}

Why have you connected Reset and sleep together?

Have you tried hooking Enable up?

Many guides mentioned that reset and sleep have to be connected together. I also tried it without this connection, but it didn't work.

I have also tried hooking enable up with Pin D4, but this doesn't work either.

Best Regards,
Sevvvv

Yup the guide I just read says the same things. Perhaps you don't have enough power. Have you adjusted the current limiting pot? Make sure power is off when you do.

@sevvvv, full marks for using code tags and for providing a wiring diagram - which seems to be correct. The Pololu A4988 web page has a wiring diagram and lots of other useful info.

I'm not sure what this means

I have noticed that when I power just the A4988 and increase the current,

I wonder if it means that you are turning up the current on your lab power supply? If so, it should always be at max current and the current limitation should be left to the A4988. Otherwise the two of them are likely to fight.

Please post a link to the datasheet for your stepper motor - there are hundreds of different Nema 17 motors.

...R
Stepper Motor Basics
Simple Stepper Code

Thank you for your replys.

My Nema 17 is 17HS4401, please find the attached Datasheet that I found online.

I wonder if it means that you are turning up the current on your lab power supply? If so, it should always be at max current and the current limitation should be left to the A4988. Otherwise the two of them are likely to fight

Yes, it's true, Im turning up the current. I do this because I don't have a suitable power supply right now.
But shouldn't this still work if I turn it up to the rated current of 1.7A?

@wildbill no I have not adjusted the limiter. I don't have a multimeter. But if the coils are actually getting powered and produce a magnetic field, the limiter should be ok, no?

17HS4401-MotionKing.pdf (94.9 KB)

sevvvv:
Yes, it's true, Im turning up the current. I do this because I don't have a suitable power supply right now.
But shouldn't this still work if I turn it up to the rated current of 1.7A?

I thought what I said earlier is clear - turn the power supply to max and regulate the current with the A4988

Also, an A4988 is not capable of providing 1.7 amps - it will almost certainly overheat and shut down to protect itself. Set the A4988 current limit to 1.4 amps (or less). A DRV8825 driver can supply more current but it may also struggle at 1.7 amps. The drivers that can provide a nominal 3 amps or more (to give you some headroom) will be a bit more expensive.

...R

Ok, I just bought a multimeter so I can regulat the limiter.

If the A4988 is not capable of providing 1.7 amps, does that mean that I will not be able to power my stepper motor with this motor driver? Or will just the performance suffer?

Could this be the reason that my motor is not working?

sevvvv:
If the A4988 is not capable of providing 1.7 amps, does that mean that I will not be able to power my stepper motor with this motor driver? Or will just the performance suffer?

Could this be the reason that my motor is not working?

If you set the current limit to 1.4 amps your motor should work but it will not be able to produce its maximum torque.

...R

Thank you very much. I will try this once I have received my multimeter.

I will report my result.

Hello again,

I have now received the multimeter and adjusted the current limiter to 1.4A.

I could make it work with @Robin2 simple stepper Code. It works like a charm.
Thank you very much Robin2 for pointing me in the right direction!

Now I still have one problem left, but I will post this issue in a new topic.

Thank you :slight_smile:

Your original code was expecting a motor to jump from stationary to 500 steps/second instantly..

This ain't going to happen. Physical objects have inertia. This means you have to ramp up
the step rate to allow the rotor to accelerate upto speed without losing lock. Once a stepper
loses lock it can do all sorts of odd things, including but not limited to stalling, vibrating, randomly
moving in both directions.

The AccelStepper library is a good place to start as it implements speed ramping for you.

I think you are doing everything correctly. One of the most important steps is to adjust the potentiometer screw on the a4988 board to determine the amount of current being sent to the stepper. Without a voltmeter you can simply turn the screw clockwise until the motor starts to turn without skipping steps. If you turn it too high the driver chip on the board will get too hot. Be sure to use the heat sink on the chip. I adjust them all the time this way and when I check it with a voltmeter it is usually very close. You can also use a couple of leds and batteries as a test light to make sure that you have the coil wire pairs correct. Keep in mind that the pairing may vary from motor to motor so it;'s best to check them.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.