Measuring Displacements Using Accelerometers: Part 3- Testing And Video

EDITED 20/05/2017

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})

L being the length of the arc, r being the radius of the gear and θ being the angle the servo turned. One of the tests had the servo turn 165 degrees and the gear radius was 1.1cm so the distance traveled was 3.168cm and the results from one of them tests is shown below:


In the test the servo moved to the set angle at a constant speed, paused and returned to the starting position and this graph gives a very good representation of that, I did 7 tests for this distance and the average displacement was 3.0703cm with a standard deviation of  +-0.13cm showing that this is very accurate for a displacement of this size, some of the error can be attributed to the accuracy of the servo which had an accuracy of about +-0.1919mm using the above equation. I conducted other tests for decreasing distances and the results were very good until I got to distances of 1cm or smaller, the acceleration from the servo stepping through the angles became too large compared to the acceleration of the movement so I couldn’t measure the accuracy below this distance. I also conducted other linear tests where the sensor wasn’t mounted flat as seen in the picture below:


I mounted the sensor on a parer which had an inclination of 15 degrees and conducted the same tests as before and found that I got different results than before because the incoming acceleration is at an angle to the recording axis, the output won’t be completely right, this can be explained in the diagram below:


Because the acceleration is coming in at an angle this has to be account for and using trigonometry we can get this equation:

Acc(n)=\frac{Y(n)}{cos(\Theta (n))}

15 degrees won’t have much of an effect but it can be seen graph below:


The blue line is the displacement not accounting for the angle and the orange is accounting for the angle, the orange gets closer to real value. For larger angles, the difference would be more noticeable, you could also you the same approach using the acceleration recorded on the Z axis but as the acceleration came in at an angle of 75 to the Z axis, it might not pick up the incoming acceleration accurately. You could also use Pythagoras Theorem using the Y and Z axis accelerations but you’d lose the sign telling you the direction of the movement.

The above shows that device can measure linear displacement so now I needed to test its ability to measure displacement including linear and angular movements, for this I used a rig which would change the angle a few degrees and gave a displacement of a few cm. The rig can be seen below:


On the left is the rig which has the sensor mounted on some felt which has a wheel behind it, this wheel is controlled by a servo. When the wheel is moved the sensor is pushed or falls back depending on the position of the wheel. This rig was difficult to measure the actually distance the sensor moves along each axis but from using a ruler, I estimated the Z distance to be roughly 2cm and the Y distance of a few millimeters. The acceleration and displacement graph on the Z axis and trajectory graph from one of these tests are below:

Looking at the acceleration graph, the calculated gravity follows pretty well and the displacement graph shows a max displacement of roughly 2cm and has the shape expected of this movement. I plotted the displacements against each other to show the 2D movement of the sensor as if viewed from the side, it’s just another way of seeing if the results were correct and helps with visualising the movement. Now after this and the previous tests, I could conclude that the device was able to measure displacements but only under certain circumstances. Them being:

  • The sensor must return to its starting position
  • Must not rotate around the X axis during the movement
  • The movement must have a duration of less than 3s due to integration error
  • The minimum amount of samples are integrated to reduce integration error(user chooses start and end of movement)

So after about three and a half months, I was finished with the project and I’d say I’m happy with how it went, the problem with converting the acceleration held me back for weeks, every day I would try to try something new and it was just disheartening to not have it working for so long but it worked in the end. If someone wanted to make a device like this or if I was to make it again I would know the highest frequency you’ll be measuring then you could choose an appropriate sampling frequency to reduce integration error, make a test rig which is both very low noise and can accurately perform a movement of a few millimeters to test the accuracy of the device and finally improve the methods for removing gravity like designing a filter to do the job, even that I tried to design a filter, it’s not something I’d know too much about and maybe someone else would have better luck. Below is a video of me demonstrating the device and doing a linear test.

As I mentioned in the video because this device was built fro a research group I can’t post the Processing sketch as it has a lot of code to do with the project and would take a while to edit as to include all of the functions but remove things referencing to the project, if there’s a lot of demand I’ll post the Processing sketch. I can post the Energia code and the circuit diagram though and this can be seen below:


I have edited the processing schetch so I could upload, it and the Energia code can be found here


<< Part 1Part 2 >>


2 thoughts on “Measuring Displacements Using Accelerometers: Part 3- Testing And Video

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s