How to calculate angle without moving the sensor?

Hello, I'm new to arduino (some experience with butterfly AVR)

I have searched for quite a while but I couldn't find out how to calculate the angle the sensor is in without moving the senor itself.

To clarify, If the starting position of the sensor is tilted, then I want it to correct itself so it's flat along the ground.

I would be grateful with any help.

Check this out.

Also, what is your "sensor"? Do you have any code? I hope it is a type of accelerometer and gyroscope.

Power_Broker: Check this out.

Also, what is your "sensor"? Do you have any code? I hope it is a type of accelerometer and gyroscope.

I have a Arduino 9 AXES MOTION SHIELD, Currently I have no code. I want to know what I'm going to do before I code.

In the link you provided it says "gyroscope reading for short time durations and the accelerometer average reading for longtime durations" with that they mean reading during movement right? Then that isn't what I want.

Imagine that the sensor is started while placed on an open drawbridge, I want it to calculate that it's currently in a steep angle, without the need for the bridge to move up or down. So it works like a spirit level.

Is this impossible?

fandig2: In the link you provided it says "gyroscope reading for short time durations and the accelerometer average reading for longtime durations" with that they mean reading during movement right? Then that isn't what I want.

No, it is EXACTLY what you want.

You seem to misunderstand how an IMU (Inertial Measurement Unit), such as your motion shied, works.

How it really works: The IMU sends data to the Arduino at a specific frequency. This is called the "sample frequency" and has no dependency on movement. Each piece of data send for a particular sample includes the IMU's acceleration, angular velocity, and magnetic field strength in the x, y, and z directions. (The magnetic field strength data points are probably not useful in your case, but the other data points ARE)

These pieces of data then need to be processed. This processing must happen for two reasons: 1.) The IMU itself will introduce noise that will throw off your data. Processing the data correctly will filter out this noise and leave you with a very good approximation of what orientation your IMU is positioned in. 2.) The raw data given by the IMU does not give orientation data directly. You must first convert the raw data to angles (in degrees).

After processing, you will be left with the orientation of your IMU in the x, y, and z directions.

The above process for obtaining the angles occurs periodically and the outputs can then be used to do whatever the heck you want with them (or even not at all - the choice is yours). My real question is: Why do you think the IMU needs to be moving in order to output data? It outputs data when your Arduino asks for it.

Can you provide a link to your shield?

I see, thank you for your help.

Power_Broker: My real question is: Why do you think the IMU needs to be moving in order to output data? It outputs data when your Arduino asks for it.

Can you provide a link to your shield?

In here for example he talked about degrees per second over a time period. To me that sounded like it calculates during movement (how else would the degrees change during the time?).

But it seems like I didn't understand it. Arduino 9 AXES MOTION SHIELD

The gyroscope measures the [u]rate of sensor rotation[/u], (degrees per second).

However, gyros tend to drift which means it will output some rate even if the sensor is not rotating.

The software needs to subtract that off as well as correct for other sorts of errors, while combining readings from the accelerometer and magnetometer. See this introductory page: http://www.chrobotics.com/library

Your sensor, the BNO055, can read out Euler Angles (what you are looking for) when polled by the Arduino. In this case, [u]you don't need to do any processing[/u], just have the Arduino ask for the Euler Angles and use them as you will.

fandig2: I see, thank you for your help.

In here for example he talked about degrees per second over a time period. To me that sounded like it calculates during movement (how else would the degrees change during the time?).

But it seems like I didn't understand it. Arduino 9 AXES MOTION SHIELD

You have to make a couple of assumption:

  • The sensor is fixed to the object being measured.
  • You have a known zero degree reference. The nine axis sensor has three acceleration measurement axis. You use the Known Zero degree reference to calculate the current angular position from the difference between the Known Zero and the Current acceleration measurements.
  • the sensor is not in motion.
  • the Sensor is not in rotation.

If these assumptions are true, then you can assume any acceleration is due to gravitational attraction from the Earth. The total acceleration on all axis will sum to the local gravity field. This vector will point towards the local gravitational center. Depending on how sensitive your detectors are,your altitude, and latitude this sum may not match the 1.0 standard 'g'. But it will give you a 'down' vector. When I calibrate loadcell measurement devices I have to account for the local variation of 'g' to correctly report mass using weight(acceleration).

It would not seem this would be necessary, but a 0.5% 'g' difference between the Equator and the poles is measurable.

My local 'g' is 9.79927m/s^2 at the Equator it is 9.7803m/s^2. at the poles it is 9.83216m/s^2

Using a scale calibrated at my location on the Equator would report a 50kg mass as measuring 49.903kg.

Chuck.

I didn't realize that the "Arduino 9-axes gizmo" is the BNO055.

In that case, just read out the orientation, after making sure that [u]sensor calibration is complete[/u]. See the calibration section of the BNO055 data sheet if you don't know what this means.

As usual, the documentation of the Arduino product is essentially nonexistent, so consult the tutorial posted by Adafruit (you can also use their library).

Post the code you are using, with code tags.