The SDA and SCL bus lines for the three sensors (magnetometer HMC 5883L, accelerometer and gyro) were joined with not issues checked through the serial communication. (picture below).
Biasing was completed with the following pseudo code. It makes use of a running summation and computes an average once a number of measurements have been collected.
/*
This is a script to remove signal bias
from filtered signal.
Author: Paulin Kantue
Date: June 2013
*/
#define COUNT 50 //Number of values to be counted for biasing
boolean computeBias(int raw_vec[], int bias_vec[], int8_t size_count, int8_t *bias_count){
int8_t counter = *bias_count;
boolean flag; // flag to compute sensor bias;
if (counter < COUNT){
for (int i = 0; i < size_count; i++){
bias_vec[i] += raw_vec[i];
}
*bias_count+=1;
flag = true;
}
else {
for (int i = 0; i < size_count; i++){
bias_vec[i] /= COUNT;
raw_vec[i] -= bias_vec[i];
}
flag = false;
}
return flag;
}
void removeBias(int raw_vec[], int bias_vec[], int8_t size_count){
for (int i = 0; i < size_count; i++){
raw_vec[i] -= bias_vec[i];
}
}
// set gravity for Accelerometer to -250LSB/g
void setGravity(int raw_vec[]){
raw_vec[2] -= 250;
}
It makes us of 50 values (irrespective of update rate) and can be executed ONCE at the beginning of the code.
Biasing was completed with the following pseudo code. It makes use of a running summation and computes an average once a number of measurements have been collected.
/*
This is a script to remove signal bias
from filtered signal.
Author: Paulin Kantue
Date: June 2013
*/
#define COUNT 50 //Number of values to be counted for biasing
boolean computeBias(int raw_vec[], int bias_vec[], int8_t size_count, int8_t *bias_count){
int8_t counter = *bias_count;
boolean flag; // flag to compute sensor bias;
if (counter < COUNT){
for (int i = 0; i < size_count; i++){
bias_vec[i] += raw_vec[i];
}
*bias_count+=1;
flag = true;
}
else {
for (int i = 0; i < size_count; i++){
bias_vec[i] /= COUNT;
raw_vec[i] -= bias_vec[i];
}
flag = false;
}
return flag;
}
void removeBias(int raw_vec[], int bias_vec[], int8_t size_count){
for (int i = 0; i < size_count; i++){
raw_vec[i] -= bias_vec[i];
}
}
// set gravity for Accelerometer to -250LSB/g
void setGravity(int raw_vec[]){
raw_vec[2] -= 250;
}
It makes us of 50 values (irrespective of update rate) and can be executed ONCE at the beginning of the code.
Comments
Post a Comment