Buy from Amazon

Powered by Blogger.

Comments

Recent

Bottom Ad [Post Page]

Contact Form

Name

Email *

Message *

Search This Blog

Travel the world

Full width home advertisement

Pages

Author Description

Hey there, We are Blossom Themes! We are trying to provide you the new way to look and use the blogger templates. Our designers are working hard and pushing the boundaries of possibilities to widen the horizon of the regular templates and provide high quality blogger templates to all hardworking bloggers!

Post Page Advertisement [Top]

Climb the mountains

Latest Updates

Wednesday, 14 March 2018

Android Controlled Robot using 8051 Microcontroller

Posted By: Unknown - March 14, 2018







Android Controlled Robot using 8051 Micro-controllerAndroid Controlled Robot using 8051 Micro-controller
In this project we are going to build an Android Phone controlled robot using 8051 microcontrollers and Bluetooth module. The robot is designed using DC motors and the direction of DC motors will be controlled by the commands received from the android application. The status of the robot is sent back to the Android app. This project will also help for interfacing of HC-05 Bluetooth module with 8051 microcontrollers. We already used Bluetooth module to control home appliances with 8051.

Components Required:

  • 8051 microcontroller (AT89S52)
  • HC-05 Bluetooth module
  • L293D Motor Driver
  • Robot chassis
  • DC Motors (2)
  • Wheels (2)
  • Castor Wheel
  • Jumper wires
  • Bluetooth terminal android app

Circuit Diagram:

 Android Controlled Robot Circuit diagram using 8051 Micro-controller

Android Controlled Robot Block diagram using 8051 Microcontroller

 

8051 Microcontroller:

8051 microcontroller is a 8-bit microcontroller which has 128 bytes of on chip RAM, 4K bytes of on chip ROM, two timers, one serial port and four 8bit ports. 8052 microcontroller is an extension of 8051 microcontroller. In this project we are using AT89S52 microcontroller. The table below shows the comparison of 8051 family members.
              Feature
8051
8052
ROM (in bytes)
4K
8K

RAM (bytes)
128
256
Timers
2
3
I/O pins
32
32
Serial port
1
1
Interrupt sources
6
8

HC-05 Bluetooth Module:

Bluetooth-Module-HC-05
HC-05 is a serial Bluetooth module. It can be configured using AT commands. It can work in three different configurations (Master, Slave, Loop back). In our project we will be using it as a slave. The features of HC-05 module includes,
  • Typical -80dBm sensitivity.
  • Default baud rate: 9600bps , 8 data bits , 1 stop bit , no parity.
  • Auto-pairing pin code: “1234” default pin code
  • It has 6 pins.
  • Vcc and Gnd pins are used for powering the HC-05.
  • Tx and Rx pins are used for communicating with the microcontroller.
  • Enable pin for activating the HC-05 module. when it is low , the module is disabled
  • State pin acts status indicator. When it is not paired/connected with any other Bluetooth device, LED flashes continuously. When it is connected/paired with any other Bluetooth device, then the LED flashes with the constant delay of 2 seconds.

L293D Motor Driver IC:

L293D is a dual H-bridge motor driver IC. This acts as a current amplifier, the output of L293D drives the DC Motors. It contains two inbuilt H-bridge circuits. In common mode of operation , it can drive two dc motors simultaneously in both the directions. The below table shows the pin description of L293D IC. Here are some projects using L293D Motor Driver.
L293D Motor Driver ICL293D Pinout
Pin Description
Pin No.
Name
Function
1
Enable 1,2
Enable pin for motor 1
2
Input 1
Input 1 for motor 1
3
Output 1
Output 1 for motor 1
4
Gnd
Ground (0V)
5
Gnd
Ground (0V)
6
Output 2
Output 2 for motor 1
7
Input 2
Input 2 for motor 1
8
Vcc 2
Supply voltage for motors(5V)
9
Enable 3,4
Enable pin for motor 1
10
Input 3
Input 1 for motor 2
11
Output 4
Output 1 for motor 2
12
Gnd
Ground (0V)
13
Gnd
Ground (0V)
14
Output 4
Output 2 for motor 2
15
Input 4
Input 2 for motor 2
16
Vcc 1
Supply voltage (5V)

