# Accelerometer and calculating position, angle,time

1. May 10, 2013

### angier

I am working on a project where we will use a 3-axis accelerometer on the door and using the ax, ay, az data to calculate position and angle of the door. The accelerometer will be positioned near doorhandle. So the initial position of coordinate system will be there, where the accelerometer is.
While the door will be opening the position of coordinate system will be moving(rotating).
Need help with calculating the position and after that the angle of the door. Especially I don't know how to take into account that we have rotating coordinate system. It seems a tough problem...

#### Attached Files:

• ###### Accelerometer.JPG
File size:
8 KB
Views:
279
2. May 10, 2013

### Simon Bridge

Welcome to PF;
Your accelerometer is attached to the door - so that's your coordinates.
If you put x horizontal, y vertical, and z pointing away from the door, then any instantaneous acceleration in the z direction will be tangential to path the door makes - then you can predict which axis there will be reading in for the accelerometer.

You need to use your knowledge of rotational motion for this.
If the door opens with a constant angular velocity, which direction is it accelerating?
However, the door will have some angular acceleration too - can you relate angular and tangential acceleration and velocity?

That should get you started.

3. May 13, 2013

### angier

Dear Simon! Can you be more specific, I need more help! Thanks in advance!

4. May 13, 2013

### Simon Bridge

I have been specific.

...
...
"dear"? :/

5. May 13, 2013

### angier

I prefer the natural system of axis orientation, so x is horizontal, y is away from the door and z vertical. So, the y axis will be tangential to path the door makes. In this way also door is accelerating in y direction.
And yes, tangential acceleration is a product radius and angular acceleration. I know physics, I just need help with math...

6. May 13, 2013

### Simon Bridge

Fair enough - use whatever axis system you are comfortable with :)

... it is not good enough that you know - you have to tell me or I'll waste time telling you stuff you already know ;)
The questions are supposed to tell me what you already know, identify weak spots, and guide you through the experiment design - which you are supposed to be doing yourself BTW.

Anyway, you just related some of the math you needed - so you do know some of the math.

From what you said:
The y-axis acceleration readings will be the tangential acceleration.
How would you measure the radius to use to get the angular acceleration?

Is the y-axis the only direction you should see an acceleration?

7. May 13, 2013

### angier

Basically we get data from accelerometer, which means ax, ay and az. So if I set the coordinate system as I have described above, this means that ax=w2R(w-angular velocity, R-radius) will be radial acceleration, ay=aR(a-angular acceleration) will be tangential acceleration and az will measure gravitational acceleration-g. Correct me, if I am wrong. From ay I can calculate angular acceleration, from ax angular velocity and from there probably the angle the door makes? Radius is fixed and determined by the door size.

8. May 13, 2013

### jbriggs444

Using centripetal acceleration (ax = ω2r) to compute angular velocity will, I suspect, tend to run into problems with resolution at low accelerations. Since centripetal acceleration scales as the square of angular velocity, a small velocity will be reflected as a very small acceleration.

Then too, you can only measure the door's angular speed, not velocity, based on centripetal acceleration. Opening and closing look the same.

You could integrate angular acceleration to get angular velocity instead. But then you hit the opposite problem. If the door slams you get very high and very sudden accelerations for modest velocities. Your equipment may not be able to register that accurately.

And you also have the problem that small systematic errors grow quadratically over time.

Possibly you want to apply some to sanity-checking to the measurements that you obtain -- cross-checking the speed figures estimated from centripetal acceleration against the velocity figures dead-reckoned from angular acceleration.

Possibly you want to figure out some heuristics to detect slamming events and coast-to-a-stop events.

If it were me, I'd be sanity-checking the z axis data as well. If somebody takes the door off the hinges, it'd be good to know.

9. May 13, 2013

### Simon Bridge

Now you are cooking :)

You know the equations for all those right?
Then you have all the math you need.

There are limits to how I can advise you because you haven't provided a lot of detail. I'm not going to wrestle the information from you - you don't want to tell me anything just say so and I'll leave you to it. Going only off what you've told me, I have to guess some stuff, i.e.

