Stepper Motor Rotating Back and forth random

Hi Community,

I have attached the sketch of the project below.. I am using a visual basic application to connet with the Arduino to send serial commands .
Everything was working fine until i took a pause for couple of days and when i started to work again on the project there seems to be an issue with the Stepper motor movement . It randomly moves back and forth on sending pulses . I don't think this is a software issue because i did not make any changes in the code , also i di not make any changes in the wiring . can anyone help me debug the issue please. I have Nema 23 motors with DM245T 4.0 driver . i am only using pulse and dir pins to rotate the motor. The drivers are connected to 32V power supply.

Can any one help me figure out if this is a software issue or hardware issue .

Below is the code for my project.
sketch_sep16c_latest.ino (23.0 KB)

This is my first time in the forums .Please let me know if missed any information to share .

Thank you,
Abhi

The diagram showing all the components, including power supplies, is missing. So is a log of your various voltage readings while this problem is occurring.

This is the link for the components that i bought .
https://www.omc-stepperonline.com/s-series-3-axis-cnc-router-kit-3-0nm-425oz-in-nema-23-stepper-motor-driver-3-dm542t-s30?language=en&currency=USD&srsltid=AfmBOopmW6DpGq-KJ5sQa3JyKWO9UGQeUEYFk1J_vffkXuo8UPtlPZmGmjE&gQT=1

I am using a arduino Mega .
Below is the image . I doubt anyone will understand form the image . I am still in the testing phase.

i just checked my power supply voltage which is connected to drivers . It is steady 35 volts even when the problem occurs.

without seeing any code or cabeling I asked my crystal ball and it gives a hint that this might be a problem of the 4 wires towards to the steppermotor. If one wire is a little loose the motor looses power and turns in a random direction while vibrating.
I am telling this because I had a simillar issue with a stepper.

Is that the only voltage in your project?

I have two power supplies . For the motors i am using 35 V powersupply and for rest of the stuff like sensors , Led , Relays i am using 24,12,5 volts respectively .

What about the "direction" pin? Does it's voltage remain constant?

You are using Wago connectors. I find them untrustworthy in so many ways, and trustworthy in a very few ways. Replace them with terminal blocks or soldering.

void setup() {
  // put your setup code here, to run once:
pinMode(23,OUTPUT);
pinMode(24,OUTPUT);
digitalWrite(24,HIGH);

}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(23,HIGH);
delayMicroseconds(200);
digitalWrite(23,LOW);
delayMicroseconds(200);
}

I just used this code for testing the stepper motors . Everything seems to be working fine .
Is this issue related to coding? am i giving pulses improperly ? i the code which i have attached i am having issue in troubleshooting Function . inside that there is a if condition which rotates the Left motor Up. Can you check that once if possible .?

This is only for testing and i am using them for connecting limit switch wires .

You have trouble in answering questions about measuring voltages, so good luck!

i meant the troubleshooting Function inside the code .

solid 4.7 Volts in my Dir pin

The your program is NOT causing the direction to change. There must be an electrical problem. Check that there is not some broken wire or connection problem with the stepper controller board.

Note: substitute one of the other drivers for the one with a problem.

may be dir pin was casuing the issue . I rewired it and its working .

Thank you Paul and everybody for helping me with this issue .
Abhi

Good! Now you know some of the steps necessary to track down problems!