miniIMU-9 v3 Calibrating/Gain Value

Hi, I am using the calibrating sample code for the miniIMU-9 v3 (lsm303, L3GD20H) and got the value as follow.
min: { -2790, -2730, -3857} max: { +2864, +2344, +1722}.
Am getting int, float values, is there anyway to reduce the gain value?
I got this error message when compiling.

C:\Users\Roblox Click Here\Downloads\headtracking-from-kris-master\headtracking-from-kris-master\headtracking-from-kris\headtracking-from-kris.ino:108:40: error: cannot convert ‘int*’ to ‘float*’ for argument ‘1’ to ‘void Smoothing(float*, float*)’

 Smoothing(&compass.a.x, &smoothAccX);

Here is the link:

Best regards
Ki

Hi, Ki.

A simple way to get your code to compile should be to use some intermediate float variables that you can pass (with pointers) to the Smoothing() function:

    float floatAccX = compass.a.x;
    float floatAccY = compass.a.y;
    float floatAccZ = compass.a.z;
    Smoothing(&floatAccX, &smoothAccX);
    Smoothing(&floatAccY, &smoothAccY);
    Smoothing(&floatAccZ, &smoothAccZ);

However, I have not looked at the code in detail, so I don’t know if this will produce the behavior that you want.

I am also not sure what you mean by:

Am getting int, float values, is there anyway to reduce the gain value?

If that is still an issue for you, could you describe what you are trying to do and what problems you are encountering?

Kevin

Hi Kevin
I am trying to bring down the calibration values similar to this

/* 
27  * To find the calibration values, load the Calibrate sketch from LSM303 library in menu : examples > LSM303 > Calibrate 
28  * https://github.com/pololu/lsm303-arduino/blob/master/LSM303/examples/Calibrate/Calibrate.ino 
29  * Then put the calibration values below 
30  */ 
31 #define compassXMin -310.0f 
32 #define compassYMin -351.0f 
33 #define compassZMin -327.0f 
34 #define compassXMax 290.0f 
35 #define compassYMax 263.0f 
36 #define compassZMax 208.0f 
37 #define inverseXRange (float)(2.0 / (compassXMax - compassXMin)) 
38 #define inverseYRange (float)(2.0 / (compassYMax - compassYMin)) 
39 #define inverseZRange (float)(2.0 / (compassZMax - compassZMin))

My current values are (min: { -2790, -2730, -3857} max: { +2864, +2344, +1722}.).
the values are very stable and 99.9 percent fixed.

Also the current sample/calibrate value
(LSM303::vector<int16_t> running_min = {32767, 32767, 32767}, running_max = {-32768, -32768, -32768};

And the LSM303_version 1.4.4 has the following values
LSM303::vector<int16_t> running_min = {2047, 2047, 2047}, running_max = {-2048, -2048, -2048};

I’ve tried both but couldn’t brought the value down below approx. 350.0f

Regards and thanks for reply.
Ki Nguy

Hi, Ki.

I edited your post to format the code so it’s easier to read; you can do this with the “Preformatted text” button above the editing area. It looks like you’re referring to this part of the code you linked to earlier: https://github.com/paulgreg/headtracking-from-kris/blob/master/headtracking-from-kris.ino#L26-L36

Was that program written by someone else? If so, I recommend that you try to contact the author about what version of the LSM303 library it was written for and how the calibration values were obtained. Note that versions of the library before 2.0.0 scaled the magnetometer output differently; it is basically smaller by a factor of 16, so if you are using a newer version of the library, you could try dividing all your magnetometer readings by 16.

Kevin