Sunday, February 26, 2012

Beginners Robotics : Motors


This article covers the 3 main types of motors which are used in robotics namely the DC motor , Stepper motor and the Servo motor. The article also gives various circuits which can be used to drive the motors . This article is a must for all those starting out or are confused about motors .
Nearly all the robots we make have motors be it servo , stepper or some other unless you are using stuff like pneumatics , synthetic muscle etc . Any way coming back to the point there are mainly 3 types of motors

DC Motors

DC motors are widely used in robotics because of their small size and high energy output. They are excellent for powering the drive wheels of a mobile robot as well as powering other mechanical assemblies.

Ratings and Specifications

Several characteristics are important in selecting a DC motor. The first two are its input ratings that specify the electrical characteristics of the motor.
Operating Voltage.
If batteries are the source of power for the motor, low operating voltages are desirable because fewer cells are needed to obtain the specified voltage. However, the electronics to drive motors are typically more efficient at higher voltages. Typical DC motors may operate on as few as 1.5 Volts or up to 100 Volts or more. Robotics often use motors that operate on 6, 12, or 24 volts because most robots are battery powered, and batteries are typically available with these values.
Operating Current.
The ideal motor would produce a great deal of power while requiring a minimum of current. However, the current rating (in conjunction with the voltage rating) is usually a good indication of the power output capacity of a motor. The power input (current times voltage) is a good indicator of the mechanical power output. Also, a given motor draws more current as it delivers more output torque. Thus current ratings are often given when the motor is stalled. At this point it is drawing the maximum amount of current and applying maximum torque. A low voltage (e.g., 12 Volt or less) DC motor may draw from 100 mA to several amperes at stall, depending on its design.
Speed.
Usually this is specified as the speed in rotations per minute (RPM) of the motor when it is unloaded, or running freely, at its specified operating voltage. Typical DC motors run at speeds from one to twenty thousand RPM. Motor speed can be measured easily by mounting a disk or LEGO pulley wheel with one hole on the motor, and using a slotted optical switch and oscilloscope to measure the time between the switch openings.
Torque.
The torque of a motor is the rotary force produced on its output shaft. When a motor is stalled it is producing the maximum amount of torque that it can produce. Hence the torque rating is usually taken when the motor has stalled and is called the stall torque. The motor torque is measured in ounce-inches (in the English system) or Newton-meters (metric). The torque of small electric motors is often given in milli-Newton-meters (mN-m) or 1/1000 of a N-m. A rating of one ounce-inch means that the motor is exerting a tangential force of one ounce at a radius of one inch from the center of its shaft. Torque ratings may vary from less than one ounce-inch to several dozen ounce-inches for large motors.
Power.
The power of a motor is the product of its speed and torque. The power output is greatest at about half way between the unloaded speed (maximum speed, no torque) and the stalled state (maximum torque, no speed). The output power in watts is about (torque) x (rpm) / 9.57.
DC Motor Control

HBridge
To control a DC motor we have to first convert the Digital 01 output into one which can drive the motor for this we use the HBridge . Given below is a simple HBridge circuit
                       

When both the points A & B are "HIGH" Q1 and Q2 are in saturation. Hence the bases of Q3 to Q6 are grounded. Hence Q3,Q5 are OFF and Q4,Q6 are ON . The voltages at both the motor terminals is the same and hence the motor is OFF. Similarly when both A and B are "LOW" the motor is OFF. When A is HIGH and B is LOW, Q1 saturates ,Q2 is OFF. The bases of Q3 and Q4 are grounded and that of Q4 and Q5 are HIGH. Hence Q4 and Q5 conduct making the right terminal of the motor more positive than the left and the motor is ON. When A is LOW and B is HIGH ,the left terminal of the motor is more positive than the right and the motor rotates in the reverse direction. You could have used only the SL/SK100s ,but BC148 used have a very low hFE ~70 and they would enter the active region for 3V(2.9V was what I got from the computer for a HIGH) . You can ditch the BC148 if you have a SL/SK100 with a decent value of hFE ( like 150).The diodes protect the transistors from surge produced due to the sudden reversal of the motor. The approx. cost of the circuit without the motor is around Rs.40.

After the Hbridge is you wish to control the power of the motor this can be easily done with a PWM based control
Pulse Width Modulation
Pulse width modulation is a technique for reducing the amount of power delivered to a DC motor. Instead of reducing the voltage operating the motor (which would reduce its power), the motor's power supply is rapidly switched on and off. The percentage of time that the power is on determines the percentage of full operating power that is accomplished. This type of motor speed control is easier to implement with digital circuitry. It is typically used in mechanical systems that will not need to be operated at full power all of the time.
 

Figure illustrates this concept, showing pulse width modulation signals to operate a motor at 75%, 50%, and 25% of the full power potential.
Stepper Motors
The shaft of a stepper motor moves between discrete rotary positions typically separated by a few degrees. Because of this precise position controllability, stepper motors are excellent for applications that require high positioning accuracy. Stepper motors are used in X-Y scanners, plotters, and machine tools, floppy and hard disk drive head positioning, computer printer head positioning, and numerous other applications.
                         
Stepper motors have several electromagnetic coils that must be powered sequentially to make the motor turn, or step, from one position, to the next. By reversing the order that the coils are powered, a stepper motor can be made to reverse direction. The rate at which the coils are respectively energized determines the velocity of the motor up to a physical limit. Typical stepper motors have two or four coils. For more information on stepper motors you can read the stepper motor tutorial on the website . Any way here is a very simple stepper controller


Servo Motors
Servo motors incorporate several components into one device package:
* a small DC motor;
* a gear reduction drive for torque increase;
* an electronic shaft position sensing and control circuit.
The output shaft of a servo motor does not rotate freely, but rather is commanded to move to a particular angular position. The electronic sensing and control circuitry -- the servo feedback control loop -- drives the motor to move the shaft to the commanded position. If the position is outside the range of movement of the shaft, or if the resisting torque on the shaft is too great, the motor will continue trying to attain the commanded position.

Servo Motor Control
A servo motor has three wires: power, ground, and control. The power and ground wires are simply connected to a power supply. Most servo motors operate from five volts.


The servo controller receives position commands through a serial connection which can be provided by using one I/O pin of another microcontroller, or a PCs serial port! The communication protocol, that is used for this controller, is the same with the protocol of all the famous servo controllers of Scott Edwards Electronics Inc., this makes this new controller 100% compatible with all the programs that have been written for the "SSC" controllers...! However, if you want to write your own software, it is as easy as sending positioning data to the serial port as follows:
Byte1 = Sync (255)
Byte2 = Servo #(0-15)
Byte3 = Position (0-254)
So sending a 255,4,150 would move servo 4 to position 150, sending 255,12,35 would move servo 12 to position 35.
The standards of the serial communication should be the following: 9600 baud, 8 data bits, 1 stop bit and no parity.
The control signal consists of a series of pulses that indicate the desired position of the shaft. Each pulse represents one position command. The length of a pulse in time corresponds to the angular position. Typical pulse times range from 0.7 to 2.0 milliseconds for the full range of travel of a servo shaft. Most servo shafts have a 180 degree range of rotation. The control pulse must repeat every 20 milliseconds. This pulse signal will cause the shaft to locate itself at the midway position +/-90 degrees. The shaft rotation on a servo motor is limited to approximately 180 degrees (+/-90 degrees from center position). A 1-ms pulse will rotate the shaft all the way to the left, while a 2-ms pulse will turn the shaft all the way to the right. By varying the pulse width between 1 and 2 ms, the servo motor shaft can be rotated to any degree position within its range.

Friday, February 24, 2012

Robot Basics


A robotic hand, developed by NASA, is made up of metal segments moved by tiny motors. The hand is one of the most difficult structures to replicate in robotics.



Robot Basics

