5 - Auto / Manual
Home Up

 

 

SOFIA

Home Page
Table of Contents
Background             
Astronomy
Mount
Infrared
Balancing
Experiments
1 Balance and Torque
2 Center of Mass
3 Moment of Inertia
4 Handy Board
5 Auto / Manual
6 Light Sense
7 Track Control
Interactive-C Code
   

 

Manual versus Automatic Data Gathering and Control

Introduction:

As you progress to more complex experiments you will find it helpful to shift from manual to automated procedures for both data gathering and system control.
Some procedures are naturally manual, such as measuring torque with a balance beam and weights, or finding the weight of the fans and the meter stick, or finding the center of mass of the meter stick & fans system. Some data gathering procedures, such as calibrating a proximity sensor which measures the intensity of infrared signal reflected from a surface, can done manually, or can be completely automated. In general extra effort is put into the development of the automated procedure, but that effort is rewarded (1) by easing the effort to complete, or execute the procedure, and (2) allowing the same procedure to be repeated many times with very little deviation. Thus if you have a single sensor to calibrate, for only one configuration, and the number of data points is small (say less than ten), then a manual measurement and recording the angle, distance and sensor value is probably easiest.

For calibrating multiple sensors or a sensor for multiple configurations, it is less costly and more accurate to build a actuator to create the sensor motion and to write a program which commands the actuator through the position steps and then to save the sensor responses together with the position steps. The Handy Board, and its Interactive C programming, together with its servo control and the analog input ports provides a complete environment for such automated data gathering.

The Botball contest presents a challenging problem for automatic control, but many engineering functions rely on developing similar control. For example, if you are pointing the meter stick system with a camera attached to take a picture or two remotely for a short time, pointing it might be best done manually by looking at the scene from the camera and steering the system up or down to the angle where you can take the pictures. However, if the angle must be held for a long time (e.g. 30 minutes for a long exposure), you would want to develop an automated method for holding the angle, especially if you found it difficult to do manually. The automated control of a system (as in Experiment 6 & 7) will illustrate the kind of control needed for holding the SOFIA telescope pointed in a fixed position for long time periods.

Objectives:

1. To build a photo sensor testing jig.
2. Provide a comparative example of manual versus automated data gathering.
3. Introduce a control experiment with remote manual pointing and automated pointing using a computer-controlled feedback.

Procedure:

1. Gather legos, an a phototransistor, a servo, and the Handy Board (all components in the Botball robot kit) plus a lantern lamp* and masking tape. Build a test structure out of legos with a beam to hold the phototransistor above the servo and link the servo arm to the beam as shown in Figure A, such that the servo rotation is reduced by the ratio of 3:1 to 5:1 (4:1 is shown). Use the ‘servo test’ program to change the beam position, up and down from level, about 6 degrees (~0.1 radian). Check the calibration of the beam angle versus the servo position by measuring changes in height at the end of the beam and using the approximation for small angles: A ~= sin(A) ~= tan(A) where A is the angle in radians. The angles you get should fit the calculated values from the ratio of arm lengths if your structure matches the figure, and the central (zero reference) servo position is parallel to the beam.

*For the lamp you can use a flashlight without the reflector (A 6 volt type for long life is suggested.) or you can wire a A.C. powered lamp from parts available at Radio Shack, or similar electronics outlet store for about the same price (A 12 volt power supply, and 12-14 volt threaded lamp, of about 4 watts, and socket is suggested). The light source will need to be positioned at various heights and distances from the phototransistor for this and other experiments, so having a camera tripod to attach the lamp to was found useful, but not necessary.

2. Apply a tube, ~6 mm dia. and 35 mm long, black or dark on the inside, to the phototransistor, and tape it to the beam (pay attention to covering the back side of the sensor as well). Place the lamp about 40 cm from the sensor at the same height as the beam. Connect the sensor to the analog(0) input port and load the ‘sensor test’ program to the Handy Board which will display the servo position and the sensor readings and adjust the servo in approximately 5 degree increments, manually recording the position and sensor values at each step to give about 8 measurements covering +/- 5 degrees from the level position. If the sensor readings are uniformly too low (indicating a high signal), add length to the tube, or move the lamp farther away; if they are too high except for a small angle in the middle, shorten the tube, or move the lamp closer (explain why). Using a piece of graph paper and the calibration used in task #1 above, plot the sensor response versus pointing angle.

