The Handy Board & Interactive C

The Handy Board


The Handy Board Kit

A complete, assembled Handy Board Kit consists of the following:

Connecting the Handy Board to the Computer

Let us connect the Handy Board to the MAC and power it up. This involves the following steps:

Bootstrapping the Handy Board

The Handy Board requires two software components: A 6811 runtime library, and the Interactive C application program. Both are provided on the Interactive C floppy disk. The 6811 runtime routines are like a small operating system for the Handy Board. They are normally pre-loaded on the Handy Board and reside there permanently. When you turn the Handy Board ON, if the display on the Handy Board shows the following:

Interactive-C
V 2.81 9/28/93

then we know that the 6811 runtime libraries are already pre-loaded. If you do not see the above display, you will have to download these libraries from your floppy. Here is what you will have to do:

Find the application labeled "Init board R2 7.2 Modem" on your Interactive C floppy. Double click the application and you will get the following screen on your MAC:

Turn OFF the power switch on the Handy Board. Turn it ON again while pressing the STOP button. This puts the Handy Board into bootstrap download mode. I.e. when you press the RETURN key on the MAC, the downloader will place the 6811 runtime system on the Handy Board. The downloader screen will show the following:


At this point, turn the Handy Board OFF and turn it back ON. You will now see the Interactive C message:

Interactive-C
V 2.81 9/28/93


Also, notice in the bottom right corner of the Handy Board screen, there is a blinking heart. A blinking heart indicates a healthy Handy Board. You may now exit the downloader application. Most likely you will not need to use it again. In case the contents of the Handy Board memory do get corrupted, you can follow the above steps to reload the 6811 runtime system.

Interactive C

We are now ready to look at the second piece of software. One that will be used for programming agents controlled by the Handy Board. Find the Interactive C application on the floppy disk. It is named IC R2 2.852 modem. Double click on the application and you will see the following screen on your MAC:

In the above window, as a result of launching the application, the software first tries to make contact with the Handy Board. If the Handy Board is turned ON, IC will synchronize with it. It will also load additional program libraries before giving the prompt (>C).

At the prompt, you can enter any valid Interactive C (IC, from now on) statement. The application will translate the statement into code (pcode) that can then be executed by the Handy Board. The results of the execution will be returned on the MAC screen, or displayed on the Handy Board display, depending on the command issued. For example, try entering the following IC statement:

printf("I am alive!\n");

The string in the printf message will be displayed on the Handy Board display. Try typing the expression:

2 + 2;

This statement will be compiled and then executed on the Handy Board and the result of the evaluation will be returned on the MAC screen. Both of these are shown below:


Interactive C is a little-sister version of C. Additionally, it comes with several useful, Handy Board specific, libraries containing procedures and fuctions that provide access to various Handy Board features. Read the first 9 sections (pages 1 to 28) of the Interactive C manual.

Building An Embedded Agent

In Chapter 2 of Russell & Norvig's text an agent is defined as anything that can perceive its environment and act upon it. This requires the agent to have some sensors for perception and some effectors for acting. In this session, we will create mobile agents that are capable of moving about in their environments. From the previous day, you should now have a wheeled LEGO Bug (chasis) capable of carrying the Handy Board. If you haven't already mounted the Handy Board on the LEGO Bug, do so now. You will need extra LEGO parts for this. Also, be careful not to flip the Bug over when the Handy Board is mounted. The Bug assembly is powered by two motors. Now, we will connect these motors to the mounted Handy Board so that we can build agent programs that exibhit simple motion behaviors. You may assume, for this lab, that the environment of the agent will be a big flat surface without any obstacles. Let us start by connecting the motors.

Place the Handy Board on the chasis. Connect the two motor cables to the motors (if not done already). Plug the pin ends of the two motor cables onto two motor ports of the Handy Board. Jack up the chasis so that the wheels are off the ground. Let us first see how to run the motors through a C statement. The motor ports are numbered 0 through 3. The Handy Board's library contains procedures for controlling the motors. The command:

void motor(int m, int p)

turns motor m on at speed p. There are typically seven speeds available ranging in values from -100 to 100. Negative numbers indicate a backward rotation and positive for forward motion. A value of 0 will turn the motor off. Issue some motor commands to both the motors. Make sure that the motors go forward when you give them positive speeds. if the polarities are switched they will go in the opposite direction. Switch the pin connections and make sure the motors are cofigured properly.

Writing Procedures

In this section, we will learn to write short procedures and programs that control the behavior of mobile agents. Here is a simple program:

int LeftMotor = 3;  /* Left motor is connected to port 3 */
int RightMotor = 0;   /* Right motor is connected to port 0 */

void goForward(int Time) {
   motor(LeftMotor, 100);
   motor(RightMotor, 100);
   msleep((long) Time);
   alloff();
}

Before you enter this program, go to the Interactive C disk, open the IC-Libraries folder and in it, create a new folder (say Agents). Open SimpleText, and enter the above program. Save it in a file (say moves.c). Next, launch the IC application. Turn the Handy Board ON, and at the IC prompt enter the command:

load Agents:moves.c

Your program will be loaded, compiled, and downloaded into the Handy Board's memory. After this has been done successfully, you can issue a command to the agent as follows:

goForward(500);

Observe the actions. You can also write a main procedure as follows:

void main(void) {

}

This is a simple program that you can add to the moves.c file. Next load the file again. After the file is loaded, you may disconnect the RJ11 cable from the Handy Board, turn the Handy Board OFF, place the agent on a flat surface, and then turn the board ON. As soon as the board is turned ON, the main procedure is executed.

Using two motors, you can program the agent to go forward or backward in a straight line, or turn going in the forward or backward directions. Write some IC procedures to make your agent go forward, backward, turn while going forward, and turn while going backward, etc. Here are some exercises to work on:

It may seem that the agent is only acting and is not capable of any sensing. However, remember that the agent has access to a clock using which it can sense time. You can utilize this facility to together with the speed you calculated above to make the agent travel in a straight line while at the same time giving a display of the distance it has traveled. How accurate are the readings?


Next: Touch & Light Sensors

Previous: Embedded Agents

Back to Using Robots in an AI Course