This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

accelerometer_result_error

Hello ,I wrote a program that allows to control the LIS2DE12 accelerometer but I am reviewing a fixed result which is always X = 72, Y = 33, Z = 32, I find out where the problem , thanks you in advance.

`int main(void)	
{
	int8_t X,Y,Z;
    
    uart_config();
    
    //accel_I2C_datawrite(&twi_instance);
    twi_init();
     m_device_address = accel_addr;
 
    uint8_t rx_buffer[6];
   rx_buffer[0] = 0x00;
//int threshold;
//accel_set_threshold(threshold);
    
        




            while(true)
        {
            accel_xyz_read(&X,&Y,&Z);
         printf("Groupeer accelero DATA2:  X: %d  Y: %d  Z: %d  \n", X ,Y,Z);
					nrf_delay_ms(1000);
        }      
    
}
`
Parents
  • Hello Amed

    From what I can see in the code you posted, you do not write anything to the LIS2DE12 chip (the accel_I2C_datawrite in main is commented out) until you try and read from it.

    So you never configure the chip on start-up.

    In your accel_I2C_datawrite function (which is currently commented out) you write to the CTRL_REG1 register, however it seems like you write all zeroes, 0x00. If you look at the description of CTRL_REG1 in the LIS2DE12 datasheet this will ensure the chip is in power-down mode, as well as disable all axis. It also states specifically in the LPen field that the field must be set to 1 for correct operation of the device.

    I would imagine you have to have the chip powered up and correctly configured, with the axis sensors enabled, for it to generate any sensible data.

    You state in your comment that you want an indication that there is movement without reading the axis, I recommend you look at the INT1_CFG and INT2_CFG register. There you can configure interrupts on movement detection for the different axis. This will generate a change in pin 11 and 12 of the LIS2DE12, which you can sense with a GPIO of the nRF chip.

    Best regards

    Jørn Frøysa

  • Could you please edit this comment and use the code functionality? the normal formatting of comments completely mess up the code. Just press edit on your comment, select all your code and press the button with the "101 010" in the toolbar above.

Reply
  • Could you please edit this comment and use the code functionality? the normal formatting of comments completely mess up the code. Just press edit on your comment, select all your code and press the button with the "101 010" in the toolbar above.

Children
No Data
Related