2018-05-14 06:01 AM
Hi There,
I am using the STM Accelerometer(LIS2DE12) with STM(stm32l432kb) controller. While getting the readings from the Accelerometer it gives the random value continuously. Even it shows false value at steady position.Here some how I am facing problem and need some idea and suggestion to solve this issue. If some one has the document , relevant data and sample code for it please let me know and help me.
Thanks
2018-05-14 07:56 AM
Are you able successfully to read the WHO_AM_I register?
2018-05-15 04:33 AM
Yes Miroslav B, I am getting 0x33 after reading the WHO_AM_I register....
2018-05-15 03:10 PM
OK, good.
So please share your sensor configuration, and the data which you read.
2018-05-16 12:08 AM
OK ... Sure
Codes// For Writing , ACC_ADDMW = 0x32
Used to configure the Registers tx_data = 0x0F; // CTRL_REG1 register(0x20) with value 0x0Fresult = HAL_I2C_Mem_Write(&hi2c3, ACC_ADDMW, 0x20, I2C_MEMADD_SIZE_8BIT, &tx_data, 1, 1000);tx_data = 0x00; // CTRL_REG5 register(0x24) with value 0x00result = HAL_I2C_Mem_Write(&hi2c3, ACC_ADDMW, 0x24, I2C_MEMADD_SIZE_8BIT, &tx_data, 1, 1000);tx_data = 0x00; // FIFO_CTRL_REG(0x2E) with value 0x00result = HAL_I2C_Mem_Write(&hi2c3, ACC_ADDMW, 0x2E, I2C_MEMADD_SIZE_8BIT, &tx_data, 1, 1000);// For reading , ACC_ADDMR = 0x33
Used for Who Am I ....HAL_I2C_Mem_Read(&hi2c3, ACC_ADDMR, 0x0F, I2C_MEMADD_SIZE_8BIT, &read_mem, 1, 1000);Used to Read the register 0x28
HAL_I2C_Mem_Read(&hi2c3, ACC_ADDMR, 0x28, I2C_MEMADD_SIZE_8BIT, (uint8_t *)&read_mem, 2, 1000);Used to Read the X-Axies
HAL_I2C_Mem_Read(&hi2c3, ACC_ADDMR, 0x29, I2C_MEMADD_SIZE_8BIT, (uint8_t *)&read_mem_x, 2, 1000);Used to Read the Y-Axies
HAL_I2C_Mem_Read(&hi2c3, ACC_ADDMR, 0x2B, I2C_MEMADD_SIZE_8BIT, (uint8_t *)&read_mem_y, 2, 1000);Used to Read the Z-axies
HAL_I2C_Mem_Read(&hi2c3, ACC_ADDMR, 0x2D, I2C_MEMADD_SIZE_8BIT, (uint8_t *)&read_mem_z, 2, 1000);2018-05-16 12:25 AM
Hi Miroslav,
i think im having the same issue with LIS2DH12:
config:
{0x20, 0x27}; //10Hz Normal
{0x22, 0x10}; //interrupt on 1 if data ready
{0x23, 0x00}; //default
{0x24, 0x00}; //no fifo
{0x2E, 0x00}; //no fifo
{0x1E, 0x90}; //disable pullup
reading xyz registry with auto-increment (0x80 | 0x28) on interrupt. values are stored in m_sample array.
expecting values to be returned in the same order as registry (X_L, X_H, Y_L, Y_H, etc)
it seems the values are ordered ok but shifting as in circular buffer.
As you can see below the first value is last on the second RX event, then second on the third event etc.
i am not sure which is x, y or z....
(m_sample[0] |(m_sample[1] << 8),
(m_sample[2] |(m_sample[3] << 8), (m_sample[4] |(m_sample[5] << 8)
<info> app: data ready
<info> app: RX event done 61568, 64000, 16256 <info> app: data ready<info> app: RX event done 64000, 16384, 61824 <info> app: data ready<info> app: RX event done 16256, 61760, 64064 <info> app: data ready<info> app: RX event done 61760, 64064, 16320<info> app: data ready<info> app: RX event done 64064, 16384, 61760 <info> app: data ready<info> app: RX event done 16192, 61632, 638722018-05-16 02:04 AM
Hi
Batek.Miroslav
,It will be great of yours if you can share me the details for control register(with its configuration in FIFO and WITHOUT FIFO mode) for running program.
2018-05-21 06:13 AM
Hi
Batek.Miroslav
I getting the output now i have configure the register with below details:-
(Reg_Add,Loaded_value)
(0x1E, 0x10) // CTRL_REG0 register
(0x20,0x9F) // CTRL_REG1 register
(0x23, 0x00)// CTRL_REG4 register (0x24, 0x00) // CTRL_REG5 register(0x2E, 0x00) // FIFO_CTRL_REG register
while (1)
{ MemAdd = 0x29; // 0x29 address for the X-Axis HAL_I2C_Mem_Read(&hi2c3, ACC_ADDRMR, MemAdd, I2C_MEMADD_SIZE_8BIT, (uint8_t *)&rx_data_x, 1, 1000);MemAdd = 0x2B; // 0x2B address for the Y-Axis
HAL_I2C_Mem_Read(&hi2c3, ACC_ADDRMR, MemAdd, I2C_MEMADD_SIZE_8BIT, (uint8_t *)&rx_data_y, 1, 1000);MemAdd = 0x2D; // 0x2D address for the Z-Axis
HAL_I2C_Mem_Read(&hi2c3, ACC_ADDRMR, MemAdd, I2C_MEMADD_SIZE_8BIT, (uint8_t *)&rx_data_z, 1, 1000);HAL_Delay(100);
}In the output i am getting the value but it not showing the constant value. It shows 0, 255, 254 at steady position in X and Y-Axis. In Z-Axis it shows 64(or 63,62) constantly. But yes when we move it, it shows the change value as per the movement.
So here I am little bit confused for my output that it is okay or not.
Is it so? or am I wrong?
All correction will be helpful and welcome.
Best regards.
Sachin
2018-05-22 12:00 PM
Your measurement is correct.
To get the acceleration value in g unit, you have to firts convert the raw data into signed value and then multiply it by sensitivity defined in datasheet.
So in your case for X, Y axis: 0 ... 0g, 255 ... -16mg, 254 ... -32 mg (basicaly noise). for Z axis 64 ... 1024 mg (gravity).
2018-05-23 07:34 AM
Hi
Batek.Miroslav
,For sure, that's all I need! ...
All the answers are really useful.
Many Thanks for your kind response.
I am trying to get speed(velocity) using
Accelerometer(LIS2DE12) this for my hobbyist project. I have searched a lotfor that, it would be great if you can give a suggestion from your experience.
Thanks &Regards
Sachin