Date: 21st of February, 2013
Participating group members: Kenneth Baagøe Kristiansen, Morten Djernæs Bech, Thomas Winding
Activity duration: 5 hours
The overall goal of this lesson is to familiarize ourselves with the NXT sound sensor by doing the exercises described here.
The goal is to mount the microphone sensor and try to see how it works.
Follow the instruction on how to mount the sensor in manual and upload program, and try with sound levels and distances.
A loud sound very close the sensor gives us a reading of 90. A similar loud sound at half a meter gives us reading between 20 and 50, it differs a lot.
Very close to the sensor the read outs are pretty constant, the further away from the source of the sound, the lower the read outs, while also varying a lot more.
The goal in this exercise is to use a datalogger for saving sound data. Furthermore we will sketch a graph explaining this data.
Implement the datalogger, implement the SoundSampling.java, and download the sample.txt. Using the data gathered, plot a graph and analyze it.
As can be seen from the graph there is a logarithmic development in the value measured by the sensor. The slight inconsistencies in the values measured can be attributed to ambient noise, like other students talking and experimenting with sounds as well, and the fact that we moved the robot manually which means that the velocity away from the sound source was not constant.
The goal in this exercise is to make our first application using the sound sensor. We’ll observe how the car responds to shouting and clapping.
Implement the SoundCtrCar.java and use it with the simple class Car.java.
Test the behaviour of the car and watch what happens.
The car would move around keeping the same direction until a clap or a noise/sound was made loud enough making the car turn the other direction.
A demonstration of the car is shown in exercise 4.
Before running the program, we looked at the code so we had an idea of what it was supposed to do. Testing it, it behaved as we expected, shifting between the different states (forward, left, right, stop) when making sounds that went above the threshold. We discovered that it only reacted to quite loud sounds, basically e.g. clapping had to be done very close to the sensor to get a reaction from the robot. What we didn’t expect was that we were unable to stop the program by any other means than removing the battery.
The goal in this exercise create a ButtonListener which listens for the ESCAPE button and exit the program when its pressed.
Implement the ButtonListener in the car using a simple example from the leJos tutorial. Observe what happens.
As the video illustrates, the behaviour of the program is as followed:
1st clap makes the car start running forward. 2nd clap makes the car turn right until the 3rd clap which makes the car turn left. The car is stopped by the 4th and last clap. With our button listener on the Escape button implemented it is now also possible to actually end the execution of the program as opposed to Exercise 3.
Sivan Toledo has investigated how the sound sensor can be used to detect claps.
The goal in this exercise is making the car able to detect claps and compare Sivan Toledo’s method with the one used in SoundCtrCar.java.
We will implement the methods and observe the car using the different methods.
This video shows our result which is available on YouTube (http://youtu.be/9JpNqvhbjNY).
As can be heard and seen in the video it’s not working perfectly.
The method used to detect claps in SoundCtrCar.java is simpler compared to the method proposed by Sivan Toledo. The method used in SoundCtrCar simply detects a single loud sound and then acts, while in comparison, Sivan Toledo’s method detects an increase in sound by first listening for a lower sound volume, then a high volume, e.g. the clap, and then a low sound volume again.
This difference in the methods to detect volumes means that the robot, with implementations of the two different methods, would have a differing behaviour. With the method proposed in SoundCtrCar, in an environment with a constant loud sound would repeatedly change between its different states (forward, left, right, stop) while, with our implementation of Sivan Toledos clap-detection, it would remain in one state (either forward or stop) since there would be no rises in sound volume.
The goal in this exercise is to make the car drive towards the location in which the sound is coming from.
We’ll mount a second sound sensor to the car, making the car have two, and check where the sound is coming from – turning in that direction.
Having the sound sensors pointing straight forward gave us som trouble making the car follow the claps correctly. This we assume was because both sound sensors picked up the clapping sound and thus had a chance of either continuing to go forward or even turning the wrong way. By placing the sensors at a larger angle away from each other (as demonstrated in the video above), we made the car follow the claps without any trouble, which confirms our assumption.