Rev 270 | Rev 275 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 270 | Rev 271 | ||
---|---|---|---|
Line 279... | Line 279... | ||
279 | } |
279 | } |
Line 280... | Line 280... | ||
280 | 280 | ||
281 | 281 | ||
- | 282 | void NCMAG_Calibrate(void) |
|
282 | void NCMAG_Calibrate(void) |
283 | { |
283 | { |
284 | u8 new = 1; |
284 | static s16 Xmin = 0, Xmax = 0, Ymin = 0, Ymax = 0, Zmin = 0, Zmax = 0; |
285 | static s16 Xmin = 0, Xmax = 0, Ymin = 0, Ymax = 0, Zmin = 0, Zmax = 0; |
Line 285... | Line 286... | ||
285 | static s16 X = 0, Y = 0, Z = 0; |
286 | static s16 X = 0, Y = 0, Z = 0; |
Line 303... | Line 304... | ||
303 | Zmax = -10000; |
304 | Zmax = -10000; |
304 | break; |
305 | break; |
Line 305... | Line 306... | ||
305 | 306 | ||
306 | case 2: // 2nd step of calibration |
307 | case 2: // 2nd step of calibration |
307 | // find Min and Max of the X- and Y-Sensors during rotation in the horizontal plane |
308 | // find Min and Max of the X- and Y-Sensors during rotation in the horizontal plane |
308 | if(X < Xmin) Xmin = X; |
309 | if(X < Xmin) { Xmin = X; if(new) BeepTime = 20;} |
309 | else if(X > Xmax) Xmax = X; |
310 | else if(X > Xmax) { Xmax = X; if(new) BeepTime = 20;} |
- | 311 | if(Y < Ymin) { Ymin = Y; if(new) BeepTime = 60;} |
|
- | 312 | else if(Y > Ymax) { Ymax = Y; if(new) BeepTime = 60;} |
|
- | 313 | ||
- | 314 | if(new) |
|
- | 315 | { |
|
310 | if(Y < Ymin) Ymin = Y; |
316 | if(Z < Zmin) { Zmin = Z; BeepTime = 100;} |
- | 317 | else if(Z > Zmax) { Zmax = Z; BeepTime = 100;} |
|
- | 318 | } |
|
311 | else if(Y > Ymax) Ymax = Y; |
319 | |
Line 312... | Line 320... | ||
312 | break; |
320 | break; |
313 | 321 | ||
- | 322 | case 3: // 3rd step of calibration |
|
314 | case 3: // 3rd step of calibration |
323 | // used to change the orientation of the MK3MAG vertical to the horizontal plane |
Line 315... | Line 324... | ||
315 | // used to change the orientation of the MK3MAG vertical to the horizontal plane |
324 | // if(new) Compass_CalState = 5; |
316 | break; |
325 | break; |
317 | 326 | ||
318 | case 4: |
327 | case 4: |
319 | // find Min and Max of the Z-Sensor |
328 | // find Min and Max of the Z-Sensor |
Line 320... | Line 329... | ||
320 | if(Z < Zmin) Zmin = Z; |
329 | if(Z < Zmin) { Zmin = Z; if(new) BeepTime = 80;} |
321 | else if(Z > Zmax) Zmax = Z; |
330 | else if(Z > Zmax) { Zmax = Z; if(new) BeepTime = 80;} |
322 | break; |
331 | break; |
Line 609... | Line 618... | ||
609 | // -------------------------------------------------------- |
618 | // -------------------------------------------------------- |
610 | u8 NCMAG_SelfTest(void) |
619 | u8 NCMAG_SelfTest(void) |
611 | { |
620 | { |
612 | u8 msg[64]; |
621 | u8 msg[64]; |
Line 613... | Line 622... | ||
613 | 622 | ||
614 | #define LIMITS(value, min, max) {min = (90 * value)/100; max = (110 * value)/100;} |
623 | #define LIMITS(value, min, max) {min = (80 * value)/100; max = (120 * value)/100;} |
615 | u32 time; |
624 | u32 time; |
616 | s32 XMin = 0, XMax = 0, YMin = 0, YMax = 0, ZMin = 0, ZMax = 0; |
625 | s32 XMin = 0, XMax = 0, YMin = 0, YMax = 0, ZMin = 0, ZMax = 0; |
617 | s16 xscale, yscale, zscale, scale_min, scale_max; |
626 | s16 xscale, yscale, zscale, scale_min, scale_max; |
618 | u8 crb_gain, cra_rate; |
627 | u8 crb_gain, cra_rate; |