The vast majority of robots do have several qualities in common. First of all, almost all robots have a movable body. Some only have motorized wheels, and others have dozens of movable segments, typically made of metal or plastic. Like the bones in your body, the individual segments are connected together with joints.
Robots spin wheels and pivot jointed segments with some sort of actuator. Some robots use electric motors and solenoids as actuators; some use a hydraulic system; and some use a pneumatic system (a system driven by compressed gases). Robots may use all these actuator types.
A robot needs a power source to drive these actuators. Most robots either have a battery or they plug into the wall. Hydraulic robots also need a pump to pressurize the hydraulic fluid, and pneumatic robots need an air compressor or compressed air tanks.
The actuators are all wired to an electrical circuit. The circuit powers electrical motors and solenoids directly, and it activates the hydraulic system by manipulating electrical valves. The valves determine the pressurized fluid's path through the machine. To move a hydraulic leg, for example, the robot's controller would open the valve leading from the fluid pump to a piston cylinder attached to that leg. The pressurized fluid would extend the piston, swiveling the leg forward. Typically, in order to move their segments in two directions, robots use pistons that can push both ways.
NASA's Urbie climbing stairs
Photo courtesy NASA JPL
The robot's computer controls everything attached to the circuit. To move the robot, the computer switches on all the necessary motors and valves. Most robots arereprogrammable -- to change the robot's behavior, you simply write a new program to its computer.
Not all robots have sensory systems, and few have the ability to see, hear, smell or taste. The most common robotic sense is the sense of movement -- the robot's ability to monitor its own motion. A standard design uses slotted wheels attached to the robot's joints. An LED on one side of the wheel shines a beam of light through the slots to a light sensor on the other side of the wheel. When the robot moves a particular joint, the slotted wheel turns. The slots break the light beam as the wheel spins. The light sensor reads the pattern of the flashing light and transmits the data to the computer. The computer can tell exactly how far the joint has swiveled based on this pattern. This is the same basic system used in computer mice.
These are the basic nuts and bolts of robotics. Roboticists can combine these elements in an infinite number of ways to create robots of unlimited complexity.

Robot Dynamics - Getting the Specs Right

Well this article covers the dynamics involved in making a good robot! So let’s see what are the dynamics involved in making a perfect Robot there are many factors that can affect like RPM torque of the motor, diameter of the wheel friction between the tyres and the floor etc. We shall discuss how to calculate your requirement and then proceed into its application. For that you’ll need to brush up your knowledge of kinematics and dynamics the first few pages explain the concept’s involved if you feel you know all the concepts right just go directly to the implementation of the concepts.

Rotations per Minute (RPM):

It’s the number of times the axle of the motor spins in a minute. I.e. the number of rotations the wheel makes in a minute. We get motors having different rpm’s the common ones being 45, 60,100,150,200,250,300 in normal gear motors and higher rpm’s for brushless motors. 

Velocity:

Velocity is the distance travelled in unit time (unit time can be anything like second’s minutes or hours) so the units are meters per second or kilometres per hour etc. So how do we apply this to our robot and calculate the velocity of our robot. First of all we need to know the RPM of the motor used and the diameter of the wheel. Now we come to the fundamental concepts of circles. Consider a point on a circle let’s assume this point is touching the ground when rotating the circle without slippage the point again touches the ground when the circle finishes one rotation .the distance travelled during this time period is the distance travelled for one rotation 



And that distance is the product of the diameter and Ï€ (Ï€=3.14). The total distance travelled per minute. 


Speed of Bot = RPM x Distance per rotation


I have used diameter in calculating if you consider the radius it will be 2Ï€R.

Example:-

Let’s consider an example 

RPM = 150;

Diameter = 7 cm (0.07 m)

Distance per rotation = 3.14 x 0.07 = 0.2198

Speed = 0.2198 x 150 = 32.98 m/min or 0.5496 m/s

Torque:- 

It is the weight carrying capacity of the motor. The general units of torque are Kg/cm. I.e. the weight it can lift when attached at a distance of 1cm. Torque is also known as moment of force it is the force multiplied with the perpendicular distance from the point where the force is acting so the higher the torque the greater the force the robot can produce 



Here you should notice the greater the radius the lesser will be the force at the end point you’ll need to consider this when choosing the radius of the wheel. 


Stall Torque: - 

This is the force that can stop the motors from rotating i.e. this force is equal to the maximum torque that is produced by the motors so the forces act against each other and nullify .This is also the condition when the motor pulls the maximum current and can damage itself. Care has to be taken so that the motor doesn’t stall. A motor shouldn’t be left in stalled condition for a long time you will end up losing the motor. In India we don’t find any local shop mentioning the torque of the motors (some online shops do list) and those things are the ones sold at the shop just look for similar models and take in those values for calculations. It is equally important to know the stall current of the motor so as to decide upon your power supply the stall torque is the highest current that a motor takes up when in stalled condition.




Acceleration:-

