Problem Stepper Library High Speed

Hi, I'm working on a project with a Stepper Motor and I need to go up to 1400 RPM of speed.
-- To control it I'm using this board (it's really greats...) : https://shop.ruggedcircuits.com/index.php?main_page=product_info&cPath=4&products_id=14&zenid=dd070fea017add31d25eb346801f7012

-- For the power I'm using a 0-30 V, 4Amp.... using it at 24 VDC

The problem now is that I've discover that the Stepper Library is limited to 300RPM... Why ?
If you open the Stepper Library file you found this :

setSpeed() function:

void Stepper::setSpeed(long whatSpeed)
{
this->step_delay = 60L * 1000L / this->number_of_steps / whatSpeed;
}

The problem is that if whatSpeed is 300 then the above expression becomes:

this->step_delay = 60 * 1000 / 200 / 300; // This equals 1!

Anything bigger than 300 and the above expression becomes 0, which causes the inter-step delay to be 0 and the whole process fails.

So, I trying to see how we can update an high speed Stepper Library, but I'm not so "programmer"....

Did someone have an idea to how change the library to be able to go up with High-Speed Stepper Motor ????

Thanks

KinoLab

To do 1400 RPM you wil need 4666 steps per second (0.214 milliseconds between steps). I suspect the stepper library uses delay() to time the steps. If you make a version of the library that uses delayMicroseconds() instead you might be able to get close to the desired speed, assuming your stepper can handle stepping that quickly at the load you are putting on it.

Thanks for your answer, I'll work on this on next days and I'll post if I can do it....
:fearful:

No need to suspect the Stepper library of anything! Look at the source - it uses millis() as its time control.

This could easily be converted to use micros().

However the problem is deeper - to get to high speeds momentum efffects are important and you need to smoothly accelerate the steps which is something Stepper can't handle.

I believe theres an AccelStepper library or something of similar name - try this...

Hi I found the AccelStepper Library here : AccelStepper: AccelStepper library for Arduino
But When I try it, I can't go up to 1000 step per second.... so that i can't use it...

someone have others ideas ???

I'll try the Microseconds idea to see what happen..

Best

SO, this is the code of the stepper library:

/*
Sets the speed in revs per minute

*/
void StepperHighSpeed::setSpeed(long whatSpeed)
{
this->step_delay = 60L * 1000L / this->number_of_steps / whatSpeed;
}

/*
Moves the motor steps_to_move steps. If the number is negative,
the motor moves in the reverse direction.
*/
void StepperHighSpeed::step(int steps_to_move)
{
int steps_left = abs(steps_to_move); // how many steps to take

// determine direction based on whether steps_to_mode is + or -:
if (steps_to_move > 0) {this->direction = 1;}
if (steps_to_move < 0) {this->direction = 0;}

// decrement the number of steps, moving one step each time:
while(steps_left > 0) {
// move only if the appropriate delay has passed:
if (millis() - this->last_step_time >= this->step_delay) {
// get the timeStamp of when you stepped:
this->last_step_time = millis();
// increment or decrement the step number,
// depending on direction:
if (this->direction == 1) {
this->step_number++;
if (this->step_number == this->number_of_steps) {
this->step_number = 0;
}
}
else {
if (this->step_number == 0) {
this->step_number = this->number_of_steps;
}
this->step_number--;
}
// decrement the steps left:
steps_left--;
// step the motor to step number 0, 1, 2, or 3:
stepMotor(this->step_number % 4);
}
}
}

I've found in the code a millis() option, but there is something that i don't understand, if i try to change for micros() the motor is hiss, so how can i change things to be able to read microsecond delay step ??

Thanks for the help...

When you change millis() to micros() in those two places you should also change:

 this->step_delay = 60L * 1000L / this->number_of_steps / whatSpeed;

to

 this->step_delay = 60L * 1000000L / this->number_of_steps / whatSpeed;

That calculates the number of microseconds between steps to get the RPM speed specified.

Try a super- slow speed like 30 RPM (1/2 revolution per second) for testing. Then slowly increase the speed until you reach 1400 or the limit of your stepper motor.

Hi Thanls for your answer,
I think that we have to look for others solutions....
I've try with your idea and when I arrived around 345 RPM the motor start to work in a strange way....

In the datasheet of the motor they speek of 4000 pps...
This is the link : http://www.cnsoyo.com/product_show_e.asp?id=8
and this is the model : SY42STH47-1206A

I don't know...
I'm loose...

The chart that shows pps up to 4000 also says HALF STEP. Since the motor does 400 half-steps per revolution that's only 10 RPS (600 RPM). Maybe if you figure out how to do half-step driving you can get it up to that speed. It's still less than half your desired speed.

Perhaps if you said why you want a stepper to run that fast somebody could recommend a solution that will work. There are many kinds of motors that can turn at a controlled speed and/or stop in a specified position.

I looked through the Stepper Library code and found the problem and also came up ... 60 * 1000 / #ofsteps / speed = 60 * 1000 / 200 / 301

HI Johnwasser, thanks for your answer, i'm trying different option and nothing with this motor... I'm looking around of the ACEELSTEPPER LIBRARY...
Anyway, the project is to modify a 16mm projector and be able to control it trough a Laptop... is for that the stepper motor... Cinema running at 24 images per second...

Anyway, i don't understand the Rubenjohnson answer ???

thanks again

KinoLab:
Anyway, i don't understand the Rubenjohnson answer ???

Neither do I.

There must be some kind of motor that will give you the speed and control you want. A servomotor might do it: http://www.electricmotors.machinedesign.com/guiEdits/Content/bdeee4a/bdeee4a_1.aspx