Contents
|
MultiWii Magneterometer (compass) Sensor
The sensor has two major functions:
To stabilize the YAW axis.
To help the GPS sensor to find the direction.
The physical sensor board orientation is done with Y pointing front and X pointed right.
I am using a Sparkfun HMC5843 break out board (BOB). This chip will be no longer delivered.
Now you have to order a HMC5883L. Unfortunately the direction of the Sparkfun HMC5883L BOB is different to the old BOB.
Before use a calibration must be done, see software Sensors, void Mag_getADC():
First press the button CALIB_MAG in the config program
- The trick is to rotate the quad one turn on all axis during the 30 second CALIB_MAG period.
Output in Config while turning: Head 0 - 180 - -179 - 0
The function test can be done with the config program, see from Alexinparis
- Z MAG should be positive and not move a lot if the multi remains flat.
- X MAG: ROLL RIGHT = positive; ROLL LEFT = negative
- Y MAG: PITCH FORWARD = positive; PITCH backward = negative
- The important thing is not the absolute direction of the arrow, but the difference to the direction at the time the MAG was activated.
Problem with intermittent false Data
I am using a Sparkfun HMC5843 break out board with software MultiWii_dev_20110928, but the problem happens also in version MultiWii_1_8_patch2. In principle the Magnetometer works, also the calibration. VCC ist 2.5V from the ELV BMA020 board.
The problem is, that intermittent about every 10-30 seconds a false value is shown, please see the attached image. That happens while the quadrocopter is sitting on the table.
First I had a look to the I2C data after a Logic Level Shifter (LLC) between 2.5 V and 5 V, see attached scope picture.
The I2C signals are looking good for me.
Then I added a routine in serial.pde to output the raw MAG values in hex in the Serial Monitor Window.
void itoh(unsigned int n) { int digit; const char *hex = "0123456789abcdef"; if ((digit = n / 16) != 0) itoh(digit); // recursive call serialize8(hex[n % 16]); } void serialCom() { int16_t a; uint8_t i; uint16_t intPowerMeterSum, intPowerTrigger1; // 2011-10-10 RR, show Mag raw data if(MAG && !tx_busy) { point=0; itoh(magADC[ROLL]); serialize8(' '); itoh(magADC[PITCH]); serialize8(' '); itoh(magADC[YAW]); serialize8(0x0d); // carriage return serialize8(0x0a); // line feed UartSendData(); }
Then I found in the Serial Monitor Window the following disturbed data (ROLL, PITCH, YAW):
ffd6 ff7b 194 ffd6 ff7b 194 ffcc ff7e 3fdb ffcc ff7e 3fdb ffcc ff7e 3fdb ffcc ff7e 3fdb ffcc ff7e 3fdb ffcc ff7e 19f ffcc ff7e 19f and ff9b ff97 1b0 ff9b ff97 1b0 ff4b 5d88 a23d ff4b 5d88 a23d ff4b 5d88 a23d ff4b 5d88 a23d ff4b 5d88 a23d ffa8 ff90 1a7 ffa8 ff90 1a7 and ffb7 ff93 1a9 ffb7 ff93 1a9 ffaa 1e ba7 ffaa 1e ba7 ffaa 1e ba7 ffaa 1e ba7 ffaa 1e ba7 ffaa ff91 1ad ffaa ff91 1ad
What looks surprising to me, there is always a block of 5 consecutive wrong values.
That looks too systematic for me, to believe in a random disturbance.
Next Step is to trigger at the readout time, change the program. With digitalWrite() the pulse width is 280us. With #define macro just us.
in Program MultiWii_dev_... void Device_Mag_getADC() { i2c_getSixRawADC(0X3C,0X03); #if defined(HMC5843) MAG_ORIENTATION( ((rawADC[0]<<8) | rawADC[1]) , ((rawADC[2]<<8) | rawADC[3]) , -((rawADC[4]<<8) | rawADC[5]) ); if (magADC[YAW] > 1000) { DIGITAL_MAG_DBG_HIGH; // 2011-10-10 RR, signal Mag data fault, pin 7 DIGITAL_MAG_DBG_LOW; } in def.h #define DIGITAL_MAG_DBG_HIGH PORTH |= 1<<4; #define DIGITAL_MAG_DBG_LOW PORTH &= ~(1<<4);
List of pages in this category:
-- RudolfReuter 2011-10-11 13:05:09
Go back to CategoryQuadrocopter or FrontPage ; KontaktEmail (ContactEmail)