Hey everyone,
My goal is to run the stepper motor that is mounted on 1200 mm linear stage at its maximum speed (3.5 rps = 210 rpm) in room temperature for at least an hour without the stepper motor getting stuck. The goal after that is to do the same at -20 degrees Celcius.
The problem is that when the stepper motor is mounted on the linear stage, it won't start moving when I try to run it at 210 rpm at room temperature. However
- previously stepper motor has been able to run at 210 rpm at room temperature while mounted on the linear stage
- it does run at 210 rpm now when not mounted on the stage
- in both cases my 12V, 4.2A power supply shows that current drawn is fluctuating between maximum (0.5-0.8A depending on the stepper motor driver's potentiometer setting) and 0.1A.
Details of the setup:
I have a 400steps/rev bi-polar stepper motor (datasheet), A4988 driver (datasheet) with heatsink installed, 12V motor power supply and 100uF capacitor with voltage rating 25V. I'm using Arduino Uno as my microcontroller. My electronics set up is equivalent to the one in the attached picture.
I have adjusted the potentiometer on A4988 according to the formula Vref = (8 × R)Imax = 80.050*2 = 0.8V from Makerguide website.
Things that I have tried to solve the problem:
- swapping the stepper motor with another one of the same type
- swapping the motor driver with another one of the same type
- swapping the capacitor with another one of the same type
- readjusting all the wires by plugging them out and in again to eliminate loose connections
- swapping all the jumper wires with another ones of the same type
- swapping all the jumper wires with thicker wires (0.25 mm2) which tips I tinned
- using a different power supply (12 V, 16.5A)
- readjusting the location of the wires by moving power wires away from signal wires to eliminate electromagnetic interference
- using AccelStepper library for running the motor continuously instead of the code attached
The timeline up until now:
- Stepper motor not moving at 210 rpm at room temperature while mounted on the linear stage. The current drawn is fluctuating.
- Problem was caused by bad connection and was solved by readjusting the wires.
- Stepper motor not moving at 210 rpm at -20 degrees Celcius while mounted on the linear stage. The current drawn is fluctuating.
- Stepper motor not moving at 210 rpm at room temperature while mounted on the linear stage. The current drawn is fluctuating.
- I tried all the possible solutions listed above none of which helped to solve the problem.
Here is my code:
#define stp 5 // step
#define dir 6 // direction: LOW -> step forward, HIGH -> step in reverse
unsigned long t_spd = 0; // stepper timing
int spd = 350; // microseconds --> corresponds to speed 3.5 rps = 210 rpm.
bool stp_finished = true;
long pos_steps = 0; // position
long steps = 0; // distance
bool dir_forward; //direction
void setup() {
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
resetEDPins();
Serial.begin(9600);
}
void loop() {
if (steps == 0){
if (Serial.available() > 0) {
long steps = Serial.parseInt();
if (steps > 0){
digitalWrite(dir, LOW);
dir_forward = true;
}
else{
digitalWrite(dir, HIGH);
dir_forward = false;
}
}
}
else{
if ((unsigned long)(micros() - t_spd) > spd){
if (stp_finished == true){
digitalWrite(stp, HIGH);
stp_finished = false;
}
else{
digitalWrite(stp, LOW);
stp_finished = true;
if (dir_forward == true){
steps--;
pos_steps++;
}
else{
steps++;
pos_steps--;
}
}
t_spd = micros();
}
}
}
void resetEDPins()
{
digitalWrite(stp, LOW);
digitalWrite(dir, LOW);
}
Do you have any ideas what the problem could be or/and what else to try out?
motor_control_minimal_py.txt (376 Bytes)