Tool/software: Code Composer Studio
Hello,
I'm working with the mpu6050 sensor connected to my Launchpad board.
The readings are very noisy - so to improve the results I wanted write a function that does the following:
1. Takes a reading
2. Accumulates (adds the new reading to the sum of all the history readings.
3. Divides the accumulated sum by the number of readings.
This is what I wrote:
void sample_accumulate_average ( int number_of_samples , float *accelerometer_average[3] , float *gyro_average[3] ) // the function receives as an argument pointer to arrays of 3 elements { float accelerometer_reading[3], gyro_reading[3]; int sample_counter ; int axis_number ; tMPU6050 g_sMPU6050Inst; // MPU6050 sensor driver structure. "tMPU6050" is defined in the mpu6050.h file. for ( sample_counter = 0 ; sample_counter < number_of_samples ; sample_counter ++ ) { MPU6050DataRead(&g_sMPU6050Inst, USER_MPU6050Callback, 0); while(!g_bMPU6050Done) { } MPU6050DataAccelGetFloat(&g_sMPU6050Inst, &accelerometer_reading[0], &accelerometer_reading[1], &accelerometer_reading[2]); MPU6050DataGyroGetFloat(&g_sMPU6050Inst, &gyro_reading[0], &gyro_reading[1], &gyro_reading[2]); for ( axis_number = 0 ; axis_number < 3 ; axis_number ++ ) { *accelerometer_average [ axis_number ] = *accelerometer_average [ axis_number ] + accelerometer_reading [ axis_number ] ; // accumulate accelerometer readings *gyro_average [ axis_number ] = *accelerometer_average [ axis_number ] + accelerometer_reading [ axis_number ] ; // accumulate gyro readings } } for ( axis_number = 0 ; axis_number < 3 ; axis_number ++ ) { *accelerometer_average [ axis_number ] = *accelerometer_average [ axis_number ] / number_of_samples ; *gyro_average [ axis_number ] = *gyro_average [ axis_number ] / number_of_samples ; } }
And this is how I call the function in my code
sample_accumulate_average ( 64 , &fAccel , &fGyro ) ;
I get the following warning:
Description Resource Path Location Type
#169-D argument of type "float (*)[3]" is incompatible with parameter of type "float **" main.c /PID line 186 C/C++ Problem
What did I do wrong ?