在同一条i2c总线轮询使用两个vl53l1x出现只有一个有反应的问题
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-02-06 12:58 AM
这是我的代码,我之前以前改地址成功了的,这里就开始测量数据
- Labels:
-
Time of flight
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-02-06 7:57 AM
I just spent 2 hours on the phone with a guy. And it was the I2C address, and he had the same symptoms as you.
- Choose I2C addresses that are EVEN numbers. The odd numbers are the read addresses. Default is 0x52. For his 3 sensors we chose 0x62, 0x72 and 0x82. (Although 0x54, 0x56 and 0x58 would work as well.)
- Put all sensor into reset.
- Bring out the first one, initialize it (this step waits until the sensor is booted), then change its address.
Then repeat for the other sensor.
Do NOT put them back into reset. Doing this will undo everything.
At this point you should be good to go.
And if you don't get a response from the other sensors, it's because they have been reset or their addresses are conflicting.
-john
If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-02-06 6:20 PM
你好,我想我知道是什么原因了!
我选择了0x62,0x64的地址,并且也是按照你说的步骤进行改地址操作的,并且也是成功的,但是现在在运行获取数据的时候,只有位于后面改地址的传感器有反应,并且我还参考了st官网上的使用9个2d lidar例程。
经过后面测试我发现是初始化i2c的原因,他覆盖了之前初始化的i2c端口。
但是我也有个问题,难道每次轮询不同地址的lidar都要再去进行初始化i2c端口吗?你有办法可以优化吗?还是可以有其他的解法?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-02-06 6:30 PM
并且我还有一个问题就是,每次轮询不同地址的Lidar都要初始化i2c端口,这样做会太频繁更改了,程序也会崩溃的
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-02-10 8:05 AM
After getting each sensor on a different address, you do NOT have to change anything. Don't re-initialize the sensors or the I2C bus. The sensors will be just fine.
Simply change the 'dev' address in the first argument to the address of the sensor you want to control.
That should be enough.
(Please consider translating your text to English before you post it. Makes it easier on the rest of the community. Otherwise, you will only get Chinese speakers and I to respond.)
If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-02-10 7:46 PM
Thanks for the reminder.
I think my problem has not been solved yet. The I2C bus initialized at the beginning is at address 0X29. If it is not initialized and updated to the new device address later, the program will not be able to proceed.
Do you mean the 'dev' of the following function? I don't think it works. I always change i2c_Addr. Before modifying the device address, it is 0x29. After modifying it, I initialize and change i2c_Addr to the new device address (0x31, 0x32) for communication.
You can see that the red circle in my code is used to change the new i2c port for communication.
