The attached example code uses a NI myDAQ and a multi-axis accelerometer to determine pitch and roll attitudes.
The MX2125 accelerometer uses a simple design premise to perform static acceleration measurements that can be converted to a pitch or roll angle. The accelerometer "has a chamber of gas with a heating element in the center and four temperature sensors around its edge. Just as hot air rises and cooler air sinks, the same applies to hot and cool gasses. If you hold the accelerometer still, all it senses is gravity, and tilting it gives us an example of how it senses static acceleration. When you hold the accelerometer level, the hot gas pocket...rises to the top-center of the accelerometer's chamber, and all the temperature sensors measure the same temperature. Depending on how you tilt the accelerometer, the hot gas will collect closer to one or maybe two of the temperature sensors." This sensed acceleration can then be converted to a pitch or roll angle via basic trigonometric functions, using known gravitational acceleration. The accelerometer works by generating a pulse train where the duty cycle of the pulse is proportional to the acceleration.
Steps to Implement or Execute Code
Requirements to Run
LabVIEW 9.0 or compatible
NI-DAQmx 9.1.5 or compatible
Memsic 2125 Accelerometer
10 µF Capacitor
7805 +5V Fixed-Voltage Regulator