A01 – Tilt Sensor

Create a LabVIEW project that will use your myDAQ and the provided ADXL335 accelerometer to create a tilt sensor that will indicate the tilt angle of the device and provide a notification if the absolute value of the tilt angle is below a user specified maximum value.

In a static situation, the ADXL335 will measure the acceleration due to gravity (the large red vector in the adjacent animation).  Note that this acceleration will always be pointed downward, toward the center of the Earth.  As you rotate the accelerometer you are changing the reference frame (the thin white vectors represent the x- and z-axes of the accelerometer frame) causing your acceleration components (the thin red vectors)  in this frame to change.  You can use these components, and your knowledge that the acceleration is directed downward, to determine the orientation of the device.

Click anywhere inside animation to see how the acceleration components change as the orientation of the accelerometer changes.  Click again to pause/resume the animation.  The accelerometer is initially horizontal in the animation.  We will express the tilt angle of the device as the angle between the acceleration vector and the z-axis of the accelerometer.  In the animation, this angle will rotate to +160° and then reverse to -160° and continue indefinitely.

Video Demonstration

Detailed Requirements

  • Measure a horizontal component of acceleration (\(a_x\) or \(a_y\)) on channel /ai0 and the vertical component of acceleration (\(a_z\)) on channel /ai1 of your myDAQ. You should use the provided subVI called Read Two Analog Input Channels.vi to measure the components of acceleration in raw voltage units provided by the accelerometer.
  • You will need to manually determine the output values of the sensor for zero acceleration (offset in volts) and the change in output for a change in acceleration (sensitivity in V/g) so that you can scale the output into acceleration units of acceleration due to gravity (“g”). You may hard code the numerical values for the offset and sensitivity into your code for the channel scaling.
  • The code for converting the voltage to an acceleration should be encapsulated into a subVI so that you can use it in two places for the two separate acceleration components.  You may create additional subVIs as you see fit, but this conversion subVI is required.
  • Using the acceleration components find the angle of tilt of the sensor.
  • The application should show an indication of the angle of tilt using a front panel indicator of your choice.
  • Light a front panel Boolean indicator if the absolute value of the angle is less than than a user specified maximum value and also light a real LED on channel /port0/line0 of your myDAQ. You should use the provided subVI called Write Digital Line.vi for writing the boolean value to the myDAQ digital output.
  • All directions should be displayed to the user in degrees with zero degrees indicating the sensor is horizontal. Be careful because the standard trig routines in LabVIEW will expect the angles in radians so you will need to convert to/from radians in your internal calculations.
  • When finding the polar angle from Cartesian components, recall that the standard atan function always returns an angle in quadrant I or IV.  You should try to find a method to correctly report vectors that are in quadrant II or III in your Cartesian to Polar routine (for situations where the tilt angle is greater than 90°).
  • The control for the Maximum Tilt angle should have a default value of 5 degrees.
  • Your program should run continuously, update the display at least 5 times each second, and quickly shut down if the user presses a STOP button on the front panel.
  • All subVIs should be given clearly identifying names, should have unique, descriptive icons, and should be stored in an auto-populating folder in the project.
  • The top-level VI should be clearly identifiable at the top level of your project.  It should be well documented and have a unique icon.
  • Document the subVIs and top level VIs with appropriate comments on the block diagram and by entering a Description in VI Properties.
  • Document the controls and indicators of your top-level VI.
  • Submit your solution in our source-code control repository at
    svn://physics.wku.edu/phys318/dropbox/lastname.firstname/a01/

    with a comment that this is your final version submitted for grading. It is your responsibility to make sure that all of the needed files are present in your submission.

  • Extra Credit: Find a method to indicate the range of desired tilt angles on your angle indicator.
Print Friendly, PDF & Email
Top