Shop OBEX P1 Docs P2 Docs Learn Events
Accelerometer not working. Is it me or the Mesmic 2125? — Parallax Forums

Accelerometer not working. Is it me or the Mesmic 2125?

dodgerdodger Posts: 37
edited 2009-05-05 00:14 in Propeller 1
I am trying to measure the angle of the accelerometer. I havent had much luck.· My output does not vary consistently and is usually constant no matter how i move the accelerometer.· The accelerometer was given to me so Im not sure·if its working properly.· Can someone look over my·app maybe I messed up somewhere?

{{ Prop Serial}}
CON
· _clkmode = xtal1 + pll16x
· _xinfreq = 5_000_000
· CTS·· = 11················· ' RTS# Request To Send (Connects to MCU CTS)
· TXD·· = 8·················· ' RXD Receive Data (Connects to MCU TXD)
· RXD·· = 10················· ' TXD Transmit Data (Connects to MCU RXD)
· RTS·· = 9·················· ' CTS# Clear To Send (Connects to MCU RTS)
· Xout_pin··· =· 1··········· 'Propeller pin MX2125 X out is connected to
· Yout_pin··· =· 0··········· 'Propeller pin MX2125 Y out is connected to
· Gnum = 3
VAR
· Byte MyStr [noparse][[/noparse]64]
· long XVal, YVal
· long TempX, TempY
· long clk_scale, clk_scale2

OBJ
· Num :········ "Numbers"
· Ext :········ "Extended_FDSerial_128ByteBuffers"
· flash:······· "USBdrive"
· memel :······ "memsic2125"
· accel :······ "MXD2125 Simple"
PUB Main | i, dx, dy, raw, mg, deg, raw1
· Num.init
· Ext.start (31,30,0,9600)
· Ext.SetDelimiter (13)
· flash.start(TXD,RTS,RXD,CTS)
·
· memel.start(Xout_pin,Yout_pin)
· memel.setlevel
· clk_scale := clkfreq / 500_000·······················
· clk_scale2 := clkfreq / 1_000_000
· repeat 30
··· Ext.rxflush
··· Ext.Str(string("D"))
··· flash.openForWrite(@filename)
···
···
···
··· raw· := memel.ro
··· mg·· := raw / clk_scale······························
··· raw1 := raw / clk_scale2
··· raw1 := ((raw1/10)-500)*8
···
··· deg· := memel.theta >> 19
··· deg· := deg*360/8192
·
···
···
··· Ext.RxStrTime (500,@MyStr)
··· Ext.Str(@MyStr)
··· Ext.dec(deg)
··· 'Ext.Tx(deg)
··· Ext.Tx(13)
··· flash.writeline(@MyStr)
··· waitcnt (clkfreq * 1 + cnt)
··· flash.write(num.tostr(deg,Num#DDEC))
···
· flash.close(@filename)
·
dat
· filename···· byte····· "Sub.txt", 0······
·

Comments

  • BADHABITBADHABIT Posts: 138
    edited 2009-05-01 08:43
    you can check to see if the part works by spinning up -MXD2125 Simple Demo- from the demo object library.

    module
    Pin 1or2 --> Prop pin1
    Pin 5 --> Prop pin0
    Pin 3 and 4 --> ground
    Pin 6 --> 3.3-5v+
  • dodgerdodger Posts: 37
    edited 2009-05-04 23:39
    Yeah I had a faulty accelerometer got a new one and all works well.

    I have another related question.

    I want to know the time between measurements. For example if i do not ad any delays in my application how do i know the time between each angle measurment. I want to convert my degrees of rotation from the accelerometer into degrees per second.

    I plan on setting up some equations in excell or with C++ (Unless someone has a better idea)

    (final angle - previous angle)/time = degrees per second


    Thanks for everyones help so far
  • jazzedjazzed Posts: 11,803
    edited 2009-05-05 00:14
    Use WAITPEQ or WAITPNE in combination with CNT to get elapsed time. See obex spin example.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
Sign In or Register to comment.