Friday 29 May 2015

Bump detection circuit for robot using aluminium foil and a transistor









 Its very simple to make a bump detection circuit for any autonomous robot, wherein the robot gets to know that it has bumped and can go back.

The mechanism is implemented using one NPN transistor and aluminum foils...

Components needed:

1. Any robot chassis that you are working on.
2. Aluminum foil.
3. Transistor
4. Any controller (here we have used Arduino).

Its Simple :


 Take a aluminium foil suitable to cover your robot that is likely to bump with walls or objects.

Paste it on your robot's body:


Now take a chart paper, and apply a layer of aluminium foil on it..






Attach wire with foils:


How to make it work?

When two foils come in contact with each other, a switch should change its state, which can cause interrupt to the controller.

We give Vcc to one strip. And the other strip should be the input to a switch. Here transistor comes to the rescue.  (look at the figure below) When the two strips don't touch each other, there is no input at the base of transistor, and output at the collector end is high. When contact is made, base gets +5V and transistor conducts, resulting to low output.





Now cut few paper strips and arrange it in a way that the colored strip is little away from the chassis.





We wanted our robo to go reverse and then right whenever it bumped. So this is the code:



#define mota1 4

#define mota2 53

#define motb1 7

#define motb2 6

#define en1 3

#define en2 5




void forward(void);

void reverse2(void);

void pause(void);

void right(void);

void setup()

{

  Serial.begin(9600);

  pinMode(19,INPUT);

  attachInterrupt(4,bump,LOW);

  pinMode(mota1,OUTPUT);

pinMode(mota2,OUTPUT);

pinMode(motb1,OUTPUT);

pinMode(motb2,OUTPUT);

pinMode(en1,OUTPUT);

pinMode(en2,OUTPUT);

}

void loop()

{


    forward();

 

}


void bump()

{

  for(long i = 0; i < 10000; i++){

    pause();

  }

  for(long i = 0; i < 30000; i++){

    reverse2();

  }

  for(long i = 0; i < 60000; i++){

    right();

}

}


void forward()

{

analogWrite(en1,125);

analogWrite(en2,125);

digitalWrite(mota1,HIGH);

digitalWrite(mota2,LOW);

digitalWrite(motb1,HIGH);

digitalWrite(motb2,LOW);

}

void reverse2(void){

  analogWrite(en1,255);

   analogWrite(en2,255);

   digitalWrite(mota1,LOW);

   digitalWrite(mota2,HIGH);

   digitalWrite(motb1,LOW);

   digitalWrite(motb2,HIGH);

}


void right(void)

{


        analogWrite(en1,0);

        analogWrite(en2,255);

        digitalWrite(mota1,HIGH);

        digitalWrite(mota2,LOW);

        digitalWrite(motb1,HIGH);

        digitalWrite(motb2,LOW);

  }

  void pause()

  {

    analogWrite(en1,0);

        analogWrite(en2,0);

  }




No comments:

Post a Comment

Powered by Blogger.