Nema 23 stepper motor skipping steps/not moving enough steps

Hi,
I recently got my first ever Arduino, it is an Arduino Giga R1 Wifi, a Nema 23 stepper motor (23HS45-4204S from StepperOnline) and a suitable driver (DM556Y from StepperOnline).

The driver gets power from a 48v 20a ac-dc power supply. The driver is set to 400 steps/rev. In the program seen below I'm trying to make the stepper motor do 1 full rotation (meaning 400 steps).
However, during testing I've noticed, that the stepper rotates less (each time by a different amount).
I've tried giving the motor more power from the drive (the motor is rated for 4.2a, I've tried 3.1-4.3a, 3.5-4,9 and even 4.0-5.6a), but there was no difference.

The code:

#include <AccelStepper.h>

#define dir 2
#define pul 22

AccelStepper stepper1(1,pul,dir);
void setup() {
  // put your setup code here, to run once:
  stepper1.setMaxSpeed(1000);
  stepper1.setAcceleration(200);
  stepper1.moveTo(400);
}

void loop() {
  // put your main code here, to run repeatedly:
  stepper1.run();
}

When I start the program and images of the circuit:

The former link leads to a site where you can download the .mp4 and .png files:

I have tried using another Nema 23 (same model) and a different driver (same model) but just got the same results. I'd we incredibly happy if someone can help me to solve the problem I have.

Thank you and enjoy your Christmas!

Hi @jacobutermoehlen

welcome to the arduino-forum.
You have posted a picture and a code-section of your code.
Always post code as code-section.

Use smaller values for a basic test.
It might be that your acceleration is too high

// Bounce.pde
// -*- mode: C++ -*-
//
// Make a single stepper bounce from one limit to another
//
// Copyright (C) 2012 Mike McCauley
// $Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#include <AccelStepper.h>

// Define a stepper and the pins it will use
//AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
AccelStepper stepper1(AccelStepper::DRIVER,pul,dir);

void setup() {  
  stepper.setMaxSpeed(100);
  stepper.setAcceleration(20);
  stepper.moveTo(400);
}


void loop() {
    // If at the end of travel go to the other end
    if (stepper.distanceToGo() == 0)
      stepper.moveTo(-stepper.currentPosition());

    stepper.run();
}

best regards Stefan

Thanks for the quick response. I've now decreased the values as you said, but still, the motor is not moving accurately.
When I execute the sketch, the motor starts spinning but jitters a bit, is skipping some steps and sometime makes a click.

You should really post pictures of your setup
For posting pictures you have to do a few things that are easy to do
You have to reach trustlevel 1 through these activities:

Get to trust level 1 by…

  • clicking on 5 different threads
  • reading 30 postings (they must have been visible on the screen)
  • beeing a minimum time of 10 minutes in the forum

Post the exact type of stepper-motor. There are unipolar and bipolar stepper-motors

They must be wired differently.
Additionally: never connect / disconnect the motorwires with powersupply switched on
Disconnecting under power causes high voltage spikes like on an electric fence that can destroy the stepper-driver

The DM556Y datasheet says logic signal current minimum is 7 mA, how much current does the Giga output pins provide?

@jacobutermoehlen
The DM556Y DIR and STEP inputs require 5V at up to 15mA
The GIGA can only provide 3.3V at 8mA
You will need an interface circuit for reliable operation

Hi, @jacobutermoehlen
Welcome to the forum.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Did you ever look up any tutorial how to connect a stepper-motor to a microcontroller?

What does the usermanual of your stepper-driver show as circuits?

On the official Arduino website it says, that each pin can output up to 8 mA.

I have updated my post. but because I'm new I couldn't post enough images. Thats why I included a link where you can download the files and a video. Sorry for the compromise.

3.3V at 8mA is not enough

Thanks for all the quick responses. Ok, how can I get higher Amps out of my Giga, do I need extra components? Or even a new board, would a Teensy 4.1be fine?

That would be worse.
You just need a simple one transistor driver circuit.
You will need a 5V or 12V supply
Or you could use an UNO or Mega

Thank you, I'll try that.

This will work

The usermanual shows minimum voltage required is 5V

But what does the 3.3V fall to when the output transistor is sourcing 8mA?

According to the datasheet it would drop to a minimum of Vcc-0.4V but it's totally irrelevant here

Thanks @jim-p and @StefanL38 for the quick responses. I bet your suggestions will work perfectly, unfortunately I accidentally fried my Arduino Giga R1 Wifi.
To use transistors for each of the -pins sound impractical, I've searched a bit, and it is possible to use a level-shifter, right. If I have a power supply, which outputs 12V what is a good and cheap one?

Since you fried the GIGA why don't you buy a board that uses 5V?
Level shifters will not work.
Why is a transistor circuit impracticle, it's just one transistor and one resistor.