# How would I condition the signal from an accelerometer for a microphone input?

I'm looking to measure vibrations using a 3-axis analogue accelerometer connected the the microphone input on a PC. Ideally I want to combine the 3 axis into one signal as I don't really care about the x,y and z components, just the amplitude and the frequencies of the vibration.

I was looking at the Freescale MMA7361L, but I imagine anything similar will suffice.

I did an Electronics degree, but after many years of only using the digital, embedded and software side, my analogue knowledge is pretty rusty.

• Can I combine the signals using appropriately selected capacitors or should I buffer them first?
• I'm guess I'm going to have to do some level adjustment and impedance matching for the signal to be suitable for a microphone input?
• Can I use a simple passive filter to remove frequencies over 20kHz? Do I need to do this?
• What other considerations are there if I want to sample signals between 20Hz and 20kHz?

The only way I can think of doing that is to modulate the three signals using three different, audio-frequency carriers, probably using AM (since it's the easiest and cheapest to implement). You'll probably be able to find an IC that just does AM modulation, but I don't know any off the top of my head.

Essentially, you'll be taking each signal and multiplying it by a different carrier frequency, which will produce a carrier frequency that varies in amplitude as the accelerometer's signal changes. Since it's going to be a low-noise signal, you can demodulate it using a bandpass filter (to select from the three signals you want) and then use a peak detector to find the average value of the signal.

You'll do this for each signal simultaneously.

# For example:

Let's say you assign the X-axis to 1 kHz, the Y-axis to 10 kHz and the z-Axis to 20 kHz. You'll start by multiplying the X-axis output with a 1 kHz signal, the Y-axis output with a 10 kHz signal, and the Z-axis output with a 20 kHz signal. You'll then combine these signals using an Op-Amp Adder (make sure to use an op-amp with a high enough bandwidth!). This will produce a single signal that overlays the three signals on top of each other. If you looked at the spectrum analysis of the output, you'd see three spikes -- one at each frequency. The height of each peak would be the value of each associated axis.

# Extracting the signal

Once it's in the computer, you'll have to use DSP techniques to bandpass each frequency, and detect its average amplitude (after throwing away negative data, otherwise the average amplitude will be 0!)

# Pitfalls

• You'll need to pre-filter the accelerometer's data with a low-pass filter to ensure high-frequency content is removed. If you don't, you'll get a lot of cross-talk between the channels
• Writing the DSP software on the computer is not a trivial process, and there aren't any off-the-shelf programs I know that can do it. You can script it out in MATLAB or Mathematica fairly easily, but it's going to be time-consuming to develop.
• Since your signals will be bandpassed, they won't react well to sudden changes in acceleration (which generate high-frequency content).

# This is a terrible idea. Instead, do this:

I'm answering the question under the constraints you provided, however, I wouldn't ever actually implement a system like this, as every computer in the world has a USB port. Buy an accelerometer that has an i2C/SPI interface, and slap a USB-equipped microcontroller on it. Set it up as an HID device and you don't even need to worry about drivers.

Done.

• I was wanting to combine the 3-axis as I don't really care about the x,y and z components, just the amplitude and the frequencies of the vibration. I'm hoping to use the microphone input of other devices in the future (mobile phones) otherwise I would have started with USB. I'll amend my answer to make it more clear. – Tim Sep 23 '12 at 23:29
• Alright, that dramatically simplifies everything! – Jay Carlson Sep 24 '12 at 0:21

To do this right, you need to compute the magnitude of the acceleration vector from the X, Y and Z sensor values ($\sqrt{x^2+y^2+z^2}$), and then convert this result into your microphone signal.

If you simply add the three components together as the other answers have suggested, vibrations in certain directions will simply cancel out, giving no signal. Specifically, any component of the vibration in the plane defined by the equation x+y+z=0 will be "invisible", which is another way of saying that you'll only be sensitive to vibrations along the axis perpendicular to this plane (x=y=z). In other words, this scheme is no better than simply using the signal from any one axis by itself.

Unfortunately, the magnitude calculation also rectifies the signal (the result is always positive), so the microphone signal won't be a direct representation of the ± value of the actual vibration. I can't immediately think of a workaround for this; perhaps it doesn't matter in your application. Or you could, for example, simply multiply the magnitude by the sign of one of the original x, y or z components, chosen arbitrarily.

• Adding the squares of the x-, y- and z- components is even worse than adding each component directly, as it is constant for any rotary acceleration. – Curd Sep 24 '12 at 13:50
• @Curd: Of course, that's why it's a good idea to restore some sort of sign information. – Dave Tweed Sep 24 '12 at 14:12

I would build a simple "virtual earth mixer" around an op-amp operated inverting mode, followed by another op-amp to buffer the signal, un-invert it and provide a bit of gain adjustment.

After you clarified your question to indicate you don't need to differentiate the separate signals, I drew up a schematic for you: It's a non-inverting summing amplifier. You'll want to adjust the gain (by adjusting the R4 pot) so that the signal doesn't clip.

You won't be able to use a "virtual ground" configuration that another answer mentions because your signal is not AC, and therefore, cannot be capacitively-coupled. Because of that, you'll have to use a non-inverting summing amplifier, instead of the more traditional inverting one.

Of course, if you have access to a bipolar supply, you can just use the inverting summing amplifier instead.

Since you don't care about each component (x-, y-, z-) separately the easiest solution is to measure only one component and ignore the other two (This is at least as good as adding all components together which is nothing else but a special matrix multiplication of the acceleration vector. And the same result you could get if you rotate the sensor mechanically and consider ony one component).

So I suggest to measure only one acceleration component and mechanically adjust the direction of the sensor for maximum amplitude.