CS122A-Fall Quarter, 1999


Lab 6 : 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 assist a user to control a robot arm. The goal 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

The robot arm comes with two joysticks, each also having several buttons, to control the numerous axes of the arm. However, consider a person with physical disabilities, who cannot operate these joysticks, and instead who's only ability to control the arm is to push a couple of buttons, or perhaps just turn his/her head from side to side. We will use the 8052 to convert just two buttons into the more complex arm control signals. The robot arm will be interfaced to an 8052. Since the actual arm does not have a feedback 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. You should define a strategy for making best use of those buttons. The 8052 will also be interfaced to an LCD.

There is only one Robot available for this experiment. It is in B256 across the hall from B265. You will need to make an appointment to work on this experiment. The Robot will remain in B256 at all times. 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 to achieve the goal of putting sugar cubes in the cup.

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 begins with the arm in some unspecified position (in other words, don't assume it will be in any particular initial position). Furthermore, the cup will already be placed and the cubes will already be in an unarranged pile. You will plug in your 8052 chip into the board, reset and start the game. You will have exactly 4 minutes to put as many sugar cubes into the coffee cup as possible. The number of sugar cubes in the coffee cup will determine your score.

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.
  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.

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!