Build Robot from the parts near you

Objective: The main objective is to build robot from the parts available near you except for the electronics like the microcontroller, battery, servos etc.

Convert a DVD case to Robot!

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!

 

Walkbot

Objective: To build a robot that simulates the walk of a human being. I consider this to be one of the challenging projects I ever worked on and I am very happy to share this work with you.

 

Description: I always wanted to build a robot that simulates the walk of a human being with the parts available around. This robot walks with the help of two legs and the third leg (at the center) just for balancing. Balancing the robot with two legs is very challenging and I tried hard to implement in this project but I could not achieve it. I hope in future I would be able to do this. The legs are built to simulate the movement of the thighs and the knees. The string connected to the toe of the each leg is connected to the tin cap which is attached to the servo motor at the back which moves the knee portion of the leg whenever the tin cap rotates. The thighs are attached to different servos which controls it movement individually and separately from the knee portion. I used a photo sensor which is used to start and stop the robot. It took me around 2 months to complete this project and most of the time I spent in search of the parts and design.

 

How it works: When the 9v battery is inserted the power is on; closing the photo sensor will start the robot motion. The robot starts walking by moving the left and right legs individually. The robot can be stopped by again closing the photo sensor. The video explains better how the robot works.

 

Parts:

BASIC Stamp Microcontroller: 1 $80 from Radio shack

4 Standard servos

Photo sensor – 1 (to stop and start the robot)

Umbrella strings – 2 (to connect the knee to the tin cap)

Tin cap – 2 (for rotating the Umbrella strings)

CD spindle (for balancing the robot)

Old caterpillar toy for the case and legs

Necessary tools for cutting and drilling holes

1 9V battery for the BASIC Stamp

 

Programming Language used:

I used the same BASIC STAMP microcontroller used in my previous project (Convert a DVD case to a robot) and hence the same programming language.  The basic technique used here is to rotate the servo to the correct angle such that the leg movement is achieved accordingly. Most of the time it is done using trial and error method. Here is the source code for this work:

 

' {$STAMP BS2}

' {$PBASIC 2.5}

'Author         : vijay narayan

'Date Created   : 7/29/07

'Date Modified  : 8/28/07

'Purpose: program to simulate a walking robot

 

i VAR Word

time VAR Word

off VAR Byte

cnt VAR Byte

walkCount VAR Byte

 

'Constants for legs and knee

LeftLeg   CON   15

LeftKnee  CON   12

RightLeg  CON   7

RightKnee CON   4

PhotoSensor CON 2

USSensor CON 1

BaseWheel CON 9

 

 off = 1

 cnt = 1

 walkCount = 1

 PULSOUT BaseWheel, 580

 

 'stand still position

 FOR i = 1 TO 10

     PULSOUT LeftLeg,650

     PULSOUT LeftKnee,650

     PULSOUT RightLeg,600

     PULSOUT RightKnee,600

    PAUSE 10

 NEXT

 

DO

 

  DEBUG HOME, "Walkcount outside ", DEC walkCount, CR

  IF walkCount = 3 THEN

      DEBUG HOME, "Walkcount inside ", DEC walkCount, CR

      walkCount = 1

  ENDIF

 

  HIGH PhotoSensor

  RCTIME PhotoSensor,1, time

 

  IF time > 700 THEN

      IF off = 1 THEN

        off = 0

      ELSEIF off = 0 THEN

        off = 1

        cnt = 1

      ENDIF

  ENDIF

 

 'if off =1 then make it stand still

 IF off = 1 THEN

    'stand still position

    IF cnt = 1 THEN

       PULSOUT LeftLeg,650

       PULSOUT LeftKnee,650

       PULSOUT RightLeg,600

       PULSOUT RightKnee,600

       cnt = 0

    ENDIF

ENDIF

 

 'make the robot walk only of the flag = 0

 IF off = 0 THEN

       '''''''''''''''''''''''''''''''Left leg movement

    FOR i = 650 TO 900

      PULSOUT LeftLeg,i

      PULSOUT LeftKnee,i  'move up the knee'

    NEXT

 

    ' 'move the knee from back to front

    FOR i = 900 TO 600

      PULSOUT LeftKnee,i

    NEXT

 

    'bring back the leg to straight position

    FOR i = 900 TO 650

      PULSOUT LeftLeg,i

    NEXT

 

    PULSOUT LeftKnee,650

    PULSOUT LeftLeg,650

    'This should bring the right leg to the straight position

 

    '''''''''''''''''''''''''''''''Right leg movement

 

    'Move the right leg front

    FOR i = 600 TO 350

      PULSOUT RightLeg,i

    NEXT

 

     'move the knee from back to front

    FOR i = 600 TO 650

      PULSOUT RightKnee,i

    NEXT

 

    PAUSE 100

    'bring back the leg to straight position

    FOR i = 350 TO 600

      PULSOUT RightLeg,i

    NEXT

    PAUSE 100

    PULSOUT RightKnee,580

    PULSOUT RightLeg,580

 

    walkCount = walkCount + 1

  ENDIF

LOOP

 

 

Pictures:

I would like to share the video. I am having trouble attaching the youtube video here hence I am sharing the link.

 

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

 

Conclusion: This is my second project and I am really proud of this great achievement. I believe this would help people who ever wanted to build a robot that walks. Also I guess this would encourage the beginners who wanted to build robots with the parts available around you. Thanks for your time in reading this and expect to drop your comments.

 

More robots to come!