Axis Module Issue

Hello,

I am using an axis control to detect momentary movement.

Here is the code to get the axis values

      Vector raw = compass.readRaw();
      xCur = raw.XAxis;
      yCur = raw.YAxis;
      zCur = raw.ZAxis;

the xCur is the current value of the sensor.

Then I save the last position of the sensor in order to detect movement.

  void location set ()
{
  xCal = raw.XAxis;
  xMin = (xCal - tolerance);
  xMax = (xCal + tolerance);
  yCal = raw.YAxis;
  yMin = (yCal - tolerance);
  yMax = (yCal + tolerance);
  zCal = raw.ZAxis;
  zMin = (zCal - tolerance);
  zMax = (zCal + tolerance);
}

The problem is that when the program exits the function and reads again the values of the sensor it always detects movement no matter whats the "tolerance" value.

Results:

location set

Xraw = -303 xMin = -383 xMax =
-223

Yraw = -63 yMin = -143 yMax = 17

Zraw = 207 zMin = 127 zMax = 287

Read Values.

raw.XAxis-354 raw.YAxis-148 raw.ZAxis80tsoup

  void location set ()

That is not a valid function name.

A one-time read of the compass is NOT good enough for calibration as I told you in one of you other threads.