Subversion Repositories NaviCtrl

Rev

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

Rev 339 Rev 342
Line 168... Line 168...
168
// self test value
168
// self test value
169
#define HMC5843_TEST_XSCALE             555
169
#define HMC5843_TEST_XSCALE             555
170
#define HMC5843_TEST_YSCALE             555
170
#define HMC5843_TEST_YSCALE             555
171
#define HMC5843_TEST_ZSCALE             555
171
#define HMC5843_TEST_ZSCALE             555
172
// clibration range
172
// clibration range
173
#define HMC5843_CALIBRATION_RANGE   550
173
#define HMC5843_CALIBRATION_RANGE   600
Line 174... Line 174...
174
 
174
 
175
// the special LSM302DLH interface
175
// the special LSM302DLH interface
176
// bit mask for rate
176
// bit mask for rate
177
#define LSM303DLH_CRA_RATE_0_75HZ       0x00
177
#define LSM303DLH_CRA_RATE_0_75HZ       0x00
Line 194... Line 194...
194
// self test value
194
// self test value
195
#define LSM303DLH_TEST_XSCALE   495
195
#define LSM303DLH_TEST_XSCALE   495
196
#define LSM303DLH_TEST_YSCALE   495
196
#define LSM303DLH_TEST_YSCALE   495
197
#define LSM303DLH_TEST_ZSCALE   470
197
#define LSM303DLH_TEST_ZSCALE   470
198
// clibration range
198
// clibration range
199
#define LSM303_CALIBRATION_RANGE   500
199
#define LSM303_CALIBRATION_RANGE   550
Line 200... Line 200...
200
 
200
 
201
// the i2c ACC interface
201
// the i2c ACC interface
202
#define ACC_SLAVE_ADDRESS               0x30    // i2c slave for acc. sensor registers
202
#define ACC_SLAVE_ADDRESS               0x30    // i2c slave for acc. sensor registers
203
// register mapping
203
// register mapping
Line 346... Line 346...
346
                                if(NCMAG_MagType == MAG_TYPE_LSM303DLH)
346
                                if(NCMAG_MagType == MAG_TYPE_LSM303DLH)
347
                                 {
347
                                 {
348
                                  UART1_PutString("\r\n\r\nLSM303 calibration\n\r");
348
                                  UART1_PutString("\r\n\r\nLSM303 calibration\n\r");
349
                                  MinCaclibration =LSM303_CALIBRATION_RANGE;
349
                                  MinCaclibration =LSM303_CALIBRATION_RANGE;
350
                                 }
350
                                 }
-
 
351
                                if(EarthMagneticStrengthTheoretic)
-
 
352
                                 {
-
 
353
                                  MinCaclibration = (MinCaclibration * EarthMagneticStrengthTheoretic) / 50;
-
 
354
                                  sprintf(msg, "Earth field on your location should be: %iuT\r\n",EarthMagneticStrengthTheoretic);
-
 
355
                                  UART1_PutString(msg);
-
 
356
                                 }
-
 
357
                            else UART1_PutString("without GPS\n\r");
Line 351... Line 358...
351
 
358
 
352
                                Calibration.MagX.Range = Xmax - Xmin;
359
                                Calibration.MagX.Range = Xmax - Xmin;
353
                                Calibration.MagX.Offset = (Xmin + Xmax) / 2;
360
                                Calibration.MagX.Offset = (Xmin + Xmax) / 2;
354
                                Calibration.MagY.Range = Ymax - Ymin;
361
                                Calibration.MagY.Range = Ymax - Ymin;
Line 357... Line 364...
357
                                Calibration.MagZ.Offset = (Zmin + Zmax) / 2;
364
                                Calibration.MagZ.Offset = (Zmin + Zmax) / 2;
358
                                if((Calibration.MagX.Range > MinCaclibration) && (Calibration.MagY.Range > MinCaclibration) && (Calibration.MagZ.Range > MinCaclibration))
365
                                if((Calibration.MagX.Range > MinCaclibration) && (Calibration.MagY.Range > MinCaclibration) && (Calibration.MagZ.Range > MinCaclibration))
