cancel
Showing results for 
Search instead for 
Did you mean: 

Do these IIS2DLPC XYZ output values look correct?

DDuga.641
Associate

Hello,

I apologize in advance for my long post, and ignorance when it comes to interpreting this linear accelerometer data. The only one I have used in the past gave me euler angles, and I had no problem calculating tilt from them.

I am trying to periodically poll the IIS2DLPC for X Y and Z values, and then convert them to a tilt value. The evaluation board is just sitting on my desk not moving, so I thought that the values shouldn't be changing (at least not changing much), but every reading is different.

I did some googling, and I see that linear accelerometers usually output euler angles or quaternions. I assumed the X Y and Z values were euler angles, but regardless of the unit of measurement, I still can't figure out why the values are changing every time I read them when the sensor is not moving at all.

Could someone give me a little guidance on parsing the X Y and Z data output registers?

Here are my register definitions:

//Registers 
//#define TILT_RESERVED           0x1FU // - RESERVED
#define TILT_OUT_T_L             0x0DU //R  00001101 00000000 Temp sensor output
#define TILT_OUT_T_H             0x0EU //R 00001110 00000000
#define TILT_WHO_AM_I            0x0FU //R 00001111 01000100 Who am I ID
#define TILT_CTRL1               0x20U //R/W 00100000 00000000
#define TILT_CTRL2               0x21U //R/W 00100001 00000100
#define TILT_CTRL3               0x22U //R/W 00100010 00000000
#define TILT_CTRL4_INT1_PAD_CTRL 0x23U //R/W 00100011 00000000
#define TILT_CTRL5_INT2_PAD_CTRL 0x24U //R/W 00100100 00000000
#define TILT_CTRL6               0x25U //R/W 00100101 00000000
#define TILT_OUT_T               0x26U //R 00100110 00000000 Temp sensor output
#define TILT_STATUS              0x27U //R 00100111 00000000 Status data register
#define TILT_OUT_X_L             0x28U //R 00101000 00000000
#define TILT_OUT_X_H             0x29U //R 00101001 00000000
#define TILT_OUT_Y_L             0x2AU //R 00101010 00000000
#define TILT_OUT_Y_H             0x2BU //R 00101011 00000000
#define TILT_OUT_Z_L             0x2CU //R 00101100 00000000
#define TILT_OUT_Z_H             0x2DU //R 00101101 00000000
#define TILT_FIFO_CTRL           0x2EU //R/W 00101110 00000000 FIFO control register
#define TILT_FIFO_SAMPLES        0x2FU //R 00101111 00000000 Unread samples
#define TILT_TAP_THS_X           0x30U //R/W 00110000 00000000
#define TILT_TAP_THS_Y           0x31U //R/W 00110001 00000000 Tap thresholds
#define TILT_TAP_THS_Z           0x32U //R/W 00110010 00000000
#define TILT_INT_DUR             0x33U //R/W 00110011 00000000 Interrupt duration
#define TILT_WAKE_UP_THS         0x34U //R/W 00110100 00000000
#define TILT_WAKE_UP_DUR         0x35U //R/W 00110101 00000000 Wakeup duration
#define TILT_FREE_FALL           0x36 //R/W 00110110 00000000 Free-fall configuration
#define TILT_STATUS_DUP          0x37 //R 00110111 00000000 Status register
#define TILT_WAKE_UP_SRC         0x38 //R 00111000 00000000 Wakeup source
#define TILT_TAP_SRC             0x39 //R 00111001 00000000 Tap source
#define TILT_SIXD_SRC            0x3A //R 00111010 00000000 6D source
#define TILT_ALL_INT_SRC         0x3B //R 00111011 00000000
#define TILT_X_OFS_USR           0x3C //R/W 00111100 00000000
#define TILT_Y_OFS_USR           0x3D //R/W 00111110 00000000
#define TILT_Z_OFS_USR           0x3E //R/W 00000100 00000000
#define TILT_CTRL7               0x3F //R/W 00000100 00000000

Here is where I am storing the values:

typedef struct iis2dlpc
{
    uint8_t Temperature_Low_Byte_12bit;     //TILT_OUT_T_L            
    uint8_t Temperature_High_Byte_12bit;    //TILT_OUT_T_H            
    uint8_t Who_Am_I;                       //TILT_WHO_AM_I                    
    uint8_t Control_Register_1;             //TILT_CTRL1              
    uint8_t Control_Register_2;             //TILT_CTRL2              
    uint8_t Control_Register_3;             //TILT_CTRL3              
    uint8_t Control_Register_4;             //TILT_CTRL4_INT1_PAD_CTRL
    uint8_t Control_Register_5;             //TILT_CTRL5_INT2_PAD_CTRL
    uint8_t Control_Register_6;             //TILT_CTRL6              
    uint8_t Temperature_8bit;               //TILT_OUT_T              
    uint8_t Status;                         //TILT_STATUS             
    uint8_t X_Axis_Low_Byte;                //TILT_OUT_X_L            
    uint8_t X_Axis_High_Byte;               //TILT_OUT_X_H            
    uint8_t Y_Axis_Low_Byte;                //TILT_OUT_Y_L            
    uint8_t Y_Axis_High_Byte;               //TILT_OUT_Y_H            
    uint8_t Z_Axis_Low_Byte;                //TILT_OUT_Z_L            
    uint8_t Z_Axis_High_Byte;               //TILT_OUT_Z_H            
    uint8_t Fifo_Control;                   //TILT_FIFO_CTRL          
    uint8_t Fifo_Samples;                   //TILT_FIFO_SAMPLES       
    uint8_t Tap_Threshold_X;                //TILT_TAP_THS_X          
    uint8_t Tap_Threshold_Y;                //TILT_TAP_THS_Y          
    uint8_t Tap_Threshold_Z;                //TILT_TAP_THS_Z          
    uint8_t Interrupt_Duration;             //TILT_INT_DUR            
    uint8_t Wakeup_Threshold;               //TILT_WAKE_UP_THS        
    uint8_t Wakeup_Duration;                //TILT_WAKE_UP_DUR    
    uint8_t Tilt_Free_Fall;                 //TILT_FREE_FALL          
    uint8_t Event_Detection_Status;         //TILT_STATUS_DUP         
    uint8_t Wakeup_Source;                  //TILT_WAKE_UP_SRC        
    uint8_t Tap_Event_Source;               //TILT_TAP_SRC            
    uint8_t SixD_Src;                       //TILT_SIXD_SRC           
    uint8_t All_Interrupt_Src;              //TILT_ALL_INT_SRC        
    uint8_t X_User_Offset;                  //TILT_X_OFS_USR          
    uint8_t Y_User_Offset;                  //TILT_Y_OFS_USR          
    uint8_t Z_User_Offset;                  //TILT_Z_OFS_USR          
    uint8_t Control_Register_7;             //TILT_CTRL7                           
}IIS2DLPC_REGISTERS;

When I run a function that reads and prints each register, I get what I expect in the registers that I have written to, and the "WHO_AM_I" register, but the X Y and Z data is different every time I call my function "read and print every register" function.

If you look at the attached image, this is me calling this function twice with a few seconds between each call. Notice the temperature and XYZ data changing. I am printing the HEX and binary representation of each value (sorry for the lack of labels).

0690X00000ArN42QAF.jpg

0 REPLIES 0