hi
im trying to port nxp fusion library to another MCU
i did download sdk that have issdk in it
till now i dont have any sensor so i want to feed fusion library some data to see if it calculate right or not
this is my feedeing value function like
int8_t FXAS21002_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
{
sfg->Gyro.iFIFOCount=0;
sensor->isInitialized = F_USING_GYRO;
sfg->Gyro.isEnabled = true;
return SENSOR_ERROR_NONE;
}
int8_t FXAS21002_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
{
int16_t sample[3];
sample[CHX] = 200;
sample[CHY] = 100;
sample[CHZ] = 100;
conditionSample(sample);
addToFifo((union FifoSensor*) &(sfg->Gyro), GYRO_FIFO_SIZE, sample);
return SENSOR_ERROR_NONE;
}
int8_t FXOS8700_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
{
sfg->Accel.iFIFOCount=0;
sensor->isInitialized = F_USING_ACCEL;
sfg->Accel.isEnabled = true;
return SENSOR_ERROR_NONE;
}
int8_t FXOS8700_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
{
int16_t sample[3];
sample[CHX] = 300;
sample[CHY] = 100;
sample[CHZ] = 100;
conditionSample(sample);
addToFifo((union FifoSensor*) &(sfg->Accel), ACCEL_FIFO_SIZE, sample);
return SENSOR_ERROR_NONE;
}
int8_t MPL3115_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
{
sfg->Mag.iFIFOCount=0;
sensor->isInitialized = F_USING_MAG;
sfg->Mag.isEnabled = true;
return SENSOR_ERROR_NONE;
}
int8_t MPL3115_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
{
int16_t sample[3];
sample[CHX] = 100;
sample[CHY] = 100;
sample[CHZ] = 200;
conditionSample(sample);
addToFifo((union FifoSensor*) &(sfg->Mag), MAG_FIFO_SIZE, sample);
return SENSOR_ERROR_NONE;
}
and then in the rest of main.c
SensorFusionGlobals sfg;
struct ControlSubsystem controlSubsystem;
struct StatusSubsystem statusSubsystem;
struct PhysicalSensor sensors[3];
registerDeviceInfo_t i2cBusInfo ;
typedef struct _ARM_DRIVER_I2C {
char navid;
} const ARM_DRIVER_I2C;
int main(){
ARM_DRIVER_I2C* I2Cdrv ;;
initializeControlPort(&controlSubsystem);
initializeStatusSubsystem(&statusSubsystem);
initSensorFusionGlobals(&sfg, &statusSubsystem, &controlSubsystem);
sfg.installSensor(&sfg, &sensors[0], 0, 1, (void*) I2Cdrv, &i2cBusInfo, FXOS8700_Init, FXOS8700_Read);
sfg.installSensor(&sfg, &sensors[1], 0, 1, (void*) I2Cdrv, &i2cBusInfo, FXAS21002_Init, FXAS21002_Read);
sfg.installSensor(&sfg, &sensors[2], 0, 1, (void*) I2Cdrv, &i2cBusInfo, MPL3115_Init, MPL3115_Read);
sfg.initializeFusionEngine(&sfg);
int i = 0 ;
while(1){
sfg.readSensors(&sfg, 1);
sfg.conditionSensorReadings(&sfg);
sfg.runFusion(&sfg);
sfg.applyPerturbation(&sfg);
sfg.loopcounter++;
}
}
u see data that i feed is in sample variable in each sensor read function
when i watch sfg. SV_9DOF_GBY_KALMAN all of the parameter is zero
what valuse should i feed in accel and mag and gyro to see if it work right . do u have any sample to give me so i can try with it?
my build.h
#define F_USING_ACCEL 0x0001
#define F_USING_MAG 0x0002
#define F_USING_GYRO 0x0004
#define F_USING_PRESSURE 0x0000
#define F_USING_TEMPERATURE 0x0000
#define F_ALL_SENSORS 0x001F
#define F_1DOF_P_BASIC 0x0000
#define F_3DOF_G_BASIC 0x0200
#define F_3DOF_B_BASIC 0x0400
#define F_3DOF_Y_BASIC 0x0800
#define F_6DOF_GB_BASIC 0x1000
#define F_6DOF_GY_KALMAN 0x2000
#define F_9DOF_GBY_KALMAN 0x4000
thanks allot