Hi Guys,
I am trying to control a stepper motor using arduino uno and a stepper driver (photo attached) from a old CNC machine. Everythings working fine but the problem is that the motor does not rotate at the maximum speed (100 rpm). It goes till a certain speed and than remains constant.
The stepper motor is 2.3V and 4.3 amps. Due to the high current I have to use the old stepper driver and I cannot replace the motor because I need high torque.
I need to know why the motor is not going to the full speed.? Do I need to replace the driver?
Any help is highly appreciated.
Note: When I tested this motor with Arduino Motor Shield R3, it used to run at high speed but I can not use the shield as it is not capable of supplying the required current.
Regards
#include <Stepper.h>
const int stepsPerRevolution = 200;
Stepper myStepper(stepsPerRevolution, 12, 13);
int stepCount = 0;
int buttonState = 0;
int buttonState_1 = 0;
const int buttonPin_1 = 4; // ON/OFF Switch
const int buttonPin = 2; // the number of the direction switch
const int ledPin_1 = 7; // the number of the LED pin
const int ledPin_2 = 5;
const int ledPin_3 = 6;
const int pwmA = 10;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 12;
const int dirB = 13;
int potPin = 2; // select the input pin for the potentiometer
int val = 0;
int motorSpeed = 0;
void setup() {
pinMode(ledPin_1, OUTPUT);
pinMode(ledPin_2, OUTPUT);
pinMode(ledPin_3, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(buttonPin_1, INPUT);
pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(brakeA, OUTPUT);
pinMode(brakeB, OUTPUT);
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
digitalWrite(brakeA, LOW);
digitalWrite(brakeB, LOW);
Serial.begin(9600);
}
void loop() {
digitalWrite (ledPin_1, LOW);
digitalWrite (ledPin_2, LOW);
digitalWrite (ledPin_3, LOW);
buttonState_1 = digitalRead(buttonPin_1);
if (buttonState_1 == HIGH)
{
digitalWrite (ledPin_3, LOW);
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
digitalWrite (ledPin_1, HIGH);
digitalWrite (ledPin_2, LOW);
digitalWrite (ledPin_3, LOW);
val = analogRead(potPin);
motorSpeed = map(val, 0, 1023, 1, 100);
myStepper.setSpeed(motorSpeed);
myStepper.step(stepsPerRevolution / 100);
Serial.print("CW ");
Serial.print(motorSpeed);
Serial.println(" RPM");
}
else
{
digitalWrite (ledPin_2, HIGH);
digitalWrite (ledPin_1, LOW);
digitalWrite (ledPin_3, LOW);
val = analogRead(potPin);
motorSpeed = map(val, 0, 1023, 1, 100);
myStepper.setSpeed(motorSpeed);
myStepper.step(-stepsPerRevolution / 100);
Serial.print("CCW ");
Serial.print(motorSpeed);
Serial.println(" RPM");
}
}
else
{
digitalWrite(ledPin_3, HIGH);
digitalWrite(ledPin_1, LOW);
digitalWrite(ledPin_2, LOW);
}
}