Terrapin Resources


Developing Subprocedures

The Main Pro-Bot program is the series of commands Pro-Bot follows when you press GO. Each time you turn Pro-Bot on, the most recent Main program appears. Add to or change the Main program by following the steps to edit or delete a Main program and change what Pro-Bot does when GO is pressed.

Create and Store Subprocedures

It is often useful to have Pro-Bot remember a series of commands you would like to use in different Main programs. This can be done by creating subprocedures or programs that are stored in Pro-Bot’s memory. The sequence of commands in a subprocedure is executed by Pro-Bot when the subprocedure is called by the Main program.

Expand the Main Program

You can also expand your Main program by including subprocedures. A Main program can have up to 128 commands. A subprocedure can itself have up to 128 commands. Calling a subprocedure from the Main program is only one command in the Main program, but Pro-Bot follows all the commands in the subprocedure before returning to the next line in the Main program. Including subprocedures allows you to greatly expand the number of commands you can include in a Pro-Bot program.

Subprocedure Names

Pro-Bot can remember up to 32 subprocedures that you define. Each of these subprocedures is identified by the word Proc (for procedure) followed by its number. For example, Proc1 is the first procedure in the Menu list, Proc2 is the second procedure in the Menu list, and so forth to Proc32. To show the available subprocedures, press Menu, use the down arrow to highlight New Proc, and press Menu again.

Scrolling through Subprocedures

After you have pressed Menu, a list of choices appears. The first line in the list is Back. Selecting Back and pressing Menu takes you back one level in the menu system. The second line in the list is New Proc, indicating that Pro-Bot is ready for you to enter a new subprocedure. The Pro-Bot screen displays up to 16 lines at one time. There are more subprocedures than can be displayed at once. You can scroll the highlight through the list of subprocedures by pressing the up and down arrow keys next to Menu. When the last line in the list is highlighted and you press the down arrow, the next line appears and the first line in the list scrolls off the top of the screen. When Back is highlighted and you use the up arrow to move to the previous line, it appears below Back and the last line in the list scrolls off.

Try it: Create a subprocedure that causes Pro-Bot to move in a square route. First, clear the Main program. Then from the Main display, press Menu. Press the down arrow key to select New Proc. Press Menu to enter the new subprocedure menu section. Press the down arrow key to select Proc1 and then press Menu to select that subprocedure.

Enter the commands for Pro-Bot to follow a square route. You can enter

When you have entered the commands for Pro-Bot to follow a square route, press Menu to define Proc1. This returns you to the Main program. Test your new procedure by using it as a command in the Main program. To do so, press Proc followed by 1, which is the number of the subprocedure that you defined. The screen displays

Since the commands to direct Pro-Bot along a square route are contained in Proc1, this is a sufficient Main program instruction to make Pro-Bot trace a square. Try it out by pressing GO.

From Main Program to Subprocedure

When Pro-Bot encounters a subprocedure command, it moves from the commands in the Main program to the commands in the subprocedure. When that happens, the display changes from the Main program to show the commands in the subprocedure. The title of the display changes from Main to the name of the subprocedure. As Pro-Bot executes the subprocedure commands, the display highlights each command as it is executed. When the subprocedure concludes, control returns to the Main program, which the display once again displays, highlighting the command in the Main program currently being executed.

Mixing Subprocedures and Direct Commands

In the Main program, you can mix subprocedures with direct commands. For example, to make Pro-Bot trace a flag shape, you can tell Pro-Bot to move forward and then follow a square route. Do so by editing the Main program and inserting a forward instruction prior to the subprocedure that tells Pro-Bot to follow a square route. Use the up arrow key to locate the highlight on Main. Press F. Fd is inserted after Main and prior Proc1. Press GO. Pro-Bot moves forward and then follows the commands in Proc1.

Try it: Try making the flagpole section of the route longer by editing the Main program and extending the forward distance that Pro-Bot travels before following the square route specified by Proc1.

Editing Subprocedures

Selecting the Subprocedure

Like the Main program, Pro-Bot subprocedures can be edited. The editing process is similar to that for the Main program, but first you must enter Edit mode and choose the subprocedure you would like to edit. To do so, press Menu and press the down arrow key to highlight Edt Proc. Then press Menu to select edit procedure mode.

A list of subprocedure names appears. Use the arrow keys to highlight the name of the subprocedure you would like to edit. Then press Menu to edit the selected subprocedure.

Try it: For example, most flags are rectangular in shape rather than square. You can change the program in Proc1 by editing the commands so that they instruct Pro-Bot to follow a rectangular route rather than a square one.

Edt Proc vs. New Proc

When you choose Edt Proc and choose the subprocedure you want to edit, the current contents of the subprocedure appear. When you choose New Proc, indicating that you want to create a new subprocedure, any content of the subprocedure you choose is erased so that you can write a new subprocedure for that procedure number. Be sure to choose Edt Proc when you want to edit the contents of a subprocedure and New Proc only when you want to erase the contents of a particular subprocedure and create a new one.

Specialized Sensor Subprocedures

The Pro-Bot has five specialized subprocedures, which correspond to inputs from its sensors. These are:

Executing Sensor Commands

The commands in each of these subprocedures are executed when the condition of the corresponding sensor condition is met. When the sensor condition is met, the Main program is interrupted so that the commands in the corresponding subprocedure are run. If there are no commands in the subprocedure corresponding to the sensor, then the Pro-Bot does not respond to changes in the sensor condition.

Storing Sensor Commands

Subprocedures 33 FRONT and 34 REAR correspond to the front and rear bumpers of Pro-Bot respectively.

Subprocedures 35 DARK and 36 LIGHT correspond to light conditions perceived by the light sensor located in the middle of Pro-Bot’s hood.

Subprocedure 37 SOUND corresponds to the sound sensor on the underside of Pro-Bot.

You can create and edit sensor subprocedures in the same way as any other subprocedure.