Hello there, I am relatively new to stepper motors in general so I'm not sure what the issue is. I am using a NEMA 42 30nm stepper motor and its respective DM2282T driver to rotate an assembly for a sort of simulator I'm building. The motor is connected to a 1:60 ratio wormgear gearbox, I believe it's called a 090 size wormgear gearbox.
The issue I'm having is that when I apply a slight resistance to the gearbox output, the motor jams up until the driver stops the motor and restarts it. I'm using the AccelStepper library and doing a simple left & right rotation.
Wiring is simple, just 4 wires of the stepper going into stepper driver according to the stepper documentation, 1 ground wire to the arduino and two signal wires for pulse and direction to the driver.
Current limiting setting on the driver is set to max (8.2 amps)
Motor substepping is 400 pulses per rev
In the arduino, max motor speed is set to 4000 pulses per second
I have uploaded videos of the issue here:
This is the page for the motor and driver. These very ones have been purchased and used:
- https://www.omc-stepperonline.com/nema-42-cnc-stepper-motor-bipolar-30nm-4248oz-in-8a-110x201mm-4-wires-42hs79-8004s
- https://www.omc-stepperonline.com/digital-stepper-driver-0-5-8-2a-180-240vac-for-nema-34-42-stepper-motor-dm2282t?search=Digital%20Stepper%20Driver%200.5-8.2A%20180-240VAC%20for%20Nema%2034%2C42%20Stepper%20DM2282T
Please help!
I have attached the Arduino code below:
#include <AccelStepper.h>
//Defining pins
int Stepper1Pulse = 5; // Pulse or step pin
int Stepper1Direction = 6; // Direction pin
int InterruptPin = 10; // Interupt button pin
int StepperEnPin = 2;
//defining terms
int speedmin = 0; //pulses per second
int Speed = 4000; //pulses per second //calibrated for NEMA 42 30nm. RPM does not go higher by hardware design. Higher pulses per second also causes desync because of the slip ring assembly inefficiencies.
int speedmax = 4000; //pulses per second //calibrated for NEMA 42 30nm. RPM does not go higher by hardware design. Higher pulses per second also causes desync because of the slip ring assembly inefficiencies.
int StepperAcceleration = 5000;
long StepperDirection = 12000; // this should be half of speed for 1 complete revolution on the 1:60 gearbox.
bool STOP = false;
AccelStepper step1(1, Stepper1Pulse, Stepper1Direction);
long DelayIteration = 0;
int Iterator = 1;
void setup() {
Serial.begin(2000000);
pinMode(InterruptPin, INPUT_PULLUP);
pinMode(Stepper1Pulse, OUTPUT);
pinMode(Stepper1Direction, OUTPUT);
pinMode(StepperEnPin, OUTPUT);
digitalWrite(StepperEnPin, LOW);
digitalWrite(Stepper1Pulse, LOW);
digitalWrite(Stepper1Direction, LOW);
step1.setMaxSpeed (speedmax);
step1.setSpeed(Speed);
step1.setAcceleration(StepperAcceleration); //speed up or slow down at this number of steps per second
step1.moveTo(StepperDirection); // some large number to keep it spinning
}
void loop() {
//////////////////////// INTERRUPT BUTTON START //////////////////////
if(digitalRead(InterruptPin) == LOW)
{
// step1.stop(); //requests stop. run() still needs to continue in order to decelerate
if(STOP == false)
{
STOP = true; //bool to be checked before moveTo() function asn moveTo() will override stop()
digitalWrite(StepperEnPin, HIGH); // Uses Stepper Enable Pin to disable Stepper Driver
return;
}
if(STOP == true)
{
STOP = false; //bool to be checked before moveTo() function asn moveTo() will override stop()
digitalWrite(StepperEnPin, LOW); // Uses Stepper Enable Pin to disable Stepper Driver
return;
}
}
//////////////////////// INTERRUPT BUTTON END //////////////////////
//////////////////////// AUTOMATED LOOP START //////////////////////
// Serial Print slows down the loop speed significantly. Use millis method to isolate looping code that may cause delays
/*
if (millis() - lastPrintTime >= 100)
{ // Print every 100ms
lastPrintTime = millis();
Serial.println("Loop running...");
}
*/
if(step1.distanceToGo() == 0)
{
if(STOP == false)
{
step1.moveTo(-step1.currentPosition()); // toggle direction
}
}
step1.run(); //don't use runSpeed as it does not take acceleration into account.
//////////////////////// AUTOMATED LOOP END //////////////////////
}
<CODE/>











