Pages: [1]   Go Down
Author Topic: Stepper Motor Acceleration  (Read 918 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello to all,
I am new to arduino(sorry about my English). I have working on a X-Y plotter and i have a prolem. At the bottom of the program "for" loop doesn't seem to work properly.When i gave the input "a" it works however when i gave again i doesn't work again. Have you any ideas?

#include <AccelStepper.h>
#include <Stepper.h>
AccelStepper stepper1 (4,2,3,4,5);
AccelStepper stepper2 (4,8,9,10,11);

const int stepsPerRevolution = 200;
Stepper myStepper1(stepsPerRevolution, 2,3,4,5);
Stepper myStepper2(stepsPerRevolution, 8,9,10,11);
char p;

void setup()
{
Serial.begin(9600);
Serial.println("TEST");
stepper1.setMaxSpeed(200.0);
    stepper1.setAcceleration(200.0);
    stepper1.moveTo(200);
   
    stepper2.setMaxSpeed(200.0);
    stepper2.setAcceleration(200.0);
    stepper2.moveTo(200);

}
void loop()
{
  if(Serial.available()>0)
{
p=Serial.read();


Serial.println(p);
if(p=='a'){
al();//nor(650)

}
int al(){
 
    for(int s=1; s<200; s++)
{
    stepper1.run();
    stepper2.run();
    delay(1);
}
       
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46291
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In setup(), you define where the steppers are to go to. The first time that 'a' is received, the steppers go there. The next time that 'a' is received, they are already there, so nothing happens. Why is that a surprise?
Logged

Pages: [1]   Go Up
Jump to: