technology                     workshop                     craft           home              food            play           outside                costumes
Complete Motor guide for Robotics
by taifur on December 11, 2015
Table of Contents
Complete Motor guide for Robotics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .            1
    Intro: Complete Motor guide for Robotics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .               2
    Step 1: Types of Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .        2
    Step 2: Motor Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .       4
    Step 3: Brushed DC Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .         6
    Step 4: Controlling of Brushed DC Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                8
    Step 5: H Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
    Step 6: Arduino DC Motor Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
    Step 7: Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
    Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
    Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
Intro: Complete Motor guide for Robotics
Robot is an electromechanical device which is capable of reacting in some way to its environment, and take autonomous decisions or actions in order to achieve a
specific task.
Roboticists develop man-made mechanical devices that can move by themselves, whose motion must be modelled, planned, sensed, actuated and controlled, and
whose motion behavior can be influenced by “programming”.
This definition implies that a device can only be called a “robot” if it contains a movable mechanism, influenced by sensing, planning, actuation and control components.
Motors and actuators are the devices which make the robot movable. Motors and actuators convert electrical energy into physical motion. The vast majority of actuators
produce either rotational or linear motion.
In this instructables I will explain more common types of motors and actuators, their basics and how to control them.
Step 1: Types of Motors
You already know that electric motors are used to “actuate” something in your robot: its wheels, legs, tracks, arms, fingers, sensor turrets, camera, or weapon systems.
There are literally dozens of types of electric motors but I will discuss the most common types used in amateur robotics. Motors are classified as:
       AC motor
       Brushed DC motor
       Brushless DC motor
       Geared DC motor
       Servo motor
       Stepper motor
       DC Linear Actuator
AC (alternating current) motors are rarely used in mobile robots because most of the robots are powered with direct current (DC) coming from batteries. Also, since
electronic components use DC, it is more convenient to have the same type of power supply for the actuators as well. AC motors are mainly used in industrial
environments where very high torque is required, or where the motors are connected to the mains / wall outlet. So, I will not explain about AC motors here.
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
Step 2: Motor Controller
A motor controller is an electronic device that helps microcontroller to control the motor. Motor controller acts as an intermediate device between a microcontroller, a
power supply or batteries, and the motors.
Although the microcontroller (the robot’s brain) decides the speed and direction of the motors, it cannot drive them directly because of its very limited power (current and
voltage) output. The motor controller, on the other hand, can provide the current at the required voltage but cannot decide how the motor should run.
Thus, the microcontroller and the motor controller have to work together in order to make the motors move appropriately. Usually, the microcontroller can instruct the
motor controller on how to power the motors via a standard and simple communication method such as UART or PWM. Also, some motor controllers can be manually
controlled by an analogue voltage (usually created with a potentiometer).
The physical size and weight of a motor controller can vary significantly, from a device smaller than the tip of your finger used to control a mini sumo robot to a large
controller weighing several Kg. The size of a motor controller is usually related to the maximum current it can provide. Larger current means larger size.
Since there are several types of motors, there are several types of motor controllers (different type of motor requires different type of controller) :
       Brushed DC motor controllers: used with brushed DC, DC gear motors, and many linear actuators.
       Brushless DC motor controllers: used with brushless DC motors.
       Servo Motor Controllers: used for hobby servo motors.
       Stepper Motor Controllers: used with unipolar or bipolar stepper motors depending on their kind.
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
Step 3: Brushed DC Motor
A brushed DC motor is one which uses two brushes to conduct current from source to armature. There are several variations on the brush DC motor theme but
permanent magnet DC motor (PMDC) is used extensively in robotics. Brushed DC motors are widely used in applications ranging from toys to push-button adjustable car
seats. Brushed DC (BDC) motors are inexpensive, easy to drive, and are readily available in all sizes and shapes.
The brush DC Motor consists of six different components: the axle, armature/rotor, commutator, stator, magnets, and brushes. A Brush DC Motor consists of two
magnets facing the same direction, that surrounding two coils of wire that reside in the middle of the Brush DC Motor, around a rotor. The coils are positioned to face the
magnets, causing electricity to flow to them. This generates a magnetic field, which ultimately pushes the coils away from the magnets they are facing, and causes the
rotor to turn.
The Brush DC Motor has two terminals; when voltage is applied across the two terminals, a proportional speed is outputted to the shaft of the Brush DC Motor. A Brush
DC Motor consists of two pieces: the stator which includes the housing, permanent magnets, and brushes, and the rotor, which consists of the output shaft, windings and
commutator. The Brush DC Motor stator is stationary, while the rotor rotates with respect to the Brush DC Motor stator.The stator generates a stationary magnetic field
that surrounds the rotor. The rotor, also called the armature, is made up of one or more windings. When these windings are energized they produce a magnetic field. The
magnetic poles of this rotor field will be attracted to the opposite poles generated by the stator, causing the rotor to turn. As the motor turns, the windings are constantly
being energized in a different sequence so that the magnetic poles generated by the rotor do not overrun the poles generated in the stator. This switching of the field in
the rotor windings is called commutation.
Unlike other electric motor types (i.e., brushless DC, AC induction), BDC motors do not require a controller to switch current in the motor windings. Instead, the
commutation of the windings of a BDC motor is done mechanically. A segmented copper sleeve, called a commutator, resides on the axle of a BDC motor. As the motor
turns, carbon brushes slide over the commutator, coming in contact with different segments of the commutator. The segments are attached to different rotor windings,
therefore, a dynamic magnetic field is generated inside the motor when a voltage is applied across the brushes of the motor. It is important to note that the brushes and
commutator are the parts of a BDC motor that are most prone to wear because they are sliding past each other.
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
Step 4: Controlling of Brushed DC Motor
By the term controlling I mean both direction control and the speed control. The direction of the DC motor can be reverse by simply reversing the polarity of the battery
connection. The speed of the motor can be control by changing the voltage level and dc voltage level can be changed by PWM signal. For higher voltage level speed will
be higher and for lower voltage level speed will also be lower.
Practically, Drive circuits are used in applications where a controller of some kind is being used and speed control is required. The purpose of a drive circuit is to give the
controller a way to vary the current in the windings of the BDC motor. The drive circuits discussed in this section allow the controller to pulse width modulate the voltage
supplied to a BDC motor. It is more efficient way to vary the speed of a BDC motor compared to traditional analog control methods. In some cases the motor only needs
to spin in one direction then a single switch topology with PWM modulation can be used to vary the voltage applied to the motor and thus to control its speed. The higher
the PWM duty cycle, the faster the motor will go. Figure shows circuit for driving a BDC motor in one direction using single FET (field effect transistor).
Note that inthe circuit there is a diode across the motor. This diode is there to prevent Back Electromag- netic Flux (BEMF) voltage from harming the MOSFET. BEMF is
generated when the motor is spinning. When the MOSFET is turned off, the winding in the motor is still charged at this point and will produce reverse current flow. D1
must be rated appropriately so that it will dissipate this current.
Resistors R1 and R2 in the Figure are important to the operation of the circuit. R1 protects the microcontroller from current spikes while R2 ensures that transistor is
turned off when the input pin is tristated.
When positioning is required or when both directions of rotation are needed (most robots need) a full H-bridge with PWM control is used. The H-Bridge is a 4-transistor
circuit that allows you to reverse the current flow to the motor. With an H-Bridge and a PWM pin, you can control both the speed and direction of the motor.
To understand please follow the next step.
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
Step 5: H Bridge
A H bridge is an electronic circuit that enables a voltage to be applied across a load in either direction. These circuits are often used in robotics and other applications to
allow DC motors to run forwards and backwards.
An H-bridge is a transistor-based circuit capable of driving motors both clockwise and counter-clockwise. It’s an incredibly popular circuit – the driving force behind
countless robots that must be able to move both forward and backward. Fundamentally, an H-bridge is a combination of four transistors with two inputs lines and two
outputs:(Note: there’s usually quite a bit more to a well-designed H-bridge including flyback diodes, base resistors and Schmidt triggers.)
To understand this, the H-bridge must be broken into its two sides, or half-bridges. Referring to Q1 and Q2 make up one half-bridge while Q3 and Q4 make up the other
half-bridge.
Each of these half-bridges is able to switch one side of the BDC motor to the potential of the supply voltage or ground. When Q1 is turned on and Q2 is off, for instance,
the left side of the motor will be at the potential of the supply voltage. Turning on Q4 and leaving Q3 off will ground the opposite side of the motor. The arrow labeled I
FWD shows the resulting current flow for this configuration. The switching elements (Q1..Q4) are usually bi-polar or FET transistors, in some high-voltage applications
IGBTs.
Note the diodes across each of the transistor (D1-D4).
These diodes protect the transistors from current spikes generated by BEMF when the transistors are switched off. The top-end of the bridge is connected to a power
supply (battery for example) and the bottom-end is grounded.
The capacitors (C1-C4) are optional. The value of these capacitors is generally in the 10 pF range. The purpose of these capacitors is to reduce the RF radiation that is
produced by the arching of the commutators.
The basic operating mode of an H-bridge is fairly simple: if Q1 and Q4 are turned on, the left lead of the motor will be connected to the power supply, while the right lead
is connected to ground. Current starts flowing through the motor which energizes the motor in (let’s say) the forward direction and the motor shaft starts spinning.
..............................................................................................................
If Q2 and Q3 are turned on, the reverse will happen, the motor gets
energized in the reverse direction, and the shaft will start spinning backwards.
.............................................................................................................................................................................................
In a bridge, you should never ever close both Q1 and Q2 (or Q3 and Q4) at the same time. If you did that, you just have created a really low-resistance path between
power and GND, effectively short-circuiting your power supply. This condition is called ‘shoot-through’ and is an almost guaranteed way to quickly destroy your bridge,
or something else in your circuit.
There are many different models and brands of H-Bridge IC is available. Most commonly used are Texas Instruments L293NE or a Texas Instruments SN754410 and
L298 from STMicroelectronics.
L293D
The L293NE/SN754410 is a very basic H-bridge. It has two bridges, one on the left side of the chip and one on the right, and can control 2 motors. It can drive up to 1
amp of current, and operate between 4.5V and 36V. The small DC motor generally used in robot bots can run safely off a low voltage so this H-bridge will work just fine.
The H-bridge has the following pins and features:
           Pin 1 (1,2EN) enables and disables our motor whether it is give HIGH or LOW
           Pin 2 (1A) is a logic pin for our motor (input is either HIGH or LOW)
           Pin 3 (1Y) is for one of the motor terminals
           Pin 4-5 are for ground
           Pin 6 (2Y) is for the other motor terminal
           Pin 7 (2A) is a logic pin for our motor (input is either HIGH or LOW)
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
       Pin 8 (VCC2) is the power supply for our motor, this should be given the rated voltage of your motor
       Pin 9-11 are unconnected as you are only using one motor in this lab
       Pin 12-13 are for ground
       Pin 14-15 are unconnected
       Pin 16 (VCC1) is connected to 5V Below is a diagram of the H-bridge and which pins do what in our example.
       Included with the diagram is a truth table indicating how the motor will function according to the state of the logic pins (which are set by our Arduino).
Bear in mind that all motors are available in different sizes.
Small motors are engineered for applications where compactness is valued over torque. While there are small high-torque motors, these tend to be expensive because
they use rare earth magnets, high efficiency bearings, and other features that add to their cost.Large motors may produce more torque, but also require higher currents.
High current motors require larger capacity batteries, and bigger control circuits that won’t overheat and burn out under the load. Therefore, match the size of the motor
with the rest of the robot. Don’t overload a small robot with a large motor when big size isn’t important.When decided on the size of the motor, compare available torque
after any gear reduction. Gear reduction always increases torque. The increase in torque is proportional to the amount of gear reduction: if the reduction is 3:1, the torque
is increased by about three times (but not quite, because of frictional losses).
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
Step 6: Arduino DC Motor Control
As you already know DC motor must not connect directly to arduino pin because it can burn your arduino. So you must connect a transistor between arduino and motor.
Let's first control a small DC motor using single transistor. Using single transistor you know only speed can be control. PWM is used to control speed of a DC motor.
Connect your circuit as Figure-1. Arduino PWM pin must be connected to the base pin of transistor.
   /*
   Single transistor DC Motor control
   */
   int motorPin = 3;
   int speed = 100;
   void setup()
   {
     pinMode(motorPin, OUTPUT);
   }
   void loop()
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
     {
       // analogWrite() function is used to generate PWM signal.
       // speed define the duty cycle of the PWM.
       // if the speed = 0 means duty cycle is 0 and motor is off
       // the maximum value of speed can be 255, then motor will run with maximum speed
       analogWrite(motorPin, speed);
       delay(1000); // wait 1 sec
       analogWrite(motorPin, 175);
       delay(1000);
       analogWrite(motorPin, 255); // maximum speed
       delay(1000);
     }
Now, connect the motor using H-Bridge IC (I used L293 here). Follow Fig-3 & Fig-4. We can control both speed and direction now. Pin 9 is used as PWM pin and a switch
is added to control the speed.
const    int   switchPin   =   2;   //   switch input
const    int   motor1Pin   =   3;   //   H-bridge leg 1 (pin 2, 1A)
const    int   motor2Pin   =   4;   //   H-bridge leg 2 (pin 7, 2A)
const    int   enablePin   =   9;   //   H-bridge enable pin
//In the setup(), set all the pins for the H-bridge as outputs,
//and the pin for the switch as an input. The set the enable pin high
//so the H-bridge can turn the motor on.
void setup() {
   // set the switch as an input:
   pinMode(switchPin, INPUT);
     // set all the other pins you're using as outputs:
     pinMode(motor1Pin, OUTPUT);
     pinMode(motor2Pin, OUTPUT);
     pinMode(enablePin, OUTPUT);
     pinMode(ledPin, OUTPUT);
     // set enablePin high so that motor can turn on:
     digitalWrite(enablePin, HIGH);
 }
//In the main loop() read the switch. If it’s high,
//turn the motor one way by taking one H-bridge pin high and the other low.
// If the switch is low, reverse the direction by reversing the states of
// the two H-bridge pins.
void loop() {
   // if the switch is high, motor will turn on one direction:
   if (digitalRead(switchPin) == HIGH) {
     digitalWrite(motor1Pin, LOW);   // set leg 1 of the H-bridge low
     digitalWrite(motor2Pin, HIGH); // set leg 2 of the H-bridge high
   }
   // if the switch is low, motor will turn in the other direction:
   else {
     digitalWrite(motor1Pin, HIGH); // set leg 1 of the H-bridge high
     digitalWrite(motor2Pin, LOW);   // set leg 2 of the H-bridge low
   }
 }
next
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/
   Step 7: Conclusion
I am still working on this instructable. Very soon more steps will be added.
If you like this please Vote for me.
   Related Instructables
                               GOduino III - the
                               breadboard-                                                             How-To: Motors
                               friendly                                               GOduino II =
 Arduino - Grove                                   DIY Servo Motor   Arduino + L298                    by
 I2C Motor Driver              Arduino-based                         motor driver     Arduino +
                                                   by vu2aeo                          L293D Variable   audreyobscura
 by ThisIsSteve                robot controller                      integrated by
                               by techbitar                                           Speed Motor
                                                                     MustafaT2        Controller by
                                                                                      techbitar
Advertisements
   Comments
                 1 comments   Add Comment
                       arduino-raspi says:                                                                              Dec 13, 2015. 1:50 PM REPLY
                       Very nice work!
  http://www.instructables.com/id/Complete-Motor-Guide-for-Robotics/