I'm guessing that the accelerometer is some device hooked to a computer that sends a time-series of acceleration data.
The data gets stored somehow and you have some sort of software to access it somehow.

You could, in principle, plot this data as acceleration vs time graphs.
Software typically provided with accelerometers has the ability to do this built in.
The area under the a-t graph is the velocity.
The area under the v-t is the displacement.
... again, software typically supplied is capable of computing these graphs from the data.
If not, then you will have to tell it how - hint: numerical integration.

Careful with centripetal acceleration.
Since the radius is fixed, what is wrong with using the tangential acceleration to get velocity and position?

Try to anticipate wrinkles. i.e.
The door will not generally be moving at a constant angular speed.
It is possible that the door can have accelerations that are too big or small to be measured by the instrument.
You have to figure what to do about this stuff ... and what else you can think of.

However - I am guessing that this is a teaching experiment set you so you can discover/learn about experimental design.
If that is the case, then you shouldn't stress about getting everything perfect. You'll quickly discover what sort of thing can go wrong when you do it - which is the whole point.

10. May 17, 2013

### angier

Thnx to both, Simon Bridge and jbriggs444! I am aware of the problems you have mentioned, but we will try and we see what comes out. There is another challenge. What if the z axis is not exactly in the direction towards the center of the earth and also the x axis not exactly towards the origin of rotation etc. Then probably I will have to apply rotation matrix 3 times, to calculate the exact values of ax, ay and az? What do you think about it?
Also, the accelerometer has the sampling rate of about 250 Hz.... and it's accuracy is 5 %, at least that's what they say....

11. May 17, 2013

### jbriggs444

If the alignment of the accelerometer is off by a bit, that seems like a simple thing to deal with -- at least as long as the door behaves ideally.

All you need to do is rotate your as-measured acceleration readings in the accelerometer frame to ax, ay and az readings in the door frame. As long as the angle between accelerometer and door is fixed, that's a fixed 3x3 rotation matrix applied to the input 3-vector to produce the output 3-vector.

An accuracy of five percent... I'm not sure what to make of that. Sounds hideous. Which suggests that you have some calibration work to do. You need to figure out just how far you can trust your tools.

12. May 17, 2013

### Simon Bridge

A 5% accuracy is pretty bad for an accelerometer - it sounds like the sort of thing you get in a phone in fact [1][2] - but it means you probably don't have to be very accurate in setting it up. What level are you performing this experiment at? (It sounds like a HS exercise in rotational motion - but it could be part of a senior undergrad project in electronic and computational engineering.)

You can probably get away with using a spirit level and a set-square to set the alignment - you may want to tape a protractor to the door (use with a plumb-line) to see that it opens horizontally.

Note: it will probably be helpful to get something to read the position vs time directly.
Integrating the acceleration-time graph (once for velocity and twice for position) leads to very large errors.[3]

-----------------------

[1] Google Tech Talk, August 2, 2010 (~23:20)
[2] Manohar C., McRady C, et al, Laboratory evaluation of the accuracy of a triaxial accelerometer embedded into a cell phone platform for measuring physical activity; FASEB J. April 2010 - 24 (Meeting Abstract Supplement) 1044.5
[3] Weinberg H. Accelerometers - Fantasy and Reality (no date) - see "Personal Navigation".

13. May 18, 2013

### angier

Dear jbriggs444,
did you mean applying 3x3 matrix 3-times probably, first around z-axis, then x-axis and on the end y-axis to get the new ax,ay,az vector of acceleration?

#### Attached Files:

File size:
4.8 KB
Views:
166
File size:
4.7 KB
Views:
150
• ###### 3 times matrix.JPG
File size:
2.6 KB
Views:
138
14. May 18, 2013

### angier

Dear Simon, I am working on a project for intelligent door, no study stuff anymore. :) We want to distinguish between different people entering the house or something and then apply the data to artificial intelligence software. How can you measure the distance vs time? What kind of sensor?

15. May 18, 2013

### jbriggs444