Working of Android Phone Controlled Robot:

In this Smart Phone controlled Robot, the user of android app sends the data to 8051 microcontroller through HC-05 module. The received data is compared in 8051 microcontroller and the decision is made accordingly. The below table shows the direction of motors and status of robot for different received characters.
Received character
Motor 1
Motor 2
Status of robot
f
Forward
Forward
Moves forward
b
Backward
Backward
Moves backward
r
Forward
Backward
Moves Right
l
Backward
Forward
Moves left
s
Off
Off
Stopped
Android Controlled Robot in action

The Bluetooth terminal app allows us to emulate a Bluetooth terminal. This app supports bidirectional communication and this app is compatible with most of the devices.
The steps below show how to install and use this app.
1. Download and install Bluetooth terminal app on your android phone. The app can be downloaded from the below link.
2. After installing the app, open the app and turn on Bluetooth.
3. Select the device and click on connect option. After successful connection, we  can start sending data to HC-05 module.
Bluetooth terminal app window  Connected phone to Robot Bluetooth
Check the Code Explanation below to see how the character is sent and received by 8051 Microcontroller to rotate the required motors.

Code explanation:

The complete C program and demonstration Video for this project is given at the end of this project. The code is split into small meaningful chunks and explained below.
For L293D interfacing with 8051 microcontrollers, we have to define pins on which L293D is connected to 8051 microcontroller. In1 pin of motor 1 is connected to P2.0, In2 pin of motor 1 is connected to P2.1, In1 pin of motor 2 is connected to P2.2, In2 pin of motor 2 is connected to P2.3
sbit m1f=P2^0;             // in1 pin of motor1
sbit m1b=P2^1;             // in2 pin of motor1
sbit m2f=P2^2;             // in1 pin of motor2
sbit m2b=P2^3;             // in2 pin of motor2

Next we have to define some functions which are used in the program. Delay function is used to create specified time delay. Txdata function is used to transmit data through serial port . Rxdata function is used to receive data from serial port.
void delay(unsigned int)  ;             //function for creating delay
char rxdata(void);                           //function for receiving a character through serial port of 8051
void txdata(unsigned char);        //function for sending a character through serial port of 8051


In this part of the code we are going to configure 8051 microcontroller for serial communication. TMOD register is loaded with 0x20 for timer 1, mode 2 (auto reload). SCON register is loaded with 0x50 for 8 data bits, 1 stop bit and receive enabled. TH1 register is loaded with 0xfd for baud rate of 9600 bits per second. TR1=1 is used to start the timer.
  TMOD=0x20; 
   SCON=0x50; 
   TH1=0xfd; 
   TR1=1;        
In this part of the code, the returned character of rxdata function is stored in the variable ‘s’ for further use.
s=rxdata();                          //receive serial data from hc-05 bluetooth module

In this part of the code, we have to compare the received character with preassigned characters for different directions. If the received character is ‘f ‘, then the robot has to move in forward direction. This is accomplished by making m1f, m2f pins high and m1b, m2b pins low. Once this is done, next we have to send status of robot to android app. This is done with the help of txdata function. The same process is repeated for different characters received and decision is taken accordingly. Table 1 shows different values of m1f, m1b, m2f, m2b for different directions of movement of robot.
if(s=='f')               //move both the motors in forward direction
 {
      m1f=1;
      delay(1);
      m1b=0;
      delay(1);
      m2f=1;
      delay(1);
      m2b=0;
      delay(1);
      for(i=0;msg1[i]!='\0';i++)          //send status of robot to android app through bluetooth
     {
         txdata(msg1[i]);
     }
 }

