Memsic 2125 Question
jesawyers
Posts: 6
I have a Memsic 2125 that when level is not putting out the the value 2500 (approx).· When I hook up the device as shown in the instructions I am getting 6620 (approx) on both axis on a level surface.· When I tilt each axis 90 deg I get 8330 (approx) in one direction and 4990 (approx) in the other direction.
I am using a BS2p40 and here is the code I'm using to read the device...
'{$STAMP BS2p}
'{$PBASIC 2.5}
AccelXin·········· ·· PIN···· 4
AccelYin··········· · PIN···· 3
AccelXRaw········· VAR···· Word
AccelYRaw········· VAR···· Word
Main:
··· PULSIN AccelXin, 1, AccelXRaw
··· PULSIN AccelYin, 1, AccelYRaw
··· DEBUG CR,? AccelXRaw, ? AccelYRaw
··· PAUSE 750
····GOTO Main
·
I am using a BS2p40 and here is the code I'm using to read the device...
'{$STAMP BS2p}
'{$PBASIC 2.5}
AccelXin·········· ·· PIN···· 4
AccelYin··········· · PIN···· 3
AccelXRaw········· VAR···· Word
AccelYRaw········· VAR···· Word
Main:
··· PULSIN AccelXin, 1, AccelXRaw
··· PULSIN AccelYin, 1, AccelYRaw
··· DEBUG CR,? AccelXRaw, ? AccelYRaw
··· PAUSE 750
····GOTO Main
·
Comments
#SELECT $STAMP
· #CASE BS2, BS2E, BS2PE
··· Scale······ CON···· $200··········· ' 2.0 us per unit
· #CASE BS2SX, BS2P, BS2PX
··· Scale······ CON···· $0CC··········· ' 0.8 us per unit
#ENDSELECT
This allows you to get the same output no matter which Stamp you're using.· Modify your program like this:
Main:
· PULSIN AccelXin, 1, accelXRaw
· accelXRaw = accelXRaw */ Scale
··PULSIN AccelYin, 1, accelYRaw
··accelYRaw = accelYRaw */ Scale
··DEBUG CR, ? accelXRaw, ? accelYRaw
··PAUSE 750
··GOTO Main
What you should get now -- on a level surface -- is a reading of about 5000 on each axis.· This corresponds to the 0.5 ms output when the sensor is level.
The BS2p is faster than the BS2 that is used in most of our demos, so you will want to check any program you run to make sure the behavior of the commands is the same.· When that is not the case, the help file will show how you can make them the same with conditional compilation.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax