完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,
我在使用LSM9DS1 FIFO时遇到了一些问题...... 我的目标是在不丢失样品的情况下不断获取陀螺仪和加速数据。 (磁力计关闭) 这就是我做的: - 我将水印阈值设置为21个样本(IMU_FIFO_samples = 21 (IMU_FIFO_samples = FlashBuffer_Initialize(IMU_6);) - 我将中断配置为发送到引脚INT1_A / G. (LSM9DS1_configInt(XG_INT1,INT_FTH,INT_ACTIVE_HIGH,INT_PUSH_PULL);) - 我在旁路模式下配置FIFO(LSM9DS1_setFIFO(FIFO_OFF,IMU_FIFO_samples);) - - 为了开始数据采集,我在连续模式下配置FIFO(LSM9DS1_setFIFO(FIFO_CONT,IMU_FIFO_samples);) (我确实尝试将IMU_SAMPLE_RATE设置为14Hz和900 + Hz,但结果是一样的) void IMU_Initialize(void) { uint16_t tst; IMU_FIFO_samples = FlashBuffer_Initialize(IMU_6); LSM9DS1_LSM9DS1(IMU_MODE_SPI,XGADDR,MADDR); settings.accel.sampleRate = IMU_SAMPLE_RATE; settings.gyro.sampleRate = IMU_SAMPLE_RATE; settings.mag.operatingMode = 0x03; //已禁用 tst = LSM9DS1_begin(); LSM9DS1_enableBLE(真); //大小印第安人 LSM9DS1_enableBDU(真); //阻止数据更新 LSM9DS1_configInt(XG_INT1,INT_FTH,INT_ACTIVE_HIGH,INT_PUSH_PULL); // LSM9DS1_setFIFO(FIFO_CONT,IMU_FIFO_samples); LSM9DS1_enableFIFO(真); __delay_ms(50); LSM9DS1_setFIFO(FIFO_OFF,IMU_FIFO_samples); } uint8_t Acquisition_Start(void) { EX_INT2_InterruptFlagClear(); EX_INT2_InterruptEnable(); LSM9DS1_setFIFO(FIFO_CONT,IMU_FIFO_samples); 返回BT_OK; } 生成中断时,将调用以下ISR void Data_Acquisition_IMU(void) { ... //从IMU读取数据 // n5 = LSM9DS1_getFIFOSamples(); // n4 = LSM9DS1_getFIFOSamples(); // n3 = LSM9DS1_getFIFOSamples(); n = LSM9DS1_getFIFOSamples(); LSM9DS1_readAccelGyro_nAll(& FlashBufferIMU [ptr],IMU_FIFO_samples); n1 = LSM9DS1_getFIFOSamples(); if(n1> 31) { LSM9DS1_setFIFO(FIFO_OFF,IMU_FIFO_samples); n3 = IMU_INT1_AG_GetValue(); n2 = LSM9DS1_getFIFOSamples(); EX_INT2_InterruptFlagClear(); n4 = LSM9DS1_getFIFOSamples(); LSM9DS1_setFIFO(FIFO_CONT,IMU_FIFO_samples); } ... } ++++问题++++ 偶尔(经常但不总是)从FIFO读取的数据块是错误的(参见附图) LSM9DS1_readAccelGyro_nAll(& FlashBufferIMU [ptr],IMU_FIFO_samples); void LSM9DS1_readAccelGyro_nAll(uint8_t * data,uint8_t n) { LSM9DS1_xgReadBytes(OUT_X_L_G,data,12 * n); } 我从FIFO中读取了12 * 21 = 252字节的块,有时数据看起来不对(参见附图) 数据应始终为0但对于az。 为了调试程序,我一直在读取调用ISR时FIFO中可用的数据样本数。 //从IMU读取数据 // n5 = LSM9DS1_getFIFOSamples(); // n4 = LSM9DS1_getFIFOSamples(); // n3 = LSM9DS1_getFIFOSamples(); n = LSM9DS1_getFIFOSamples(); 读n5,n4,n3和n我读取不一致的值 uint8_t LSM9DS1_getFIFOSamples(void) { return(LSM9DS1_xgReadByte(FIFO_SRC)& 0x3F); } 有时n5 = 0(即使在FIFO中应该调用ISR时应该有21个样本)并且在我读取n4 = 21(预期值)之后立即调用 - >为什么我读n5 = 0 ??? 有时n5 = 21但是我得到n4 = 0x3F - >报告的FIFO中的样本数量突然变化了? 有时n5 = n4 = n3 = n = 21并且我读取FIFO数据 LSM9DS1_readAccelGyro_nAll(& FlashBufferIMU [ptr],IMU_FIFO_samples); 有时当我读取FIFO中的剩余样本时,而不是读取0,或者最多只读取一小部分,我得到0x3F 一旦我得到0x3F,为了在FIFO中读取有意义的数字样本,重置FIFO设置FIFO_OFF并通过设置FIFO_CONT重新启用它 有关如何解决它的任何线索? 谢谢 #fifo#lsm9ds1 以上来自于谷歌翻译 以下为原文 Hi, I'm having some problem using the LSM9DS1 FIFO... My objective is to continuously acquire, without loosing samples, the Gyro and Accelleration data. (The magnetometer is turned off) This is what I do: - I set the watermark threshold to 21 samples (IMU_FIFO_samples = 21 (IMU_FIFO_samples = FlashBuffer_Initialize(IMU_6);) - I configure the interrupt to be sent to pin INT1_A/G (LSM9DS1_configInt(XG_INT1, INT_FTH, INT_ACTIVE_HIGH, INT_PUSH_PULL);) - I configure the FIFO in Bypass Mode (LSM9DS1_setFIFO(FIFO_OFF, IMU_FIFO_samples);) - - In order to start the data acquisition I configure the FIFO in Continous Mode (LSM9DS1_setFIFO(FIFO_CONT, IMU_FIFO_samples);) (I did try to set the IMU_SAMPLE_RATE to 14Hz and 900+Hz but the results are the same) void IMU_Initialize(void) { uint16_t tst; IMU_FIFO_samples = FlashBuffer_Initialize(IMU_6); LSM9DS1_LSM9DS1(IMU_MODE_SPI, XGADDR, MADDR); settings.accel.sampleRate = IMU_SAMPLE_RATE; settings.gyro.sampleRate = IMU_SAMPLE_RATE; settings.mag.operatingMode = 0x03; // Disabled tst = LSM9DS1_begin(); LSM9DS1_enableBLE(true); // Big Little Indian LSM9DS1_enableBDU(true); // Block Data Update LSM9DS1_configInt(XG_INT1, INT_FTH, INT_ACTIVE_HIGH, INT_PUSH_PULL); //LSM9DS1_setFIFO(FIFO_CONT, IMU_FIFO_samples); LSM9DS1_enableFIFO(true); __delay_ms(50); LSM9DS1_setFIFO(FIFO_OFF, IMU_FIFO_samples); } uint8_t Acquisition_Start(void) { EX_INT2_InterruptFlagClear(); EX_INT2_InterruptEnable(); LSM9DS1_setFIFO(FIFO_CONT, IMU_FIFO_samples); return BT_OK; } When the Interrupt is generated the following ISR is called void Data_Acquisition_IMU(void) { ... // Read Data From IMU //n5 = LSM9DS1_getFIFOSamples(); //n4 = LSM9DS1_getFIFOSamples(); //n3 = LSM9DS1_getFIFOSamples(); n = LSM9DS1_getFIFOSamples(); LSM9DS1_readAccelGyro_nAll(&FlashBufferIMU[ptr], IMU_FIFO_samples); n1 = LSM9DS1_getFIFOSamples(); if(n1 > 31) { LSM9DS1_setFIFO(FIFO_OFF, IMU_FIFO_samples); n3 = IMU_INT1_AG_GetValue(); n2 = LSM9DS1_getFIFOSamples(); EX_INT2_InterruptFlagClear(); n4 = LSM9DS1_getFIFOSamples(); LSM9DS1_setFIFO(FIFO_CONT, IMU_FIFO_samples); } ... } ++++ PROBLEMS ++++ Once in a while (quite often but not always) the block of data read from the FIFO is wrong (See attached picture) LSM9DS1_readAccelGyro_nAll(&FlashBufferIMU[ptr], IMU_FIFO_samples); void LSM9DS1_readAccelGyro_nAll(uint8_t *data, uint8_t n) { LSM9DS1_xgReadBytes(OUT_X_L_G, data, 12*n); } I read 12*21 = 252 bytes blocks from the FIFO and sometime the data look wrong (see attached picture) The data should be always 0 but for az. In order to debug the program I have been reading the number of data samples available in the FIFO when the ISR is called. // Read Data From IMU //n5 = LSM9DS1_getFIFOSamples(); //n4 = LSM9DS1_getFIFOSamples(); //n3 = LSM9DS1_getFIFOSamples(); n = LSM9DS1_getFIFOSamples(); Reading n5, n4, n3 and n I read inconsistent values uint8_t LSM9DS1_getFIFOSamples(void) { return (LSM9DS1_xgReadByte(FIFO_SRC) & 0x3F); } Sometime n5 = 0 (even if the ISR should be called when in the FIFO there should be 21 samples) and immediately after I read n4 = 21 (the expected value) --> WHY I READ n5 = 0 ??? Sometime n5 = 21 but then I get n4 = 0x3F --> The reported number of samples in the FIFO changes abruptly ??? Sometime n5 = n4 = n3 = n = 21 and I read the FIFO data LSM9DS1_readAccelGyro_nAll(&FlashBufferIMU[ptr], IMU_FIFO_samples); Sometime when I read the remaining samples in the FIFO, instead of reading 0, or at most a small number, I get 0x3F Once I get 0x3F, in order to read meaningful number samples in the FIFO is to reset the FIFO setting the FIFO_OFF and the re-enabling it by setting FIFO_CONT Any clue on how to fix it? Thank you #fifo #lsm9ds1 |
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2632 浏览 1 评论
3208 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1783 浏览 1 评论
3607 浏览 6 评论
5987 浏览 21 评论
939浏览 4评论
1315浏览 4评论
在Linux上安装Atollic TRUEStudio的步骤有哪些呢?
582浏览 3评论
使用DMA激活某些外设会以导致外设无法工作的方式生成代码是怎么回事
1302浏览 3评论
1357浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 05:56 , Processed in 1.144583 second(s), Total 77, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号