
Andy Roid
USA
Asked
— Edited

I have purchased a 4 in One Orientation Sensor. My desire is to use the compass function.
Once loaded and running, I view the compass heading values in the Variable watch window.. The value fail to read correctly. I find when I set the device in 90 degree directions ( 0 - 90 - 180 - 270 - back to zero ) I get value that do not even come close to the set position., nor do they repeat. I have changed my location, and even tried it in a wooden shed without any potential magnetic interferences, and still it did not work.
Has anyone use this sensor and has been able to get it to display correctly?
My reason for buying this was for the compass only and I am disappointed to see it not work.
Ron R
Hi DJ, I see you are up early too (or late). I saw your update after I posted my test results. I look forward to your next release.
Thanks
Ron R
This evening's build is much much better. With the circuit board facing up and the plug to the rear, it is working correctly. Heading still jumps around a good bit. +/- about 6 degrees when sitting still, but for gross motor movements (~45/90/180 turns) it will be quite useable.
Does not seem to work, even if recalibrated, if the board is facing down, like you would if installing on JD's chest. Also does seem to pick up some interference and lose accuracy if too close to the EZ-B (or maybe too close to the servos). I am testing with adventure bot, and have it on a pair of extension cubes off the front and it works fine. If I put it on the cube closest to the body, it loses all sense of direction. But with careful placement, this will definitely do what I need it to.
Alan
At this point it's in the hands of physics
Actually, if I calibrate with it in the "face forward" position (ie, like on a JD chest) it does work, but the jumping is +/- 15 instead of +/-6. So, maybe useable like that, but not as precise.
Alan
There is no axis at that angle for the sensor to read... well - not easily anyway. The Z axis has to make up for two axis at that point. Because X is front, Y is side, and Z is bottom.
Here's some code with will generate a file that you can load into excel and display what the compass values return. Notice how the Z axis is much less sensitive and really only used for tilt compensation,
Example graphed in excel:
Fair enough. I wonder what chip is used in Android and iPhones, and my even my old Delorme GPS that has a tri-axial compass. All work in any position and hold position more stable (my even older Garmin only works when held flat, but the new ones are tri-axial). I am guessing that the chip they use is more expensive?
Alan
It's data interpolation on the collected data - and data smoothing by averages over a time period. You can do that same, collect a bunch of data over time and divide to obtain the average. However, you will only want a rolling average with a circular buffer. Meaning, there are only a maximum number of X measurements in the buffer. Adding to the buffer overwrites the oldest measurements. This is really really easily done on phones/micro's with DMA. DMA has circular buffer attribute. So as the dma collects data from the specified peripheral, the data is added and overwrites the oldest.
Doing it like that, gives you the ability to keep "motion" so the compass points in directions.
Because you are only collecting 1 sample every X ms, you're own circular buffer would need to consider the sample frequency as to not appear "lagged".