How to troubleshoot I2C bus sensor response problem?
- July 19, 2020
- 4 replies
- 1870 views
I have a project where I am attempting to use six ST Microelectronics VL53L0X Time-of-Flight (ToF) sensors grouped into two 3-element arrays for position/orientation sensing on an autonomous wall-following robot. I originally had both arrays installed on Wire1 of a Teensy 3.5, but discovered that only 4 of the 6 elements were reporting 'real' values. After screwing around for a while, I came to the conclusion that the integral 10K pullup resistors on each sensor (times 6) was too much for the I2C bus. So, I decided to move one of the two 3-element arrays to Wire2, so I would be driving three sets of 10K pullups on Wire1 and three sets of 10K pullups on Wire2.
Unfortunately, even with the arrays split over the two secondary I2C busses, I can't get all six sensors to operate properly. One array of three elements will report believable values, but one or more of the other array will not. For all the gory details, see my 'Paynters Palace' post on this subject.
I ran the program with all 6 sensors (3 on each Teensy auxiliary I2C bus), and as expected, the first two sensors report bogus results. Then I ran it again using the 'debug' option on the 'rangingTest()' function to see if I could understand a little more about what is happening. Here is a representative readout from the program:
Opening port
Port open
Teensy Triple VL53L0X V2
In Adafruit_VL53L0X::begin(2A,0,7D0)
In Adafruit_VL53L0X::begin(2B,1,7D0)
VL53L0X Info:
Device Name: VL53L0X ES1 or later, Type: VL53L0X, ID: VL53L0CBV0DH/1$1
Rev Major: 1, Minor: 1
VL53L0X: StaticInit
VL53L0X: PerformRefSpadManagement
refSpadCount = 7, isApertureSpads = 0
VL53L0X: PerformRefCalibration
VL53L0X: SetDeviceMode
In Adafruit_VL53L0X::begin(2C,1,7D0)
VL53L0X Info:
Device Name: VL53L0X ES1 or later, Type: VL53L0X, ID: VL53L0CBV0DH/1$1
Rev Major: 1, Minor: 1
VL53L0X: StaticInit
VL53L0X: PerformRefSpadManagement
refSpadCount = 5, isApertureSpads = 0
VL53L0X: PerformRefCalibration
VL53L0X: SetDeviceMode
In Adafruit_VL53L0X::begin(2D,1,6F8)
VL53L0X Info:
Device Name: VL53L0X ES1 or later, Type: VL53L0X, ID: VL53L0CBV0DH/1$1
Rev Major: 1, Minor: 1
VL53L0X: StaticInit
VL53L0X: PerformRefSpadManagement
refSpadCount = 4, isApertureSpads = 0
VL53L0X: PerformRefCalibration
VL53L0X: SetDeviceMode
In Adafruit_VL53L0X::begin(2E,0,6F8)
In Adafruit_VL53L0X::begin(2F,0,6F8)
Init complete
VL53L0X API Simple Ranging example
Msec Front Center Rear Steer
sVL53L0X: PerformSingleRangingMeasurement
Range Status: 146 : No Update
RANGE IGNORE THRESHOLD: 11.41
Measured distance: 8850
sVL53L0X: PerformSingleRangingMeasurement
Range Status: 0 : Range Valid
RANGE IGNORE THRESHOLD: 1.47
Measured distance: 65398
sVL53L0X: PerformSingleRangingMeasurement
Range Status: 2 : Signal Fail
RANGE IGNORE THRESHOLD: 5.84
Measured distance: 173
sVL53L0X: PerformSingleRangingMeasurement
Range Status: 2 : Signal Fail
RANGE IGNORE THRESHOLD: 0.52
Measured distance: 661
sVL53L0X: PerformSingleRangingMeasurement
Range Status: 2 : Signal Fail
RANGE IGNORE THRESHOLD: 0.63
Measured distance: 464
sVL53L0X: PerformSingleRangingMeasurement
Range Status: 2 : Signal Fail
RANGE IGNORE THRESHOLD: 0.46
Measured distance: 490
9495 1000 1000 173 661 464 490As can be seen, the first two sensors always return very large values (that get trimmed to 1000 by my code) so the first two values in each normal output line are always '1000' and '1000'. I have included my code for reference, but it is very simple. It just initializes all six sensors to consecutive I2C addresses and then calls 'rangingTest' on each one sequentially. After all six measurements, a line is printed out containing the number of milliseconds since program start, followed by each measurement value in the order taken.
I suspect there may be an issue with some interaction of the Wire1 & Wire2 auxiliary I2C busses on the Teensy 3.5 controller (and I have a separate post on their forum to explore this matter), but I was hoping there was something else I might be able to do to better understand exactly why the first two sensors are reporting bogus values. Any help would be appreciated.
I have attached a file containing the Teensy 3.5 sketch used to obtain the above printout (I had to change the file type from .ino to .txt)
Frank
