Convert a DVD case to Robot!

Submitted by vijuram on May 13, 2008 - 7:01pm.

Objective: To build a robot with the parts available at your home. I always wanted to build a robot on my own. So how to start! I did a lot of research by gaining knowledge on robotics, sensors and microcontroller; www.societyofrobots.com is one of my favorite sites, which helped me to understand the basics of building robots and I am glad to be a part of this society today. I wanted to share my experience of building my first robot with you all.

 

Description: Since I am a beginner I wanted to start with the basic stuff. First the microcontroller: In my learning I have seen people always talking about three microcontrollers for programming the robots; BASIC Stamp, PIC and ATMega; I went for BASIC Stamp which is readily available in Radio Shack which comes with great electronics like servos, LED’s, jumper cables, switches and reading material. The material is very helpful and explains how each electronic part works along with the diagram, a simple code in BASIC programming language. I was able to go through all the chapters within a week and was able to successfully complete all the projects given in the book. I got an idea about the sensors, servos etc and it is time for me to put this into test. As my first task I thought of building an unmanned vehicle with the help of sensors and servos.

The Base: After searching for a base for my vehicle I decided to use my old DVD (non-workable) player case. I had to dismantle all its parts to detach the base along. I attached two servos to the front side (one on either side) of the base after cutting it in proper dimension. I am not a CAD user hence I used a ruler and approximation to cut them with the help of a normal kitchen knife. I do not want to use another set of servos at the back and hence attached a small wheel taken from the wheel chair. This wheel helps the robot to turn freely. Now this becomes a 3-wheeled robot. I attached a third servo, which is a standard servo (standard servo – rotates 180 degrees and continuous servo – rotates continuously) to the front-middle of the base and attached an ‘L’- shaped plastic to the top, the ultrasonic sensor will fit into this ‘L’ shaped plastic. This now acts as the eye for this robot and rotates 180 degrees looking forward. This was the most exciting moment of this project J

 

How it works: When the battery is on, the microcontroller signals the two servo motor to rotate forward and also signals the ultrasonic sensor to scan for objects at the front. If the sensor finds an object within say ‘x’ meters it signals back the microcontroller to stop the robot. Now it signals the standard servo to rotate both directions to measure the distance with the help of the sensor. The two values are then compared and the greatest of them is chosen. If the left side has the greatest it means the robot can now go towards the left and vice versa. The controller then instructs the robot to move in that direction. I am using the simple differential drive algorithm where if the robot wants to move towards left, it stops the left side servo and rotates the right-hand side servo forward, this will enable the robot to turn left and vice versa. This continues until I remove the battery from the microcontroller of the battery drains completely.

 

Parts:

BASIC Stamp Microcontroller: 1 $80 from Radio shack

1 Standard servo: comes with the BASIC Stamp kit

2 Continuous rotation Servo: $13 each (I had to order online)

1 DVD case for the base

2 wheels from my old toy car

1 wheel taken from the wheel chair (for the rear wheel)

1 L shaped plastic taken from the CPU monitor screen

Necessary tools for cutting and drilling holes

1 9V battery for the BASIC Stamp

 

Programming Language used:

I used the BASIC programming language for this as the compiler comes with the package. You can also program this in C or any other language you are familiar with but BASIC is very easy and I recommend for the beginners using BASIC Stamp microcontroller. Some people also build their own microcontroller circuit which I do not want to because my aim was to build a robot and not programming the microcontroller. Here is the source code for my robot. It took me around 3 months to study about the robotics and come up with this robot.

 

' {$STAMP BS2}

' {$PBASIC 2.5}

 

'Author         : vijay narayan

'Date Created   : 6/28/07

'Date Modified  : 7/3/07

'Purpose: Robot program to simulate unmanned vehicle

 

 

'---minimum pulse duration for clockwise-most---

RIGHTMOST VAR Word

 

'---minimum pulse duration for anti-clockwise-most---

LEFTMOST VAR Word

 

'---center pulse duration---

CENTER VAR Word

 

'---pause duration---

PAUSE_DURATION VAR Word ' the smaller the value, the smoother the turn

 

'---used for loop variant---

i VAR Word

 

'---keep track of current position---

CURRENT_POSITION VAR Word

 

'---the step for the turning---

ROTATION_STEP VAR Word

 

 

'**********initialize the values**********

RIGHTMOST = 200'190

LEFTMOST = 1100'1180

CENTER = 650

PAUSE_DURATION = 10         ' the bigger the value, the slower it is

CURRENT_POSITION = CENTER   ' always turn to the center point

ROTATION_STEP = 20          ' the bigger the value, the more it turns

'SCANNING_STEP = 1           ' the bigger the value, the faster it scans

'***********************************

 

 

LeftInch VAR Word

RightInch VAR Word

 

'Constants for pins

RightWheel  CON   15

LeftWheel   CON   13

CenterWheel CON   11

USSensor     CON   3

 

 

'Variables

rawDist VAR Word

inches VAR Word

