i have an analogue devices ADXL203 accelerometer on a breadout board and was wanting to use this to measure the inclination of some equipment at a reasonably high frequency (20-30 Hz). i am hooking it up to a campbells cr3000 logger to do the sensing. Does anyone have directions on how to interpret the sensor outputs. thanks
I have a number of things to say here, and some of them do involve agreeing with pingswept and some with penjuin.
The cr3000 sampling at 16 bits and 100 Hz is going to be sampling a little slow for you to easily remove noise from your data but at a significantly higher precision then will be usable. I doubt you can get 13 or 14 bits of precision without some pretty good filtering algorithms. Accelerometers have taught me that vibration is the devil, blasted phonons.
You need to make sure you do as the datasheet says and signal theory dicates. To quote the datasheet:
The output of the ADXL103/ADXL203 has a typical bandwidth of 2.5 kHz. The user must filter the signal at this point to limit aliasing errors. The analog bandwidth must be no more than half the analog-to-digital sampling frequency to minimize aliasing. The analog bandwidth can be further decreased to reduce noise and improve resolution.
This means you need to pick a capacitor to keep your rate below 50Hz. If you place it above this you can get aliasing, and aliasing makes vibration noise a devil you signed a deal with. They state how to calculate the noise levels from the device, and at a 50Hz bandwidth a peak to peak noise of .006 * Gravity will not even be noticed if you have this on a device with vibrations.
This is probably what you are most interested in, and is relatively easy to do. You need to tag a time that the device is at neutral, this being when it is flat and you have it relatively still. Give it a second or two at this point, and then you can take the median of this data to determine the no-G voltage. Then you can use this as a point you compare the device to. Now, from this point, I can directly quote the data-sheet:
So you can just simply use this approximation if you are not going to tilt very much, but you will need to use geometry if you plan to tilt in both direction and in angles that are not extremely small.
If you are going to be going larger, they even have the equations spelled out as:
As far as I can tel your device gives a 1V change per 1G of acceleration placed on it. If you have done the calibrate phase, then you should be able to take measurments, subtract the offset, and you have the number of Gs being experienced.
Stop Reading Here unless you run into issues or you would like more information to improve approach.
I added a decent bit more talking about other approaches and methods to improve your approach for fast changing systems or systems where you are going to program the device doing the samples.
You need to be sampling significantly faster than the speed at which your device changes the directions in which it is accelerating, as you have to measure orientation 20-30 times per second. you need to be able to measure quickly enough to filter out vibration noise and acceleration due to other affects, which i have found to be quite large when working with an accelerometer.
Second, if you have a three axis accelerometer, then you can quite easily recognize when one axis is losing part of the acceleration due to gravity(ie. When the z axis has it's magnitude drop by 2m/s^2, you know that the gain you saw on the other axis is gravity). This will still be messy, but in general there will be an addition of acceleration which gives the velocity needed to change your orientation and then a change in acceleration due to orientation change, often allowing you to recognize orientation.
Problems with 2-axis
This is going to be, as penjuin said, almost impossible with a 2 axis accelerometer, and sketchy at best if you have a system that can have 20-30 different orientations a second, or if you need to have an exact measure of orientation at all times. I am sure a master's student could write a pretty nice thesis on this, or a Doctorate could write a dissertation on improving this algorithm.
To add more, if you can put your device on top of something that will keep it statically locked to the motion of your device, but dampens vibration, you will get much better numbers and not need as much software filtering. Some simple foam type padding can be placed between the accelerometer and your device, and if it is digital this should not increase electrical noise and help absorb some vibration noise. This should only be done if you see problems with the vibration noise.
I would suggest a digital accelerometer that you can use SPI to connect to. Data can be clocked out at a very very high rate and you can work in the back ground as your SPI does the constant work of loading the next set of values. You will need to have a nice microcontroller if it is going to be done digitally. If you can give me better specifics on what you are wanting to do I can give better feedback. If you want a warning based on tilt detection then it should be very easy to do with all analog, but if you want to measure the position and angle of equipment during operation, get ready for some work.
Please let me know if there is something I can add to make this answer more clear or applicable to what you were looking for.
I have written and rewritten this answer several times with many crazy mathematical ideas, but I honestly don't think this can be done with any accuracy. You can do some vector maths, but what if:
- The object stops moving
- The object has a constant velocity
- The object hits a bump/you bump it
- The force generated moving up the incline is below the resolution of the Z axis
While I'm sure there is some crazy workaround for doing this sort of thing, I'm not sure it would be worth it; accelerometers are simply not designed for this task (at least to my knowledge). For what you are trying to achieve, I would suggest a gyroscopic approach using any of these, all of which would be fairly resistant to all of the above problems.
If I understand the datasheet correctly, the output for each axis will vary between 1.5 V and 3.5 V as you tilt around the axis. When the device is flat (ignoring the ±1 degree package alignment error), both outputs should read 2.5 V.
If you only need to measure the tilt in one direction, you can take the arcsin of the deviation from 2.5 V to get the angle in radians, then convert to degrees. If the device can tilt in any direction, you can calculate the two angles, and then calculate the compound angle from those.
To be explicit: angle around one axis = (180/π) * arcsin (Vout - 2.5)
To get good frequency response, you'll need small output capacitors, Cx and Cy. From footnote 6 on p. 3 of the datasheet, it looks like 0.02 uF would give you a bandwidth of 250 Hz, which is probably about right for your sample rate. You could perhaps go as high as 0.1 uF, limiting the bandwidth to 50 Hz, but your signals will start to get attenuated.
I am adding a second answer, because my other one is large, and you may just want simple.
Your filter cap needs to be 0.10 uF or larger to keep you below your aliasing rate(50Hz). You need to give a calibration phase of a couple seconds with your device sitting level with all Gravity acceleration in the Z direction, this is to determine your zero G point.
The voltage you measure for your zero G point, it will probably be different for the X and Y direction, represents nothing. Just take whatever voltage you get and subtract that from it. This voltage, with offset subtracted is the number of Gs that you are getting in that direction.
Take the arcsin and you are going to get your angle in that direction.
This ignores noise and other acceleration. be prepared for NaN to be a result if you have it fully tilted and there is any noise.
To get any angle, you need to measure gravity's acceleration in both X- and Y- directions. subtract out the middle voltage (2.5V) so that zero is "no acceleration."
Now you can find the angle with arcsin(y/x). But that is annoying to use, because of the division, and because the sign is ambiguous, so what you really want the C function atan2(y,x). atan2() gets the sign right for all 360 degrees.
Off-topic, since you aren't using a micro: If you are looking for atan2() to use on a microcontroller, there is an atan2() generator on my website: http://vivara.net/cgi-bin/cordic.cgi