A three dimensional rotation (or, indeed, any sequence of 3 dimensional rotations) through any combination of roll, pitch and yaw can always be expressed as a single 3x3 rotation matrix.

http://en.wikipedia.org/wiki/Rotation_matrix

So just one matrix multiplication.

You could decompose your rotation into a roll followed by a pitch followed by a yaw and you could express each of those as a simplified 3x3 matrix. See "Basic Rotations" in the wiki reference above. If you multiply those 3 basic rotation matrices together you get the composite rotation matrix. You can then multiply by that.

This works because matrix multiplication is associative.

16. May 18, 2013

### angier

17. May 18, 2013

### Simon Bridge

Well, a position sensor of course! :)
There are lots of different ways -
You probably already have various rotation sensors that talk to your computer.
If not you can rig something i.e put a potentiometer by the hinge rigged so the door turns the shaft - resistance is proportional to angle.

18. Jul 12, 2013

### angier

I have some more questions regarding movement of the doors. Can we assume that while the doors are moving, we have uniform circular motion, at least in the middle of the period (definitely not in the beginning while we are pushing them with hands and in the end, when they slow down). By assuming this we have tangential acceleration equal zero and constant radial acceleration. I need this assumption for calculating the rotation matrix between the door frame and accelerometer frame of reference. Is it wrong to assume this?

19. Jul 12, 2013

### Simon Bridge

Not usually.

It depends on the control of the door ... i.e. if you open the door by giving it a shove (delivering an impulse) and the door opens on its own momentum, then the significant air resistance, as well as other losses, will guarantee non-uniform motion.

Of course, if you use a machine to open the door, and the machine is programmed to do so at a constant speed, then sure. You may get small fluctuations but the a-t graph should be close to zero for much of the motion.

Normally, yes.
It is certainly an assumption that you would be expected to justify from your data ... i.e. is there a period where your acceleration-time graph looks like it is trying to be horizontal - does it hover around a=0? If you do a linear regression on the $\small \omega$-t graph, do you get a slope of zero?

Note: you don't need a constant angular velocity to get a rotation matrix - you just need to know how the angle varies with time.

-----

On another note - you will also get systematic errors from the orientation of the xyz accelerometer with the door ... i.e. if it is rotated slightly wrt the door frame, or tilted, or if the door is not quite square on to gravity... just in case you thought that experiments were not already messy enough ;)

Last edited: Jul 12, 2013
20. Jul 15, 2013

### angier

Thnx for your help! If we take into account also air resistance etc. the equations change definitely. How to write equations of motion for such a case, where also this forces are present?

21. Jul 15, 2013

### Simon Bridge

Air resistance usually depends on some power of the velocity ... and it is not usually a trivial calculation.
You have a bunch of data - you should be able to see if air resistance and other losses are significant and what effect they have.

For the purposes of data analysis, you should not assume anything about the motion without some observation to justify it: the observation may come from what someone else, say, some authority, has written.

Usually the motion of the door is smooth the the eye - but the data is jagged, indicating random uncertainties in the measurement (i.e. random vibrations of the door). The data should look like if judders about a curve and you want to try to find that curve. Look at the data and see what sort of curve makes sense: if you are lucky, it's a line.

Note: you can do an experiment and show that the data does not support some assumptions about the motion.
That counts as a successful experiment.

22. Jul 16, 2013

### omega_minus

Have you looked into a gyro? It would allow you to directly measure rotational velocity. In my experience with making inertial measurement units, accelerometers are not so good at rotations in the plane. Tilting against gravity they're ok but not rotations.

23. Jul 17, 2013

### Simon Bridge

The gyro will give orientation changes without needing to integrate twice ... but I suspect this is a "use this equipment to investigate" type project. i.e. stuck with the stopwatch, ruler, protractor, accelerometer, etc. provided.

24. Jul 17, 2013

### omega_minus

Oh, I wasn't aware of it being an exercise. My first thought when reading the OP was later mentioned by you as well: potentiometer in the hinge.

25. Dec 19, 2013

### rskravi92

Hi , I am using adxl335 accelerometer for my project.Can any of you tell how to calculate angles from voltage readings of x,y and z axis.