I am working on a class project that is a rotating wheel like a Ferris
wheel, instead of chairs it has dixie cups. There are a total of 12
positions. Here are the logical steps.
1. Rotate wheel 30 degrees and stop.
2. Turn on Solid State Relay ,which is attached to a small pump, the pump stays on for 2 seconds adds some water.
3. Wait 5 seconds for drips to stop.
4. Rotate to next position and repeat above.
5. Do this for all 12 positions.
After all cups have water.
1. Rotate wheel 360 for X number of times.
2. Start fill sequence again.
I
am new to the Arduino platform and have been running into some issues
with the stepper motor being able to start and stop. I am using the
AccelStepper with the following hardware.
Arduino Uno
Spark Fun Solid State Relay Kit (KIT-10684)
Spark Fun Stepper Motor - 125
oz.in (200 steps/rev) (ROB-10847)
Big Easy Driver (ROB-10735)
I
have everything together and working. I can't seem to figure out the
code to get the pause to happen for 5 seconds between when the pump
turns off and the motor indexes to next position or how to get the
second phase to integrated. I have provided the code I am using below.
Can one of you pro's take a look and make some suggestions? It seems
pretty straight forward.
Thanks in advance for any help or suggestions.
[code]
#include <AccelStepper.h>
#define relayPin 2 //Output Pin for the SSR
#define dirPin 9 //Direction Output on pin 8
#define stepPin 8 //Step Output on pin 9
#define relayOn 8000 //Amount of time the SSR stays on
#define relayOff 4000 //Amount of time the SSR stays off
#define maxSpeed 4000
#define shaftSpeed 4000
const int steps = 200;
AccelStepper stepper(1, dirPin, stepPin);
int Distance;
unsigned long ms; //time from millis()
unsigned long msLast; //last time the relay changed state
boolean relayState; //current state of relay on or off
void setup()
{
Serial.begin(9600);
stepper.setMaxSpeed(maxSpeed);
stepper.setSpeed(shaftSpeed);
relayState = 0;
}
void loop()
{
ms = millis();
changeRelayState();
if (relayState == 0)
{
stepper.runSpeed();
}
else
{
digitalWrite(dirPin, LOW);
digitalWrite(stepPin, LOW);
}
}
void changeRelayState()
{
if (ms - msLast > (relayState ? relayOn : relayOff))
{
digitalWrite(relayPin, relayState = !relayState);
msLast = ms;
}
}
[/code]