As I'm brand new to the subject and I've come to a point with my project where I just don't know what to do next.
I'm trying to build a robot to solve a Rubik's Cube and since I'm probably the 1000th to do so, there seems to be an abundance of material. But I just can't find what I'm doing wrong.
I planed to use the following parts:
5x Nema 17 stepper 1.5A
5x a4988 driver
1x Arduino mega
1x 12V 10A Power Supply
The first thing to do is to set the coil current limit on the A4988 stepper driver. The coil current should be found in the motor data sheet. Set the current to less than or equal to the spec current. To set the current limit you will need to know the value of the sense resistor on the A4988 driver board. Then enter the value of the resistor and the required coil current into the formula Vref = Imot x 8 x Rsen where Imot = the coil current and Rsen = the value of the sense resistor. The Pololu A4988 page covers how to set the Vref but you must use the sense resistor value on YOUR board. This page shows how to locate the sense resistor.
// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// this version uses delay() to manage timing
const byte directionPin = 5; // **** change to suit
const byte stepPin = 2; // **** change to suit
const byte enablePin = 8; // **** change to suit
int numberOfSteps = 100;
byte ledPin = 13;
int pulseWidthMicros = 20; // microseconds
int millisbetweenSteps = 100; // milliseconds - or try 1000 for slower steps
void setup()
{
Serial.begin(9600);
Serial.println("Starting StepperTest");
digitalWrite(ledPin, LOW);
delay(500);
pinMode(directionPin, OUTPUT);
pinMode(stepPin, OUTPUT);
pinMode(stepPin, OUTPUT);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW);
pinMode(ledPin, OUTPUT);
digitalWrite(directionPin, HIGH);
for (int n = 0; n < numberOfSteps; n++)
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(pulseWidthMicros); // this line is probably unnecessary
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
digitalWrite(ledPin, !digitalRead(ledPin));
}
delay(3000);
digitalWrite(directionPin, LOW);
for (int n = 0; n < numberOfSteps; n++)
{
digitalWrite(stepPin, HIGH);
// delayMicroseconds(pulseWidthMicros); // probably not needed
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
digitalWrite(ledPin, !digitalRead(ledPin));
}
}
void loop()
{
}
The motor should rotate 1/2 turn one way (200 step/revolution motor) wait 3 seconds and rotate 1/2 turn the other direction.
How secure are the motor to driver connections? If one disconnects the motor from the driver while the driver is powered there is a very good chance that the driver is destroyed. Just a momentary bad connection can do it.
When the motor is powered and the code is running, can you, easily, turn the motor shaft?
Are you writing a low to the enable pin like in the simple test code?
Post your test code. Read the forum guidelines to see how to properly post code and some hints on how to get the most from this forum. Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
I had them disconnected because I wanted to test if something is wrong with my Arduino. It doesn’t work even if I connect them like it is shown in the schematic.
Breadboards are for low power logic circuitry and cannot handle typical motor currents. The tracks will burn, leading to unstable connections and destruction of the motor driver. NEVER change any wiring while the circuit is powered.
You really need to solder motor leads directly to the motor driver, or use secure screw terminals if provided.
Thank you for the advice!
I know that a Breadboard is not the ideal for it. I wanted to try it out before soldering it. And that probably isn't a valid point, but a lot of people used them like that.
Is there a way to test the system without the need to solder everything in?
Not safely with high current circuits like steppers.
Soldering is easily reversible, and if you intend to continue in this hobby, it is something you should learn to do. There are excellent tutorials on line at Adafruit and Sparkfun, etc.