Accelerometers

From Mech
Jump to navigationJump to search

[Note: This page describes particular accelerometers, but you should expect to get your own (and not necessarily these models) as the Mechatronics Lab does not generally stock significant numbers of these. You can buy the accelerometer chips by themselves, but they usually come in surface mount packages that may be difficult to work with. Instead, it is easier to buy evaluation boards that break out the pins for you. Accelerometers with analog voltage outputs are recommended for easy interfacing to a PIC. These boards often have low-pass filters on the output, too; if so, you may need to change the capacitor to get the cutoff frequency you want. Expect to pay $30-$50 or so for two-axis and three-axis accelerometers from vendors such as Sparkfun, Digikey, and Parallax, or directly from the manufacturers such as Analog Devices, where you may also be able to get free samples. Choose the range best suited for your application (e.g., 1.7-2 g's if you're simply measuring orientation in a gravity field, or perhaps up to 5-20 g's if you are actively vibrating). Some accelerometers offer you a choice of operating ranges.]

Mems accelerometer.png

Accelerometers measure linear acceleration and also gravity; the two are indistinguishable. Thus they unavoidably function as tilt sensors as well. Inexpensive 1, 2, and 3-axis accelerometers are available which are constructed with MEMS techniques. MEMS gyroscopes are also available, for measuring angular velocity, but are more expensive.


Carrier.jpg

The LIS2L02AS4-TR accelerometer gives you a choice of +/-2g or +/-6g full scale. It needs only a single +5V supply. Its bandwidth is from DC to 1.5KHz. The output is usually low-pass filtered in applications which do not need the full 1.5KHz bandwidth, using an external capacitor.

The chip is available only in a surface-mount SO-24 package. Fortunately an adapter socket (Digikey A322-ND) can be used to give the chip convenient DIP-24 legs.


Somesoldered.jpg

Soldering the chip into the adapter socket is a little challenging. Here are some tricks that make it easier. The more of these you can take advantage of, the easier it will be.


  • Use a very fine pointed soldering iron and fine solder.
  • Apply a bead of liquid flux to the pads, which will make the solder flow in between the pin and the pad enthusiastically.
  • Tape the chip down onto its socket adapter.
  • Have a magnifying lens or loupe available.
  • Know which pins are not used.


The last point is especially useful. Start with pin 1 which is NC (Not Connected), so that even if you get a solder blob connecting pins 1 & 2 that's ok. If the other pins are all aligned with their pads, pin 1's solder will now hold them there. If not, melt pin 1's solder and adjust.


Chip.gif


Now solder only the other pins that are in use, as shown in red on the diagram. Solder one or two on the opposite edge as well, for mechanical stability.


Pins marked "reserved" should not be solder-blobbed to their neighbors because we don't know what they connect to inside the chip. Reserved is not the same thing as NC.



Circuit.gif


Use a supply shunt near the chip (1uF) from +5 to ground). Use low-pass filter capacitors on the outputs (called Cload in the diagram). The output impedance of the chip is 110Kohm, so a 0.1uF capacitor gives a low pass time constant of ~10mS.


Tie ST, PD low, and FS low for +/-2g full scale operation. The output voltage ranges 0-5V, well matched to PIC inputs. 2.5V is the output when acceleration is zero and and the chip is horizontal (not tilted.)


The circuit shows some optional buffer amplifiers to produce a low impedance output.



Accelerometers and Low Pass Filtering

When using accelerometers in applications with high ambient vibrations, filtering the output signal is essential for limiting noise. While in many cases first order (RC) low pass filters may be sufficient to attenuate ambient vibration, if those vibrations are great in magnitude and/or relatively close in frequency to the desired output, second order filtering may be necessary. In addition, in order to protect the accelerometer from sourcing excessive current and dropping its output voltage, it is advisable to use active rather than passive filtering. Both of these criteria are met by Second Order Active Filters, specifically a second order active low pass filter.


The one major disadvantage of a second order filter is an increased maximum lag from 90 to 180 degrees but as with any filter, if C and R values are chosen carefully, the desired signal should not lie within that range.

Two Axis Accelerometer Analog Devices ADXL203


AccelXY.JPG

This accelerometer from Analog Devices is very useful due to its availability from circuit suppliers as an evaluation board. Although the component itself is small it comes mounted to a board which allows it to be plugged into any breadboard for testing and prototyping. The range of the accelerometer is ±1.7 times gravity which is useful when the primary value of interest is the angle of a plane with respect to gravity.

The accelerometer takes in a 5V power signal and outputs two voltages which are the x axis and y axis outputs. When the accelerometer is perpendicular to gravity both the x and y outputs read a voltage of about 2.5V. Rotation about one axis, Z axis in the example images, will produce a varying signal from the Y output and a constant 2.5V signal from the X output. Rotation about a second axis, X axis in the example images, will produce a varying signal from the X output and a constant 2.5V signal from the Y output. Rotation about the final axis, Y axis in the example images, will produce varying signals for both outputs.


AccelYZ.JPG

Tilt of a Two Dimensional Object

If you only need to sense the tilt of a planar object, one accelerometer is sufficient. The accelerometer should be mounted so that the circuit is perpendicular to gravity, either face up or face down, for the standard orientation of your object. This mounting will give the greatest change in voltage output per degree of tilt. In this position, both the X and Y output should read roughly 2.5V. Tilting -45 to +45 degrees about either axis should vary that output between 1.75V and 3.25V. In this range, the change in voltage is roughly linear and equal to .0167 V/degree. For angles of tilt much greater than 45 degrees in either direction the accelerometer is less sensitive and the linear relationship no longer holds. If the angle of tilt that you are expecting to measure is much greater than 45 degrees consider either a second accelerometer or a look-up table.

Orientation of a Three Dimensional Object

Because the accelerometer gives the same response whether the circuit side is up or the circuit side is down, a second accelerometer is needed to distinguish between these two orientations. The second accelerometer should be oriented out of plane with the first accelerometer, preferably at a 90 degree angle. If either accelerometer is perpendicular to gravity, the outputs from that accelerometer will be roughly 2.5V. However, the second accelerometer will have a low output for one orientation and a high output for the other orientation.

If the object of interest is oriented with both accelerometers parallel to gravity, each accelerometer will have at least one output that is either very high (3.5V) or very low (1.5V). This allows orientation to be determined for the third axis without the need for a third accelerometer. The other outputs from the accelerometers will be roughly 2.5V but will be very sensitive to tilting out of plane. These outputs can therefore be used to determine the precise angle of the object with respect to gravity.


AccelXZ.JPG

Using the Output

To read the x axis and y axis outputs, which are analog voltage signals, you can use the analog to digital converter built into the PIC. Sample code to read in the data from two accelerometers can be found here. This converter takes in the analog signal and converts it to either a 10 bit or 8 bit value which can be understood by the PIC. A 10 bit value will give better resolution, with every binary increment being equal to an increase of 0.005V in the analog signal. A 8 bit value will have slightly lower resolution, with every binary increment being equal to an increase of 0.02V in the analog signal.

The analog voltage is converted to a binary value with the specified bit value and can also be read as a decimal value. The analog voltages along with their resultant binary and decimal values for 10 bit and 8 bit resolution are given in the table below. All other intermediate values follow a linear relationship between analog voltage and binary value.

To determine which side is upwards, the controller can compare the four accelerometer outputs. When any side is facing upwards, one of the four accelerometer inputs will be either very high voltage (greater than 3.25V) or very low voltage (less than 1.75V). The controller checks the accelerometer output values until one of these conditions is met and references the correct side as being upward. Sample code for this calculation is given here. This code assumes that two accelerometers are being used so that orientation can be determined if any of the six primary sides is facing upwards: +X, -X, +Y, -Y, +Z, -Z.


ADCvalues.JPG