Terrapin Resources


Developing Sub-Procedures

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 Sub-Procedures

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 sub-procedures or programs that are stored in Pro-Bot’s memory. The series of commands in a sub-procedure are executed by Pro-Bot when the sub-procedure is called by the Main program.

Expand the Main Program

You can also expand your Main program by including sub-procedures. A Main program may have up to 128 commands. A sub-procedure can itself have up to 128 commands. Calling a sub-procedure from the Main program is only one command in the Main program but Pro-Bot follows all the commands in the sub-procedure before returning to the next line in the Main program. Including sub-procedures allows you to greatly expand the number of commands that may be included in a Pro-Bot program.

Sub-Procedure Names

Pro-Bot has the capability to remember up to 32 sub-procedures that you can define. Each of these sub-procedures is identified by the word Proc (for procedure) followed by its number. For exampe, 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 sub-procedures, press Menu, use the down arrow to highlight New Proc, and press Menu again.

Scrolling through Sub-Procedures

The list of sub-procedure names appears. The first line in the list is New Proc, indicating that Pro-Bot is ready for you to enter a new sub-procedure. The second line in the list is Back. Selecting Back and pressing Menu takes you back one level in the menu system. The Pro-Bot screen displays up to 16 lines at one time. There are more sub-procedures than can be displayed at once. You can scroll the highlight through the list of sub-procedures 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.

The title New Proc and Back are fixed on the screen and are always present when you scroll up and down through the entire list of sub-procedures. If you highlight Back and press the up arrow key, the previous line in the list appears and the last line in the list scrolls off the screen. If you highlight Back and press Menu, you will move up one level in the Pro-Bot menu structure.

Try it: Create a sub-procedure 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 sub-procedure menu section. Press the down arrow key to select Proc1 and then press Menu to select that sub-procedure.

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 sub-procedure 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 to make Pro-Bot trace a square. Try it out by pressing GO.

From Main Program to Sub-Procedure

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

Mixing Sub-Procedures and Direct Commands

In the Main program, you can mix sub-procedures 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 sub-procedure 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 Sub-Procedures

Selecting the Sub-Procedure

Like the Main program, Pro-Bot sub-procedures may be edited. The editing process is similar to that for the Main program, but first you must enter Edit mode and choose the sub-procedure 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 sub-procedure names appears. Use the arrow keys to highlight the name of the sub-procedure you would like to edit. Then press Menu to edit the selected sub-procedure.

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 sub-procedure you want to edit, the current contents of the sub-procedure appear. When you choose New Proc, indicating that you want to create a new sub-procedure, any content of the sub-procedure you choose is erased so that you can write a new sub-procedure for that procedure number. Be sure to choose Edt Proc when you want to edit the contents of a sub-procedure and New Proc only when you want to erase the contents of a particular sub-procedure and create a new one.

Specialized Sensor Sub-Procedures

The Pro-Bot has five specialized sub-procedures which correspond to inputs from its sensors. These are

Executing Sensor Commands

The commands in each of these sub-procedures 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 sub-procedure are run. If there are no commands in the sub-procedure corresponding to the sensor, then the Pro-Bot does not respond to changes in the sensor condition.

Storing Sensor Commands

Sub-procedures 33 FRONT and 34 REAR correspond to the front and rear bumpers of Pro-Bot respectively. Sub-procedures 35 DARK and 36 LIGHT correspond to light conditions perceived by the light sensor located in the middle of Pro-Bot’s hood. Sub-procedure 37 SOUND corresponds to the sound sensor on the underside of Pro-Bot. Sensor sub-procedures may be created and edited in the same way as any sub-procedure.