digitalWrite(dirpin, LOW); // Set the direction.
delayMicroseconds(5000);
for (i = 0; i<30000; i++) // Iterate for 4000 microsteps.
{
digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delayMicroseconds(20); // This delay time is close to top speed for this
} // particular motor. Any faster the motor stalls
for (i = 0; i<30000; i++) // Iterate for 4000 microsteps
{
digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delayMicroseconds(20); // This delay time is close to top speed for this
} // particular motor. Any faster the motor stalls.
}
It maxes out at around 30,000 steps and 15 microseconds delay. Right now, with my stepper motor, that delay achieves roughly 2 revs/sec on the motor and but will only rotate twice for the 30,000 steps. My motor is a 1.8 degree (200 Steps) stepper motor with 12888 oz-in and 6.3 amps (very large stepper motor).
Can anyone help me with explaining how to achieve greater rpm's and more total revolutions with programming code?
The first question would be what kind of stepper motor controller are you using?
The second question is why aren't you using the Stepper library, or the AccelStepper library?
It doesn't make sense to say it is a 200 step/rev motor and 30,000 steps cause it to make 2 revolutions. Even with 16x microstepping it should go more revolutions than that.
My guess is the motor is nowehere near capable of responding to the fast step rate you are trying.
Have you tried it at a sedate 100 steps / second to see what happens. If that works properly then gradually increase the step rate. When you have send more steps than the motor moves you know you have gone too far.
I presume you have a stepper driver board that limits the current and allows you to use high voltages. Higher speed need higher voltage to offset the coil inductance at higher frequencies.
...R
PS. I don't think the Stepper library would be any better than the code you have and while the AccelStepper library offers the possibility of accelerating up to speed I think the present problem needs to be solved before that library is considered. ...R
I am having troubles uploading the Stepper Library to my Arudino Folder on my Macbook for whatever reason (any tips?). However, I do have the Accel Stepper Library and have been running the following code:
#include <AccelStepper.h>
// Define two steppers and the pins they will use
AccelStepper stepper1(1, 9, 8);
AccelStepper stepper2(1, 7, 6);
int pos1 = 3600;
int pos2 = 5678;
void setup()
{
stepper1.setMaxSpeed(3000);
stepper1.setAcceleration(30000);
stepper2.setMaxSpeed(2000);
stepper2.setAcceleration(800);
}
void loop()
{
if (stepper1.distanceToGo() == 0)
{
pos1 = -pos1;
stepper1.moveTo(pos1);
}
if (stepper2.distanceToGo() == 0)
{
pos2 = -pos2;
stepper2.moveTo(pos2);
}
stepper1.run();
stepper2.run();
}
With the above code, how can I get a faster RPM's and more revolutions then? Seems to max out as the same numbers as the previous code...Thanks
digitalWrite(dirpin, LOW); // Set the direction.
delayMicroseconds(5000);
for (i = 0; i<100; i++) // Iterate for 4000 microsteps.
{
digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delay(1); // This delay time is close to top speed for this
} // particular motor. Any faster the motor stalls.
for (i = 0; i<100; i++) // Iterate for 4000 microsteps
{
digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delay(1); // This delay time is close to top speed for this
} // particular motor. Any faster the motor stalls.
}
With this code inserted, it twitches back and forth, barely rotating at all? 100 steps and a delay of 1 second. Not sure why it does that. I have a proper driver that corresponds to my power source and motor. It was a package type deal where all these components were designed for each other so the driver board should be limiting current to allow higher voltages.
byte directionPin = 8;
byte stepPin = 9;
int numberOfSteps = 5000;
byte ledPin = 13;
int pulseWidthMicros = 10; // microseconds
int millisbetweenSteps = .015; // milliseconds
With the following parameters entered, I get around 1/4 rotation. If I increase the number of steps to 25,000 again, I get approximately one full rotation. Anything under 1 millisecond for the between steps part had the same speed approximately, and was the fastest. Anything above 1 was extremely slow. Any idea what that means?
Why have you int millisbetweenSteps = .015; // milliseconds
How can an integer hold a floating point number?
Why haven't you left it at 25 like in my code?
-- at least until you can be sure the motor works perfectly at that speed. Maybe even try a slower speed.
AND WHY can't you put your code in code tags as the How To Use The Forum recommends ???