Jump to content

Erosand

Members
  • Posts

    2
  • Joined

  • Last visited

Erosand's Achievements

Newbie

Newbie (1/4)

0

Reputation

  1. Thanks @JColvinfor the quick reply! I've been trying to modify the code in various ways for while now but still don't quite get it. Here's what I'm thinking/wondering so far: Could this be fixed by just setting the globlal minimum value to 32768? Or does it even matter considering the lines where it's actually used look like this? if (measured_data[0] < Min[0]) { //x min Min[0] = measured_data[0]; } I'm wondering if it would be possible at all to get an accurate heading without rotating it 360 degrees first for calibration? I don't see how that would work since it won't have any values to compare with unless it gets rotated. Looking at the guide for calibration here https://reference.digilentinc.com/reference/pmod/pmodcmps2/reference-manual (and assuming it's correct) where it says Output1 = H + Offset Output2 = −H + Offset I think the math in the code makes sense since the line components[0] = (components[0] - X) / 2.0; // H = (Output1 - Output2) / 2.0 should give just H ( H = (Output1 - Output2) / 2.0 ), or am I missing something? (where H is the desired measured value to use in the trigonometry calculations) Another thing I've noticed is the line measured_data[0] = 1.0 * (int)(tmp[1] << 8 | tmp[0]); //x which supposedly reconstructs the raw data. Doesn't interpreting the 16 bit binary number as an int cause overflows if the MSB from the sensor is unsigned? Or is the raw data supposed to be signed? Is the leftmost bit of tmp[1] part of the value or just indicating the sign? When plotting the reconstructed raw data I'm seeing these overflow jumps (?) every now and then when rotating the compass around the z-axis. As before, all help is greatly appreciated!
  2. Hi! I'm using the CMPS2 compass module with an Arduino Uno and the example code from https://reference.digilentinc.com/reference/pmod/pmodcmps2/start#example_projects to get a heading from the compass module, but it seems to be only jumping between specific values and never taking the values in between. For example, running the program while keeping the module horizontal and slowly spinnng it 360° around the z-axis gives an output like this: Heading = 231.18° Heading = 231.19° Heading = 186.09° Heading = 141.09° Heading = 186.12° Heading = 231.10° Heading = 231.09° Heading = 231.08° Heading = 231.09° Heading = 231.03° Heading = 230.96° Heading = 321.25° Heading = 321.15° Heading = 321.04° Heading = 51.20° Heading = 51.06° Heading = 51.06° Heading = 50.96° Heading = 50.91° Heading = 96.12° Heading = 96.10° Heading = 51.00° Heading = 141.17° Heading = 141.11° Heading = 141.12° Heading = 141.04° Heading = 141.04° Heading = 186.11° Heading = 141.01° Heading = 231.16° Heading = 231.16° Heading = 231.16° Basically, plotting the heading as a function of time doesn't give a continuos plot no matter how slowly the module rotates. I have tried to check for disturbances from metal objects or electronic devices using another compass, so I'm pretty sure that's not the problem. I don't need to get down to the 1° accuracy promised by the maker (5° is probably enough for my project), but these giant leaps from 320° to 50° won't work. All help is appreciated!
×
×
  • Create New...