Accelerometer tilt error correction - arduino

I am using arduino and accelerometer MMA7341 to measure the acceleration in x direction of an oscillating metal table. But the mounting of the accelerometer is tilted by a small angle (say Q) . Is it affect the acceleration?. If it is affect the acceleration in x direction , how can correct it without changing the tilt of the acceleration sensor.

"Tilt" and "acceleration" are both the same, from the perspective of most sensors, since both measure a force, rather than an actual angle (tilt) or change in velocity (acceleration).
What you should do is make sure the object on which the sensor is mounted is "level", within the best of your ability to determine such a thing, and use the values from analogRead() or whatever else your device provides, as the "0" values.
For the MMA7341 you'll also need to calibrate your analog signals, or else use a high precision reference as input to the Aref pin, assuming you're Arduino exposes that pin.

I think this depends on what you are measuring. THe MMA7341 looks to be able to be used for acceleration as well as tilt. If you are measuring acceleration then the mounting position doesn't matter since acceleration is a change of velocity and the velocity delta will be constant regardless of orientation.
If you are measuring tilt then thats obviously different. You could theoretically measure the initial tilt and then compensate for that in your code if you wanted to of course.

Related

Is it necessary to control a servo with pid

So, I need to build a simple gimbal with three servos to control pitch, roll and yaw. I have a 9dof imu which can give me the euler angles in degrees. Can I just connect these angle errors to servo outputs? As in with 1 degree error, the servo should rotate 1 degree, or do I have to use some form of pid control? I have worked with controlling regular dc motors with pid so that the bigger the error, the faster the motor should rotate to compensate. But it's not like I can adjust the speed the servo rotates at.
I recon there would be a problem when the angle error becomes very high in a small amount of time since the servo would take more time to reach the desired position instead of when the error is very small.
I did a similar project. It isn't perfect, but good enough. Cheap servos can't really be precise because of the cheap potentiometer inside and the horrible plastic gears.
There wont be much error overtime because common servos use a potentiometer and not a rotary encoder. Thus a PID is almost impossible.

Can I cancel out gravity only with gyro and magnetometer?

On a device I want to detect a range of forces: small forces (Minimum around 0.01g) but also stronger forces like 0.1g - 0.15g.
This device will have different positions in 3d space so in order to detect the small forces I have to know its angle in order to be able to subtract 1g. Because the device can have a random position (angle position).
What I did so far: I used the MPU6050 and used a complementary filter with accel. and gyro.
It's something like:
agnleX_k+1 = 0.98*(angle_k + deltaT * gyro_k+1) + 0.02*angle_acc_k+1;
angle_acc is the angle calculated from the accel. sensor. Something like:
arctan(accelX / sqrt(accelX^2 + accelY^2 + accelZ^2 + ))
So I am interested in:
forceX_k+1 = accelX_k+1 - 1g*sin(agnleX_k+1)
The problem is:
If I want to detect a small force coming in very fast, let's say on accelX_k+1 I would want to detect a Change from 0g to 0.01g or more but in a very small time range. The problem is that my calculated angle would then also be influenced by this small and fast change of the accel. sensor although the angle haven't really changed.
I think I would have to do the angle calculation independent of the accel. sensor. Can I do something like a complementary filter with gyro and magnetometer? Would that work the same as my filter described above but just with the mag. sensor instead? Or how would you do that? I was thinking about using MPU9250.
You stated using MPU6050, which contains both an accelerometer and a gyrosocpe. You could use them independantly - get acceleration from the accelerometer and get angles from the gyroscope, and then use the angles to compensate for rotation. There is no need for the angle to depend on your accelerometer.
Using DMP library fromJeff Rowberg will do the work for you.
it can compensate gravity acceleration internally way faster that Arduino code.
Link to github

Arduino Accelerometer: detect braking/ deceleration on a bike