m1f
m1b
m2f
m2b
Motor 1 rotation
Motor 2 rotation
Status of robot
1
0
1
0
forward
forward
Moving forward
0
1
0
1
reverse
reverse
Moving backward
1
0
0
1
forward
reverse
Moving right
0
1
1
0
reverse
forward
Moving left
0
0
0
0
stopped
stopped
stopped

This is you can rotate the Robot car in any direction by controlling the four motors using 8051 microcontroller. This robot can also be controlled using DTMF with 8051, if you don’t have android phone.
Also check all the Robotics Projects here.
Code: 
/*this program is for controlling a robot using bluetooth and android app*/
 
#include<reg51.h>
 
unsigned char ch1;
unsigned char s;
 
sbit m1f=P2^0;             // in1 pin of motor1
sbit m1b=P2^1;             // in2 pin of motor1
sbit m2f=P2^2;             // in1 pin of motor2
sbit m2b=P2^3;             // in2 pin of motor2
  
void delay(unsigned int)  ;        //function for creating delay
char rxdata(void);                 //function for receiving a character through serial port of 8051 
void txdata(unsigned char); //function for sending a character through serial port of 8051 
 
void main(void)
 {
unsigned char i;
unsigned char msg1[]={"robot is moving forward"};
unsigned char msg2[]={"robot is moving backward"};
unsigned char msg3[]={"robot is moving right"};
unsigned char msg4[]={"robot is moving left"};
unsigned char msg5[]={"robot is stopped"};
 
TMOD=0x20;   //timer 1 , mode 2 , auto reload
SCON=0x50;    //8bit data , 1 stop bit , REN enabled
TH1=0xfd;     //timer value for 9600 bits per second(bps)
TR1=1;            
 
while(1)             //repeat forever
{
     s=rxdata(); //receive serial data from hc-05 bluetooth module
if(s=='f') //move both the motors in forward direction
     {
         m1f=1;
   delay(1);
         m1b=0;
   delay(1);
         m2f=1;
   delay(1);
         m2b=0;
   delay(1);
        for(i=0;msg1[i]!='\0';i++)
{
    txdata(msg1[i]);
 
    }
 
     else if(s=='b')  
     {
         m1f=0;
    delay(1);
         m1b=1;
    delay(10);
         m2f=0;
    delay(10);
         m2b=1;
    delay(10);
    for(i=0;msg2[i]!='\0';i++)   
         {
   txdata(msg2[i]);
    }
     }
 
     else if(s=='r')
     {
         m1f=1;
         delay(1);
         m1b=0;   
   delay(10);
         m2f=0;
   delay(10);
         m2b=1;
delay(10);
for(i=0;msg3[i]!='\0';i++)   
{
    txdata(msg3[i]);
                }
 
     else if(s=='l')
     {
         m1f=0;
         delay(1);
         m1b=1;
    delay(1);
         m2f=1;
    delay(1);
         m2b=0;
    delay(1);
    for(i=0;msg4[i]!='\0';i++)
        {
    txdata(msg4[i]);
   } 
    }
 
     else if(s=='s')  
     {
         m1f=0;
         delay(1);
         m1b=0;
    delay(1);
         m2f=0;
    delay(1);
         m2b=0;
   delay(1);
   for(i=0;msg5[i]!='\0';i++)
        {
  txdata(msg5[i]);
   }
    }
      txdata('\n');  
     
                    }
}
 
char rxdata()
{
  while(RI==0);   //wait till RI becomes HIGH
  RI=0;           //make RI low
  ch1=SBUF;      //copy received data 
  return ch1;     //return the received data to main function.
}
 
void txdata(unsigned char x)
{
   SBUF=x; //copy data to be transmitted to SBUF
   while(TI==0); //wait till TI becomes high
   TI=0; //mae TI low for next transmission
}
 
void delay(unsigned int z)
{
  unsigned int p ,q;
  for(p=0 ; p<z ; p++)    //repeat for 'z' times
  {
    for(q=0 ; q<1375 ; q++);   //repeat for 1375 times
  }
}

build Arduino Metal Detector by arduino

Posted By: Unknown - March 14, 2018

build Arduino Metal Detector by arduino  


Metal Detector is a security device which is used for detecting metals which can be harmful, at various places like Airports, shopping malls, cinemas etc. Previously we have made a very simple Metal detector without a microcontroller, now we are building the Metal Detector using Arduino. In this project, we are going to use a coil and capacitor which will be responsible for the detection of metals. Here we have used an Arduino Nano to build this metal detector project. This is very interesting projects for all electronics lovers. Wherever this detector detects any metal near it, the buzzer starts beeping very rapidly. 



Required Components:

  1. Arduino (any)
  2. Coil
  3. 10nF capacitor
  4. Buzzer
  5. The 1k resistor
  6. 330-ohm resistor
  7. LED
  8. 1N4148 diode
  9. Breadboard or PCB
  10. Connecting jumper wire
  11. 9v Battery

Working Concept:

Whenever some current passes through the coil, it generates a magnetic field around it. And the change in the magnetic field generates an electric field. Now according to Faraday's law, because of this Electric field, a voltage develops across the coil which opposes the change in magnetic field and that’s how Coil develops the Inductance, means the generated voltage opposes the increase in the current. The unit of Inductance is Henry and formula to measure the Inductance is:
L = (μο * N2 * A) / l

Where,
L- Inductance in Henries
μο- Permeability, its 4π*10-7 for Air
N- Number of turns
A- Inner Core Area (πr2) in m2
l- Length of the Coil in meters

When any metal comes near to the coil then coil changes its inductance. This change in inductance depends upon the metal type. It's decreases for non-magnetic metal and increases for ferromagnetic materials like iron.
Depending on the core of the coil, inductance value changes drastically. In the figure below you can see the air-cored inductors, in these inductors, there will be no solid core. They are basically coils left in the air. The medium of flow of magnetic field generated by the inductor is nothing or air. These inductors have inductances of very less value.
Air Cored Inductors

These inductors are used when the need for values of few microHenry. For values greater than few milliHenry these are not a suitable one. In below figure you can see an inductor with ferrite core. These Ferrite Core inductor has very large inductance value.

Ferrite Core Inductors

Remember the coil wound here is a air cored one, so when a metal piece is brought near the coil, the metal piece acts as a core for the air cored inductor. By this metal acting as a core, the inductance of the coil changes or increases considerably. With this sudden increase in inductance of coil the overall reactance or impedance of the LC circuit changes by a considerable amount when compared without the metal piece.  

So here in this Arduino Metal Detector Project, we have to find inductance of the coil to detect metals. So to do this we have used LR circuit (Resistor-Inductor Circuit) that we already mentioned. Here in this circuit, we have used a coil having around 20 turns or winding with a 10cm diameter. We have used an empty tape roll and wind the wire around it to make the coil.
Coil of Metal Detector

Circuit Diagram:


Arduino Metal Detector Circuit Diagram
We have used an Arduino Nano for controlling whole this Metal Detector Project. A LED and Buzzer are used as metal detection indicator. A Coil and capacitor is used for detection of metals. A signal diode is also used for reduce the voltage. And a resistor for limiting the current to the Arduino pin.

Metal Detector using Arduino hardware implementation

Working Explanation:

Working of this Arduino Metal Detector is bit tricky. Here we provide the block wave or pulse, generated by Arduino, to the LR high pass filter. Due to this, short spikes will be generated by the coil in every transition. The pulse length of the generated spikes is proportional to the inductance of the coil. So with the help of these Spike pulses we can measure the inductance of Coil. But here it is difficult to measure inductance precisely with that spikes because that spikes are of very short duration (approx. 0.5 microseconds) and that is very difficult to be measured by Arduino.
Metal Detector using Arduino in action
So instead of this, we used a capacitor which is charged by the rising pulse or spike. And it required few pulses to charge the capacitor to the point where its voltage can be read by Arduino analog pin A5. Then Arduino read the voltage of this capacitor by using ADC. After reading voltage, capacitor quickly discharged by making capPin pin as output and setting it to low. This whole process takes around 200 microseconds to complete. For better result, we repeat measurement and took an average of the results. That’s how we can measure the approximate inductance of Coil. After getting the result we transfer the results to the LED and buzzer to detect the presence of metal. Check the Complete code given at the end of this Article to understand the working.

Complete Arduino code is given at the end of this Article. In programming part of this project, we have used two Arduino pins, one for generating block waves to be fed in Coil and second analog pin to read capacitor voltage. Other than these two pins, we have used two more Arduino pins for connecting LED and buzzer.
You can check the complete code and Demonstration Video of Arduino Metal Detectorbelow. You can see that whenever it detects some metal the LED and Buzzer starts to blink very fastly.
Code: 
#define capPin A5
#define buz 9
#define pulsePin A4
#define led 10
long sumExpect=0; //running sum of 64 sums
long ignor=0;   //number of ignored sums
long diff=0;        //difference between sum and avgsum
long pTime=0;
long buzPeriod=0; 
void setup()
{
  Serial.begin(9600);
  pinMode(pulsePin, OUTPUT);
  digitalWrite(pulsePin, LOW);
  pinMode(capPin, INPUT);
  pinMode(buz, OUTPUT);
  digitalWrite(buz, LOW);
  pinMode(led, OUTPUT);
}
void loop()
{
  int minval=1023;
  int maxval=0;
  long unsigned int sum=0;
  for (int i=0; i<256; i++)
  {
    //reset the capacitor
    pinMode(capPin,OUTPUT);
    digitalWrite(capPin,LOW);
    delayMicroseconds(20);
    pinMode(capPin,INPUT);
    applyPulses();
 
    //read the charge of capacitor
    int val = analogRead(capPin); //takes 13x8=104 microseconds
    minval = min(val,minval);
    maxval = max(val,maxval);
    sum+=val;
 
    long unsigned int cTime=millis();
    char buzState=0;
    if (cTime<pTime+10)
    {
      if (diff>0)
        buzState=1;
      else if(diff<0)
        buzState=2;
    }
    if (cTime>pTime+buzPeriod)
    {
      if (diff>0)
      buzState=1;
      else if (diff<0)
      buzState=2;
      pTime=cTime; 
    }
    if (buzPeriod>300)
    buzState=0;
    if (buzState==0)
    {
      digitalWrite(led, LOW);
      noTone(buz);
    }
    else if (buzState==1)
    {
      tone(buz,2000);
      digitalWrite(led, HIGH);
    }
 
    else if (buzState==2)
    {
      tone(buz,500);
      digitalWrite(led, HIGH);
    }
  }
  //subtract minimum and maximum value to remove spikes
  sum-=minval;
  sum-=maxval;

  if (sumExpect==0)
  sumExpect=sum<<6; //set sumExpect to expected value
  long int avgsum=(sumExpect+32)>>6;
  diff=sum-avgsum;
  if (abs(diff)<avgsum>>10)
  {
    sumExpect=sumExpect+sum-avgsum;
    ignor=0;
  }
  else
    ignor++;
  if (ignor>64)
  {
    sumExpect=sum<<6;
    ignor=0;
  }
  if (diff==0)
    buzPeriod=1000000;
  else
  buzPeriod=avgsum/(2*abs(diff)); 
}
void applyPulses()
{
    for (int i=0;i<3;i++)
    {
      digitalWrite(pulsePin,HIGH); //take 3.5 uS
      delayMicroseconds(3);
      digitalWrite(pulsePin,LOW);  //take 3.5 uS
      delayMicroseconds(3);
    }



Full Process  clip :


SCIENCE & TECHNOLOGY

Games & Multimedia

Copyright © 2013 Robotic projects idea and tools you need to buy ruspburry pi 3™ is a registered trademark.

Designed by Templateism. Built with Blogger Templates.