CS122A-Fall Quarter, 1998


Lab 5 : The Sugar in My Coffee Cup Experiment: A Robot Race

Prof. Frank Vahid

Lab prepared by Tony Givargis, with the help of Roman Lysecky, Deepa Varghese, and Jason Villarreal

The objective of this experiment is to program an embedded processor, namely the 8052, to perform some autonomous Robot guidance. Well almost! The goal of the lab, or the "game", is to pickup sugar cubes from a tray in front of the Robot and drop them into a nearby coffee cup. The number of sugar cubes dropped into the cup, within a pre-determined time, will be your score. You will compete against your classmates.

The Game

In this experiment, a Robot will be interfaced to an 8052. Since the actual Robot does not have a feed-back loop, i.e., sensors reading its current position, you will be allowed to use two (2) buttons to manually provide the processor with feed-back. In defining your game strategy, you are allowed to use these two buttons for any purpose. In addition, the Embedded System will have a LCD display.

Now for the bad news, there is only one Robot available for this experiment. It is in B256 across the hall from B265, which is down the hall from B255, which is across the hall from B252. You will need to make an appointment to work on this experiment. The Robot will remain in B256 AT ALL TIMES. Now for the good news, you do not have to build any circuits. There is a circuit and some sample c code available to talk to the Robot, read/write to the LCD and read the status of the two buttons. All that you have to do is write the code for the game.

The Robot

In case you are wondering how the Robot works, here is a brief description. The Robot has five electric motors allowing it to have five degrees of freedom, namely, base, shoulder, elbow, wrist, and gripper. The Robot is attached to the 8052 using five wires. One of these is the ground, others are A, B, C and D. The following truth table describes the Robot movements.

A

B

C

D

Robot Movement

0

0

0

0

Turn the wrist counter-clock-wise

0

0

0

1

Turn the wrist clock-wise

0

0

1

0

Turn the base counter-clock-wise

0

0

1

1

Turn the base clock-wise

0

1

0

0

Move the elbow down

0

1

0

1

Move the elbow up

0

1

1

0

Move the shoulder up

0

1

1

1

Open the gripper

1

0

0

0

Close the gripper

1

0

0

1

Move the shoulder down

1

0

1

0

None

1

0

1

1

None

1

1

0

0

None

1

1

0

1

None

1

1

1

0

None

1

1

1

1

None

Once again, a sample circuit and some c code are available for you to use. Don’t reinvent the wheel. Instead, make it better!

Floor Plan

To simplify this handout and allow for later changes, we ask you to come into the lab and perform your own measurements of the Robot, Table, sugar cubes and coffee cup. At the same time, you can manually move the Robot, using joysticks, to get a feel for what needs to be done. Good luck.

Rules

The rules are simple. You are not allowed to have any input to the Navigation System other than the two push buttons. By the way, these are connected to ports 1.6 and 1.7 of the 8052. The other obvious rule is that you are not allowed to touch, or physically aid, the Robot at any time during the game. (Telepathy is allowed.) Come to think of it, you should NOT ever try to move the Robot in anyway other than sending it the appropriate electric signals. Since the nearest Robot Doctor is in Brockport, New York, we don’t want to break anything.

The Game

The game will start by you "homing" the Robot using the joysticks. You decide what initial position corresponds to home. Likewise, you can rmove the coffee cup and arrange the suger cubes in the tray as long as the height of the stacks does not exceed the height of the cup. You can also move the sugar cube tray to anywhere on the table. Stop. No more touching anything after you initially set things up. When you are ready, you will plug in your 8052 chip into the board, reset and start the game. You will have exactly 5 minutes to put as many sugar cubes into the coffee cub as possible. The number of sugar cubes in the coffee cup will determine your score. A wrestling match at the end of the game will break ties.

Hints

  1. Use one of the buttons to initially signal your program to start playing.
  2. There is a LCD. Use it to get insight into what your program is doing. The LCD is your program’s way of talking to you. Contrary to this, the buttons are your means of talking to your program.
  3. Consider gravity. The Robot will fall faster and rise slower. So profound.
  4. Read the warning sign that came with the Robot. It is framed and on the table next to the Robot.
  5. I can’t think of a reason for moving the wrist of the Robot. Of course, you may think of one.
  6. Pi = 3.14159265359.

Code

main.c
lcd.c
lcd.h

Help

If you need help with anything, talk to someone in the lab or your TA. Have someone explain the circuit that is already built for you. Likewise, have someone explain the existing c code that you will be given. This should be a simple and fun project! These people may be able to help you.

(Not particularly in that order.)

Judges

  1. Deepa (President of the Judiciary Committee of Robot Justice - Inland Empire)
  2. Tony (Vice President of the Judiciary Committee of Robot Justice - Inland Empire)
  3. Roman (Assistant Vice President of the Judiciary Committee of Robot Justice - Inland Empire)
  4. Jason (Assistant to the Assistant Vice President of the Judiciary Committee of Robot Justice - Inland Empire)

The End (not the beginning)