I have the following issue: I'm having an Arduino + accelerometer(MMA8452Q) mounted on a bike. I'm trying to read decelerations when braking. The issue is that, due to design constraints, I can only mount the above hardware setup on the bike rider. Since the rider will change position very often the accelerometer will also change the base values I'm using for measuring decelerations (e.g. when the Z axis is perpendicular to the ground it will measure 1g, but at a different angle it will show a different value), thus rendering my code unusable.
Here are some snippets from my code:
/* Set up thresholds - 0.42g is maximum braking force the bike can do */
maximum_value = 0.7;
soft_braking = 0.4 * maximum_value;
strong_braking = 0.6 * maximum_value;
if(val > strong_braking)
{
analogWrite(ledPin, 255);
}
else if(acc > soft_braking)
{
analogWrite(ledPin, 127);
}
*val is the acceleration on the axis I'm using for measuring deceleration (after some moving average filtering).
How I can reliably compute deceleration considering that the hardware is not having a fixed position relative to the bike frame and also readings are influenced by the angle of the terrain? I'm considering using a 6DOF board (e.g. MPU6050) with a gyro and measure the angle of the board continually and adjust accelerations values based on this, but I do not know on what math I should use for this? Does anybody had the same issue or can direct me to some similar project?
You're going to have to give up on using the acceleration in a particular direction, but you can use the norm of the acceleration measurement and infer the deceleration in the forward direction by assuming that it is roughly perpendicular to the acceleration downwards.
As for mounting on the rider, I suggest a belt around the waist. This is near the center of gravity of the rider, and you can ignore shortlived accelerations from the rider moving by standing up, etc.
Don't bother trying to track the angle of the board with a gyro. The movements are so small and the uncertainties accumulate so quickly that you won't get a useful result.
For the math, let g be the acceleration due to gravity, gb be the acceleration/deceleration of the bicycle, and gx, gy, gz, be the measurements of acceleration from the device. Then by the Pytagorean theorem, the square of the acceleration
gx^2 + gy^2 + gz^2 = g^2 + gb^2
gb = sqrt(gx^2 + gy^2 + gz^2 - g^2)

Detect 3D direction of an impulse with accelerometer

I know that what I'm going to ask could sounds crazy, but I'm trying to figure out how to resolve a problem in a smart way.
It's quite difficult to explain my problem, that's why I made an hand-made draft downloadable from here :) https://dl.dropboxusercontent.com/u/5049281/static/Images_Impulse_Direction.zip.
images in that zip (copied by Spektre)
The setup can be approximated with a pipe endorsed on a rubber wall. The pipe is firmly connected (whit an unknown position and orientation) to a IMU equipped with an accelerometer and a gyroscope (sample frequency 110 hz).
I would like to discover the direction of the pipe axis (expressed in the IMU reference system) analyzing the data acquired during some taps at the end of the pipe in the same direction of the pipe axis. The taps are applied with the palm of the hand. In the figure the direction should be just on X axis.
I think that if the motion is just a translation (I could verify it checking if gyroscope data is close to zero), the acceleration (with the gravity removed) during the tap should have the same direction of the pipe axis.
Is there a smarter solution than just apply an high-pass filter to the signal an then save the direction of the sample with the higher magnitude?
Thanks for your help!

Determining the position/direction of an aircraft

I'm working in a project that involves gyroscopes...
I'm using Arduino and an ITG 3200 to read the data from the gyroscope. I get 3 values in deg/s for each axis (x,y,z).
My question is: How can I know the actual (physical) position or direction of the device (let's say an airplane). There has to be a math formula or something like that.
Using only the gyroscope signal (which you have to integrate numerically), you'll eventually run into trouble, due to drift. What's normally done is combining an accelerometer (for low frequency signals, i.e. drift) with a gyroscope (for high frequency signals). Here's a link few links showing more or less exactly what you want:
http://www.starlino.com/imu_guide.html
http://www.instructables.com/id/Accelerometer-Gyro-Tutorial
http://www.starlino.com/quadcopter_acc_gyro.html
Also, see these StackOverflow questions:
Combine Gyroscope and Accelerometer Data
Integrating gyro and accelerometer readings
gyro, accelerometer, magnetometer and Kalman filter
How to determine relative position using accelerometer and gyro data
We are working on a similar problem.
We found this video on YouTube especially helpful, as it came with a paper as well as an implementation (which runs on Arduino):
http://www.youtube.com/watch?v=fOSTOnQzZCI
The paper and source code:
http://code.google.com/p/imumargalgorithm30042010sohm/
In our case (getting the orientation of a remote-controlled ball), we also had to include an accelerometer and a magnetoscope.

Resources