Ultrasonic Sensors

One of the key elements of our accessible instrument, and something that Lucas and me had very clear about the development of the instrument since the beginning was the idea of implementing sensors in the functionality of the device. These sensors, the HC-SR04, known as ultrasonic sensors or distance sensors are commonly used in interactive installations and they have been widely used in combination with Bela Board and Pure Data, some tools that we were studying during the beginning of this course in the unit “Expanded Studio Practice for 21st Century Sound Artists”.

The way these sensors work is similar to the ultrasonic vision that allows bats to navigate in the space. One of the round devices emits an ultrasonic signal, whereas the second device receives the echo. Sending a trigger from PD to the Bela Board and with an space/time equation which is available with Bela’s online documentation, the sensor is able to output the equivalent value to the distance to which any object can interfere in that direction. The sensor also needs some wiring and a couple of resistors to work, and I built these schematics in a breadboard to start experimenting with one of the sensors.

Little setup to test one sensor

But using these sensors to control parameters is not as straightforward as it can look at first sight, and it took me quite a lot time to find out the best possible patch in order to obtain a natural and smooth feel when controlling the volume of the sample, which is the feature that we wanted to achieve in this instrument. Here is a short video of the first experimentations with volume control of a sample, in the Bela’s console we can also see the print of the distance, calculated every 60ms.

In order to make this volume control more natural, I added some smoothing to the printed values, with the object [line~] and sending the message [$1 800], where $1 is a variable, in this case is the distance, but it will take 800ms to move from a value to the next one, making the volume control smoother. I also used the objects [samphold~] and [snapshot~] to retain the distance at any point, otherwise the distance, therefore the volume, was continuously increasing after removing the hand. The maximum distance is also capped at 25cm to make a reasonable movement range. Once I had a good patch for the first sensor I just needed to duplicate it four times, with the only difference that the last one would control a filter that I made with [vcf~], and the other three samples would be routed to the filter and master output. Here is the final patch in Pure Data ready to be tested with four sensors.

Leave a Reply

Your email address will not be published. Required fields are marked *