FXAS21000 Zero-Rate Offset Compensation not working correctly.

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

FXAS21000 Zero-Rate Offset Compensation not working correctly.

Jump to solution
1,420 Views
johnwolfe
Contributor II

Hello,

               I am seeking help/advice on initializing the FXAS21000 gyro chip.  I am using the FRDMK64 board and the Xtrinsic board. The WHO_AM_I response from this chip is $D1 indicating this is a FXAS21000 chip.

               It seems that only on cold power on does the gyro chip come up with offset compensations that appear somewhat reasonable.   This results in gyro values of -4.0 to +4.0 dps for each axis when later retrieving data via polling (I have interrupts turned off)…although this still seems a little high to me.  I have it configured for +/-1600 range with ODR=200Hz, and the K64 is sampling and retrieving data every 12ms.  I keep the FXAS21000 in Active state at all times when running.

               However, when doing a K64 running reset or FRDM64 reset (push reset button),  the FW will run through the init code for the FXAS21000 chip but the offset compensation does not  appear to work.  I can show this by first purposely moving the device during power up to establish bad offset compensation values. Lets say after I do this that subsequent polling of data shows  X/Y/Z = +50.0/-20.0/2.0 when the device is not moving.  Then keeping device steady (unmoving), when I do a K64 micro reset (press reset button on FRDM board),  after FW initialization and when polling I now get  values of X/Y/Z = -50.0/+20.0/-2.0, plus or minus say 4dps on each.  NOTICE the sign of the values have changed. If I do reset again they signs invert again.

I have tried 3 different algorithms shown below, but they all give me the same results.
It appears that after initialization, when polling I get reasonable values from the device as it is moved…it is just that the offset may not be correct.

Can anyone identify the common problem on these init steps, or suggest what steps I should try instead.  Any help would be greatly appreciated. For example, in Algo 1 it purposely moves the device to Active mod and waits for first data to be acquired because the Spec suggests that ZR_cond should not be set unless there are first samples available??

Thanks in advance.
John Wolfe

Algo #1:

-        Repeatedly read INT_SOURCE_FLAG($0B)  until BOOTEND flag is SET

o   Because if Power on cycle Gyro could be going through boot

-        Write CTRL_REG1($13)=$40 to do Soft Reset (RST=1)

o   Because if only K64 running reset want to force gyro with init values

-        Repeatedly read INT_SOURCE_FLAG($0B)  until  BOOTEND flag is SET

o   Because Soft Reset causes gyro to go through boot

-        Write CTRL_REG0($0D)=$00 for range of +/- 1600 and hi-pass filter disabled

-        Write CTRL_REG1($13)=$02 to move to Active Mode

o   Because FXAS21000 spec says “ZR_cond may be written only after the first sample is available, as it uses the current sample for calibrations.

-        Repeatedly read DR_STATUS until ZDR, YDR, XDR are set (we have valid data)

-        Write CTRL_REG1($13)=$82 to start Offset compensation (ZR_Comp=1)

-        Repeatedly read CTRL_REG1($13) until ZR_Comp=0

Algo #2:

-        Write CTRL_REG1($13)=$40 to do Soft Reset (RST=1)

-        Delay a short time

-        Write CTRL_REG0($0D)=$00 for range of +/- 1600 and hi-pass filter disabled

-        Write CTRL_REG1($13)=$82 to force into ACTIVE mode and initiate Zero Compenstation

Algo #3: Similar to init algo at “FXAS21000 Bare metal Example project” at  https://community.freescale.com/docs/DOC-100869

-        Repeatedly read INT_SOURCE_FLAG($0B)  until BOOTEND flag is SET

o   Because whole device powered Gyro could be going through boot

-        Write CTRL_REG1($13)=$40 to do Soft Reset (RST=1)

-        Repeatedly read CTRL_REG1 until  RST is CLEARed

-        Write CTRL_REG1($13)=$80 to start Offset compensation (ZR_Comp=1)

-        Repeatedly read CTRL_REG1($13) until ZR_Comp=0

-        Write CTRL_REG0($0D)=$00 for range of +/- 1600 and hi-pass filter disabled

-        Write CTRL_REG1($13)=$02 to put into ACTIVE mode.

Labels (1)
0 Kudos
1 Solution
1,052 Views
johnwolfe
Contributor II

Hello,

    I believe I have resolved my problem.   The key to getting the offset compensation to work is that the Gyro must be fully in the ACTIVE mode prior to initiating the Zero Compensation (setting ZR_cond).  Thus the Gyro init algo I am now using is the following:

   - Write $40 to CTRL_REG1($13) to force a Soft Reset
   - Wait a short time (2ms) for boot to complete

   - Write $00 to CTRL_REG0($0D) to setup for +/-1600dps range and turn off Hi Pass Filter

   - Wrrte $06 to CTRL_REG1($13) to put device into ACTIVE mode with ODR=100Hz

   - Wait 325ms for device to transition from STANDBY mode to ACTIVE mode . spec says ODR/2+250)

   - Write $86 to CTRL_REG1($13) to Start Offset Compensation (ZR_cond=1) + Active+ ODR=100Hz

   - Read CTRL_REG1 repeatedly until it indicates Offset Compensation has finished

   So this inits the Gyro such that a main micro can poll the device to retrieve Gyro data (say ever 15ms).

John

View solution in original post

0 Kudos
1 Reply
1,053 Views
johnwolfe
Contributor II

Hello,

    I believe I have resolved my problem.   The key to getting the offset compensation to work is that the Gyro must be fully in the ACTIVE mode prior to initiating the Zero Compensation (setting ZR_cond).  Thus the Gyro init algo I am now using is the following:

   - Write $40 to CTRL_REG1($13) to force a Soft Reset
   - Wait a short time (2ms) for boot to complete

   - Write $00 to CTRL_REG0($0D) to setup for +/-1600dps range and turn off Hi Pass Filter

   - Wrrte $06 to CTRL_REG1($13) to put device into ACTIVE mode with ODR=100Hz

   - Wait 325ms for device to transition from STANDBY mode to ACTIVE mode . spec says ODR/2+250)

   - Write $86 to CTRL_REG1($13) to Start Offset Compensation (ZR_cond=1) + Active+ ODR=100Hz

   - Read CTRL_REG1 repeatedly until it indicates Offset Compensation has finished

   So this inits the Gyro such that a main micro can poll the device to retrieve Gyro data (say ever 15ms).

John

0 Kudos