weird subtraction of accelerometer readings
PAX-O
Posts: 5
Hello everybody,
The attached picture contains the output data from an accelerometer. Basically I am doing 2 readings from the accelerometer and then I am subtracting the values and display the result with D (Dmin and Dmax stand for the min and max deltas calculated from subtracting the two readings).
Now the weird part: When I do the subtraction of the two readings that are for example 2520 and 2519 or vice versa sometimes i get an answer of 5535 instead of just 1... I also get the 5535 delta when the accelerometer is just sitting on the board of education. Can someone explain to me why I can't just get a 1 or a -1 or other numbers that are reasonable and make sense and instead I get those extremes of 0 and 5535?
The attached picture contains the output data from an accelerometer. Basically I am doing 2 readings from the accelerometer and then I am subtracting the values and display the result with D (Dmin and Dmax stand for the min and max deltas calculated from subtracting the two readings).
Now the weird part: When I do the subtraction of the two readings that are for example 2520 and 2519 or vice versa sometimes i get an answer of 5535 instead of just 1... I also get the 5535 delta when the accelerometer is just sitting on the board of education. Can someone explain to me why I can't just get a 1 or a -1 or other numbers that are reasonable and make sense and instead I get those extremes of 0 and 5535?
Comments
http://en.wikipedia.org/wiki/Two%27s_complement
Also look into the ABS operator and HIGHBIT.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 8/6/2007 12:19:13 AM GMT
-Phil
Here's one way to keep them inline:
DEBUG· "Dmin", CRSRX,(10-Dmin.HIGHBIT),SDEC4 Dmin,CR
DEBUG· "Dmax", CRSRX,(10-Dmax.HIGHBIT),SDEC4 Dmax,CR
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 8/6/2007 1:21:29 AM GMT
suggestion but change mine to :
DEBUG CRSRXY, (7-axCount.HIGHBIT), (6),SDEC4 axCount
DEBUG CRSRXY, (7-lowestCount.HIGHBIT), (11),SDEC4 lowestCount
DEBUG CRSRXY, (7-highestCount.HIGHBIT), (12),SDEC4 highestCount
DEBUG CRSRXY, (7-secondRead.HIGHBIT), (7),SDEC4 secondRead
DEBUG CRSRXY, (7-D.HIGHBIT), (8), SDEC4 D
DEBUG CRSRXY, (7-Dmin.HIGHBIT), (9), SDEC4 Dmin
DEBUG CRSRXY, (7-Dmax.HIGHBIT), (10), SDEC4 Dmax
and you'll get nice clean columns - like your ScreenCap
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 8/6/2007 2:37:50 AM GMT