My hardware is the DRV8825 Stepper Motor Driver Carrier, High Current: an A-Star 32U4 Prime SV microSD with LCD and a Stepper Motor - Unipolar -/Bipolor, 200 Steps/Rev, 57x76mm, 8.6v, 1 A/Phase (item numbers 2133 and 3115 1477 respectively).
This application is a Life Cycle test. The entire travel requirement for this stepper motor is to go from:
- Start/Home position
- Rotate 180 degrees
- Stop
- Reverse direction
- Return to Start/Home
…and repeat this for a minimum of 400,000 times. This will be done for five (5) separate sessions for a total of 2,000,000 cycles. Therefore, each of the five sessions will run continuously at 1.5 sec/cycle for about seven (7) straight days.
Using the bottom part of the following code I have made 60,000 partial cycles (approx. 160 degrees) just to check out the mechanics. Now I need to add a front end loop, that moves in one direction (ccw) until it finds the Home Switch, and then proceed to the last loop that will be repeated for 400,000 cycles.
Since doing the following, I have heard that Pin 1 could possibly be problematic and should use another pin. Pin 5 for example is available. Thank you in advance for your collective collaboration.
#define HOME_PIN 1
#define STEP_PIN 2
#define DIR_PIN 3
bool dirHigh;
void setup()
{
dirHigh = true;
digitalWrite(DIR_PIN, HIGH);
digitalWrite(STEP_PIN, LOW);
pinMode(DIR_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
digitalWrite(HOME_PIN, HIGH);
pinMode(HOME_PIN, INPUT);
}
void loop()
{ int HOME_PIN = 1;
int val = 0;
}
if(HOME_PIN LOW)
{
digitalWrite(dir_Pin, HIGH);
}
void loop()
{
if(dirHigh)
{
dirHigh = false;
digitalWrite(DIR_PIN, LOW);
}
else
{
dirHigh = true;
digitalWrite(DIR_PIN, HIGH);
}
for(int i = 0; i < 50; i++)
{
digitalWrite(STEP_PIN, HIGH);
delay(250);
digitalWrite(STEP_PIN, LOW);
delay(250);
}
}