accelstepper functions and control help

hello,
i have a project I'm working on that requires a set of steps to increment a paper threw a roller not much more complicated then that ,except i want to ( increment )

so i place said paper in to roller call that start postion ( 0 )

then i want to step the motor 100 times , and stop at that position .

all is well at this point . using the example code to do it like this.

 stepper3.setMaxSpeed(300.0);
    stepper3.setAcceleration(100.0);
    stepper3.moveTo(100); 
}

void loop()
{
   
stepper3.run();

}

but now if i want to move it another 100 steps i have to

    stepper3.moveTo(200); 
}

void loop()
{
   
stepper3.run();
}

so i don't under stand how i can rest the number of steps form the last 100 so i can just move the paper forward 100 steps every time with out adding it up. smiler to how you could with the motor library !

the problem with the steps adding up is when the paper is at its end and i load the next sheet i will be up to 10,000 steps then the next sheet will be 20,000 and so on

so if i could gather some under standing of why im haveing troble doing this then i can move on to my next problem

witch is im trying to run my program the way i had it with the afmotor shield , now using a type of easy driver with a 2 wire setup dirction and pulse ...

my program way ;laid out like this before

( load paper )
1 press button
2 increment paper threw a while loop till sensor found the center of the sheet then wait,
3 press button paper index's half an inch stops and wai ton buttons press,
4 repeat button press as meany times as possible till paper runs out,
5when paper runs out expend the last of the paper threw the rollers, aproxmitly 500 steps
6 then wait for a new sheet
(load new sheet )
repeat !
so im having a hard time figuring out how to make this work with the easy driver & accelstepper library when it was functioning on the afmotor shield and library,

i will post my code that i use to use tomorrow

.. if that helps get a better idea of what im trying to do
i would spend days and use up pages on this forum trying to explain what i have tried and what has not worked

iam missing some thing that i can not find in the accelstepper library that would allow me to treat the motor as if it was controlled using the afmotor library being in one big loop run the motor threw bunch of desired steps and directions running outta paper at the same time as running outta program and looping to the beginning when a new paper is loaded

Have you studied accelStepper.move() as an alternative to ...moveTo() ?

...R

Do you need to be able to drive more than one stepper at a time? Do you need to control the acceleration of the stepper? If the answer to both of these questions is no, then use Stepper, rather than AccelStepper. Stepper has a far simpler API.

first i would like to thank you for looking in to my topic ,, ill post the code i used with the afmotor shield and maybe that can shed some light on whats going on ...

old code Warning im not a pro

// 2 stepper machije used to peel labels from backing


#include <AFMotor.h>
#include <Stepper.h>

AF_Stepper motor1(48, 1);// using this any more
AF_Stepper motor2(48, 2);// <--- this ch is hooked to the stepper moveing
//ir sensor left to right
int TAG1 = A0;
int TAG2 = A1;
int TAG3 = A2;
int TAG4 = A3;
//humaninterface case buttons 1 and 2
int button01 = A4;
int button02 = A10;
//optosensor has a pair of components consisting of a matched IR transmitter and receiver built in
int papercheck = A11;
int drawbar = A12;
//3 useable leds
int papperfeedingled = A13;
int ERROR = A14;
int learnled = A15;
// thats all for pin use

int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button
int waittime = 0;
int set1 = 0;
int set2 = 0;
int set3 = 0;
int set4 = 0;
int set5 = 0;
int stepCount = 0;


