Stepper motor stops before reaching target

Hi All,
I’ve been working on a project that has multiple stepper motors running simultaneously and independent of each other.
I am using the TinyStepper_28BYJ_48 with 28BYJ_48 motors and driver boards connected to and UNO.
I have one stepper I need to run continuously. I accomplished that by telling to a certain number of revolutions (one rev 20), but i have run into a problem, if i try to do more than about 15 revolutions (152048 steps) than the motor will complete about 11-12 then stop.

Does anyone know why this may be?

if i do 10 or 11 it does fine but higher numbers it stops before reaching the total steps.

Bellow is my code.

#include <TinyStepper_28BYJ_48.h>


const int ONE_REV = 2048;
int t =1;
int cycle = 1;
//
// create two stepper motor objects, one for each motor
//
TinyStepper_28BYJ_48 armA;
TinyStepper_28BYJ_48 armB;



void setup(){ 
	Serial.begin(9600);
	//
	// connect and configure the stepper motors to their IO pins
	//
	armA.connectToPins(8,9,10,11);
	armB.connectToPins(4,5,6,7);

}


void loop(){

	armA.setSpeedInStepsPerSecond(300);
	armA.setAccelerationInStepsPerSecondPerSecond(1000);

	armB.setSpeedInStepsPerSecond(500);
	armB.setAccelerationInStepsPerSecondPerSecond(1000);

	armA.setupRelativeMoveInSteps(1);

	armB.setupMoveInSteps(ONE_REV*20);

	while((!armA.motionComplete()) || (!armB.motionComplete())){
		if(armA.motionComplete()){
			switch(cycle){
				case 1:
					armA.setupRelativeMoveInSteps(ONE_REV/-8);
					cycle = 2;
				break;
				case 2:
					armA.setupRelativeMoveInSteps(ONE_REV/4);
					cycle = 3;
				break;
				case 3:
					armA.setupRelativeMoveInSteps(ONE_REV/-8);
					cycle = 4;
				break;
				case 4:
					armA.setupRelativeMoveInSteps(ONE_REV/4);
					cycle = 1;
				break;
			}		

		}
		if(!armA.motionComplete()){
			armA.processMovement();
		}
		if(!armB.motionComplete()){
			armB.processMovement();
		}
	}

}

Let me know if anyone has any insights as to why this may be.

Thanks,
Oliver

I have one stepper I need to run continuously.

Then, clearly, you should NOT be using a stepper motor.

Why do you, on every pass through loop(), need to set the speed and acceleration?

What happens with your code, when arm b's motion is complete?

PaulS:
Then, clearly, you should NOT be using a stepper motor.

I don't agree at all. A stepper motor has the great advantage (over a regular DC motor) that it can be programmed to run at a specific speed which won't change when the load changes. Assuming, of course, that the load never exceed the capability of the motor.

enoc22:
if i try to do more than about 15 revolutions (15*2048 steps) than the motor will complete about 11-12 then stop.

15 * 2048 = 30720 and the max positive value for an int variable is 32767 so I suspect you need to change the relevant int to a long

If you want the motor to run continuously it is probably easier to make it do one step at a time and look after the step timing yourself.

...R

Robin2:
I don't agree at all. A stepper motor has the great advantage (over a regular DC motor) that it can be programmed to run at a specific speed

Exactly! I need to be able to have my motor spin at specific speeds.

Robin2:
15 * 2048 = 30720 and the max positive value for an int variable is 32767 so I suspect you need to change the relevant int to a long

That make sense with the Int and Long, I'm still new to programming and data type limitations didn't even cross my mind.

Robin2:
If you want the motor to run continuously it is probably easier to make it do one step at a time and look after the step timing yourself.

Do you happen know of any examples I could look at to see how this would be implemented?

Thanks,

-Oliver

enoc22:
Do you happen know of any examples I could look at to see how this would be implemented?

This is the code I use for a 28BYJ-48 stepper

void moveOneFullStep() {

    static unsigned long prevStepMicros;

    if (micros() - prevStepMicros < tableStepIntervalMicros) {
        return;
    }
    else {
        stepCount ++;
        prevStepMicros = micros();
    }

    if(tableDirection == 'F'){
        stepSequence++;
    }else{
        stepSequence--;
    }

    if(stepSequence>3){
        stepSequence=0;
    }
    if(stepSequence<0){
        stepSequence=3;
    }



    switch(stepSequence){
        case 0:
             digitalWriteFast(stepperPin1, HIGH);
             digitalWriteFast(stepperPin2, HIGH);
             digitalWriteFast(stepperPin3, LOW);
             digitalWriteFast(stepperPin4, LOW);
            break;
        case 1:
             digitalWriteFast(stepperPin1, LOW);
             digitalWriteFast(stepperPin2, HIGH);
             digitalWriteFast(stepperPin3, HIGH);
             digitalWriteFast(stepperPin4, LOW);
            break;
        case 2:
             digitalWriteFast(stepperPin1, LOW);
             digitalWriteFast(stepperPin2, LOW);
             digitalWriteFast(stepperPin3, HIGH);
             digitalWriteFast(stepperPin4, HIGH);
        break;
        case 3:
             digitalWriteFast(stepperPin1, HIGH);
             digitalWriteFast(stepperPin2, LOW);
             digitalWriteFast(stepperPin3, LOW);
             digitalWriteFast(stepperPin4, HIGH);

        break;
    }
}

Set the value of tableStepIntervalMicros to get the speed you want. In my project it is 12000 (for 12 millisecs)

…R