Subversion Repositories FlightCtrl

Rev

Rev 772 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 772 Rev 773
Line 248... Line 248...
248
 
248
 
249
        GRN_ON;
249
        GRN_ON;
Line 250... Line 250...
250
        ROT_OFF;
250
        ROT_OFF;
251
 
251
 
252
        // get maximum and minimum reading of all axis
252
        // get maximum and minimum reading of all axis
253
        while (measurement && !MM3_Timeout)
253
        while (measurement)
254
        {
254
        {
Line 255... Line 255...
255
                if (MM3.x_axis > x_max) x_max = MM3.x_axis;
255
                if (MM3.x_axis > x_max) x_max = MM3.x_axis;
Line 274... Line 274...
274
                while(!CheckDelay(timer));
274
                while(!CheckDelay(timer));
Line 275... Line 275...
275
 
275
 
276
                // If thrust is less than 100, stop calibration with a delay of 0.5 seconds
276
                // If thrust is less than 100, stop calibration with a delay of 0.5 seconds
277
                if (PPM_in[ParamSet.ChannelAssignment[CH_THRUST]] < 100) measurement--;
277
                if (PPM_in[ParamSet.ChannelAssignment[CH_THRUST]] < 100) measurement--;
278
        }
-
 
279
        if(!MM3_Timeout)
-
 
280
        {
278
        }
281
                // Rage of all axis
279
        // Rage of all axis
282
                MM3_calib.X_range = (x_max - x_min);
280
        MM3_calib.X_range = (x_max - x_min);
283
                MM3_calib.Y_range = (y_max - y_min);
281
        MM3_calib.Y_range = (y_max - y_min);
284
                MM3_calib.Z_range = (z_max - z_min);
282
        MM3_calib.Z_range = (z_max - z_min);
285
 
283
 
286
                // Offset of all axis
284
        // Offset of all axis
287
                MM3_calib.X_off = (x_max + x_min) / 2;
285
        MM3_calib.X_off = (x_max + x_min) / 2;
288
                MM3_calib.Y_off = (y_max + y_min) / 2;
286
        MM3_calib.Y_off = (y_max + y_min) / 2;
289
                MM3_calib.Z_off = (z_max + z_min) / 2;
287
        MM3_calib.Z_off = (z_max + z_min) / 2;
290
 
288
 
291
                // save to EEProm
289
        // save to EEProm
292
                SetParamByte(PID_MM3_X_OFF,   (uint8_t)MM3_calib.X_off);
290
        SetParamByte(PID_MM3_X_OFF,   (uint8_t)MM3_calib.X_off);
293
                SetParamByte(PID_MM3_Y_OFF,   (uint8_t)MM3_calib.Y_off);
291
        SetParamByte(PID_MM3_Y_OFF,   (uint8_t)MM3_calib.Y_off);
294
                SetParamByte(PID_MM3_Z_OFF,   (uint8_t)MM3_calib.Z_off);
292
        SetParamByte(PID_MM3_Z_OFF,   (uint8_t)MM3_calib.Z_off);
295
                SetParamWord(PID_MM3_X_RANGE, (uint16_t)MM3_calib.X_range);
293
        SetParamWord(PID_MM3_X_RANGE, (uint16_t)MM3_calib.X_range);
296
                SetParamWord(PID_MM3_Y_RANGE, (uint16_t)MM3_calib.Y_range);
294
        SetParamWord(PID_MM3_Y_RANGE, (uint16_t)MM3_calib.Y_range);
297
                SetParamWord(PID_MM3_Z_RANGE, (uint16_t)MM3_calib.Z_range);
295
        SetParamWord(PID_MM3_Z_RANGE, (uint16_t)MM3_calib.Z_range);
298
        }
296
 
Line 299... Line 297...
299
}
297
}
300
 
298