Is there any reason why MAGBUFFSIZEX is 14 instead of 12 as description?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there any reason why MAGBUFFSIZEX is 14 instead of 12 as description?

Jump to solution
702 Views
garyto
Contributor I

I was going through the fusion code and notice this in the magnetic.h file, line32-33

// magnetic calibration constants
#define MAGBUFFSIZEX 14                    // x dimension in magnetometer buffer (12x24 equals 288 elements)
#define MAGBUFFSIZEY (2 * MAGBUFFSIZEX)    // y dimension in magnetometer buffer (12x24 equals 288 elements)

The MAGBUFFSIZEX is set to 14 instead of 12 as described in the annotation. This affects the tanarray calculation in magnetic.c, line 61-68,

// initialize the array of (MAGBUFFSIZEX - 1) elements of 100 * tangents used for buffer indexing
    // entries cover the range 100 * tan(-PI/2 + PI/MAGBUFFSIZEX), 100 * tan(-PI/2 + 2*PI/MAGBUFFSIZEX) to
    // 100 * tan(-PI/2 + (MAGBUFFSIZEX - 1) * PI/MAGBUFFSIZEX).
    // for MAGBUFFSIZEX=12, the entries range in value from -373 to +373
    for (j = 0; j < (MAGBUFFSIZEX - 1); j++)
    {
        pthisMagBuffer->tanarray[j] = (int16) (100.0F * tanf(PI * (-0.5F + (float) (j + 1) / MAGBUFFSIZEX)));
    }

the tanarray will go from -438 to 438 instead of -373 to 373.

Labels (1)
0 Kudos
1 Solution
410 Views
michaelestanley
NXP Employee
NXP Employee

No reason.  The comments are just out of date.

View solution in original post

0 Kudos
1 Reply
411 Views
michaelestanley
NXP Employee
NXP Employee

No reason.  The comments are just out of date.

0 Kudos