
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
Here's some behind the scenes code on the average circular buffer histogram module that is included with ARC's Open plugin framework....
Notice how the buffer is initiated at object creation, and all data added to it is circular. The average is returned upon each appended data call...
Gotcha I think. Since the phone/gps/whatever isn't trying to collect the data over WiFi it can take far more samples in the same amount of time and average them to appear more stable. It isn't the chip, it is the processing ability. If I set my reads to every millisecond and averged the data, it would appear more precise, but likely flood the data channel. Yes?
Alan
Lastly, the MPU has a built in accelerometer, which i use for tilt compensation. This is a filter which increases each compass axis based on the tilt to produce a heading...
First i normalize the data because each sensor returns a different data range. Then calculate Pitch and Roll. Then, tilt compensation based on the normalized values. Finally, produce a heading degree from the 3 axis.
Prior to all of this is the calibration data calculations - which merely grabs an average of highest and lowest values and adjusts the range based on your physical location, and the sensor's environment.
If you calibrate the sensor while it is not in the robot - that's defeating the purpose.
Alan, that's correct about "Flooding" the channel. What you could do is plug it into an arduino and read the data quickly, and return your own "smoothed" data.
This is something to consider for a new version of the compass module. Might be worth considering if we added a second IC that collects the data quickly, and filters it...
Cool. Now that it is working it will meet my needs and I imagine most of us. I want to have controlled turns of around 45 degrees without worrying about timing which can vary from surface or motor speed, so this will work. Someone trying to aim a turret at a precise location or something similar may not he as happy.
Alan
I might think of an EZ-Script command to throw in that will perform a range check between two degrees - should be useful for your needs. Let me think on that...
I have applied the last update but I even after calibration $CompassX, $CompassY and $CompassZ are stuck to 129 (or -129). Am I missing something ?
If it's not working, then yes you are
Here's the manual page for the MPU 9150 All In One module:https://synthiam.com/Tutorials/Help.aspx?id=213
Also, unless you wish to perform serious math, as in my previous posts, do not pay attention to the $compassx $compassy $compassz variables - that's a whole new world that you most likely don't want to experience.
Follow the manual page and use the $CompassHeading variable only.