+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 20 of 45

Thread: How to - Accelerometer (1) Fundamentals and Tilt Measurement

  1. #1

    Default How to - Accelerometer (1) Fundamentals and Tilt Measurement

    Getting Started with an Accelerometer
    Acceleration is a measure of how quickly speed changes.и Just as a speedometer is a meter that measures speed, an accelerometer is a meter that measures acceleration.и You can use the ability to sense acceleration to measure a variety of things that are very useful to electronic and robotic projects and designs:
    • Acceleration (of course!)
    • Tilt, tilt angle
    • Incline
    • Rotation
    • Vibration
    • Collision detection
    • Gravity
    Accelerometers are already used in a wide variety of machines, specialized equipment and personal electronics.и Here are just a few examples:
    • Self balancing robots
    • Tilt-mode game controllers
    • Model airplane auto pilot
    • Car alarm systems
    • Crash detection/airbag deployment
    • Human motion monitoring
    • Leveling tool
    Once upon a time, accelerometers were large, clunky and expensive instruments that did not lend themselves to electronic and robotic projects.и This all changed thanks to the advent of MEMS, micro-electro-mechanical-systems.и MEMS technology is responsible for an ever increasing number of formerly mechanical devices designed right onto silicon chips.и The accelerometer you will be working with in the forthcoming activities is the Parallax Memsic 2125 Dual Axis Accelerometer module.и
    This module measures less than 1/2” X 1/2” X 1/2”, and the accelerometer chip itself is less than 1/4” X 1/4” X 1/8”.

    People naturally sense acceleration on three axes, forward/backward, left/right and up/down.и Just think about the last time you were in the passenger seat of a car on a hilly and curvy road.и Forward/backward acceleration is the sensation of speeding up and slowing down.и Left/right acceleration involved making turns, and up down acceleration is what you felt going over hills.и

    Up/down acceleration is also the way we sense gravity.и When on the ground, people tend to sense gravity as their own weight.и In free-fall, they sense gravity as weightlessness.и In physics terms, gravity is a form of acceleration.и When an object is on the ground, gravity is sometimes called static acceleration.и When an object is rolling down hill or falling, gravity becomes dynamic acceleration.

    Instead of the three axes people sense, the MX2125 accelerometer senses acceleration on two axes.и The acceleration it senses depends on how it’s positioned.и By holding it one way, it can sense forward/backward and left/right.и If you hold it a different way, it can sense up/down and forward/backward.

    The MX2125 Accelerometer – How it Works
    The MX2125’s design is amazingly simple.и It 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.и When you hold the accelerometer level, the hot gas pocket is 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.и

    Both static acceleration (gravity and tilt) and dynamic acceleration (like taking a ride in a car) are detected by the temperature sensors.и If you take the accelerometer for a car ride, the hotter and cooler gasses slosh around in the chamber in a manner similar to a container that is partially filled with water.и

    In most situations, making sense out of these measurements is a simple task thanks to the electronics inside the MX2125.и The MX2125 converts the temperature measurements into signals that are easy for the BASIC Stamp« module to measure and decipher.

    Connecting and Testing the MX2125

    Чииииии Gather the parts listed here, and build the circuit shown below.

    Part Numberииии иQuantityиии ииDescription
    800-00016ииииииииииииии (1)ииииииии ии3-inch Jumper wires - bag of 10
    150-02210ииииииииииииии (2)ииииииии ииResistor – 220
    28017иииии иииииииииииииии (1)ииииииии ииMemsic MX2125 Dual-Axis Accelerometer

    The two axes the MX2125 uses to sense gravity and acceleration are labeled X and Y.и It will help if you set your board flat on the table in front of you as shown in the figure below.и That way, the X and Y axes point the same directions they do on an XY plot.и For room temperature testing, you can get a decent indication of tilt by just measuring the high times of the pulses sent by the MX2125’s Xout and Yout pins with the PULSIN command.и Depending on how far you tilt the board and in which direction, the PULSIN time measurements should range from 1875 to 3125.и When the board is level, the PULSIN command should store values in the neighborhood of 2500.и

    Чииииии Make sure your board is sitting flat on the table, oriented with its X and Y axes as shown in the figure above.
    Чииииии Enter and run SimpleTilt.bs2.

    ' SimpleTilt.bs2
    ' Measure room temperature tilt.

    '{$STAMP BS2}
    '{$PBASIC 2.5}

    xииииииииии иииVARииии Word
    yиииииииииииии VARииии Word
    и PULSIN 6, 1, x
    и PULSIN 7, 1, y
    и DEBUGCLS, ? X, ? Y
    и PAUSE 100

    Чииииии Check to make sure the Debug Terminal reports that the x and y variables are both storing values around of 2500.

    Чииииии Grab the edge of the board with the Y-Axis label and gradually lift it toward you.и The y value should increase as you increase the tilt.и
    Чииииии Tilt the board straight up and down.и The Debug Terminal should report that the y variable stores a value near 3125.
    Чииииии Next, instead of tilting the board toward you, gradually tilt it away from you.и The y axis value should drop below 2500 and gradually decrease to 1875 as you tilt the board until it’s straight up and down.
    Чииииии Repeat this test with the X-axis.и As you tilt the board up with your right hand, the x value should increase and reach a value near 3125 when the board is vertical.и As you tilt the board upward with your left hand, the x value should approach 1875.
    Чииииии Finally, hold your board in front of you, straight up and down like a steering wheel.
    Чииииии As you slowly rotate your board, the x and y values should change.и These values will be used in another activity to determine the rotation angle in degrees.
    __________________________________________________ _________________
    This draft material is part of a forthcoming Stamps in Class text by Andy Lindsay.
    (c) 2004иby Parallax Inc - all rights reserved.иии

    Post Edited By Moderator (Jessica Uelmen (Parallax)) : 8/25/2010 5:34:00 PM GMT
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	AccelerometerModuleChip.JPG‎
Views:	24918
Size:	15.6 KB
ID:	36612   Click image for larger version

