computer science lab report

profilefaisal0z
sample-laboratory-report.pdf

ECE206L Laboratory Report Format Page 1 of 4

1. BASIC INFORMATION

To save paper, the cover page is not necessary. Instead, include the following information on

the upper left-hand corner of the page: your name, course number, exercise number, exercise

title, and date.

2. PROBLEM STATEMENT

Describe what the program does and how does it do the task. For NXT and NXC programs,

include also the hardware configuration. For NXC and C++ programs, this section should

become your main program's comment header.

3. REVISED FLOWCHART

Include a correct flowchart which is the revision of the flowchart for the prelab.

4. COPY OF PROGRAM

Include a copy of the program, complete with the comment header(s) and comment

statements.

5. PROGRAM OUTCOME

For NXT and NXC program, describes how well the robot performs its task and states if any

improvements can be made. For C++ program, include a copy of the run-output (the actual

display output from the program) and describe the test cases that you use to prove the

correctness of the program.

6. PROBLEMS ENCOUNTERED

Describe the problems you encounter and the way you solve them.

7. COMMENTS

Give comments on the lab exercise, such as what you learn, whether it is too complicated or

too easy, any improvement you would suggest, etc.

ECE206L Laboratory Report Format Page 2 of 4

Sample Laboratory Report

Name: John Doe

Course: ECE206

Exercise 2 : Random Moves

Date: August 24, 2009

1. PROBLEM STATEMENT

Hardware:

A Touch sensor is attached to the front of NXT robot and is connected to Port 1

The left motor is connected to Port C and the right motor is connected to Port A.

Software:

This program will move the robot randomly. It will stop the robot if the total move time and

turn time is more than 30 seconds or the robot hits something. It uses the Random(1000)

function to obtain a random time between 0 and 999 milliseconds for moving and turning.

2. REVISED FLOWCHART

See attached. If the flowchart is short, copy and paste it here; otherwise, attach it to Page 2.

3. NXC Program

/*****************************************************************************

* Name: John Doe *

* Course: ECE206 *

* Exercise 2 : Random Moves *

* Date: August 24, 2009 *

* *

* Hardware: *

* A Touch sensor is attached to the front of NXT robot and is connected to Port 1 *

* The left motor is connected to Port C and the right motor is connected to Port A. *

* Software: *

* This program will move the robot randomly. It will stop the robot if the total move time and *

* turn time is more than 30 seconds or the robot hits something. It uses the Random(1000) *

* function to obtain a random time between 0 and 999 milliseconds for moving and turning. *

******************************************************************************

int move_time, turn_time, total_time; //global variables

task main( ) {

SetSensor(S1, SENSOR_TOUCH); // with default mode Boolean

total_time = 0; //start with total time 0 second

do {

move_time = Random(1000); //random number between 0 and 999 milliseconds

turn_time = Random(1000);

OnFwd(OUT_AC, 40); //go forward with 40% power

Wait(move_time); //for random move_time seconds

OnRev(OUT_C, 40); //turn left with 40% power

Wait(turn_time); // for random turn_time seconds

total_time = total_time + move_time + turn_time; //accumulate time

} while (total_time <= 30000 && SENSOR_1 != 1);

//repeat if not more than 30 sec or sensor not touched

ECE206L Laboratory Report Format Page 3 of 4

Off(OUT_AC); //stop robot

}

4. PROGRAM OUTCOME

The program works as intended. One noticeable problem was observed when the robot turned

and hit something. The robot did not stop on the dime when the robot hit something during the

turn. Because the hit was on the corner of the bumper and the touch sensor was on the middle

of the bumper, the touch sensor switch would not close if the bumper was not hit hard enough.

Only if the robot applied more pressure on the bumper by trying to turn after it hit something,

then the touch sensor switch would close giving a "1" output.

5. PROBLEM ENCOUNTERED

Two types of problems were encountered:

Syntax problems:

The problem was caused by the placement of the set sensor statement outside the task main

and no power control in the OnFwd function. After moving the set sensor statement inside

the task main and including the power factor in the Onfwd function, the compilation was

successful.

Run-Time problem:

The robot continued to move after it hit something during the 30 seconds move. The

problem was due to the incorrect use of compound condition. Instead of using logical AND

operator "&&", the logical OR operator "||" was used. With the logical OR "||", the

compound condition "total_time <= 30000 || SENSOR_1 != 1" was false only when the

total time was more than 30 seconds and the sensor 1 was touched ; hence, the robot would

not stop after it hit something during the 30 seconds move.

6. COMMENTS

We should use a shorter total time, say 10 seconds, to conserve battery power and still be able

to see the randomness of robot movements. Also, we should have more space in the lab so that

more students can test their robots simultaneously.

ECE206L Laboratory Report Format Page 4 of 4

Move Randomly Flowchart

Start

Count = 0

Configure Sensor 1

to Touch sensor

Total_time = 0

move_time =

Ramdom(1000)

total_time <= 30000

|| sensor 1 != 1

End

T

F

turn_time =

Ramdom(1000)

Move forward

move_time sec

Turn left

turn_time sec

total_time = total_time +

move_time + turn_time

Turn off robot