359
                                {
366
                                {
360
                                        NCMAG_IsCalibrated = NCMag_CalibrationWrite();
367
                                        NCMAG_IsCalibrated = NCMag_CalibrationWrite();
361
                                        BeepTime = 2500;
368
                                        BeepTime = 2500;
362
                                        UART1_PutString("\r\n Calibration okay\n\r");
369
                                        UART1_PutString("\r\n-> Calibration okay <-\n\r");
363
                                }
370
                                }
364
                                else
371
                                else
365
                                {
372
                                {
366
                                        UART1_PutString("\r\nCalibration FAILED - Values too low: ");
373
                                        UART1_PutString("\r\nCalibration FAILED - Values too low: ");
367
                                    if(Calibration.MagX.Range < MinCaclibration) UART1_PutString("X! ");
374
                                    if(Calibration.MagX.Range < MinCaclibration) UART1_PutString("X! ");
368
                                    if(Calibration.MagY.Range < MinCaclibration) UART1_PutString("y! ");
375
                                    if(Calibration.MagY.Range < MinCaclibration) UART1_PutString("Y! ");
369
                                    if(Calibration.MagZ.Range < MinCaclibration) UART1_PutString("Z! ");
376
                                    if(Calibration.MagZ.Range < MinCaclibration) UART1_PutString("Z! ");
370
                                        UART1_PutString("\r\n");
377
                                        UART1_PutString("\r\n");
371
                                        sprintf(msg, "Minimum is: %i \r\n",MinCaclibration);
-
 
372
                                        UART1_PutString(msg);
-
 
Line 373... Line 378...
373
 
378
 
374
                                        // restore old calibration data from eeprom
379
                                        // restore old calibration data from eeprom
375
                                        NCMAG_IsCalibrated = NCMag_CalibrationRead();
380
                                        NCMAG_IsCalibrated = NCMag_CalibrationRead();
376
                                }
381
                                }
377
                                        sprintf(msg, "X: (%i - %i = %i)\r\n",Xmax,Xmin,Xmax - Xmin);
382
                                        sprintf(msg, "X: (%i - %i = %i)\r\n",Xmax,Xmin,Xmax - Xmin);
378
                                        UART1_PutString(msg);
383
                                        UART1_PutString(msg);
379
                                        sprintf(msg, "Y: (%i - %i = %i)\r\n",Ymax,Ymin,Ymax - Ymin);
384
                                        sprintf(msg, "Y: (%i - %i = %i)\r\n",Ymax,Ymin,Ymax - Ymin);
380
                                        UART1_PutString(msg);
385
                                        UART1_PutString(msg);
381
                                        sprintf(msg, "Z: (%i - %i = %i)\r\n",Zmax,Zmin,Zmax - Zmin);
386
                                        sprintf(msg, "Z: (%i - %i = %i)\r\n",Zmax,Zmin,Zmax - Zmin);
-
 
387
                                        UART1_PutString(msg);
-
 
388
                                        sprintf(msg, "(Minimum ampilitude is: %i)\r\n",MinCaclibration);
382
                                        UART1_PutString(msg);
389
                                        UART1_PutString(msg);
383
                        }
390
                        }
Line 384... Line 391...
384
                        break;
391
                        break;
385
                       
392
                       
Line 429... Line 436...
429
                if(raw >= NCMAG_MIN_RAWVALUE && raw <= NCMAG_MAX_RAWVALUE)
436
                if(raw >= NCMAG_MIN_RAWVALUE && raw <= NCMAG_MAX_RAWVALUE)
430
                {
437
                {
431
                  if(NCMAG_Identification2.Sub == 0x3c) MagRawVector.Y = raw; // here Z and Y are exchanged
438
                  if(NCMAG_Identification2.Sub == 0x3c) MagRawVector.Y = raw; // here Z and Y are exchanged
432
                  else MagRawVector.Z = raw;
439
                  else MagRawVector.Z = raw;
433
                }
440
                }
434
 
-
 
-
 
441
//MagRawVector.X += 2 * ((s32) FC.Poti[7] - 128);
435
        }
442
        }
436
        if(Compass_CalState || !NCMAG_IsCalibrated)
443
        if(Compass_CalState || !NCMAG_IsCalibrated)
437
        {       // mark out data invalid
444
        {       // mark out data invalid
438
                MagVector.X = MagRawVector.X;
445
                MagVector.X = MagRawVector.X;
439
                MagVector.Y = MagRawVector.Y;
446
                MagVector.Y = MagRawVector.Y;