I want my output shaft to turn 207 revolutions one way then 207 revolutions in reverse, what I am actually getting on first power up is about 100 revolutions then my desired 207 revolutions forward & backward thereafter, I am trying to understand/ resolve this start up issue, I have read elsewhere
"at power on, at the start of the sketch, the stepper motor is assumed to be at position 0, when, in reality, it could be anywhere, so the sketch needs to "home" the motor to a known physical position and then set that as position 0 in software. This can be achieved with a limit switch at one end of the rack travel, with the switch applying an interrupt to pin 2 (int0) of the Arduino."
any one know of a way around this without introducing a physical switch assuming the above quote is applicable to my problem.
I am Usind Arduino uno with uln2003 driving STEPPER 28BYJ-48
A sketch would be brill i,m not a coder thanks dave
#include <AccelStepper.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define FULLSTEP 4
#define HALFSTEP 8
// motor pins
#define motorPin1 4 // Blue - 28BYJ48 pin 1
#define motorPin2 5 // Pink - 28BYJ48 pin 2
#define motorPin3 6 // Yellow - 28BYJ48 pin 3
#define motorPin4 7 // Orange - 28BYJ48 pin 4
// Red - 28BYJ48 pin 5 (VCC)
#define motorPin5 8 // Blue - 28BYJ48 pin 1
#define motorPin6 9 // Pink - 28BYJ48 pin 2
#define motorPin7 10 // Yellow - 28BYJ48 pin 3
#define motorPin8 11 // Orange - 28BYJ48 pin 4
// Red - 28BYJ48 pin 5 (VCC)
/*-----( Declare objects )-----*/
// NOTE: The sequence 1-3-2-4 is required for proper sequencing of 28BYJ48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
AccelStepper stepper2(HALFSTEP, motorPin5, motorPin7, motorPin6, motorPin8);
/*-----( Declare Variables )-----*/
//none
void setup() /****** SETUP: RUNS ONCE ******/
{
stepper1.setMaxSpeed(1000.0);
stepper1.setAcceleration(50.0);
stepper1.setSpeed(700);
stepper1.moveTo(148534); // 1 revolution
stepper2.setMaxSpeed(1000.0);
stepper2.setAcceleration(50.0);
stepper2.setSpeed(700);
stepper2.moveTo(-148534); // 1 revolution
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
//Change direction at the limits
if (stepper1.distanceToGo() == 0)
stepper1.moveTo(-stepper1.currentPosition());
if (stepper2.distanceToGo() == 0)
stepper2.moveTo(-stepper2.currentPosition());
stepper1.run();
stepper2.run();
}//--(end main loop )---
/*-----( Declare User-written Functions )-----*/
//none
//*********( THE END )***********