void setup() {
  Serial.begin(9600);
  //set up pins THAT ARE OUTPUTS
  pinMode(papperfeedingled, OUTPUT);
  pinMode(learnled, OUTPUT);
  pinMode(ERROR, OUTPUT);
  //set up input pins
  pinMode(button01, INPUT);
  pinMode(button02, INPUT);
  pinMode(papercheck, INPUT);
  pinMode(drawbar, INPUT);
  pinMode(TAG1, INPUT);
  pinMode(TAG2, INPUT);
  pinMode(TAG3, INPUT);
  pinMode(TAG4, INPUT);

  // spend the end of the sheet thru rollers
  motor2.setSpeed(400);
  motor2.step(350, FORWARD, SINGLE);//20 per failed W-loop FAIL 3500 WAS NOTE
  motor2.release(); //allows lower power usage and lesS heating of driver and motor
 delay(400);//DELAY START


  //check draw bar empty carriage position
  Serial.println("drawbar read!");
  int drawbar = analogRead(A12);
  Serial.println(drawbar);// PRINT TO SERIAL CONECTION FOR DEBUGING



  // home out on power up
  while (drawbar < 200) {
    drawbar = analogRead(A12);
    motor1.setSpeed(300);
    motor1.step(24, FORWARD, SINGLE);//20 per failed W-loop FAIL
    digitalWrite(ERROR, HIGH);
    delay(4);
    // print out A NEW value FROM read:
    Serial.println("drawbar set !!");
    Serial.println(drawbar);
    int drawbar = analogRead(A12);
  }

  digitalWrite(ERROR, LOW);
  delay(50);
  digitalWrite(papperfeedingled, LOW);
  motor1.release();//disables the H-brige to release coils on motor
  motor2.release(); //allows lower power usage and lesS heating of driver and motor






  // waiting  ON PERSON READY CHECK POINT
  int button01 = analogRead(A4);
  while (button01 > 700) {
    digitalWrite(papperfeedingled, HIGH);
    delay(150);
    digitalWrite(papperfeedingled, LOW);
    delay(120);
    Serial.println("waitin on button press to start feed tray!");
    Serial.println(waittime);


    button01 = analogRead(A4);
  }
  digitalWrite(papperfeedingled, LOW);

  //check and wait for label sheets
  //PAPERCHECK WHILE LOOP
  papercheck = analogRead(A11);
  while (papercheck < 200) {

    digitalWrite(ERROR, HIGH);
    delay(100);


    papercheck = analogRead(A11);
    delay(100);

    // print out the value you read:
    Serial.println(papercheck);
    delay(100);
  }
  digitalWrite(ERROR, LOW);


  // IR RAIL TEST CHECK TO SEE IF IR RAIL IS IN LOCKED POS AND WAIT FOR IT TO BE SO

  // READ AND WAIT ON ALL 4 IR POS TO OPEN UP
  TAG1 = analogRead(A0);
  while (TAG1 < 350) {
    digitalWrite(ERROR, HIGH);
    delay(250);

    Serial.println("WAIT ON OPENING POS #4 !");
    delay(200);
    TAG1 = analogRead(A0);
    Serial.println(TAG1);
    delay(50);

  }
  digitalWrite(learnled, LOW);
  TAG2 = analogRead(A1);
  while (TAG2 < 350) {
    digitalWrite(ERROR, HIGH);
    delay(250);

    digitalWrite(learnled, HIGH);
    Serial.println("WAIT ON OPENING POS #3 !");
    delay(200);
    TAG2 = analogRead(A1);
    Serial.println(TAG1);
    delay(200);
    digitalWrite(learnled, LOW);
  }
  digitalWrite(learnled, LOW);
  TAG3 = analogRead(A2);
  while (TAG3 < 350) {
    digitalWrite(ERROR, HIGH);
    delay(250);

    Serial.println("WAIT ON OPENING POS #2 !");
    delay(200);
    TAG3 = analogRead(A2);
    Serial.println(TAG3);
    delay(200);
    digitalWrite(learnled, LOW);
  }
  digitalWrite(learnled, LOW);
  TAG4 = analogRead(A3);
  while (TAG4 < 350) {
    digitalWrite(ERROR, HIGH);
    delay(250);

    Serial.println("WAIT ON OPENING POS #1 !");
    delay(200);
    TAG4 = analogRead(A3);
    Serial.println(TAG4);
    delay(200);
    digitalWrite(learnled, LOW);
  }
  digitalWrite(learnled, LOW);
  //END OF IR 4 POS WAITING
  delay(1000);
  digitalWrite(ERROR, LOW);
  digitalWrite(learnled, LOW);


  // READ TAG SENSOR STATE RECORD AND COMPAIR VALUE
  Serial.println("TAG1 read!");//PRINT A LABEL FOR THIS READ
  int TAG1 = analogRead(A0);//READ
  Serial.println(TAG1);// PRINT ACTUALE VALUE STATE FOR DEBUGING
  delay(100);//DELAY PAPPER FEED
  papercheck = analogRead(A11);

  delay(500);

  //FEED PAPPER TILL IR EYE SENSOR CHANGES STATE
  while (TAG1 > 200) {
    // SET SENSOR LED AND READ IR
    digitalWrite(papperfeedingled, HIGH);
    TAG1 = analogRead(A0);

    // MOTOR MOVMENT
    motor1.setSpeed(300);
    motor1.step(4, BACKWARD, DOUBLE);// STEP MOTOR 8 times  PER W-LOOP FAIL
    digitalWrite(papperfeedingled, LOW);
    //DEBUGING IR SENSOR VALUES
    // print out A NEW value FROM read:
    Serial.println("BEFORE!");
    Serial.println(TAG1);
    int TAG1 = analogRead(A0);
    // print out the value you read:
    Serial.println("TAG1 NOW!");
    Serial.println(TAG1);
    digitalWrite(papperfeedingled, LOW);
  }
  delay(50);
  digitalWrite(papperfeedingled, LOW);
  motor1.release();//disables the H-brige to release coils on motor
  motor2.release(); //allows lower power usage and lesS heating of driver and motor

  //PRINT A NEW DEBUGING VALUE
  Serial.println("PAPER FOUND AT IR READ !");
  Serial.println(TAG1);
  delay(10);

  //AFTER IR READS A STATE CHANGE FOLLOW THESE STEPS TO DRAW THE BACKING SHEET TO PINCH ROLLERS AND SET UP FOR PEELING
  motor1.setSpeed(240);
  motor1.step(106, BACKWARD, DOUBLE);//OFF SET FOR BRAKEING DRAWBAR
  delay(10);
  motor1.release();
  motor2.release();



  //DRAW BAR ENGAGE
  //  //DRAW BAR ENGAGE
  while (drawbar > 200) {
    drawbar = analogRead(A12);
    motor1.setSpeed(200);
    motor1.step(20, FORWARD, DOUBLE);//20 per failed W-loop FAIL
    // print out A NEW value FROM read:
    Serial.println("drawbar set !!");
    Serial.println(drawbar);
    int drawbar = analogRead(A12);
  }



  motor1.setSpeed(200);
  motor1.step(20, BACKWARD, DOUBLE);//SLACK
  delay(10);
  motor1.release();//disables the H-brige to release coils on motor
  motor2.release(); //allows lower power usage and les heating of driver and motor

  motor2.setSpeed(260);
  motor2.step(0, BACKWARD, DOUBLE);// PEEL BIG LABLE WAS 1000
  delay(100);
  motor1.release();//disables the H-brige to release coils on motor
  motor2.release(); //allows lower power usage and les heating of driver and motor

  // END OF START UP FEED FIRST SHEET AND END OF DEBUGGING VALUES

  // note big label 1s 1500 steps  large web is 300 small web 100


}

// the loop routine runs over and over again forever:
void loop() {

}

then a loop code much like that one just runs threw the loop reading the labels and feeding new sheets over and over .

viod loop{

  // debuging reads
  Serial.println(drawbar);
  Serial.println("TAG 1!");
  int TAG1 = analogRead(A0); // read the input on analog pin 0:
  Serial.println(TAG1); // print out the value you read:
  Serial.println("TAG 2!");
  int TAG2 = analogRead(A1);
  Serial.println(TAG2);
  Serial.println("TAG 3!");
  int TAG3 = analogRead(A2);
  Serial.println(TAG3);
  Serial.println("TAG 4!");
  int TAG4 = analogRead(A3);
  Serial.println(TAG4);
  Serial.println("WAIT!");
  motor1.release();
  motor2.release();

  digitalWrite(ERROR, LOW);
  int button01 = analogRead(A4);// check if the pushbutton is pressed.?if it is, the buttonState is HIGH:
  // PULL UP FIRST SET ON SHEET
  while (button01 > 700) {
    Serial.println("WAITING ON button 1 press!");
    digitalWrite(papperfeedingled, LOW);
    button01 = analogRead(A4);
    delay(150);
    digitalWrite(papperfeedingled, HIGH);
    delay(150);
  }
  Serial.println("button 1 pressed!");

  // PULL UP FIRST SET ON SHEET
  // MOVE ONE LARGE LABLE AND WAIT
  digitalWrite(papperfeedingled, HIGH); // turn LED on:
  motor2.setSpeed(290);
  motor2.step(845, BACKWARD, DOUBLE);//   1500 steps is aproxmitly 1.375 inchs  .025 short of next notch
  Serial.print("feeding SET 1 :" );
  //SLACK OR WEB SKIP
  motor1.setSpeed(250);
  motor1.step(10, BACKWARD, SINGLE);
  delay(500);
  motor1.release();
  motor2.release();
  //END OF ONE LARGE
  digitalWrite(papperfeedingled, LOW);



  // MOVE ONE LARGE LABLE AND WAIT
  digitalWrite(papperfeedingled, HIGH); // turn LED on:
  motor2.setSpeed(250);
  motor2.step(1075, BACKWARD, DOUBLE);//   1500 steps is aproxmitly 1.375 inchs  .025 short of next notch
  Serial.print("feeding SET 2:" );
  //SLACK OR WEB SKIP
  motor1.setSpeed(250);
  motor1.step(10, BACKWARD, SINGLE);
  delay(50);
  motor1.release();
  motor2.release();
  //END OF ONE LARGE LABEL MOVE

  digitalWrite(papperfeedingled, LOW);
  //END OF ONE LARGE set 2



  // spend the end of the sheet thru rollers
  Serial.println("SPEND END OF 800 STEP SHEET DELAY !");
  motor2.setSpeed(300);
  motor2.step(1100, BACKWARD, SINGLE);//20 per failed W-loop FAIL
  motor2.release(); //allows lower power usage and lesS heating of driver and motor
  motor1.release();


  // enter stage for loading new sheet !


  Serial.println("LOAD NEW SHEET DELAY !");
  delay(400);

  // waiting  ON PERSON READY CHECK POINT
  button01 = analogRead(A4);
  while (button01 > 700) {
    digitalWrite(papperfeedingled, HIGH);
    delay(150);

to anser my firends up there above the code ,... i have been trying to use the accel stepper lib.. for a long time i am yet to find a good brake down of how it works ans what the diffrance is from afmotor,,, i have skimmed threw the forum, but it seems that this same topic comes up gets one reply or a few specific ansewer to some ones project and program code and then the feed of the topic stops there..

i have found a site that has some functions i have not tried yet .
http://www.airspayce.com/mikem/arduino/AccelStepper/

but still does not explain the use or difference, due to it being a different subject .

PaulS:
Do you need to be able to drive more than one stepper at a time? Do you need to control the acceleration of the stepper? If the answer to both of these questions is no, then use Stepper, rather than AccelStepper. Stepper has a far simpler API.

AS for needing to run 2 motors yes i do need 2 motors ! yes i need to run 2 of them BUT not at the same time controling one or the other is working fine ..
thanks !

ez8mm:
i have been trying to use the accel stepper lib.. for a long time i am yet to find a good brake down of how it works ans what the diffrance is from afmotor,,, i have skimmed threw the forum, but it seems that this same topic comes up gets one reply or a few specific ansewer to some ones project and program code and then the feed of the topic stops there..

The accel stepper library takes care of managing the speed and acceleration of the motor rather than stepping it at a configured speed. That's useful when you need to accelerate the motor up to speed and back to rest again.

ok so you are suggesting that i should use another method for control of the steps ,... keep in mine im barely learning here haha and mixing and matching the library's seem scary ! But the thought did cross my mind if i could still use the the af motor libirey the way it was working but re write the library to send the pules to 2 data pains that the drivers could use and add a high low function in the main code for direction but when i looked at the library it was a vast intimidating wealth of code simple for some im sure but with out ever taking a c++ class in my life i don't know if it even posable .

does any one have a library or stepper controlling example code that i cold use to learn some other ways of setting up this function
i have looked therew all the examples that came with the accelstepper lib,.. and such but seeing some other uses of the code could help i think ,.. thank you for your time to guys ! and girls ,..

I've had a quick look back to your first post and I think it would be helpful if you describe what you want to happen rather than explore how to make it happen.

Also tell us what sort of stepper driver you are using - does it just need step and direction signals from the Arduino?

I'm not saying that you need Accelstepper but it has the best documentation for any Arduino library I have seen.

If you don't need acceleration and you only need step and direction connections this sort of code should be all that is needed for one step in the current direction

void stepMotor() {
        digitalWrite(stepPin, HIGH);
        delayMicroseconds(20);
        digitalWrite(stepPin. LOW);
}

...R