Accelerometer Problem Solving

So I have been trying to make use of the vex accelerometer to calculate distance travelled but after working on it for a short amount of time, I ran into difficulties. First of all, I will describe my set up.

I am currently only working with the x-axis and to create a controlled acceleration, I mounted the accelerometer onto a sliding rail powered by a single motor and rack and pinion gears. This way, all I have to do is hit a button and it will go for a second and a half (the length of time needed to hit the end of the rail).

I am programming in RobotC.

It is only meant to return data into an array after every millisecond. Here is a graph of what I theorized the data to look like.

If you think about it, the acceleration should increase at first until it can no longer accelerate at a faster rate, then it should drop down to zero and flat line as the slider is moving at a constant velocity; then it should slope downwards into the negatives as it decelerates and hits the end of the rail where it quickly jumps back up to zero and flat line as there is zero acceleration.

After running this test and entering the data into an excel spreadsheet, I got data that looked like this.

As you can see, there is absolutely no patterns or interpretable data in this graph. According to the data, the accelerometer is accelerating and decelerating quite randomly.

Does anybody have any ideas as to what is causing this useless data? Is it just a poor quality sensor? In case it matters, we were running it with both jumpers on it.

Thanks!

A real experiment, with real data; how unusual and admirable.

You need a low-pass mechanical filter on the accelerometer sensor.
For example, hard-mount fasten it to a battery (high mass),
and soft-mount (foam, tractionmat padding) the battery to the moving carriage.
Sometimes just padding it helps damp enough, without the added mass.

Can you post your code?
For example, how do you know your data points are 1ms (or any other time) apart?

I hadn’t thought of adding a mechanical filter, that could definitely help. Here is the code, it actually takes a reading after every 10 milliseconds. Perhaps it needs to take readings more often?

#pragma config(Sensor, in1, XAxis, sensorAccelerometer)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

task main()
{
SensorValue[XAxis] = 0;
int XAxis_Val[200];
int index = 0;
time10(T1) = 0;
while(time10(T1) < 150)
{
motor[port2] = 260;
if (index < 200)
{
XAxis_Val[index] = SensorValue[XAxis];
index ++;
}
wait1Msec(10); //Wait 10 milliseconds before taking next reading
}
motor[port2] = 0;
}

There might be a spec for how often the Accel updates.
Waiting 10ms is not same as 10ms between reads, but I’m just picking nits.
You might try reading the accel, then reading the timer, and saving both, then wait 10ms.
then using XY graph in excel to plot the accel vs timer, instead just line graph…
That will also show how close to 10ms the times are spaced.

Less time between reads won’t make the reads less jittery, only the lowpass filter can do that.
If the jumpers set the scale, you could try using the other scale as well.

I have to ask the obvious stupid questions.

  1. You did connect to analog port 1, that’s how you seem to have configured it.
  2. polarity of the connection is correct.
  3. You are moving in X and not Y.

Assuming you are connected correctly, I would check the sensor is working using the debug window, create a loop in the code that does nothing for a few seconds, move the accelerometer about whilst watching the value in the debug window change. Get that working first.

2 Likes

I’ve done a a little (read hours of hair pulling) work with VEX accelerometers, and I haven’t had too much success with calculating distance with them. I hope other people have had more luck. Here’s a link to a ROBOTC forum topic with my test code: http://robotc.net/forums/viewtopic.php?f=11&t=2962

Have you tried the “Simpsons Rule” math as suggested in the April post?
I didn’t follow the early post about using gravity to find a position of 4.2 meters(?). If you are moving the accel by hand, up and down, the apparent gravity is not constant, so you should have the same issues as X,Y movement.
If you are just using the accel to find a stable x,y,z pointing orientation by using the gravity vector, then I understand. One use in Vex would be a “tip-over” detector.

In the DIYdrones site forum, there is talk about 9 degree of measurement sensors, and using an entire ATmega processor to do Kamen filtering.

