完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
我正在使用带有STM(STM32l432kb)控制器的STM加速度计(LIS2DE12)。 从加速度计获取读数时,它会持续提供随机值。即使它在稳定的位置显示虚假价值。在某些方面我是如何面对问题的,并且需要一些想法和建议来解决这个问题。如果有人拥有该文件,相关数据和示例代码,请告诉我并帮助我。 谢谢 以上来自于谷歌翻译 以下为原文 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 |
|
相关推荐
11个回答
|
|
您是否能够成功阅读WHO_AM_I注册?
以上来自于谷歌翻译 以下为原文 Are you able successfully to read the WHO_AM_I register? |
|
|
|
是Miroslav B,我在阅读WHO_AM_I注册后得到0x33 ....
以上来自于谷歌翻译 以下为原文 Yes Miroslav B, I am getting 0x33 after reading the WHO_AM_I register.... |
|
|
|
好的,好的。
因此,请分享您的传感器配置以及您阅读的数据。 以上来自于谷歌翻译 以下为原文 OK, good. So please share your sensor configuration, and the data which you read. |
|
|
|
可以,当然
代码//用于写入,ACC_ADDMW = 0x32 用于配置寄存器 tx_data = 0x0F; // CTRL_REG1寄存器(0x20)的值为0x0F result = HAL_I2C_Mem_Write(& hi2c3,ACC_ADDMW,0x20,I2C_MEMADD_SIZE_8BIT,& tx_data,1,1000); tx_data = 0x00; // CTRL_REG5寄存器(0x24),值为0x00 result = HAL_I2C_Mem_Write(& hi2c3,ACC_ADDMW,0x24,I2C_MEMADD_SIZE_8BIT,& tx_data,1,1000); tx_data = 0x00; // FIFO_CTRL_REG(0x2E),值为0x00 result = HAL_I2C_Mem_Write(& hi2c3,ACC_ADDMW,0x2E,I2C_MEMADD_SIZE_8BIT,& tx_data,1,1000); //对于读取,ACC_ADDMR = 0x33 用于我是谁.... HAL_I2C_Mem_Read(& hi2c3,ACC_ADDMR,0x0F,I2C_MEMADD_SIZE_8BIT,& read_mem,1,1000);用于读取寄存器0x28 HAL_I2C_Mem_Read(& hi2c3,ACC_ADDMR,0x28,I2C_MEMADD_SIZE_8BIT,(uint8_t *)& read_mem,2,1000);用于读取X轴 HAL_I2C_Mem_Read(& hi2c3,ACC_ADDMR,0x29,I2C_MEMADD_SIZE_8BIT,(uint8_t *)& read_mem_x,2,1000);用于读取Y轴 HAL_I2C_Mem_Read(& hi2c3,ACC_ADDMR,0x2B,I2C_MEMADD_SIZE_8BIT,(uint8_t *)& read_mem_y,2,1000);用于读取Z轴 HAL_I2C_Mem_Read(& hi2c3,ACC_ADDMR,0x2D,I2C_MEMADD_SIZE_8BIT,(uint8_t *)& read_mem_z,2,1000); 以上来自于谷歌翻译 以下为原文 OK ... Sure Codes// For Writing , ACC_ADDMW = 0x32 Used to configure the Registers tx_data = 0x0F; // CTRL_REG1 register(0x20) with value 0x0F result = 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 0x00 result = 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 0x00 result = 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); |
|
|
|
你好Miroslav,
我认为即时通讯与LIS2DH12有同样的问题: 配置: {0x20,0x27}; // 10Hz正常 {0x22,0x10}; //如果数据就绪,则中断1 {0x23,0x00}; //默认 {0x24,0x00}; //没有 {0x2E,0x00}; //没有 {0x1E,0x90}; //禁用pullup 在中断时使用自动递增(0x80 | 0x28)读取xyz注册表。值存储在m_sample数组中。 期望值以与注册表(X_L,X_H,Y_L,Y_H等)相同的顺序返回 似乎值被排序好,但在循环缓冲区中移动。 如下所示,第一个值是第二个RX事件的最后一个,然后是第三个事件的第二个等。 我不确定哪个是x,y或z .... (m_sample [0] |(m_sample [1]&lt;&lt; 8), (m_sample [2] |(m_sample [3]&lt;&lt; 8),(m_sample [4] |(m_sample [5]&lt;&lt; 8) &LT;信息&gt; app:数据就绪 &LT;信息&gt; app:RX事件完成61568,64000,16256 &LT;信息&gt; app:数据就绪 &LT;信息&gt; app:RX事件完成64000,16384,61824 &LT;信息&gt; app:数据就绪 &LT;信息&gt; app:RX事件完成16256,61760,64064 &LT;信息&gt; app:数据就绪 &LT;信息&gt; app:RX事件完成61760,64064,16320 &LT;信息&gt; app:数据就绪 &LT;信息&gt; app:RX事件完成64064,16384,61760 &LT;信息&gt; app:数据就绪 &LT;信息&gt; app:RX事件完成16192,61632,63872 以上来自于谷歌翻译 以下为原文 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) |
|
|
|
你好
Batek.Miroslav 我现在得到输出我已经配置了以下详细信息的寄存器: - (Reg_Add,Loaded_value) (0x1E,0x10)// CTRL_REG0寄存器 (0x20,0x9F)// CTRL_REG1寄存器 (0x23,0x00)// CTRL_REG4寄存器 (0x24,0x00)// CTRL_REG5寄存器(0x2E,0x00)// FIFO_CTRL_REG寄存器 而(1) { MemAdd = 0x29; // X轴的0x29地址 HAL_I2C_Mem_Read(&amp; hi2c3,ACC_ADDRMR,MemAdd,I2C_MEMADD_SIZE_8BIT,(uint8_t *)&amp; rx_data_x,1,1000); MemAdd = 0x2B; // Y轴的0x2B地址 HAL_I2C_Mem_Read(&amp; hi2c3,ACC_ADDRMR,MemAdd,I2C_MEMADD_SIZE_8BIT,(uint8_t *)&amp; rx_data_y,1,1000); MemAdd = 0x2D; // Z轴的0x2D地址 HAL_I2C_Mem_Read(&amp; hi2c3,ACC_ADDRMR,MemAdd,I2C_MEMADD_SIZE_8BIT,(uint8_t *)&amp; rx_data_z,1,1000); HAL_Delay(100); 在输出中我得到的值,但它没有显示常量值。它在X和Y轴的稳定位置显示0,255,254。在Z轴中,它不断显示64(或63,62)。但是,当我们移动它时,它会根据运动显示变化值。 所以在这里我对我的输出有点困惑,它是否可以。 是这样吗?还是我错了? 所有更正都将有所帮助和欢迎。 最好的祝福。 萨钦 注意:原始帖子包含大量线程对话,只能迁移到第9级 以上来自于谷歌翻译 以下为原文 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 Note: the original post contained a large number of threaded conversations and was only able to be migrated to the 9th level |
|
|
|
您的测量是正确的。
要获得以g为单位的加速度值,您必须先将原始数据转换为有符号值,然后将其乘以数据表中定义的灵敏度。 所以在X的情况下,Y轴:0 ... 0g,255 ... -16mg,254 ... -32 mg(基本噪音)。对于Z轴64 ... 1024 mg(重力)。 以上来自于谷歌翻译 以下为原文 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). |
|
|
|
你好
Batek.Miroslav ,当然,这就是我所需要的! ... 所有答案都非常有用。 非常感谢您的回复。 我正在尝试使用速度(速度) Accelerometer(LIS2DE12)这适合我的爱好者项目。我已经搜索了很多,如果你能从你的经验中给出一个建议,那将是很棒的。 谢谢&amp;问候 萨钦 注意:原始帖子包含大量线程对话,只能迁移到第9级 以上来自于谷歌翻译 以下为原文 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 lot for that, it would be great if you can give a suggestion from your experience. Thanks & Regards Sachin Note: the original post contained a large number of threaded conversations and was only able to be migrated to the 9th level |
|
|
|
速度是其中不可或缺的
https://en.wikipedia.org/wiki/Acceleration 所以你必须在离散域中整合加速度,例如:velocity = velocity + acceleration *(1.0f / data_rate_Hz); 加速度必须为m / s2,表示将加速度乘以9.81m / s2。 以上来自于谷歌翻译 以下为原文 Velocity is integral of the https://en.wikipedia.org/wiki/Acceleration so you have to integrate the acceleration in discrete domain, for example like this:velocity = velocity + acceleration * (1.0f / data_rate_Hz); The accleration must be in m/s2, it means multiply the acceleration in g by 9.81m/s2. |
|
|
|
你好
Batek.Miroslav ,,还有一个问题我需要从这些速度=速度+加速度*(1.0f / data_rate_Hz)公式中得出,我们可以测量速度的减小(减速度)。 注意:原始帖子包含大量线程对话,只能迁移到第9级 以上来自于谷歌翻译 以下为原文 Hi Batek.Miroslav ‌, One more question I need to ask that from these velocity = velocity + acceleration * (1.0f / data_rate_Hz) formula, we can measure the decrease in velocity(Deceleration). Note: the original post contained a large number of threaded conversations and was only able to be migrated to the 9th level |
|
|
|
你好
Batek.Miroslav ,,在制作和开发使用加速度计测量速度的代码时,根据您建议的等式 速度=速度+加速度*(1.0f / data_rate_Hz)公式,并且在输出侧,我得到速度的连续增量而不移动,即在稳定位置,加速度计。你能让我知道并指导我为什么我得到这个速度的结果。 如果你在代码里面有任何其他细节问我,我会告诉你细节 在这里,我将分享我的小基本示例代码供您参考: 加速度= ax; // ax是来自X轴的加速度,加速度乘以X(9.81)与X轴ACC相乘。 initial_velocity = velocity; //将先前的速度分配给初始速度..... v = u + at .... u = v ...在下一个数据之后 velocity =(initial_velocity +(acceleration *(0.005))); //这里我选择了ACC的数据速率(ODR)。在200Hz 如果计算中出现问题或任何错误,请更新我.... 提前致谢 ... 注意:原始帖子包含大量线程对话,只能迁移到第9级 以上来自于谷歌翻译 以下为原文 Hi Batek.Miroslav ‌, While making and developing the code to measure the velocity using accelerometer, as per your suggested equation velocity = velocity + acceleration * (1.0f / data_rate_Hz) formula, and at output side i am getting a continuous increment in velocity without moving, i.e at steady position, the accelerometer. Can you let me know and guide me for why i am getting this result of velocity. If you any other details of inside the code you ask me, I will let know the details Here I am sharing my small basic sample code for your reference: acceleration = ax; // ax is acceleration from the X-Axis and acceleration is Multiply by g(9.81) with X-Axis ACC. initial_velocity = velocity ; // assigning previous velocity to initial velocity ..... v = u +at .... u = v ... after next data velocity = (initial_velocity + (acceleration * (0.005))); // Here i have selected the Data rate(ODR) of ACC. at 200Hz Kindly update me if there is an issue or any error in calculation .... Thanks in Advance ... Note: the original post contained a large number of threaded conversations and was only able to be migrated to the 9th level |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2671 浏览 1 评论
3224 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1796 浏览 1 评论
3625 浏览 6 评论
6007 浏览 21 评论
953浏览 4评论
1324浏览 4评论
在Linux上安装Atollic TRUEStudio的步骤有哪些呢?
599浏览 3评论
使用DMA激活某些外设会以导致外设无法工作的方式生成代码是怎么回事
1317浏览 3评论
1376浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-4 02:40 , Processed in 1.342361 second(s), Total 102, Slave 84 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号