The accelerometer is a sensor type that falls into the same category as the gyro (and is made by the same company). Surprisingly, this sensor has more technical details available than the gyro does, but by all accounts, using the accelerometer in VEX competitive robotics is either (a) limited, or (b) really, really hard.

VEX accelerometerThe Specs

Product page for the VEX accelerometer; cost: $40 for one sensor; analog.

This sensor can measure acceleration in the x, y, and/or z axes. As shown in the image at left, there are 3 rows of 3 pins in a block, with “X Y Z” printed on the component. One is not required to measure all axes; just attach a 3-wire extension from a cortex analog port to whichever direction(s) you want to measure.

As with the gyro (yaw) sensor, the black pin of the 3-wire extension goes on the side with the teeny-tiny “B”. There is also a teeny-tiny green light (next to the word “Power”) that will turn on if you’ve got it plugged in correctly.

The accelerometer also comes with a little doo-dad called a jumper (photo, left) that can be used to increase or decrease sensitivity of the measurement; that choice is a tradeoff with responsiveness.

Using It

Simply getting data out of the accelerometer is not that hard; read the analog port to a variable, and there you go. RobotC has an info-sheet with some sample code to do that.

However, most teams that think about using this sensor want to do so because they want to use it to calculate the robot’s position on the field. Chassis like an x-wing holonomic drive do not easily lend themselves to using shaft encoders, what with the wheels going in all directions, so it seems at first blush that an accelerometer would be a useful replacement when combined with a gyro.

However, this component measures acceleration, not velocity or position. To get from acceleration to velocity, one must use calculus integration for your answer. To get position on the field, one must then integrate that velocity result (while the gyro sensor looks very similar to this one, the gyro actually does this integration for you, before you even get the data into your program). Double-integration results in large amounts of noise/error, which requires employing sophisticated filtering code (Kalman filter) on top of that. This video from a presentation at Google explains what’s going on inside an accelerometer, and why using it is hard (start around the 8:50 mark in the video).

I’ve seen 2 uses mentioned that seem reasonable for competitive robotics. The first is to detect if you’ve run into something (like the field perimeter) and have come to a halt unexpectedly. The other is as a tilt sensor. In many VEX games, robots have tall lifts for stacking things; sometimes they fall over when the lift is extended up high. Using the z-axis of the accelerometer could tell you when the robot is tipping, and initiate some sort of corrective action. Figuring out what that corrective action should be on-the-fly is another matter entirely, as described here by FullMetalMentor on the VEX Forum (this thread has many helpful/instructive comments and links).

However, you must be careful when using an accelerometer this way. You must consider the difference between the dynamic measurement and the static measurement conditions. For example, when the robot is not moving so much, the conditions are nearly static, in which case the accelerometer is measuring the gravitational acceleration vector, which can be used to sense too much of a tilt. But when the robot is rapidly moving around, it will experience accelerations in all sorts of directions and the accelerometer will measure the gravitational vector added to whatever centrifugal vectors, etc. the robot might be experiencing.

You do not want to program the robot with an anti-tipping code that might get activated simply because the robot made a fast turn and sensed an acceleration that the code interpreted as being a tilt.

Here’s a screenshot from the first page of the accelerometer documentation for a single-axis tilt measurement:

Tilt-sensing with the VEX accelerometer

Additional Resources

The manufacturer’s website actually has a bevvy useful information for the accelerometer (much more than what is available for the gyro):

Share this post: