Monday, November 20, 2017

Arduino code for obstacle avoiding robot using ultrasonic sensor


//connect trig pin of ultrasonic sensor to port 5


const int trig = 5;

 //connect echo pin of ultrasonic sensor to port 7
const int echo = 7;

 //giving motor connections as follows
const int m1a = 8;
const int m1b = 9;
const int m2a = 12;
const int m2b = 13;

void setup() 
{
  // activate serial monitor
 Serial.begin(9600);

 // defining trig pin as output since it produces sound waves
 pinMode(trig, OUTPUT);

 // defining echo pin as input since it receives sound waves
 pinMode(echo, INPUT);

 // defining motor pins as outputs
 pinMode(m1a, OUTPUT);
 pinMode(m1b, OUTPUT);
 pinMode(m2a, OUTPUT);
 pinMode(m2b, OUTPUT);
}

void loop() 
{
  // define two variables to store time and distance
 long duration, distance;

 // code for producing sound waves from transmitter part of sensor
 digitalWrite(trig, LOW);
 delayMicroseconds(2);
 digitalWrite(trig, HIGH);
 delayMicroseconds(10);
 digitalWrite(trig, LOW);

 // finding time using pulseIn function and assign it into the variable duration
 duration = pulseIn(echo, HIGH); // in microsecond

 // calculating distance by multiplying time and velocity (0.034 cm per microsecond)
 // it is then divided by 2 since the wave has traveled twice the distance between the sensor and the obstacle 
 distance = duration * 0.034/2; //in cm

// print distance on serial monitor 
Serial.println(distance);

// checking whether the distance is less than 20 cm (may be varied)
 if (distance < 20)
    {
      // give command to take turn (left or right). Below code may vary according to the connection
      digitalWrite(m1a, HIGH);
      digitalWrite(m1b, LOW);
      digitalWrite(m2a, LOW);
      digitalWrite(m2b, HIGH);
    }

// checking whether the distance is greater than or equal to 20 cm   
else if (distance >= 20)
   {
      // give command to go straight. Below code may vary according to the connection
      digitalWrite(m1a, HIGH);
      digitalWrite(m1b, LOW);
      digitalWrite(m2a, HIGH);
      digitalWrite(m2b, LOW);
   }

// giving a delay of one second   
delay(1000);
}
// recommended to visit Arduino website and Instructables website 

Saturday, November 4, 2017

Additive Manufacturing

What is additive manufacturing? Before explaining additive manufacturing, let’s try to know what subtractive manufacturing is. Consider turning process in lathe machine as an example. There will be a blank of metal say mild steel and probably in cylindrical shape. We want to make something out of mild steel blank so what we do is we remove some material from it. That is we remove unwanted material from the work piece in other words we subtract material from the work piece so it is an example for subtractive manufacturing. Let’s take another example; we want to make a wooden door with creative designs on it. How would it be made? There will be a wooden material. After taking proper measurement, the unwanted materials are removed so that the remaining will result in the required shape and size. Here also we subtract material from the work piece so it is also an example for subtractive manufacturing. Then what will be additive manufacturing? It is nothing but adding something out of something to make something. In simple terms Additive Manufacturing (AM) is an umbrella term used to describe the technologies that builds 3D objects by adding layer upon layer of materials. That is we design the object and model it using CAD techniques. We input the CAD file into the machine and material will be supplied to the machine via filament like forms. The machine will read and understand the CAD file and produce the 3D object by adding layer upon layer fashion by accurately relating to the cross section of the object in the CAD file. 

The term 3D printing is commonly used in place of AM and the term 3D printer is used for a machine which works on AM techniques. Even though there are some differences between those but for understanding, those differences don’t matter for the time being. Then what is the principle of operation? There are many techniques or processes to produce 3D objects by adding layer upon layer; those will be explained in a different article. For the sake of understanding I mention some names. Stereo Lithography (SLA), Digital Light Processing (DLP), Free Form Fabrication (FFF), Electron Beam Machining (EBM), Selective Laser Sintering (SLS), Selective Deposition Lamination (SDL) etc.
Now let’s discuss the various application of additive manufacturing. Someone says that additive manufacturing technique is a revolution like computer and internet. We can agree or disagree with this but AM does create some revolution to the society. From the early stages to till now, medical industry is dominating the use of additive manufacturing techniques. These processes are not substitute for traditional manufacturing processes. For mass production these cost more. But the traditional manufacturing processes have many limitations. Conventional processes may not be suitable for working on new materials such as smart materials, composites and not economical if the needed parts are very less in number. There comes 3D printing. 3D printing or AM can be used to produce unique things in terms of material, shape or other design parameters. These are cost effective for unit things. They don’t look at the shape but they only consider the CAD file. They read what is there in CAD file after converting into the G-code and make the objects accordingly. This is very suitable for medical applications. The shape and size of heart, bone, tooth etc. will be different for different people and by 3D printing these can be made very easily. This is the reason why medical industry largely depends upon the AM techniques. 

Aerospace sector was also an early adopter of AM techniques. The aircraft and rocket components are made of different composite materials. Traditional manufacturing methods may not work well on these new materials. 3D printing overcomes this limitation. Secondly the rocket parts or aircraft parts have complex shapes and designs. Conventional machining methods may become expensive and face difficulty to produce such models. Even if it is possible to make these complex parts there is another big problem. That is these areas are of research interest. For research purpose or any other thing, the possibility of need of design change is higher. So the shape and size of the objects may also vary. Conventional subtractive manufacturing method becomes less use because of these factors. But AM does overcome these. There is no change needed for a 3D printer to produce an different object while there are many things from small scale to big scale is essential to be changed to meet the production of new object in traditional methods.

Automotive sector also started to use 3D printing techniques for manufacturing especially in sports cars and bikes because they can manufacture complex profiled parts without any extra cost. They can do new experiments. R&D works get simpler. Prototype development gets easier. Interestingly jewelry sector also exploits the power of additive manufacturing. They can try new designs and new models very easily. This is a huge advantage for them both in terms attracting customers and reducing cost. For the sake of demonstration, architectures also use 3D printing techniques. Astonishingly they now seek for direct construction method for building their firms. For making robotic components also 3D printing is very much useful. The application area of 3D printing or additive manufacturing is very large and actually it reduces the product life cycle time from ideation to actual product and there by now we can say that anything can be manufactured now whatever we think in our head.

There are also limitations for additive manufacturing. In most cases the problems are associated with the type of process or technique so those will be discussed in the respective article as I mentioned above. Some general cons of AM are discussed below. The time taken to produce one product is quit higher. Conventional processes make many things at little time and are suitable for mass production while additive manufacturing method is not suitable for mass production as it decreases the productivity. Even though for large firms, it is cost effective, it is expensive for small scale users. Buying a decent 3D printer itself costs high. There is also liability issue. The layered structure is also a problem. It decreases the smoothness and there by affects the quality. Even thought there are many limitations for additive manufacturing, more researches are being done and hope these problems will be vanished away. 

Featured Post

Words from the Prophet Muhammad (pbuh)'s last sermon

“Remember, one day you will appear before Allah and answer for your deeds. So beware, do not astray from the path of righteousness aft...