Arduino Sensor Interface

Microcontroller Max/MSP module

I worked on this project wiht David Stout and Cory Metcalf of NoiseFold. We wanted to create a physical sensor interface that could be modularly reconfigured and integrated into Max/MSP. Previously, we were using the Electrotap Teabox for this purpose. However, the Teabox streams data through the audio bus and we encountered problems with smoothness in the Max scheduler when running complicated audio-visual software. We decided to build a custom shield and enclosrue for an Arduino Microcontroller and run sensor data through USB to get smoother results.

completed Arduino sensor interface

Because our goals were for accuracy and modularity, we opted to use the Arduino Due board, which has 12 analog inputs and 12 bits of ADC resolution. The downsides of this board are cost (~$30), size (one of the larger Arduinos at 4inX2inX1in), and a 3.3V operating voltage. The restriction of 3.3V could potentially limit the selection of sensors.

Arduino Due

An Arduino Shield is a board that clips onto the top of an Arduino board and extends the functionality somehow. In many cases, shields still allow access to unused pins. Our shield only needs to provide access to the Analog Input pins with a more convenient connector like 1/8" audio jacks.

Shield on Arduino Board

This PCB was created using the toner transfer method. This is a useful method for small production batches (3 in our case). Toner transfer is cheap but is relatively time consuming. Click here for the toner transfer circuit layout (mirrored)

PCB layout (mirrored)

PCB before etching

PCB after etching

PCB after drilling

PCB after drilling

I found a plastic enclosure that barely fits the shield and Arduino, the Serpak 231,BK. This enclosure has a section for a 9V battery which had to be removed with a dremel cutting attachment to increase the main cavity volume. Additionally the USB ports for the Arduino barely fit out the side. I removed the unused Native USB port so that it would only require making one hole in the enclosure. However, this limits the ability to repurpose the Arduino for another project.

Enclosure modification to remove battery area

The enclosure's holes for the jacks on the must align precisely with the components on the shield. I created a drilling template from the circuit layout but optionally, one could assemble the shield and trace the layout onto the enclosure. Click here for drilling template

Drilling the enclosure with template

The Arduino code is specialized to this implementation but is based on examples of streaming ADC data to the serial port. An added feature is that the code on the Arduino accomplishes some of the data smoothing and can be configured over serial by Max. This offloads some of the smoothing so that it doesn't need to be done on the computer.

Click here to download the Arduino code

Like the Teabox, the shield can deal with single-channel sensors. We had previously worked with Ben Johansen to design some sensors to work with the Teabox. These terminate in XLR(M) for the Teabox so we built new sensors that terminate in 1/8" as well as some short XLR(F)-1/8" adapter cables.

Potentiometer knob sensor clipped on laptop

I created a Max/MSP interface to receive the data and patch into the NoiseFold modular system. I've recreated a version for general use which you can download here. This is designed to be loaded as a bpatcher interface but you'll want to customize the code to route the output. I also recommend adding [autopattr] to allow for saving/loading of the smoothing/configuation values.

Max Interface for Arduino shield

The interface configures interpolation and port activation on the Arduino side and clipping, offset, and additional ramping within Max. Note that the Due ADC's first bit is quite noisey so you should generally have interpolation or at least one sample.

Completed interface operating on laptop

The completed unit is fairly robust. We found that some sensors could crash the Due if they are hot-plugged into the interface. However, the Max interface is able to reset the connection without restarting Max. The interface also requires the custom creation of sensors (or adapters) to conform to the 1/8" termination. The benefits are a bus-powered, compact, cheap sensor interface that performs at relatively high resolution and low latency.