Accelerometer Scale & offset problems...
Jed
Posts: 107
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
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!