I want to build a machine that can follow a set of simple rules by which it controls a motor. These rules are yet to decided, but the patterns are as follows:
- Turn motor clockwise for
A
minutes, then pause forB
minutes and then continue in a anti-clockwise direction forC
minutes (and repeat from beginning after a wait ofD
minutes) - Turn motor clockwise for
A
minutes and then pause forB
minutes (and repeat from beginning) - Turn motor anti-clockwise for
A
minutes and then pause forB
minutes (and repeat from beginning)
Now, I might simplify things and decide not to include a switch between patterns and only use pattern 1, but let's include the option to have the user input which pattern should be executed.
I plan to use a low RPM motor, something similar to this 6 RPM motor. Moreover, could the speed of the motor be adjusted (for example, 1-6 RPM) as well? How?
With my lacking knowledge of microcontrollers, how could these features be achieved? Do I need relays for the motor as well? How about the speed settings? I suppose I could have a dial with a few preprogrammed pattern and speed settings.
Best Answer
You could achieve your goal combining a microcontroller with an H-bridge.
An H-bridge is a circuit that lets you control a motor, making it spin in both directions depending on commands given by a microcontroller. Here's an example of an H-Bridge built with BJTs.
You will then need to program your microcontroller with the exact pattern that you want, following the pseudo-code that you laid out in your question. If you are new to microcontrollers as you mentioned, I suggest you get started with an Arduino.
I hope this helps.