cm VAR Word

Counter VAR Byte

 

'Starting routine

GOSUB Main

 

'This will ping the Ultrasonic when the sensor is pointing to the left side

PINGSensorOnLeft:

    FOR Counter = 1 TO 10

      LOW USSensor

      PULSOUT USSensor,1

      PULSIN USSensor,1,rawDist

 

      rawDist = rawDist * 10

      rawDist = rawDist / 2

      LeftInch =  rawDist ** 889

      DEBUG HOME, "left inchs ",  DEC LeftInch, CR

      PAUSE 100

    NEXT

    DEBUG HOME, "Final left inchs ",  DEC LeftInch, CR

 

RETURN

 

'This will ping the Ultrasonic when the sensor is poining to the right side

PINGSensorOnRight:

    FOR Counter = 1 TO 10

      LOW USSensor

      PULSOUT USSensor,1

      PULSIN USSensor,1,rawDist

 

      rawDist = rawDist * 10

      rawDist = rawDist / 2

      RightInch =  rawDist ** 889

      DEBUG HOME, "right inchs ",  DEC RightInch, CR

      PAUSE 100

    NEXT

    DEBUG HOME, "Final right inchs ",  DEC RightInch, CR

RETURN

 

'This will ping the Ultrasonic when the sensor stand is center

PINGSensor:

    LOW USSensor

    PULSOUT USSensor,1

    PULSIN USSensor,1,rawDist

 

    PULSOUT RightWheel,1000

    PULSOUT LeftWheel,500

 

    rawDist = rawDist * 10

    rawDist = rawDist / 2

    inches =  rawDist ** 889

    cm = rawDist ** 2257

    DEBUG HOME, "inchs ",  DEC inches, CR

RETURN

 

Main:

  'Entry point of the program

  'This function would mak the robot move forward and check for the distance

  GOSUB Centralize

  DO

 

    GOSUB PINGSensor

 

    IF inches <= 70 THEN

      GOSUB Scan

      'GOSUB MoveReverse

      'GOSUB MoveLeft

      'GOSUB MoveRight

    ENDIF

 

   ' DEBUG HOME, "cm ",  DEC cm,CR

    PAUSE  20

  LOOP

RETURN 'end of Main function

 

'This function would step the robot back wards

MoveReverse:

   ' LOW USSensor

   ' PULSOUT USSensor,0

    FOR Counter = 1 TO 10

       PULSOUT RightWheel,500

       PULSOUT LeftWheel,1000

       PAUSE 100

    NEXT

RETURN

 

'Differential Move algorithm

'Function to make the robot move left

MoveLeft:

    DEBUG HOME, "Move left ", CR

    FOR Counter = 1 TO 46

      PULSOUT RightWheel,0

      PULSOUT LeftWheel,500

      PAUSE 50

    NEXT

RETURN

 

'Function to make the robot move right

MoveRight:

    DEBUG HOME, "Move right ", CR

    FOR Counter = 1 TO 46

      PULSOUT RightWheel,1000

      PULSOUT LeftWheel,0

      PAUSE 50

    NEXT

RETURN

 

'Function to scan from left to right and vice versa

Scan:

   'At the time of scan we dont want the PING to sense anythings

   LOW USSensor

   PULSOUT USSensor,0

 

   FOR i = CURRENT_POSITION TO LEFTMOST 'STEP SCANNING_STEP

      PULSOUT CenterWheel, i

      CURRENT_POSITION = i

      PAUSE PAUSE_DURATION

   NEXT

   'Now measure the distance at this point

   GOSUB PINGSensorOnLeft

 

   LOW USSensor

   PULSOUT USSensor,0

 

   FOR i = CURRENT_POSITION TO RIGHTMOST 'STEP SCANNING_STEP

      PULSOUT CenterWheel, i

      CURRENT_POSITION = i

      PAUSE PAUSE_DURATION

   NEXT

 

   'Now measure the distance at this point

   GOSUB PINGSensorOnRight

 

   'Compare between the distance

   IF LeftInch > RightInch THEN

      GOSUB Centralize

      GOSUB MoveLeft

   'ELSEIF LeftInch < RightInch THEN

   ELSE

      GOSUB Centralize

      GOSUB MoveRight

   ENDIF

 

 

RETURN

 

'function to bring back the central motor to the center

Centralize:

   FOR i = 1 TO 40

      PULSOUT CenterWheel, CENTER

      PAUSE PAUSE_DURATION

   NEXT

   CURRENT_POSITION = CENTER

RETURN

 

Pictures:

I did not realize that I had to take pictures of the parts that I used for building this robot at the time of the design but I would like to share the video.

 

 

http://www.youtube.com/watch?v=AVghsPP_Rn4

 

 

Conclusion: This is my first project and I am really glad that I was able to complete this successfully. I am looking forward to build more robots in future and would be sharing my experience with you all. Thanks for your time in reading this and expect to drop your comments.

 

Keep building Robots and Have fun!

 

( categories: )