I have a project I have been kicking around and collecting pieces for but need help putting it all together (mainly the code). I have attached an outline of what I would like to do. Here are my questions/notes:
Here is one in action for reference: - YouTube
Can someone help me put the pieces together? It's for our model railroad club so not much in the way of spending budget.
Thanks,
Wayne
Is bump needed with steppers?
At initial power, can any motor-being-off drift (is there any drift?) be corrected with an initial power-on, move to zero starting location so the rotary dump always starts in the correct position?
I have read that the stepper doesn't know its out of position if something moves when the unit is off. The rotary pretty much never moves once its in place so maybe this is a non-issue??
START DUMP CYCLE BUTTON
Determine if out of alignment
Hall or IR sensor for position?
Figure out how to determine which direction to move to get into position
Start stepper motor, run to x position
I need to look at current gear rotation to determine how many steps to fully dumped
Once dumper reaches dump position
Pause for three-five seconds
Start vibration/offset motor to release car load contents
Run for three-four seconds starting when the rotation hits about 85% rotated, keep vibrating until the end of the three-five second rotation pause
Return to zero position
Flashing led circuit?
Option for a flashing orange led circuit to run while the dumper is rotating
Enough to drive up to four led's
BUMP COUNTER-CLOCKWISE (and CLOCKWISE)
Micro-steps per button push
Holding momentary push button does nothing, only individual presses of the button will move the motor
Determine how micro of steps to make; five, ten, ?? steps per push?
A rotary encoder would probably be better for fine-tuning into position? Zero/center and rotate left/right to align?
A momentary push-button will be mounted to a panel to start the cycle.
I have an Arduino uno R3 and the basic kit stepper motor 28BYJ-48 and ULN2003 motor controller. I purchased a pack of bullet vibration motors. I think one will work but if two are needed can another one be wired in without altering code?
I was thinking about purchasing a NEMA 17 stepper motor, the rotary dump turns pretty easily so I'm not sure we need much more motor than the basic. Open to suggestion.
I have the following code which has the acceleration that looks good in my test so far. Currently its looping, I only need it to run once with the push button.
/*
- Arduino Learning Board Project - Stepper Motor Example
- Please visit http://www.ArduinoLearningBoard.com for more information
- Last modified August 2016 by Jeff Shapiro Jeff@ArduinoLearningBoard.com
*/
// - -> GND
// + -> 5V
// IN1 -> D8
// IN2 -> D9
// IN3 -> D10
// IN4 -> D11
// First DEFINE the components of the library we're going to use for this sketch
// Define #USE_ALB_Stepper to include the Stepper Motor functions of the ArduinoLearningBoard Library
// (Must do this before including ArduinoLearningBoard.h)
#define USE_ALB_Stepper
// NOW include the main ArduinoLearningBoard library
// Based on the defines above, the appropriate modules will be added to the project
#include "ArduinoLearningBoard.h"
#define HALFSTEP 8
// Motor pin definitions
#define motorPin1 8 // IN1 on the ULN2003 driver 1
#define motorPin2 9 // IN2 on the ULN2003 driver 1
#define motorPin3 10 // IN3 on the ULN2003 driver 1
#define motorPin4 11 // IN4 on the ULN2003 driver 1
// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
void setup() {
Serial.begin(9600);
stepper1.setMaxSpeed(1000.0);
stepper1.setAcceleration(300.0);
stepper1.setSpeed(1000);
stepper1.moveTo(8000);
Serial.println("Moving Stepper to Position 8000");
}
void loop() {
// Serial.println(stepper1.currentPosition());
//Change direction when the stepper reaches the target position
if (stepper1.distanceToGo() == 0) {
Serial.print("Stepper Arrived at Destination. MoveTo(");
Serial.print(-stepper1.currentPosition());
Serial.println(")");
delay(4000);
stepper1.moveTo(-stepper1.currentPosition());
}
stepper1.run();
}
Rotary Dump Specs.pdf (36 KB)