Shop OBEX P1 Docs P2 Docs Learn Events
MMA7455 Accelerometer/Basic Stamp 2 Troubles — Parallax Forums

MMA7455 Accelerometer/Basic Stamp 2 Troubles

edited 2011-12-05 14:36 in Accessories
Hi All,

I'm new to the Basic Stamp 2 module and the programming with it. To work around this, I am attempting to setup the accelerometer to read out the XYZ coordinates of my Board of Education as I change its spatial position. The demo code from the MMA7455 site is NOT working out too well for me: http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/mma7455/List/0/SortField/4/ProductID/585/Default.aspx.

I have followed the instructions at the top of the demo:
'How TO Use:
' o With power initially off, connect VIN TO 5VDC (the same voltage
' powering the sTAMP). Connect GND TO Vss.
'
' o Connect P0, P1, AND P2 ON the Stamp directly TO the CS, DATA, AND CLK
' pins ON the Digital 3-Axis Accelerometer module.
'
' o Power ON the Stamp. Download AND run this code ON the Stamp.

How I interpret this: I have probed VIN - it is getting 5.04V, VSS is getting 4 mV. P0 is connected to the CS pin, P1 is connected to the DATA pin, and P2 is connected to the CLK pin. Is there some other issue that I am not seeing here? Does something else need to be set up?

Thank you for all help in advance - most appreciated.

- ButterflyKittens97

Comments

  • ratronicratronic Posts: 1,451
    edited 2011-12-02 14:39
    I have one of these on order to use with the Propeller but I noticed the basic stamp demo description doesn't seem to match how the pins are defined.
    ' {$STAMP BS2}                                                                          
    ' {$PBASIC 2.5}                                                                         
                                                                                            
    '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                                                           
                                                                                            
    CLKPin    PIN 0     ' Clock Pin                                                         
    DATAPin   PIN 1     ' Data Pin                                                          
    CSPin     PIN 2     ' Chip Select Pin                                                   
    
  • edited 2011-12-04 22:19
    Hi ratronic,

    Did switching the connections to P0 and P2 help fix the issue? I am trying to figure this one out - no luck...

    Thanks,

    - ButterflyKittens97
  • ratronicratronic Posts: 1,451
    edited 2011-12-05 06:57
    ButterflyKittens97 first let me say welcome to the forums. I just received my module this weekend, I will hook it up to my Basicstamp here in a few minutes and let you know.
  • edited 2011-12-05 06:59
    Thank you ratronic! I'll look forward to your response.
  • ratronicratronic Posts: 1,451
    edited 2011-12-05 07:32
    ButterflyKittens97 it works wired backwards from the directions . The program is written so that P0 = CLK PIN, P1 = DATA PIN, P2 = CS PIN. The directions for use at the top are backwards. I left a message in the "suggestions" thread to let Parallax know about this.

    Edit: Backwards in the directions at the top of the BS2 demo programs for P0-P2 connections only.
  • edited 2011-12-05 08:38
    Hey, thanks so much - you're awesome. If I could, can I continue to use you as a reference for later troubles I may have?
  • ratronicratronic Posts: 1,451
    edited 2011-12-05 09:57
    Your'e welcome. Any time you have a question just post it in the appropriate forum, there are a lot of people here ready to help. I have a BS2 but I purchased this to use with the Propeller chip.
  • edited 2011-12-05 14:13
    Where should I probe the output? Pin 7 (DATA)? Pin 3 (INT1/Data Ready)? I am needing to transmit my output wirelessly through the Xbee antenna... I know it's working via the demo, but I do not know if it is giving me the correct output because I'm not sure what I am looking at to be honest.

    Thanks for all help in advance - most appreciated!

    - ButterflyKittens97
  • ratronicratronic Posts: 1,451
    edited 2011-12-05 14:25
    In the demo program the variables containing the x,y and z axis are XAccel, YAccel, and ZAccel. Those are the variables to send to the xbee. I have never used xbee's before maybe someone that knows them can reply.
  • edited 2011-12-05 14:28
    Right, but if I were to see the voltage alterations based on adjusting the board, which pin would provide the output?
  • ratronicratronic Posts: 1,451
    edited 2011-12-05 14:36
    If you were to scope the Data Pin you would see the data being written to and received serially from the chip. The program takes and assembles all the bits read from the chip into a single word variable for each axis. Then the variables are displayed on the debug screen in this section of the code.
    DEBUG CRSRXY,50,3, SDEC XAccel, "  ",               'Display the RAW X, Y, and Z Accelerometer values     
          CRSRXY,50,4, SDEC YAccel, "  ",                                                                     
          CRSRXY,50,5, SDEC ZAccel, "  "
    
    ]
Sign In or Register to comment.