3. Now to automate this process, replace the 'sensor test' program with the ‘sensor a&b cal1’ program. Compare the program codes, noting the addition of a calibration array for the angle data taken, an array of angles, and an array to save the sensor a & b values as the sampling loop is executed. (In this case we will only be read data from sensor a.) After setting the lamp for a minimum value (peak signal) for a level beam (zero reference angle), initiate the data sampling loop. When data sampling is 'done', read the values to the display screen in Interactive C by typing the array name on the command line, at the bottom of the window. High light the printout in the display and ‘copy’ the printout to save them in a holding buffer (<ctrl c> in Windows98, or <alt c> MacOS), then open Excel, or similar spread sheet and paste the values into a cell. Parse the cell into individual items using comma delimiting (for Excel, use the “text to columns” dialog under “data”) and edit the individual cells to delete the ‘<int>’ text associated with each number. By transferring both angle and sensor values to adjacent rows of cells you should be able to generate an x-y plot of the data in the standard manner (such as using the Excel ‘Chart Wizard’). Alternatively, the data can be saved as a text file and further processed and plotted using a mathematical analysis application such as Mat Lab.
Many optics experiments can be performed with this test jig and program which would not even be considered if all the data had to be manually gathered. What would you like to try?

4. To manually control a sensor to point at the lamp use the same program and the procedure that was used to start the automated data gathering above (2). A more explicit and accurate method for finding the peak (minimum) signal would be to scan off the minimum in each direction by turning the Handy Board knob, and reading the angle and sensor values off of the LCD display. Note the angles for a sensor value of 50. Then the angle for pointing directly at the center of the lamp source is: (a1 + a2)/2 , where a1 & a2 are angles where the value is 50. (All values for angles between a1 & a2 should be less than 50.)

5. The sensor test jig can be controlled to automatically point at the lamp using two sensors and the program ‘aim7.c’, and following the procedures in Experiment 6 for test jig pointing. After setting up the two sensors and running the program, try moving the lamp up and down and see how well the controller follows. Review the program; do you understand how the two sensors are used to generate output to the servo? Can you write a program to point using only one sensor that imitates the manual method above, or uses part of that method? What advantage does the two sensor method have?

/*sena&senb_cal1 Kevan Anderson, 8/99*/

 

/*This program samples the sensor values for both analog 0

 and analog 1 in a series of steps.  The "knob" is used to set

 the sensor on the "zero point" of a fixed light source.

 Then, when the start button is pushed, the program

 samples the sensor data in a small, equal angular

 distance above and below the "zero point".   This data is stored

 into two arrays which  can later  be called up in Interactive C's

 main operation window to be viewed. The program allows for

 ten trials to be completed and offers the choice of continuing after

 every trial.  The start button is pushed to continue. */

 

int sena[10][36];

int senb[10][36];

 

void main(){

    int i;

    int j=0;

    servo_on();

    while(j!=10){  

            float a;

        printf("now # %d. \n",(j+1));

        while(!start_button()){}

        sleep(2.);

        while(!start_button()){   /*Display for manual adjustment of the

                                zero point until start button is hit.*/

                  a= (float) (knob() );

                  servo_deg(a);

                  printf ("angle=%f  %d           %d\n", a,analog(0),analog(1));

                  sleep(0.5);

                  }

        i = 0;

          

            while(i <36){  /*samples of data*/

                  servo_deg(a+ (float)i -18.);   /*samples are +/- 18 degs

                                                  from selected peak*/

                  sena[j][i] = analog(0);

                  senb[j][i] = analog(1);

                  printf("angle%d sena %d   senb %d\n", i,

                          sena[j][i],senb[j][i]);

                  i ++;

                  sleep(.5);

            }

        printf("%d runs done.           next?\n",(j+1));

            while(!start_button())

     

            j++;

        sleep(2.);   

    }   

     printf("done-\n");  

}

 

 

 

To request information on this web site in a Section 508 accessible format, please contact access@mail.arc.nasa.gov.