# OpenWave #5 : The displacement calculation problem

In this post I will go into detail about the steps I’m currently using to go from vertical acceleration data from the IMU to vertical displacement and the issues I’m having.

### Step 1: Getting acceleration data

The first step is to setup the rotating arm with the IMU attached, rotate it for a fixed amount of time, say 60 seconds and capture the raw linear acceleration data for the z-axis which is the vertical axis. See below video for an example of the rotating arm.

Note that this video is just an example of the arm rotating. All of the data used in this post was obtained with the arm set to a 40cm diameter and a rotation speed of approximately 0.2Hz. The recorded z-axis acceleration data looks something like this:

### Step 2 : Filtering acceleration signal

As it is, this signal is too noisy to work with and so it is first filtered before any other signal processing steps occur. The low-pass filtered signal is shown in orange below:

### Step 3 : Peak detection

Now that we have a relatively smooth signal to work with, peak detection is relatively simple. The orange x marks on the graph below mark the peaks and troughs of the signal.

### Step 4: Break signal into chunks and double integrate each chunk

These peak detection points are used to break the signal into chunks where each chunk is separately integrated twice to go from acceleration chunks to displacement chunks. The displacement chunks can then be graphed which looks like this:

Note that I’m using dots to represent the points instead of a continuous line so you can actually see the separate displacement data chunks. Another issue is that the way in which the signal is broken into chunks drastically affects the end result. The above image was obtained by detecting the minima and maxima and breaking the signal into chunks at those points. If you break the signal at just the minima you get the following displacement graph:

By using the maxima to reset the integration you get this graph:

Remember that the actual arm diameter was 40cm so we should see a maximum displacement of 40cm. Take the above image for example. The first blueline on the left goes from approximately 0.2m down to -0.5m which is a total displacement of 0.7 meters. The rightmost blue line is a better example of what I’m looking for. It goes from 0.2 down to -0.2 which is exactly what the expected result would be. I’ll do some more testing over the next few days to try and narrow down what the problem is. It may just be that the accelerometer itself has quite a lot of drift even with the short integral reset periods.

This entry was posted in Uncategorized. Bookmark the permalink.