Quantcast
Channel: EngineerZone : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 51060

Interfacing ADXL375 problem

$
0
0

I have interfaced ADXL375 & I have some below. I have attached the code.

 

 

1. The offset I am getting is huge.

It is 1g approx on both x & y axis & 1.5g on z-axis.

I don't know what could be problem. I read offset registers , they are all zero in ADXL375.

I had read thread on Analog forum, someone gad same problem with offset +4G on z axis.

He had removed the IC & resoldered new one & problem gone.

But I wan't to know what could be exact reason?

 

 

2. For ODR <= 800Hz, we multiply register value with 49 to get g value i.e:

g = (register_value * 49)

 

 

But when OCR = 1600 or 3200Hz, what is the factor.

I had red in datasheet that in this case LSB is always zero. So what will be coversion factor or it will remain same = 49.

 

 

 

 

3. I had calibrated the adxl375 by placing it in z = +1g & other axis = 0.

But I have seen example in which calibrate in all six axis is done:

https://learn.adafruit.com/adxl345-digital-accelerometer/programming

 

 

But how to calculate final offset from these six offset values?

Or should I take there average.

 

 

4. Edit: I have been able to read DEV id properly & SPi speed is 3.75Mhz.

 

[CODE]

#define ADXL_REG_DEV_ID          (0x00)

#define ADXL_VAL_DEV_ID          (0xe5)

#define ADXL_REG_PW_CTRL         (0x2d)

#define ADXL_REG_INT_EN          (0x2e)

#define ADXL_REG_INT_MAP          (0x2f)

#define ADXL_REG_DATA_FM         (0x31)

#define ADXL_REG_DATA_RATE       (0x2c)

#define ADXL_REG_DATAX0          (0x32)

 

 

 

 

void main(void)

{

    configure_adxl375();

 

 

    while(1)

    {

        //take 100 samples & average

        adxl_read_offset_values(&x_val , &y_val ,&z_val);

        x_val *= 49;

        y_val *= 49;

        z_val *= 49;

   

        //offset for x:1274 , y: 1225 , z:1597

    }

 

 

}

 

 

 

 

 

 

void adxl_read_g_values(int16_t *x_val , int16_t *y_val , int16_t *z_val)

{

    uint8_t values[6];

    uint32_t error

 

 

    adxl_read_reister(ADXL_REG_DATAX0 , 6U , &values[0]);

 

 

    *x_val = (s16_t)( ((u16_t)values[1] << 8U) | ((u16_t)values[0]) ) ;

    *y_val = (s16_t)( ((u16_t)values[3] << 8U) | ((u16_t)values[2]) ) ;

    *z_val = (s16_t)( ((u16_t)values[5] << 8U) | ((u16_t)values[4]) ) ;    

}

 

 

 

 

 

 

void configure_adxl375(void)

{

    uint8_t data;

 

 

    SPI_MODE(3);

 

 

    data = adxl_read(ADXL_REG_DEV_ID);

    if(0xe5 != data)

    {

        error_trap();

    }

 

 

/* power ctrl */

    adxl_write(ADXL_REG_PW_CTRL , 0x00);

    adxl_write_register(ADXL_REG_DATA_FM , 0x0bU);

    adxl_write_register(ADXL_REG_DATA_RATE , 0x0dU);

    adxl_write_register(ADXL_REG_PW_CTRL , 0x08U);

 

 

}

 

 

 

 

 

 

void adxl_write_register(uint8_t address , uint8_t value)

{

    ADXL_CS_ENABLE();

 

 

    adxl_spi_byte(address);

    adxl_spi_byte(value);

    ADXL_CS_DISABLE();

 

 

}

 

 

 

 

 

 

 

 

void adxl_read_reister(uint8_t address , uint32_t no_bytes , uint8_t *values)

{

    uint32_t cnt;

    uint8_t reg_add = 0x80U | address;      /* msb is high fro reading */

   

    if(no_bytes > 1U)   /* for multi read bit 6 is also set */

    {

        reg_add = reg_add | 0x40U;

    }

 

 

    ADXL_CS_ENABLE();

 

 

/* send address */

    adxl_spi_byte(reg_add);

 

 

 

 

/* sent bytes */    

    for(cnt = 0U ; (cnt< no_bytes) ; cnt++ )

    {

        values[cnt] = adxl_spi_byte(0xffU);

    }

 

 

    ADXL_CS_DISABLE();

 

 

}

[/CODE]


Viewing all articles
Browse latest Browse all 51060

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>