void ComputeIMU(void)
{

	static int16_t gyroADCprevious[3] = {0,0,0};
	int16_t gyroADCp[3];
	int16_t gyroADCinter[3];
	
	GetMagData(imu.magADC);
	
	GetAccData(imu.accADC);
	GetEstimatedAttitude(&imu);
	GetGyroData(imu.gyroADC);

	for (byte axis = 0; axis < 3; axis++)
	{
		gyroADCp[axis] =  imu.gyroADC[axis];
	}
	
	delayMicroseconds(650); //empirical, interleaving delay between 2 consecutive reads
	GetGyroData(imu.gyroADC);

	for (byte axis = 0; axis < 3; axis++)
	{
		gyroADCinter[axis] =  imu.gyroADC[axis]+gyroADCp[axis];
		// empirical, we take a weighted value of the current and the previous values
		imu.gyroData[axis] = (gyroADCinter[axis]+gyroADCprevious[axis])/3;
		gyroADCprevious[axis] = gyroADCinter[axis]>>1;
		//imu.accADC[axis]=0;
	}
}
Example #2
0
void MagCalib_TIMER_ISR()
{
#if defined DEBUG_SPECIFIC
    GetMagData(mag);
    sprintf(USB_Tx_Buffer, "%f,%f,%f\r\n", mag[1], mag[0], -mag[2]);
    sendMag = TRUE;
#endif
}