Help with controlling Nema23 stepper motor

Hello, this is my first time building anything electrical. I've made a build attached to a hand sanitizer stand so it can stand vertically. Attached are the wiring diagram, build, and code. When I upload the code and press the tactile button to close the circuit to pin 11, nothing happens. I already checked to see if the motor is wired correctly. The colors match the documentation and when plugged in it cannot be manually turned and emits a constant low buzzing noise. I can't figure out what's wrong. Also, whenever I press the tactile button, pin 13's LED lights up for some reason...

// Define stepper motor connections:
#define dirPin 2
#define stepPin 3

void setup() {
  // Declare pins as output:
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(11, INPUT); 
}

void loop() {
  while (digitalRead(11)== HIGH)

{ digitalWrite(dirPin, HIGH);

digitalWrite(stepPin, HIGH);

delayMicroseconds(500);

digitalWrite(stepPin, LOW);

delayMicroseconds(500); }

}



The wiring diagram was drawn incorrectly. This is the updated one that matches the physical build:


the dark blue wire was supposed to be on ground

EN+ & EN- to GND?
pull out, they no needed for testing, EN is activated by default

1 Like
const byte stepPin = 3;

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

void loop() {
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(500);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(500);
}

How is the stepper powered?

24V power supply. I followed the wiring colors for the stepper motor as shown in the third picture. Additionally, the top right LED of the DM542T stepper motor driver is lit up, so I don't think that is a problem.

void loop() {
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(500);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(500);
}

Jumping from 0 to 1000 steps per second won't work, the motor cannot accelerate that fast, it will just sit and buzz.
Try:

void loop() {
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(8000);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(8000);
}

What does that indicate? Did you set the DM542T's current limiter to match the motor's current rating? What is that current rating?

I thought I was responding to jremington's response. That was meant to be a reply.

Turns out, I did not switch the DM542T from 20V to 5V using the little switch on the top. A very beginner mistake and I am quite embarrassed. The code and wiring work correctly now.

Now, you mentioned 200 steps per second is too much, what do you mean by that? I have the DM542T set to 200 pulses/rev, coded the same way I had it, and the rate of rotation actually seemed quite slow. I decreased the delay to 300 to speed it up and it still worked fine.

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