Shop OBEX P1 Docs P2 Docs Learn Events
Accelerometer Scale & offset problems... — Parallax Forums

Accelerometer Scale & offset problems...

JedJed Posts: 107
edited 2008-02-09 22:45 in BASIC Stamp
I'm trying to display the accelerometer values in a range from -100 to 100. At first, it looks like it's working, but as time goes on the values start to go past 100... sometimes to like 900. My code is pretty much straight out of the smart sensors text so I'm at a lost for where I'm going wrong. The strange thing is I'm level when I turn the stamp on and it's close to 0 on both axis. But after the values start going wacky and I put it back to level the values are way off from 0. Can any of you guy spot anything?



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

x    VAR    WORD
y    VAR    WORD

PAUSE 200
SEROUT 14, 84, [noparse][[/noparse]22, 12]
PAUSE 5

DO
    PULSIN 6, 1, x
    PULSIN 7, 1, y

    x = (x MIN 1875 MAX 3125) - 1875 ** 10529 - 100
    y = (y MIN 1875 MAX 3125) - 1875 ** 10529 - 100

    SEROUT 14, 84, [noparse][[/noparse]128, SDEC ? x, SDEC ? y]
    PAUSE 100
LOOP

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-02-09 20:14
    Jed -

    Perhaps I'm mistaken, but I thought there was a calibration routine that was supposed to be used each time you use the accelerometer?

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There is no pleasure in having nothing to do;
    the fun is in having lots to do, and not doing it!
  • JedJed Posts: 107
    edited 2008-02-09 22:45
    yes, there is but I'm just trying to get the raw values to scale correctly. But I figured out what was wrong, because I was using an LCD and I did not format the variables to a length I was getting numbers that were staying on the display. Thank you anyway though.
Sign In or Register to comment.