Jump to content

Erosand

Members
  • Posts

    2
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Erosand reacted to JColvin in CMPS2 compass module with Arduino - Heading steps accuracy   
    Hello @Erosand,
    I do not know when I will have time to fix the library (or I guess the single file) but I identified a few weird things that are likely resulting in problems.
    The CMPS2_init() sets the global maximum variable to -32768, and the global minimum variable to 32767. This mismatch causes problems later. Global midpoint is set to 0. The CMPS2_read_XYZ() inside of the CMPS2_getHeading() then checks to see if the measured X and Y data (after already converting it into mG, so they aren't even the same units) is greater than the global maximum variable and the less than the global minimum variable. Because of bullet point 1, this (mostly likely) sets the global max and min values to be exactly the same as the measurement value. The global midpoint is set to the average of these two values, so exactly the same value. In the CMPS2_getHeading() a Reset function is performed (to get an opposite phase shift I guess) after bullet point 2 and then CMPS_read_XYZ is performed again. However, because the global max and min values have not been reset, the new measurement data is getting compared to the exact same data. I guess in theory if you continually repeated this process as the module was rotated around, you would get the max and min values for the X and Y axis, but this isn't done in the code. So the max or minimum may have changed slightly, but not both, and the global midpoint is the bifurcation of this potential small change. I might be misunderstanding the code though. In the CMPS2_getHeading() after bullet point 3, it says offset is eliminated between the two measurements, but all it does is assign the calculated offset to a temporary variable, component[i]. In the CMPS2_getHeading() after bullet point 4, it then uses these calculated offsets, rather than actual values, to compare to the global midpoint, in order to determine what quadrant and thus what equation should be used to determine the corresponding degree heading. I'll ask around to see if somebody will be able to address some of these changes.
    Thanks,
    JColvin
×
×
  • Create New...