This is a measure as to how fast will your bot get to its top speed. This is very tricky when correlating it to electronic motors so ill just explain you one thing straight if you feel your robot is going slower than it should and getting faster after a few seconds it’s because you are sacrificing acceleration for more weight (your bot is over loaded) you need to get higher torque motors with the same RPM ratings to get your bot to its top speed right from the beginning even here there will be a small time delay but it will be better than running a motor with less torque it will never reach the desired speed.

Traction:-

Traction is the maximum frictional force that can be produced between two surfaces without slipping. In general many people call this as grip on the floor. I.e. The force that prevents your robot from sliding off. you might be in a dilemma as to if high traction is good or not many believe that traction is only necessary for Sumo bot’s or battle bots but that isn’t true traction is required for all your bots if you have a good traction the turning and the control of the bot will be easy and precise. So, how can you have a good traction? The first thing I’d recommend is get your bot better wheels. If your robots motor has a higher torque which you think it won’t be using (like when you end up using overkill motors just because you can afford them or you have them lying around) then increase the weight of your bot as traction increases with the weight of the body. But we wise when involving concepts like this as you’ll need to be clear with the game plan to take these decisions as a wrong choice will make the bot vulnerable in some aspect or the other. Ok to make things simple ill give a few examples where you can put this into action but remember you are sacrificing some torque for this so you’ll need higher torque motors. In Battle robotics or if your robot should move on any other moving object or climbing steep inclines your bot SHOULD have a good traction in the other cases is might not be that needed but it’s always better to have some. 

How to calculate forces?

F = m.a (mass x acceleration)

Calculating forces is a must when you build your Robot! Let’s get through the basics once. Every time we consider a set of forces we need to get the resultant force and its value to know how the body experiencing the force will behave. The resultant force as the name suggests is the net force acting i.e. the actual force the body is experiencing though there a number of forces the body experiences only the resultant of the forces acting on it. Look at the diagram below to understand.



In the above figure we are considering all the forces to be acting from centre but in reality there would be a rotational force due to the forces 10F, 5F and 10F there would be rotational torque produced. Like in the figure below. 



Component of Force

You might consider some cases where force is acting at an angle then what will be the resultant force in the direction of movement of the body. Look at the diagram below and you’ll get it!



So in general when the force is acting at an angle as shown in the figure the force along the direction of movement can be found out by resolving it into its components like shown in the above diagram.
Some general Force you can encounter:-

Force of Gravitation:-

This is the force that is applied on the body directed towards the centre of the earth. This force is equal to the weight of the body (f=m.a; a=9.8 m/s^2; f=m.g)



Normal Reaction

Normal reaction is the force exerted opposite to the direction of the applied force this supports the Newton’s Third law. I.e. it gets things going for example it’s responsible for us standing on the ground.



CALCULATING FORCES ON INCLINES


UP the INCLINE:-

When climbing up the incline a component of the gravitational force acts against us so the force we have on the robot is reduced by this component as it acts in the opposite direction of the force we are applying to get our bot to the top the diagram below ill make it clear.



Down the Incline

When coming down the incline the component acts along with you so the force increases. Look at the figure below so get a clear picture



Friction on inclines:

Some times your bot might start slipping on inclines this is because the magnitude of the component of weight is greater than the force of friction in between the tyres and the surface of the inclines. When applying this concept we don’t have much to do other than to get a good set of tyres for your bot. 

How things are related!

Now I’ll tell you how all the concepts are related with each other. 

Distance from shaft v/s the effective force at the end point though the torque will remain constant for any value of the distance from shaft of the motor we should notice that as the distance from centre increases the force acting on the tip is decreasing. Because T=rxf and the total torque remains constant for a particular motor and you are increasing the radius so the effective force at the tip is reduced in turn. Have a look at the two examples below to get a clear picture



In this example the effective force at the end is torque/radius = 1 Kg



The same motor now has an effective force of 2Kg (Torque/radius = 2Kg) when the radius is reduced to 5 cm so it has to be noted that we shouldn’t go for huge radii unless inevitable. In the two pictures I used rod’s the same concept can be applied to wheels also

* When calculating force requirement for lifting objects you’ll need to consider the distance up to its centre of gravity!

Velocity V/s Rpm and Wheel Diameter

The velocity is also another thing which will give the winning edge to your robot so it is also a thing you need to think about! There are two ways in which you can increase your velocity either increase the Rpm or the Wheel diameter. You can do either of them but in general it is advised to go for higher rpm motor they somehow seem to have an edge over increasing wheel diameter but whatever you are doing you need to keep the requirement of torque in mind otherwise the winning edge if not understood or applied properly will make you lose.

Rpm V/S Torque:-

We could be confused in choosing the correct combinations of Rpm and torque. In general they are inversely proportional i.e. for a particular base motor as the rpm increases the torque decreases the maximum torque for a motor occurs at 0 RPM and the Minimum torque occurs when the motor is running at its highest possible RPM if you’re not utilizing that much torque Where does that extra torque go? The extra torque is used in accelerating your Bot though not to 100% most of it goes that way.

Let’s go a bit electrical!

You might have mastered these concepts and made a bot involving good mechanics but you’ll be powering up the entire thing using electrical energy. Many people design bot’s excellent mechanical concepts but fail when choosing the power supply. I have myself had the leading edge of a good enough power supply many times as the opponents though had good mechanism etc they didn’t have enough juice to pump through their bot. Whenever choosing a power supply you should keep in mind the power requirement of each and every part of your bot and get appropriate batteries and also never ignore the voltage recommendations of the components you are using. For example you have four motors on your bot which consume 3amps current at stall (yes! You’ll need to consider the stall current when calculating) then the battery should have a current capacity at minimum 13amps (one amp extra just to be sure) alongside you should also know the voltage requirements if the rating of the motors is 12 volts the battery should be rates 12V 13 A (considering motors are wired parallel) 

Example:-

Challenge: - SUMO ROBOT

Now it’s time we apply all the things we learnt to building an example Bot! Let’s take up a challenge we have to build a Sumo bot and the general restriction a sumo bot goes like 

Specifications:-

Max Weight 5Kg

Dimensions 30x30x30

Max voltage 12V

Now our task is to build a bot that will emerge as a winner in the competition .So let’s start out calculating our requirements of force the first main task will be to push the other bot outside the arena also there will be other tasks like pushing bricks against inclines etc in qualification rounds now let’s get to business so what would be our force requirements? First and foremost we will have to push the other bots outside the arena and they will weight around 5 Kg most people will go wrong here only they will consider this force only but there are other factors you will also need to consider the weight of your bot and some other force dampening factors like rough terrain etc. So the force will need to be around 11kg (5Kg to push + 5Kg to carry our bot + 1Kg for possible situations) now comes the incline part we need to know the angle of inclination beforehand generally around 25 degrees . Then comes in the speed of the bot this is dependent on you how much do you want? Well something around 0.50 m/s is good for sumo bots. Now let’s list out all the 

Requirements:-

Force: - 11 Kg

Velocity: - 0.50 m/s

So now we have the force required that is the effective force at the tip of the wheels what we have left to calculate is the diameter of the wheel the RPM and the torque of the motors required. Lets first get through the velocity first we have seen that

Speed of Bot = RPM x Distance per rotation


Now, 0.50 m/s = Rps distance per rotation 
(Rps = rotations per second *conversion taken as speed in m/s)
And Distance per rotation = 3.14 x 2 x radius 
Keeping it aside,
Torque = Radius x Force
And Rps = Speed of the Bot / Distance per rotation
= 0.50/2x3.14xRadius
As we can see there are a number of possible combinations you’ll need to chose based on the material available in general the diameter of the wheels available is 7cm (radius = 3.5cm) or (0.035 m) now let’s calculate the rpm needed
RPM = RPS x 60
Rps = 0.50/2x3.14x0.035
= 2.2747
RPM = Rps x 60
= 2.2747 x 60 = 136.482
So now we got the Rpm to be 136.482 and the nearest readymade values is 150 RPM 
Torque = Radius x Force
= 3.5 x 11
= 38.5 Kg/cm

Again this load is shared by the number of motors on your bot! So if it is 2 the rating would be 150RPM and 19.25 Kg/cm torque.


NOTE:-
The calculations above are considering a 100% efficient functioning of everything but that just never happens and will never happen so you’ll need to keep all efficiency reducing factors in mind I will just list a few examples undercharges batteries, things which reduce the traction of your bot like oil, water plastic sheets etc. Also things which can increase traction like adhesives etc other factors like, slopes, errors in motors can also affect your calculations by a good margin so consider all these and then decide what will be your winning configuration.