torsdag den 16. februar 2012

Lab 3






Lab session 3,

Date: 16. feb. 2012.
Duration of activity: 3 hours.
Group members participating: Jeppe, Stefan og Thomas

Goal
  • Mount sound sensor on lego car.
  • Tryout the microphone sensor.
  • Get familiar with data logging.
  • Run the SoundCtrCar program
  • Implement the Clap Controlled Car

Plan (how and why)

  • We will start by mounting the microphone so we can implement and upload a program for measuring sound (exercise 1).
  • Then we upload the SoundCtrCar program so we can observe the behavior of the program. (exercise 2).
  • Implementing the Clap Controlled Car using the pattern devised by Sivan Toldo so we can compare it with the SoundCtrCar.

Exercises
  1. Using SonicSensorTest.java, place the car at a fixed position and make sounds of
    a) different loudness and
    b) different distances.
    c) Use this to give a description of the readings from the sound sensor

  2. The sound controlled car (SoundCtrCar.java)
    a) Describe the behavior of the car as you make sounds:
    - Clapping, shouting
    b) Describe how the program interprets readings from the sound sensor as loud sounds.

  3. In the program the ESCAPE button is polled in the outermost loop so that the ESCAPE button can be used to stop the program. This does not work when the program loops in one of the four inner loops. You can make the ESCAPE button always work as a program terminator if you also poll the state of the button in the inner loops. But you can also use the ButtonListener mechanism to listen for the ESCAPE button and exit when ESCAPE is pressed. Try this in the program.

  4. Implement the Clap Controlled Car
    A clap is a pattern that starts with a low-amplitude sample (say below 50), followed by a very-high amplitude sample (say above 85) within 25 milliseconds, and then returns back to low (below 50) within another 250 milliseconds.

    a) Try to use his method to detect claps and
    b) compare it to the method used in the program SoundCtrCar.java.
    Use the DataLogger class to record and investigate clap patterne.


Results

Exercise 1
Normal talk 30 cm from microphone, gives readings between 0 and 30 (peaks at 50).
Normal talk 200 cm from microphone, gives readings between 0 and 20.
A clap results in various readings between 30 and 90, but they are all peaks.

We used the datalogger to monitor the claps. We have plotted the data on the graph below:


Exercise 2
The robot alternates between, going forward, right, left or stops on a loud noise, also the program did not terminate the first time we started the robot, so we had to be quiet (avoid activating the robot) while dismantling the robot to take out the battery.

We also observed that even though the robot is only supposed to start on loud noises, the robot actually started while there were no loud noises.

The program has a threshold value "loudSound" that makes the robot wait for a loud sound.
However the sleep in the method is set to measure

Exercise 3
We used the button listener on the escape button and a "alive" variable to exit the program.

Button.ESCAPE.addButtonListener(new ButtonListener() {
public void buttonPressed(Button b) {
alive = false;
}
public void buttonReleased(Button b) { });
...
while ( soundLevel < soundThreshold && alive);

Conclusion

References
[1], http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson3.dir/Lesson.html

Ingen kommentarer:

Send en kommentar