Shop OBEX P1 Docs P2 Docs Learn Events
Need some help monitoring data from a MMA7455 accelerometer on a BS2 Stamp — Parallax Forums

Need some help monitoring data from a MMA7455 accelerometer on a BS2 Stamp

bmthomsenbmthomsen Posts: 4
edited 2009-12-12 18:29 in BASIC Stamp
Hi, I'm working on a class project that involves using this accelerometer. We have·the sensor·set up inside a foam ball, mounted on a large spring, which is bolted to a tire rim. The idea is to hit the ball, and·have·different LEDs and music play according to·the maximum acceleration detected by the sensor. We were able to get the sensor·working properly, but I have not been able to figure out a way to get the Stamp to monitor the acceleration variable that the sensor feeds data into, and detect the peak acceleration generated from the ball being hit. I am hoping someone can give me some ideas or point me in the right direction on what the logic would look like to do something like this.

Here is specifically what needs to happen:

The sensor's acceleration variable is updated constantly with new acceleration values (we're only interested in the X axis acceleration).

The sensor can output a max value·of 127, equal to 8g. When it is standing still, it varies from -10 to 10 or so, so the program needs to disregard anything below ~30. The program needs to monitor this variable and watch for it to rise. As soon as the acceleration comes to a peak and starts to decelerate, we need this peak acceleration value to be written to another variable, so we can use it to turn on LEDs and other things.

I'm including a StampPlot graph of what the data looks like when the ball takes a hit. I appreciate any ideas anyone has to offer.

thx, BMT
791 x 608 - 96K

Comments

  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2009-12-02 22:58
    Sorry to tell you with out you posting the code that you are using no one can help you with·your code

    Please post the code that your using and the demo that you are taking the code from·



    Thanks for your understanding in this matter

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them smile.gif

    ·
    ·
    ·
    ·
    Sam
  • bmthomsenbmthomsen Posts: 4
    edited 2009-12-03 20:53
    Here is the code for my last unsuccessful try.

    thx, BMT
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2009-12-12 18:29
    Please Post the Demo Code that you took your code from

    I think I found the Demo that you are using frist of all I do not have one to play with But one thing that see right get-go is that you need to calibrate it so that when it is not moving at all it show 0000 then go from there


    'How TO Use:
    ' • With power initially off, connect VIN TO 5VDC (the same voltage
    '·· powering the sTAMP).· Connect GND TO Vss.
    '
    ' • Connect P0, P1, AND P2 ON the Stamp directly TO the CS, DATA, AND CLK
    '·· pins ON the Digital 3-Axis Accelerometer module.
    '
    ' • Power ON the Stamp.· Download AND run this code ON the Stamp.
    '
    ' • Acceleration values will stream back TO the computer, AND can be viewed
    '·· on the DEBUG terminal.
    '
    ' • The offset values FOR each axis can be calibrated by placing the device
    '·· ON a flat horizontal surface AND adjusting the corresponding constants
    '·· UNTIL the values FOR each axis READ (WHILE in 2g mode):
    '······· X = 0·· (0g)
    '······· Y = 0·· (0g)
    '······· Z = 63· (+1g)
    '·· The values already present are FOR demonstration purposes AND can
    '·· be easily modified TO fine tune your own device. Keep in mind that
    '·· the offset values are in 1/2 Bit increments, so FOR example, TO offset
    '·· an axis by 5 counts, the corresponding offset would need TO be increased
    '·· by a value of 10.· See the MMA7455L device datasheet FOR more
    '·· information.

    'Offset values FOR each axis:
    XCal····· CON 25··· 'VAR Word
    YCal····· CON 50··· 'VAR word
    ZCal····· CON 0···· 'VAR Word

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them smile.gif

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 12/12/2009 7:24:57 PM GMT
Sign In or Register to comment.