Monday, 31 March 2014

Robot Dynamics- Getting the Specifications 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) 

Saturday, 1 March 2014

Differential Drive

Differential Drive
AVR ATmega8 Based Line Follower
Easy to make PID LFR Robot.


Differential drive is a drive system in which both motion and steering can be done by two set of powered wheels. In differential drive their is a LEFT wheel and RIGHT wheels. Both are powered. It does not requires turning of front wheel for the steering like we steer car or bikes. To turn the vehicle (or robo) the LEFT and RIGHT wheels are rotated at "different" speeds. That's why its called differential drive. For example If the RIGHT wheels rotates faster than the LEFT wheels then the robot will turn towards LEFT.
For this robot we will use the following rotation of wheel for the steering and straight motion.

Motion
LEFT Wheel
RIGHT Wheel
Forward
Counter Clockwise
Clockwise
Backward
Clockwise
Counter Clockwise
Rotate LEFT
Clockwise
Clockwise
Rotate RIGHT
Counter Clockwise
Counter Clockwise



So moving and steering the robot is just the matter of controlling two DC motors.
Once you go through the articles you know how to start a particular motor either in CW or CCW direction. HereMotorA will be the right motor and the MotorB will be the left motor. So the following code snippets does the job.

Move Robo Forward

MotorA(MOTOR_CW,255);  //Right Motor Moves Clockwise (CW) with Full Speed (255)
MotorB(MOTOR_CCW,255); //Left Motor Moves Counter Clockwise (CCW) with Full Speed (255)

Move Robo Backward
MotorA(MOTOR_CCW,255); //Right Motor Moves Counter Clockwise (CCW) with Full Speed (255)
MotorB(MOTOR_CW,255); //Left Motor Moves  Clockwise (CW) with Full Speed (255)

Rotate Robo Left
MotorA(MOTOR_CW,255);  //Right Motor Moves Clockwise (CW) with Full Speed (255)
MotorB(MOTOR_CW,255); //Left Motor Moves  Clockwise (CW) with Full Speed (255)

Rotate Robo Right
MotorA(MOTOR_CCW,255); //Right Motor Moves Counter Clockwise (CCW) with Full Speed (255)
MotorB(MOTOR_CCW,255); //Left Motor Moves  Counter Clockwise (CCW) with Full Speed (255)
I have explained the code here so it does not create confusion when the whole program (which is reasonably large)of the robot is presented to you.

Sample Code #1
This code moves the robot forword for some time (t) and then moves the robot backwords for same time (t).

/*********************************************************************

                 LFR Board Sample Programs

               ------------------------------------


Description :  Demonstrate forward and backward motion of robot.

          
                  
**********************************************************************/


#include <avr/io.h>
#include <util/delay.h>

#include "lib/motor/motor.h"

//Simple Delay Function
void Wait();

void main()
{
   //Initialize motor subsystem
   MotorInit();

   while(1)
   {

      //Move Robot Forward
      MotorA(MOTOR_CW,255);
      MotorB(MOTOR_CCW,255);


      //Wait
      Wait();

      //Move Robot Backward
      MotorA(MOTOR_CCW,255);
      MotorB(MOTOR_CW,255);

      //Wait
      Wait();

   }

}

void Wait()
{
   uint8_t i;

   for(i=0;i<250;i++)
   _delay_loop_2(0);

}

HEX File Ready to Burn


Sample Code #2
Turing demo. This will show you how to make left and right turns. The robot rotates left from some time then rotates right for sometime. This process is repeated as long as the robot is supplied with power.

/*********************************************************************

                 LFR Board Sample Programs

               ------------------------------------


Description :  During demo. This will show you how to make left and right turns.
            The robot rotates left from some time then rotates right for sometime.
            This process is repeated as long as the robot is supplied with power.
         



                  
**********************************************************************/


#include <avr/io.h>
#include <util/delay.h>

#include "lib/motor/motor.h"

//Simple Delay Function
void Wait();

void main()
{
   //Initialize motor subsystem
   MotorInit();

   while(1)
   {

      //Turn Robot Right
      MotorA(MOTOR_CW,255);
      MotorB(MOTOR_CW,255);


      //Wait
      Wait();

      //Turn Robot Left
      MotorA(MOTOR_CCW,255);
      MotorB(MOTOR_CCW,255);

      //Wait
      Wait();

   }

}

void Wait()
{
   uint8_t i;

   for(i=0;i<250;i++)
   _delay_loop_2(0);

}

HEX File Ready to Burn

Sample Code #3
This will show you how to make your robot take turn while moving forward. That means the robot will keep moving forward while always taking a slow left turn. This will make robot go round in an anti-clock wise circle.
This effect is achived my running the left wheel slow in comparision to the right wheel.

/*********************************************************************

                 LFR Board Sample Programs

               ------------------------------------


Description :  During demo. This will show you how to make your robot take
            turn while moving forward. That means the robot will keep
            moving forward while always taking a slow left turn. This
            will make robot go round in an anti-clock wise circle.

         


                  
**********************************************************************/


#include <avr/io.h>
#include <util/delay.h>

#include "lib/motor/motor.h"

void main()
{
   //Initialize motor subsystem
   MotorInit();



   //Run the left motor (B) slow in comparison to right motor.
   //This will make the robot take left turn while moving forward.
   MotorA(MOTOR_CW,255);
   MotorB(MOTOR_CCW,128);

}

Sample Code #4
Zig Zag motion demo.

/*********************************************************************

                 LFR Board Sample Programs

               ------------------------------------


Description :  Zig-Zag Motion demo

                  
**********************************************************************/


#include <avr/io.h>
#include <util/delay.h>

#include "lib/motor/motor.h"
#include "lib/led/led.h"

void Wait();

void main()
{
   //Initialize motor subsystem
   MotorInit();

   //Initialize LED subsystem
   LEDInit();

   LEDOn(1);

   MotorA(MOTOR_CW,128);
   MotorB(MOTOR_CCW,255);

   Wait();


   while(1)
   {
      LEDOn(5);
      LEDOff(1);
      MotorA(MOTOR_CW,255);
      MotorB(MOTOR_CCW,128);

      Wait();
      Wait();

      LEDOn(1);
      LEDOff(5);
      MotorA(MOTOR_CW,128);
      MotorB(MOTOR_CCW,255);

      Wait();
      Wait();
   }

}

void Wait()
{
   uint8_t i;

   for(i=0;i<60;i++)
   {
      _delay_loop_2(0);
   }

}


HEX File Ready to Burn