Accelerometer Conversions?

Last week our team bought the new accelerometer from the vex store. After looking around on the forums and testing it, we encountered one problem. How do we take the value (Say 750) and convert that into velocity?

Well I’m assuming that simple physics should be able to solve your problem. I haven’t used an accelerometer so I’m not sure but here is some physics for you.

velocity_final^2=velocity_initial^2+2accelerationchange_in_distance
velocity=velocity_initial + accelerationtime
change_in_distance=velocity_initial
time +(1/2)accelerationtime^2

Turn the accelerometer 90 degrees towards the positive X direction (that is, tip it on its side).

Observe the X-axis reading from an online window. What you are measuring is exactly one G. You can assume the output is linear on these accelerometers.

One G is 9.8 meters/sec^2. That’s about 32 feet/sec^2.

Its not likely that you will see that high a reading from driving your robot around. So the number you observe is the denominator of the fraction you can use to calculate the robot’s acceleration.

Say for example the reading you see on your tip test is 800. If you later observe a reading on your robot of 200 that means 200/800 or 1/4G.

Multiplying the fraction 1/4 times 9.8 gives you about 2.5m/s^2. That is the acceleration of your robot at the time you made your measurement.

Hope this helps. Final tip, always make sure the accelerometer is mounted so that its perfectly level on the robot. If its not level then gravity will skew your readings.

Regards,
KHall

Wouldn’t that depend on how quickly you rotated it? Maybe I’m just not understanding things right.

It is a bit tricky to visualize, but the accelerometer measures linear acceleration along the three spatial dimensions. If you rotate the it around the exact point where the sensor element is inside the chip, then there will be no linear motion and so no acceleration will be measured measured. In this case, it won’t matter how quickly you rotate the sensor.

Rotating the accelerometer around a point that is not the same as the sensor element will generate two kinds of acceleration (tangential and radial):

[LIST=1]
*]There will be acceleration measured along a tangent to the sensor’s path that tracks the sensor’s angular acceleration. In this case, the sensor is actually measuring the linear acceleration along the circumference of the arc.
*]There will also be acceleration measured radially (along the line from the center of the arc to the center of the sensor) that tracks the sensor’s angular speed. This is acceleration due to centrifugal force, and is the reason the string stays taut if you swing a ball on a string around over your head.
[/LIST]
The further from the center of rotation the sensor is, and the faster you rotate it, the stronger these accelerations will be.

Rather than getting bogged down in all the geometry terms, I recommend experimenting the the accelerometer. Just mount it on a piece of Vex metal and move it around while watching the values in the On-line Window. You’ll pretty quickly get a feel for how it responds to various movements. Once you’ve done that, the math will be easier to see.

Hope that helped a bit,

  • Dean

Rest assured: if an accelerometer is tiped on it side so that its making a right angle with the Earth, and it is at rest, the axis facing down will measure exactly 1 G. In fact that is pretty much the definition of 1 G.

I think the difficulty is this. It may be surprising to realize that even when things are motionless on Earth, gravity is still causing an acceleration on them. It is rather counter-intuitive, and we humans have really only been aware of that fact for about 100 years now. Prior to that, it had been assumed that gravity was some kind of attractive force between all matter. The problem was that a force requires a field to work (like a magnetic field) and nobody could ever detect such a field.

Then a physicist pointed out that if you were in a widowless box on the surface of the Earth or in that same box out in space accelerating at 9.8m/s^2 there would be no way for you (inside the box) to be able to tell the difference. So to a local observer, gravity and acceleration are the same. Its since been confirmed many times and NASA even built a satellite that measured a strange consequence of that theory called frame dragging. It all seems to have checked out so far.

Yeah, the physicist was Albert and his relativity. He taught us that gravity causes acceleration to objects even when they are at rest. Just tip your accelerometer on its side and you can prove it to yourself. And I think he would have loved VEX if had been around during his lifetime!

Regards,
KHall

Just to be clear, my prior post was only discussing acceleration due to rotation of the sensor. As you say, gravity is a 1G constant acceleration that the sensor will always read (unless the sensor is in free-fall).

The sensor will measure the sum of acceleration it is experiencing, so the reading you get back will include actual acceleration as well as gravity. Depending on exactly what you are trying to determine with the sensor, that can be fine, or it can require some significant post-processing.

  • Dean

OHHHH

I get it now. I thought you meant the rotation is what would measure 1G, but you were really just saying to point the sensor in a direction where there is a constant, known acceleration of 1G (which would be perpindicular to the horizan).

Very smart and simple :slight_smile:

Sorry to bump the thread again, but its better than making a new one. My question is does anyone know what jumpers have to be in what places for adjusting the sensitivity of the accelerometer?

Did you look at the documentation? There are jumpers that you can install. Reading the directions would be the best place to start.

I would look at the documentation that came with it, but the problem is… there is no documentation. All we got was the accelerometer in a plastic package and thats it.

Isn’t there a PDF for it on the site? Every other vex part I get has those pages to put in your 3 ring binder.

my swerve drive kit didn’t have an insert. it was in a plastic bag with the parts, that’s it. i’d say it’s just laziness in packaging, i sort of expected a better package.

Weird, my claw that I just ordered was in a standard Vex box with the insert. I know that thing is pretty new, wasn’t sold in stores. Wonder why they slack off on some, but not others.

The lack of housing on the accelerometer is something I find sub-standard, for Vex.

Its easy to to figure out the jumper settings. Once you do please post your results so that everyone will know the answers.

The accelerometer has four ranges: 1.5G, 2G, 4G, and 6G. Another way to think of that is this: given a contant amount of acceleration, the 1.5G will register the largest analog value. Then 2G a little less, and 4G should be about half of 2G. The 6G will register the smallest analog value.