Name:	AccelerometerHowItWorks.jpg‎
Views:	24946
Size:	69.3 KB
ID:	36613   Click image for larger version

Name:	AccelerometerDebugLevel.jpg‎
Views:	24598
Size:	49.0 KB
ID:	36614   Click image for larger version

Name:	PartsSchematicWiring.jpg‎
Views:	24936
Size:	31.0 KB
ID:	36615   Click image for larger version

Name:	AccelerometerAxisCommunication.jpg‎
Views:	24528
Size:	47.4 KB
ID:	36616  

    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  2. #2



    The pdf with the specifications on the Parallax store doesn't seem to use those 220 resistors.

    I don't know much about circuits so the wiring diagram will help me a lot when I get the accelerometer in the mail!

    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  3. #3


    What's the difference between a gyroscope sensor and accelerometer?
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  4. #4


    Try this webиpage for starters:


    It talks about gyros for inertial navigation systems.и It's part of a series of pages that starts with


    and ends with

    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  5. #5



    I have started playing with freescale semiconductor's 3-axisиaccelerometer MMA7260Q

    One thing that bugs me is the fact thatиI'm notиable to determine tilt of the sensor if I'mиin an elevator or on a train or car for that matter , because of the acceleration associated with them. Correct me if I'm wrong but if you tilt the sensor to say 30deg and you have a horizontal acceleration , the sensor will indicateиsay +-0.7g Z-axis and +-0.3g X-axis , depending on the horizontal acceleration. And you won't be able to know what tilt is unless you know the true horizontal acceleration.

    Anybody have any idea how to determine tilt when other acceleration (like horizontal) is also experienced??


    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  6. #6


    Probably the easiest way of canceling out acceleration from your tilt measurement would be to use a MEMS type accelerometer (MA)иin conjunction with the Thermal Accelerometer (TA). A MEMS (micro electrical mechanical system) accelerometerи is insensitive to tilting (other than affecting the axis of measured acceleration), since the MA doesn't measure the tilt it is a "pure" accelerometer and can be used to cancel out the acceleration component from the TA obtain the tilt measurement. Various companies like Analog Devices and Memsic sell MEMS accelerometers.


    Post Edited (Paul Baker) : 12/12/2005 4:01:04 PM GMT
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  7. #7


    Similar to what Paul said....

    Having 2 sensors that are offset from each other...
    Have them offset about 45deg apart in whichever plane and you could get the idea....maybe 90deg apart for easier math!

    So....basically an X,Y sensor and then toss in another one for Z measurements (so it'd basically be mounted on end).
    As you tilt in one direction, the Z sensor will start to show a horizontal profile as opposed to its bottomed out verticle measurement....



    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  8. #8


    Yeah, from what I could gather from a couple of Google searches, inertial measurement units (IMUs) make use of gyros to give the accelerometer an absolute reference. I'm assuming with the advent of solid state gyros, that there is also software that keeps track of which direction is down based on the rotation of the unit (which is reported by the solid state gyro). The software can then subtract 1 g from whatever vector is "down" during a given measurement.

    Here's a link to an article that explains the aeronautical setups nicely and has good terms for more further searches: http://www.bookrags.com/sciences/astronomy/flight-control-spsc-03.html
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  9. #9


    Attached is the manuscript of the chapter that resulted from this post (Smart Sensors and Applications Manuscript Chapter 3.pdf).и Aside from the material above, it shows how to display the accelerometer measurements with the Parallax Serial LCD, and calculate and display rotation and tilt angles.и There's also some interesting new techniques for improving the accuracy of ** and */ calculations.

    Post Edited (Andy Lindsay (Parallax)) : 2/3/2006 10:09:51 PM GMT
    Attached Files Attached Files
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  10. #10



    Thanks for the excellent posts - I'm finally getting somewhere with my MEMSIC2125 now :)

    I don't know if you can help?! I understand that the MEMSIC, being a 2-axis part, can be used tilted at 45deg and then readings of the two axes combined to get platform angle - even when the platform is moving. MEMESIC's datasheet suggests the formula is 'angle = ACos( 0.707 * (Ax + Ay) / g)', but I'm getting changing angles whenever I move the platform (including if I 'roll' the platform).

    I'm probably missing something, but is there any code that gives me what I'm looking for?

    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  11. #11


    If the platform is not accelerating,иthe MX2125иmeasures and reportsиthe acceleration due to gravity.и If you move the platform, the movement involves acceleration and deceleration.и While the platform accelerates/decelerates, the MX2125's sensing axesиdetect (and report) the sum of the acceleration components: static (gravity) and dynamic (acceleration/deceleration).и If your platform has some portion that does not tilt when it is moved, itиshould be possible to mount a second accelerometer there, and compare the two measurements to infer and subtract the acceleration from the tilt.и Otherwise, someиGoogleиsearches onиinertial guidanceиshould lead toиsome sites that explain how it worksиwith aиdynamic system.ии
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  12. #12


    Thanks Andy,

    I'll have to Google then, as my application doesn't have any non-tilting platform :(

    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  13. #13


    the first response to this post calls for clarification on how to wire the MX2125... the text above shows using resistors pins 2 and 5, and no connection to 1 and 4... the pdf has a different configuration... which is it?

    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  14. #14


    Hey Steve,

    The first diagram accompanies the educational curriculum (Stamps in Class) - the books written by Andy. The bottom picture is from our product documentation, also available from download. Use the Stamps in Class diagram.

    Ken Gracey
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  15. #15


    Thanks Ken...

    Although I have my answer, it does beg the question as to why the differences...

    1. Why the resistors?
    2. What does T do?
    3. What are the implications of not grounding pin 4?

    Again, not that I need answers specifically for my robot... more for just an educational understanding...
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  16. #16


    Hi Steve,

    1) Stamps in Class materials include resistors in series where wires normally go when the device has outputs that send signals to BASIC Stamp I/O pins. This prevents a problem that can occur if a student builds a new circuit, but leaves the old program running for any length of time. If the old program happens to be sending output-high to a circuit which is sending output-low (or visa-versa), the resistor will protect the BASIC Stamp I/O pin and the device it's connected to.

    2) The T pin transmits an analog voltage that indicates the MX2125's internal temperature. This voltage is critical for precision accelerometer applications, which use it to compensate for temperature's effect on pulse widths the MX2125 transmits to report acceleration measurements. There are two kinds of errors this voltage can be used to compensate: zero bias offset and sensitivity. Zero bias offset error is the difference between the zero g pulse width (5 ms) and the actual 0 g pulse width. Sensitivity error is the difference in pulse width for a given acceleration at temperatures A and B. Here are links to a couple of PDFs with more info:

    Memsic Temperature Compensation Appnote: http://www.memsic.com/memsic/pdfs/an-00mx-002.pdf
    Memsic MX2125 Product Datasheet: http://www.memsic.com/memsic/data/products/MXD2125G&M/MXD2125G&M.pdf

    3) Pins 3 and 4 are connected by traces on the circuit board, and they provide 0 V to the MX2125's ground and its external clock input. One of the pins (3 or 4) has to be grounded, but it doesn't matter which one.

    There's an exception to item 3, but it does not apply to Memsic 2125 modules that accompany our educational documentation. The first revision of the Memsic 2125 circuit board had one of the pins connected to the MX2125 chip's optional external clock input, and the other connected to the chip's ground. Both of that module's pins should be grounded since applications can rely on the MX2125’s internal clock. These older modules can be identified because they have no silkscreen on the top, only on the underside. Current modules (the ones with pins 3 and 4 shorted) read Mx2125 on the top and Parallax, Inc. underneath.

    Andy Lindsay

    Education Department
    Parallax, Inc.
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  17. #17


    Andy: Understand you were away for a while... no probs... great explanation! and just in time as I will be working on my robot this weekend! Thanks again!!!!!
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  18. #18


    Thanks Steve,

    BTW, the Smart Sensors and Applications book just got posted to the web today. The chapter on the Memsic accelerometer has quite a bit of material that has not been previously posted. Likewise with the Ping))) Ultrasonic Rangefinder and the Parallax Serial LCD. The HM55B Compass Module has "some" new material, but not as much since I was more in Stamps in Class mode than I realized while writing the product docs.

    Here are some of theиSmart Sensors and Applications links:

    Product page: http://www.parallax.com/detail.asp?product_id=28029
    Book (PDF): http://www.parallax.com/dl/docs/prod/sic/SmartSensors-v1.0.pdf
    Source Code (Zip): http://www.parallax.com/dl/sw/SmartSensorsv1.0code-v1.zip

    Another resource to check out for the Memsic accelerometer mounted on a robot would be the Stamps in Class "Mini Projects" page: http://forums.parallax.com/showthread.php?p=560570

    The book points to this page for Boe-Bot projects with the Memsic 2525 accelerometer module and Ping))) Ultrasonic Distance Sensor. This page has two Boe-Bot + accelerometer projects:

    Boe-Bot« Robot Navigation with Accelerometer Incline Sensing: http://forums.parallax.com/showthread.php?p=522967
    A Tilt Radio Controller for Your Boe-Bot: http://forums.parallax.com/showthread.php?p=524063

    Hopefully, that'll add toиthe weekend's robotic fun. Enjoy!

    Regards, Andy

    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 12/22/2006 8:16:35 PM GMT
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  19. #19


    Awsome write-up!!!! everything you wanted to know about the 2525 in one source!!! As usual, fantasically written from my quick review... looks like I will sidetrack my robot this weekend and focus on this instead!!!

    Thanks much!!!
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

  20. #20


    Wow, thanks Steve!

    The accelerometer chapterиfeatures some new and kind of funky integer math techniques for minimizing error propagation while scaling the accelerometer measurements for use with various displays and output devices.ииWriting about it was kind of an interesting challenge, so we'll be watching the forum closely for questions (and their answers).иии

    Also, anyone who's got feedbackиand/or recommendations,иfeel free to email them directly to editor@parallax.com.и

    Happy holidays!

    Andy Lindsay

    Education Department
    Parallax, Inc.
    Last edited by ForumTools; 09-30-2010 at 09:20 AM. Reason: Forum Migration

+ Reply to Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts