IMU accelerometer data, integration and display

hi all,

I'm new to arduino and have no prior coding background. so forgive me for being a n00b/dumb ass etc.

I'm using the Pololu minimu v3 9dof -> https://www.pololu.com/product/2468

It comes with the minIMU-9 program as seen in the resources section on the Pololu website.

What i want to do is use the IMU for station keeping/hover mode for a model ROV i'm building.

To do this i want to take the accelerometer data for the x axis from the IMU. Then integrate this data twice so that i can get position. If i'm correct the first integration will give me velocity and the second integration will give me position.

Next i want to store the x-axis position value when a button is pressed; as this will be my desired position. Then by continuously comparing the position data to the position that I have stored I should be able to get the error between these two positions (could also be called the displacement?). I then want to print this error in the serial monitor.

After doing this for the x-axis i will repeat it for the z-axis.

later I want to use this error to control bilge pumps so I can have the rov maintain its position.

not sure i made that more confusing than it needed to be or not so this might be easier to follow...

integrate accel_x to find velocity_x integrate velocity_x to find position_x

store position_x when button (high) stored position = desired_x

desired_x - position_x = error_x

serial.println (error_x)

If anyone can help at all it would be greatly appreciated!

I never understand questions like these.

What kind of "help" are you expecting?

Do you know any programming?

What code have you attempted?

Helping is not do the whole thing for someone. You have to make some sort of attempt first.

sorry probably should have included this. i dont really know much programming.. this was my attempt so far

//station keeping//

int velocityx; int positionX;

//first integration velocityx[1] = velocityx[0] + accel_x[0] + ((accel_x[1] - accel_x[0])>>1) //second integration positionX[1] = positionX[0] + velocityx[0] + ((velocityx[1] - velocityx[0])>>1);

int desired_x = positionX; //at time = station keeping start (want to store this value) int desired_z = accel_z;

// if X_button (high) desired_x = accel_x //at that time // if X_button (high) desired_z = accel_z //at that time

//loop while station_keeping = 1 desired_x - accel_x = error_x Serial.println (error_x)

desired_z - accel_z = error_z Serial.println (error_z)

That is not a complete program. Have you looked at any examples?

Also, when you post your code:

  1. Use CTRL-T in the Arduino IDE to autoformat your code.
  2. Paste the autoformatted code between code tags (the </> button) so that we can easily see your code.

Perhaps you want the “Gigs and Collaborations” section of the forum?

This comment is wrong:

     //loop while station_keeping = 1

I don't even see where station_keeping is calculated.

This is backwards:

 desired_x - accel_x = error_x
 Serial.println (error_x)

 desired_z - accel_z = error_z
 Serial.println (error_z)

If i'm correct the first integration will give me velocity and the second integration will give me position.

In theory, and in the absence of noise and other sorts of errors, yes.

In practice, no. Read about why this idea won't work here.

jremington: In theory, and in the absence of noise and other sorts of errors, yes.

In practice, no. Read about why this idea won't work here.

okay thanks for that link; "After ten minutes, the position will be off by 62 kilometers."

that's a fair distance haha, do you have any other suggestions about how i might be able to do position based control with the IMU?