Thursday, 26 January 2012

Rig Diagnostics

Every new technique goes through a maturation process in which problems and weaknesses are gradually corrected or accounted for. While I haven't been around personally at the time I can imagine that for example patch clamp recordings have gone through a long process of determining the best material, tip sizes, hardware to minimize mains noise, etc. Virtual reality systems haven't been around for very long and because of their complexity not many groups have acquired one. Hence it is important for me to monitor as many potential sources of problems as possible to avoid wasting time figuring out why something doesn't work.

One thing I've been asked many times was whether the treadmill (and other components) mounted on the airtable cause vibrations in the rest of the system. Knowing that airtables can absorb a fair amount of disturbances my intuitive answer was no. However, vibrations are funny things with hard-to-predict behaviour. Especially if there are frequencies that hit some resonance in the table frame. Further, there will be awake mice running around and nobody (to my knowledge) really knows whether they can cause vibrations in the rig or not. Since I was just playing around with electronics to build my heating mat (it still needs to be boxed up, there will be a post in the near future), I decided to throw together a system to measure vibrations.

The system consists of an accelerometer, an mbed microcontroller, an LCD display from a Nokia 6610 (they come separately, I didn't have to sacrifice an old phone) and a PC. Following is a brief description of the system (with videos!).

All the bits and pieces of the system, explanation below. You can see a second microcontroller in the top left corner, I think I fried that one but I'm not sure yet.

The central processing unit in this system is an mbed microcontroller. These nifty little things do a lot of stuff but in my case it acts as the middle man between PC and and sensor. It reads information from the sensor on its analog input pins and sends it to the PC via a serial port. There is also a LCD display attached to it which was used for debugging and directly displaying sensor output. To program mbeds you use an online C compiler and simply download the program via a usb connection, its as simple as putting  a file on a USB stick.

mbed on my development board. On the right you see the USB connector which is also used for the serial connection.

Sensor: ADXL 335 Accelerometer
The ADXL 335 including breakout board is a triple-axis accelerometer with a range of +/- 3g. Not a lot but the advantage of this is that it has a higher resolution (300mV/g) as opposed to lower-resolution sensors which cover a wider acceleration-range. The output is fairly straightforward: each pin has an ideal output of 1.5V at 0g (it changes slightly from sensor to sensor but is constant on each individual unit). When acceleration is applied (e.g. move the sensor or just let gravity do its thing) the voltage on the respective pin changes accordingly.

ADXL 335 on a breakout board. I don't want to hear any comments on my soldering job, some of the strands broke and I had to re-solder everything!

Nokia 6610 Colour LCD Display
The display is directly connected to the mbed. There is a library for the mbed which makes it very easy to display stuff on it. It is also used to output some basic data while the mbed is calibrating the sensor so I can see directly whether there is some problem with the sensor. The video shows the display while the sensor is calibrated. Apologies for the blurryness, thats as good as it gets with my phone camera.

PC Software
The software I programmed for the PC has a GUI or Graphical User Interface and was done in Java with RxTx (a MS Windows wrapper for the java.comm API). It reads the information from the mbed via a serial interface and displays a live trace on the screen. The reason for using java and not something less bulky like C is so I can make a nice GUI that gives a good overview over what kind of vibrations there are on the rig. The idea here is to have the program running somewhere on the side during experiments to always have an eye on vibrations. If I'm doing something that's very sensitive to movement (such as recording) and for some reason things go wrong I know whether I can or cannot rule out vibrations. Here is a video showing the z-axis only. I recommend clicking the Youtube button at the bottom right to watch it in a bigger window:

Calibrating the Sensor
The sensitivity of the sensor combined with the fact that nothing is ever 100% still means there are always some changes in sensor output. Also, when the sensor is mounted in a different plane I need to account for the change in direction of gravity. The solution I came up with is that when I hit the calibration button the system takes 100 samples of each axis over a period of 5 seconds and calculates mean and standard deviation. Changes on the pins are then calculated relative to those values (e.g. send an alarm when the change of voltage on a given axis exceeds 3 times standard deviation).
Two issues have crept up while building this:
  • Sensitivity of the sensor: While it has a good resolution I have yet to test whether it can pick up very small vibrations. With the current system in place however it should be very easy to replace the sensor with a more sensitive unit.
  • Serial connection: The serial stream to the PC is fairly quick, but not quick enough to show high frequency vibrations - I'm getting between 10-15 packages per second. However, the mbed reads the sensor at a much higher frequency, so if I can't figure out a quicker way to transmit the sensor values at a higher frequency I might have analyse the signal on the mbed and send alarms to the PC for high frequency vibrations. A different approach would be to calculate spectrograms on the mbed and only transmit those, thus giving the user a good overview over frequency and power of vibrations instead of a live trace.

Final Words
Whether or not this sensor will provide me with useful information or not has yet to be determined. However, it certainly provides me with a peace of mind knowing that I can monitor movements on my rig.