I am working with a NEMA-17 Motor (17PM-K310-32VS) with motor driver DRV8225 for which I am following this guide with the exact same circuit they have given but with a addition of one push button programmed to start and stop the motor. I am using AccelStepper and EzButton library for driver and button respectively with following code.
#include <AccelStepper.h>
#include <ezButton.h>
#define MOTOR_SPEED 200
#define dirPin 2
#define stepPin 3
#define motorInterfaceType 1
AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);
ezButton motor_switch(4);
void setup()
{
stepper.setMaxSpeed(200);
stepper.setSpeed(0);
}
void loop()
{
motor_switch.loop();
if(motor_switch.isPressed())
{
stepper.speed()==0 ? stepper.setSpeed(MOTOR_SPEED) : stepper.setSpeed(0);
}
if(stepper.speed()==0)
{
stepper.stop();
//stepper.disableInputs();
}
else
{
//stepper.enableInputs();
stepper.runSpeed();
}
}
Problem: Circuit and code works as intended as I am able to start and stop the motor with the push button but I am facing one problem. My NEMA-17 motor vibrates randomly at idle. Frequency of vibration is also random that is sometimes it vibrates for a very short time (less than a second) but other times it vibrates for 5-10 seconds. Also I observed that motor is getting hot even at idle. Why is this happening and how to fix this? Things I have done so far: In order to troubleshoot this, I tried many things:
- Changing Arduino, I have tried with UNO, NANO and MEGA.
- Changing driver Library and even uploading an empty sketch. (I tried Accelstepper's disableInputs functions as well)
- Reviewing connections.
- Changing motors.
- Replacing Motor driver with another DRV8225 module.
- Changing driver's current limit using its potentiometer.
Hoping a find something here. Thank you.