Some of our favorite hobbyist electronics utilize motors to mobilize, making them fun and awesome! Including a motor in your project could be challenging, especially if you have never worked with them before.
The following Instructable will explain how motors work, and break down some of the most commonly used kinds of motors.
Step 1: The Fundamentals
Magnetic fields produce physical force that can move things. Every magnet has a magnetic field with a north pole and a south pole. If you try to push the north poles of two magnets together, they will repel each other. The same thing happens if you try to push two south poles together. If two poles are the same, they will repel each other. If, however, you play with two magnets and bring the north pole of one close to the south pole of another, they will attract each other and stick strongly together, opposite magnetic poles attract each-other.
An electric motor uses the attraction and repelling properties of magnets to create motion. There are two magnets in a standard electric motor: a permanent magnet, and a temporary magnet. The temporary magnet is a special kind of magnet, called an electromagnet. An electromagnet is created by passing an electric current through a wire. The permanent magnet has a magnetic field (a north pole and a south pole) all the time, but the electromagnet only has a magnetic field when there is a current flowing through the wire. The strength of the wire's electromagnetic magnetic field can be intensified by increasing the current through the wire, or by forming the wire into multiple loops.
In an electric motor, the electromagnet is placed on an axle so it can spin freely inside the magnetic field of a permanent magnet. When an electric current is passed through the wire, the resulting temporary electromagnetic field interacts with the static permanent magnet, and attractive and repelling forces are created. This excitation of the wire, or electromagnet, propel it to spin on its axle, and an electric motor is born.
Motors are classified by having the following properties:
- There's a permanent magnet (or magnets) around the edge of the motor case that remains static, so it's called the stator of a motor.
- Inside the stator, there is a wire coil, mounted on an axle that spinsaround at high speed - this is called the rotor.
Step 2: DC Motors
Utilizing a DC power source, very few controls are needed. Speed of the motor can be controlled by the amount of current reaching the coils from the battery to the commutator.
If you reverse the leads, or wires, coming off of the motor - the motor will spin the opposite direction as it was previously.
Step 3: Stepper Motors
The rotor is propelled by sequentially applying a pulsed voltage to these coils. The coils in the stator-casing drive the permanent magnet rotor by alternating which coil has an electromagnetic current running through it. The stepper motor steps at a specific resolution for each pulse.
Stepper motors are an excellent choice for your hobbyist needs for many reasons. They are often an inexpensive way to mobilize your project, they rarely have any kind of mechanical failure, and they are ideal for open loop positioning control. When you terminate the current running through the electromagnetic coils, stepper motors will hold their position firmly when they are not spinning.
These motors are designed to spin continuously, forwards or backwards. If you hook the battery leads of a stepper motor up to a battery, the axle will spin. If you reverse the leads, it will spin in the opposite direction. There are some stepper motors that are wired to prohibit this from happening, so just verify what kind of motor you have before you try omni-directional rotation.
Step 4: Servo Motors
Servo motors will most often have three wires: power, ground, and signal. The power wire is typically red, the ground wire is typically black or brown. The signal wire is typically yellow, orange or white.
In radio controlled servos, like steering systems on RC cars, an electric motor is mechanically linked to a potentiometer. A standard RC receiver sends pulse-width modulation (PWM) signals to the servo, through the signal wire. The electronics inside the servo translate the width of the pulse into a position. When the servo is commanded to rotate, the motor is powered until the potentiometer reaches the value corresponding to the commanded position.
The control signal is a digital PWM signal with a 50 Hz frame rate. Within each 20 millisecond(ms) timeframe, an active-high digital pulse controls the position. The pulse nominally ranges from 1.0 ms to 2.0 ms with 1.5 ms always being center of range. Pulse widths outside this range can be used for "overtravel" -moving the servo beyond its normal range. This PWM signal is sometimes (incorrectly) called Pulse Position Modulation (PPM).
A servo pulse of 1.5 ms width will typically set the servo to its "neutral" position or 90°, a pulse of 1.25 ms could set it to 0° and a pulse of 1.75 ms to 180°. The physical limits and timings of the servo hardware varies between brands and models, but the neutral position is almost always at 1.5 ms.
Step 5: Vibrating Motors
Vibrating motors are constructed in the same way many as DC and stepper motors, except at the end of their rotors, they have a counter weight extending off of the edge. As the rotor spins, the counter weight is 'thrown' in a circular motion causing the entire mechanism to to shake.
The intensity of vibration depends on the size of the motor, as well as the counterweight.
Step 6: Where to Start?
A really excellent intermediate control device to use, is an Arduino, or a like-style microprocessing board. The wonderful thing about these boards is that they are variable input/output devices and can be programed to complete multitude of tasks, including motor automation.
The following steps will outline how you can combine the motors we have already talked about with an interface like the Arduino.
Step 7: Using a Stepper Motor With an Arduino
Opening the Arduino software, browse to "File>Examples>Stepper>stepper_oneRevolution"
This program drives a unipolar or bipolar stepper motor, by attaching the motor to digital pins 8 - 11 of the Arduino. After the sketch is loaded on to the Arduino board, the motor should revolve one revolution clockwise, then one revolution moving counter-clockwise.
The example code is an excellent point to start from, you can certainly make edits to the sketch to suit your needs. The delay is listed in microseconds, so if you want there to be no break between it's revolutions, you can set delay to delay(10). Or if you want it to spin for a long time you can change stepsPerRevolution to equal = (1000000)
How you modify the sketch will depend on what you are trying to accomplish with the motor. Playing with some of the other sketches in the example sketch library will help you develop a greater understanding of how stepper motors are able to communicate with Arduino Boards.
Step 8: Using a DC Motor/Vibrating Motors
Some of your project needs will not require you to use a microprocessor like an Arduino. If you are making a plushy toy for a kid(or adult), and want to embed a vibrating motor within it, its probably best to just have a simple push-button circuit to activate the motor.
In that instance the motor would be wired directly to your power source - with a momentary switch wired to your positive lead from the motor.
Step 9: Using a Servo Motor With an Arduino
Opening the Arduino software, browse to "File>Examples>Servo>Knob"
This program drives a servo motor, by connecting the motor to PWM pin 9 of the Arduino, and a the potentiometer to analog 0. The potentiometer will determine the position of the servo by sending a variable resistance current to the A0 port on the Arduino, which the Arduino code then interprets to a pulsed signal to the servo. After the sketch is loaded on to the Arduino board, the motor will rotate based on the position that the potentiometer is turned to.