i have this dc 3rpm motor http://www.servocity.com/html/3_rpm_gear_motor.html
as one component of a larger machine i need to rotate a wheel 360 degrees with this motor on a button press then stop and wait for the next button press.
i'm assuming for accuracy (since this is not a servo or stepper motor) i would need to imbed a sensor in the wheel to give an exact posistion. maybe a reed switch and magnet like what is used in a bicycle speedometer.
has anyone used a code to accomplish this? i'm having some trouble getting started code side. up until now I've only taken code examples and adjusted them to suit my needs but i can't seem to find anything that i can even adjust to get this project going.
any tips / advice? google searchs havn't been super helpful thus far. thanks!
If you want some accuracy, you need to sense multiple times when a motor turns 360 degrees. A reed switch only senses once. I suggest a photo gate and a disk with periodic notches to sense the rotation of the motor multiple times during the 360 rotation for accuracy. With only one switch you may miss as much as a full turn.
To get code started you can just pretend you have a large set of high level functions that solve parts of the problem. Or write the story by means of comments before the code
#define MOTORPIN ??
#define BUTTON ??
void setup()
{
// For debugging
Serial.begin(115200);
// init motor
pinMode(MOTORPIN, OUTPUT);
// init button
}
void loop()
{
if (buttonPressed() == true)
{
Serial.Println("button pressed");
rotateMotor(360);
}
Serial.print(".");
}
void rotateMotor(int degrees)
{
// start the motor
digitalWrite(MOTORPIN, HIGH);
// wait until enough degrees rotated
// stop the motor
digitalWrite(MOTORPIN, LOW);
}
You could use a limit switch to stop the motor, and a momentary seal in bypass for the limit switch controlled by an arduino button setup.
robtillaart:
To get code started you can just pretend you have a large set of high level functions that solve parts of the problem. Or write the story by means of comments before the code
I just did that yesterday on a project I posted on exhibition, about the large font on 16*2 display. It's a perfect way for procrastination, you lie to yourself that this is gonna work except you don't have the component that does the actual work, like flux capacitor. XD
I think there is a CSCI model for this type of modelling, top down?
hmmmmm this limit switch idea has got me thinking in a new direction.
maybe bypass arduino altogether and go with a limit switch and a 555 chip or 2.
a harware based solution might be a bit easier for me on this one.
It's one thing to detect when the wheel has done 360, but how are you going to stop it at that point?
Rob
I guess mechanically the switch is in the way of further rotation so unless something is done to turn off the motor, it may damage or overcome (
) the switch. Just my experience with limit switches. In any way there won't be room for further turning unless you're turning back.