Return to REP Home Page

T. L. Grant 4/03/01

A Tuning and Testing Aid

Tuning and testing a Bot's capability to perform as desired is a difficult part of the preparation for the contest. Things never work as you imagine the first time and then you often need help to refine the design. Here is a little interface task code that may help you to develop that winning performance:

Usually a small number of parameter values must be guessed in order to set the path direction, length and speed, or how far and fast the Bot will extend an arm; in this example we'll aid the adjustment of only one. In this sample code the tester wants to change the motor power, labeled 'Motor power' and starts with the given a value of "ppp" .

The aid provided by this task code is to support changing one parameter while the program is running. The overall program must be configured to repeat the aiding function followed by the main function (all of what was originally named "main()") together with the variables input to the task.

The task, "read_mod(x,y,z)" enables the run time two-way exchange of information between the human user and the Handy Board program.

The program always initiates the exchange, using the display to send the parameter label, its value and a potential new value to the person doing the test.

The task output should display the following:
[ motor power = ] < 16 characters on the first line >
[ppp or new nnn ] < 15 characters on the second line (+ heart beat)>
The value "nnn" is the integer set with the knob() function.
The person can reply saying "continue with the current value" by pushing the ‘start’ button, or they can adjust the potential new value with the knob, and then change it to the current value by pushing the ‘stop’ button.

The person always ends the exchange, effectively saying "continue with the current value", by pushing the ‘start’ button.

Even though the exchange is very simple, it is hard to describe, or to understand because we are not used to communicating with another person about how to "communicate", and especially not about how to communicate with a machine. The requirement for a two-way exchange between a person and a machine is not intuitive, however, I hope you will understand the value of the two-way exchange after you use the sample program.

 

/* A sample program using "read_mod" to aid testing tlg 1/28/00,
* rev 4/02/01. The example checks the effect of motor power values.
* It also reads battery voltage assuming a voltage divider has
* been added to port #23 (without the addition, the display at
* the beginning of the operation will not really be battery
* voltage) */

void main()
{
int power = 50, div = 2, k = 0;
printf(" Bat Voltage = %d mv\n", 50*analog(23) - k);
sleep(2.0);

while (1) {

printf("press start to continue\n");
start_press();
power = read_mod(" Motor power", power, div);

/* your program to test goes here instead of the next 4 lines */

motor(1, power);
motor(2, power);
sleep(2.);
ao();
}

}

int read_mod (char label[ ], int par, int scale)
/* 'label' is a string of 12 characters, 'par' is the current value,'scale' reduces the knob range to match the range of the parameter being modified*/
{
while(!start_button()){

printf("%s = %d or new %d\n", label, par, knob()/scale);
if (stop_button()) par = knob()/scale;
sleep(0.2);
}

return par;
}