We work on VEX on Tuesday so I will spend more time working with it then. Thank you very much everyone for your help so far. I will update you all with any progress I make or any further difficulties I encounter.

I have tried to do that, but I do not have access to the accelerometer anymore (it’s at school, and I’m on summer break)

I simply left the accelerometer on the desk, and told it to start counting how far it was falling. Since acceleration is the same whether you are actually falling or not, the accelerometer determined that it had fell a distance of 4.2 meters after 1 second.

I have tried to use the new VEX v1.0 accelerometer to measure tilt angles using Easy C Pro. It seems to read each axis and return values which increase or decrease depending upon the orientation. I point accelerometer in the x direction using the arrow on the board to get a reading which I expected to be 1 G (1000 millig(s) ) but the value I get is around 800.

How can I obtain consistent readings?

Is there any calibration information available for this VEX product?

jg Bold Emphasis added:
Hopefully this is just ambiguously worded, rather than fuzzy thinking.


“This is why an accelerometer in free-fall doesn’t register any acceleration; there isn’t any.”

A robot free-falling (driving off a table?, fast elevator or rollercoaster?) in a 1g gravity field will show a z-axis acceleration of zero. It is this type of zero-g detection that some notebook computers use to retract the disk heads to avoid wrecking the disks when the inevitable multi-G “hitting the floor” event follows.
Interesting to consider that this feature would have to be tweaked or disabled for those computers to work in orbit on the International Space Station.

“This is why an accelerometer in free-fall doesn’t register any acceleration; there isn’t any.”

A robot free-falling (driving off a table?, fast elevator or rollercoaster?) in a 1g gravity field will show a z-axis acceleration of zero. It is this type of zero-g detection that some notebook computers use to retract the disk heads to avoid wrecking the disks when the inevitable multi-G “hitting the floor” event follows.

You are right, I’m sorry. Let me reword my original statement. An accelerometer at rest on the surface of the earth will display the acceleration that it would appear to be accelerating at if it were in a free-fall in a vacuum.

This page(http://www.lunar.org/docs/LUNARclips/v5/v5n1/Accelerometers.html) sums it up quite nicely: “An accelerometer is a device that senses deviation from freefall.” sums it up quite nicely: “An accelerometer is a device that senses deviation from freefall.”)

I always seem to trying to answer questions for which I have no real knowledge, lets hope this one will not cost me yet another $40 :slight_smile:

The best way to go about debugging this sort of this is to write test code to look at raw data values before starting to try and use the sensor in a real application

The VEX product page tells us that the accelerometer uses the LIS344ALH from ST microelectronics, a link to the datasheet is here http://www.st.com/stonline/books/pdf/docs/14337.pdf

Looking at the datasheet the sensor has two different sensitivities, either +/- 2g or +/- 6g, the VEX product page says these are jumper selectable. Lets assume you have the set it for +/- 2g. The datasheet also tells us that the sensitivity is Vdd/5 V/g, however, even though this is a 3.3 v part VEX has placed an amplifier on the board (LMV824, datasheet here http://www.national.com/ds/LM/LMV821.pdf). We could take an educated guess and assume VEX has amplified the output to be 5V and suitable for the A-D input on the Cortex. So this probably means a 1V output from the sensor corresponds to a 1g acceleration. The datasheet also tells us that for 0g the sensor outputs Vdd/2 or, after our amplified signal 2.5V. This would make our 1g output more like 3.5V. The range of the A-D converter is 0-4095 so each 1V change corresponds to approx 820 when reading raw data. We could therefore estimate our raw sensor data value to be 2866 if we told the firmware it was, for example, a potentiometer. I have no idea what additional processing RobotC ( or EasyC ) then adds if it knows it is an accelerometer, however, if the processing is as simple as to just make the output signed a reading of 800 (digitized +3.5V - 2.5V offset ) would not be unreasonable. Do some experiments and post back the results for us.

3 Likes