So here is how you measure that. Pick an axis, say X. Mount the sensor so that the X-axis is pointing down (that is, the sensor will be resting on its side so that the X arrow is pointing towards the ground). Doing that will give the X-axis a source of constant acceleration (gravity). Now use an online window so that you can see the analog port’s value.

It may help to get a piece of paper and make a table for the two jumpers. They should be marked 1 and 2. Here are all the possible combinations:

#1 #2
ON ON (Both jumpers installed)
OFF ON (no jumper on 1, jumper on 2)
ON OFF
OFF OFF

For each of the above combinations record the reading from the analog port. The largerst reading will be 1.5G, the next smaller reading will be 2G and so on until the smallest reading which is 6G.

Please post the numbers that you record and your conclusions about which jumper settings correspond to the four levels of acceleration.

Enjoy,
KHall

Here 'ya go. For this test, the accelerometer was bolted to a hunk of C-channel and laid flat so that X and Y were pointing toward the horizon, and Z was pointing toward the sky. X & Y should report values near 512, and Z should report a larger value (since gravity is indistinguishable from upwards acceleration).

The raw data:

Jumpers__|__X____Y____Z___|_Range__Sum
 none    | 537  520  763  |  1.5G   0
 1 only  | 530  517  699  |  2.0G   1
 2 only  | 516  517  601  |  4.0G   2
 both    | 512  510  568  |  6.0G   3

So the easy way to remember the jumper settings is to add the values of the installed jumpers; The larger the sum, the larger the range. (This is what the “Sum” column is.)

As for the connections, the white wire of each extension cable goes near the ‘X’, ‘Y’, or ‘Z’ silkscreened on the board. The black wires go at the other end, adjacent to the ‘B’ silkscreened on the board.

Here is a closeup so you can see what I’m talking about.

[INDENT][ATTACH]1191[/ATTACH][/INDENT]

Cheers,

  • Dean
    2009_2_4_20_4_10 ps.jpg

Nice job, but I was hoping to encourage the younger folks. The adults here should know how to get the answer straight off of the manufacturer’s data sheet (below).

From your numbers, it also looks like the Z axis has a built-in compensation.

If you mount it so that the X arrow in your photo points straight down you will see much more pronounced results.

KHall
MMA7260QT.pdf (195 KB)

Sorry to spoil the lesson, but I think there are lots of folks interested in this product that haven’t bought it yet. With most other VEX products, they can evaluate the guide insert online to see what they’re getting, but in this case there isn’t a ton of info available.

Being an adult working with VEX does not guarantee familiarity with data sheets. I’ve had several adults from this forum contact me for help with various data sheets. I know of several who have more of a mechanical engineering background. Also, the data sheet below does not tell the whole story, since there are op-amps on the output channels.

I just double checked, and got similar results on all three axis. It looks like the ranges are a bit wider than advertised, but that is probably to ensure linearity within the spec’d range. Analog systems tend to be less linear near the power rails, so providing a margin is good engineering practice.

Cheers,

  • Dean

There seems to be a basic science concept that keeps being missed here. Perhaps some photographs and a little simple math will clear that all up.

The first photo shows a test system. It’s a carrier board with the identical accelerometer chip VEX uses. It’s a 3.3V chip so I’ve added an op-amp with the gain set to 1.5. That will bring the output back up to the 5V range that the VEX controller is expecting.
https://vexforum.com/gallery/showimage.php?i=2746&c=4
Sitting flat as shown, the sensor’s x-axis measures 507 on the EasyC online window.

The next picture shows the sensor sitting on its side. Its x-axis arrow is now pointing straight down and it is therefore experiencing a constant acceleration of 1G. Gravity provides a constant 1G of acceleration downward to all objects at rest near to the surface of the Earth.
https://vexforum.com/gallery/showimage.php?i=2746&c=4

Here are the analog readings from the EasyC online widow:

Jumpers
1 & 2 Reading
ON ON 749
OFF ON 685
ON OFF 592
OFF OFF 568

From this data, you can see that the largest reading corresponds to the 1.5G setting and the smallest one corresponds to the 6G setting. Why? Because given a constant acceleration, you would expect the 1.5G setting to be the most sensitive and the 6G setting to be the least sensitive.

Now let’s do a little math to validate the results. First it’s handy to have the amount each reading changed from laying flat. That will tell us how the sensor responds to the difference between 0G and 1G.

749 - 507 = 242 1.5G
685 - 507 = 178 2G
592 - 507 = 85 4G
568 - 507 = 61 6G

For example you would expect the change in the readings from 2G to 4G to be twice as large. And in fact 178/85 = 2.09. And 6G should be three times 2G, and 178/61 = 2.9. You can check the rest of the ratios. But I’m sure they are all pretty close like that.

You should try this test yourself and examine your results in comparison to mine. Since I don’t have the exact same sensor as you do, I would expect there to be some differences. Please post your results once you’ve done the test and double checked your results.

Finally, armed with this information you can now measure the acceleration of your robot with a reasonable degree of precision. Let’s say you set the jumpers on your sensor to 1.5G, and when you give it a constant acceleration of 1G it measures 762. Then you lay it down flat and it reads 512. That means that 1G is 762-512 = 250 on your sensor. And 1G = 9.8 meters per second squared.

If you later observe a measurement on your robot of 562 while it is moving (562 - 512 = 50), that means it is accelerating at (50/250) * 9.8 = 2.0 meters per second squared.

Hope this clarifies this basic science fact for everyone plus demonstrates how to calibrate and make smarter use of your accelerometer sensor.

Regards,
KHall