# Measuring Displacements Using Accelerometers: Part 3- Testing And Video

In the last post I showed the results from a test of a few millimeters but that was one of the last tests I conducted, first I tested the output of the gyroscope compared to the angle moved which I talked about before, then tested measuring a linear movement, then a movement made up of both linear and angular movements and then finally I tested the device for its initial purpose. As I already discussed testing the output of the gyroscope, I’m going to talk about the linear movement tests. I tested the device ability to measure a linear movement by mounting the sensor on a rack of a rack and pinion controlled by a servo and by controlling the angle of the servo I could repeatedly move the sensor a known distance. I don’t have a picture of the actual setup but for a visual of it, I created it on CAD.

So the sensor in black was laid flat on the rack and moved varying distance and the output of the accelerometer was compared to the calculated movement. The movement was calculated by using the equation for the length of an arc that the gear moved, this would be translated to linear movement to the rack.
$L(\Theta)=2*\pi*r (\frac{\Theta }{360})$

# Measuring Displacements Using Accelerometers: Part 2- Comparing Methods and Integration

In the last post I discussed the methods I looked into for cancelling the gravity vectors measured by the ACC, if you haven’t seen that I would recommend reading that first. The way I compared the two methods was by seeing how well they follow the raw acceleration signal from an angular movement, this was done by mounting the sensor on the side of a servo motor and moving between different angles with varying starting positions(in reference to gravity) and magnitudes of angle change. Below is the graph from a 5-degree movement.

The blue graph is the raw acceleration signal on the Z axis,red is the cos method and the yellow is the tan method, looking at the full graph(left picture) they seem to be overlapped and looks like they both follow the raw signal fairly well but in the zoomed in picture(right), both are slightly off the middle of the raw acceleration so neither seems better than the other, the Y axis showed the same result that neither stood out. I did another test where the angle change was 35 degrees and the result of the of the two axes is below:

# Measuring Displacement Using Accelerometers: Part 1-Calculating Gravity Vectors

So for my final year project I had to convert the signals from an accelerometer to displacements for a movement of a few millimetres and I decided to write about my experiences(mainly problems) doing this. I can’t say exactly what the device was as it was built for a research group but I’m going to go through the theory involved with getting displacements from an accelerometer. I’ll be making a few posts to cover the different topics. If You came here from the YouTube video and want to see the code you can jump to the third post. The movement I was measuring involved the sensor moving forward/backwards and upward/downward as well as the sensor tilting forward and backwards. The sensor used was an MPU-9150 which has 9 degrees of freedom(DOF), only the accelerometer and gyroscope were used in this application(3DOF each), a diagram of the axes can be seen below. So because accelerometers measure acceleration due to gravity this would have to be canceled to isolate the acceleration caused by the movement, this wouldn’t be too difficult if all 3 axes from the accelerometer and gyro were being recorded, using some 3d vector and trig calculations this could be done easily enough but a problem I faced was having a fixed sample rate and other sensors which had to be recorded alongside the ACC and gyro, this meant that only the necessary axes from these two could be recorded. Continue reading