cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L4CD - Signal is below the defined threshold

DrD00m
Associate III

Hey,

I have a custom made board/device which is using 4x VL53L4CD Tof Sensors to measure the distance. I have trouble to calibrate the sensors correctly or get correct values from them from time to time. Sometimes it works well - sometimes it does not.
What I can see is, that for sensor where the distance is not accurate I am receiving the result status " Signal is below the defined threshold", as described in the datasheet.
What exactly does that mean and how can I fix that? What is causing this issue?

The signal threashold is set to 5000 and the sigma is set to be 10.

I noticed when I am running the offset and xtalk calibration - this issue can disappear but it takes multiple calibration iterrations and sometimes it does not fix the problem.

 

And as well: what exactly is a 17% reflective material!? (as mentioned in the datasheet to calibrate offset and xtalk)

27 REPLIES 27
John E KVAM
ST Employee

In order to get a range, the light must bounce off the target and have enough signal so we can measure the photon arrival times. We cannot measure the photon times directly. Light is too fast. So, we use a statical model. And that model takes a number of photon timings. 

Ideally, we want 20M photons per second. But as long as we get 0.5M photons per second we can give a pretty precise answer. Below the threshold you set, we will return an answer, but will set the status to 'low signal'. It's a warning to you.

We also have a Sigma value. This is a measure of precision. With a good signal we will return the distance +/- a sigma of a few mm. With a very low signal we will return a distance +/- a much larger sigma.

Setting the sigma tells the sensor what you want, and we will return a warning in the range status that we did not achieve that sigma.   

Want to get rid of the status error - Lower the signal and increase the sigma. The status error will go away, but you will have to do your own checking of the signal and sigma if you want to guarantee the range is of a good quality. 

17% reflective paper is a calibrated paper that returns 17% of the 940nm photons that hit it. 

White paper is about 88% reflective. Flat black paint sprayed on a cardboard sheet is 5% reflective. 

17% is a dark gray. Most colored paints are about 50%. You skin is somewhere between 40 and 60%.

Wool is 88% reflective, no matter what color you dye it. So reflectivity at 940nm is NOT easy to tell my looking at it.


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.

I actually found a very strange behavior on my board and I am afraid that this is layout related. 
Have you ever seen something like this:

DrD00m_0-1713978640168.png

I tested it on 3 different Board with no initial config setup, no threshold, no sigma. 
Pretty raw. I also tried different I2C Speeds (all of the sensors are on the same bus). 
This one sensor show very strange numbers, 1536 for example the most and not much variation. Any idea what could cause this? 

John E KVAM
ST Employee

This is an educated guess. 

Are all these sensors pointing the same direction?

When 2 sensors are pointed at the same place, and there is a reasonably bright target surface, they generally do not interfere with each other. But sometimes they do.

To prevent EMI we use clock dithering. And this movement of the base timing tends to ensure the clocks don't line up. But just due to the randomness, they sometimes do. 

one can keep a running average to even out the data. Or one can use the Inter-measurement period on the sensors to try to get them out of lock-step. Or one can slightly tilt one so the Field of View have less overlap. Generally this only happens with near or reflective targets. Can you avoid those?

 

- 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.

All 4 sensors point into the same direction and they are exactly 4cm appart from eachother.
There is actually no object in front of the sensor when measuring and I also tried it by using one by one, disabling all others while the one is measuring (just to make sure)
The dips you see is distance. So there is no shiny or reflective object in front.
could it be something else? This sensor returns 0 mm distance if I apply the config to it.

Okay - I have another code base written in micropython. I was running this code-base to check if it might be something different and everything worked as expected. 
I erased flash and went back to the other code-base from before and everything was working correctly. 
Then I power off the board entirly, waited a few seconds and started the code again and saw the same wrong behavior as I had before.

Could it be, that the xshut pin does not reset the sensor and it keeps some configs or registers? This is a super strange behavior I can not explain in any way. 

So for a moment everything was working as expected. How can a hard-reset affect the sensor differently if I disable all sensors every time because I have to set the I2C Address? Its seems to me, that the sensor kept some registers from before (with an entire different code-base. Maybe I miss-understand the xshut pin?

But that still does not explain to me the weird distance measurments I see

DrD00m
Associate III

I inspected the I2C now using my analg analyzer and at least on I2C side everything looks exactly as it should.
Here is the sequence I am sending with my test app:

 

 

write to 0x29 ack data: 0x00 0x01 0x2A << set I2C Address
write to 0x2A ack data: 0x00 0x08 0x81 << start temperature update 
write to 0x2A ack data: 0x0B 0x92 
write to 0x2A ack data: 0x00 0xDE 
read to 0x2A ack data: 0x00 0x26
write to 0x2A ack data: 0x00 0x6C 0x00 0x00 0x00 0x00 
write to 0x2A ack data: 0x00 0x6C 
read to 0x2A ack data: 0x00 0x00 0x00 0x00 
write to 0x2A ack data: 0x00 0xDE 
read to 0x2A ack data: 0x00 0x26
write to 0x2A ack data: 0x00 0x87 0x21 
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x02
write to 0x2A ack data: 0x00 0x86 0x01 
write to 0x2A ack data: 0x00 0x87 0x00 
write to 0x2A ack data: 0x00 0x08 0x09 
write to 0x2A ack data: 0x0B 0x00 << END start temperature setup
write to 0x2A ack data: 0x00 0x6C << start ranging
read to 0x2A ack data: 0x00 0x00 0x00 0x00
write to 0x2A ack data: 0x00 0xDE 
read to 0x2A ack data: 0x00 0x26
write to 0x2A ack data: 0x00 0x87 0x21 
write to 0x2A ack data: 0x00 0xDE 
read to 0x2A ack data: 0x00 0x26
write to 0x2A ack data: 0x00 0x6C 0x00 0x00 0x0E 0x18 << set inter measurment ms to be 90ms
write to 0x2A ack data: 0x00 0x6C 
read to 0x2A ack data: 0x00 0x00 0x0E 0x18 << reading the value we just set
write to 0x2A ack data: 0x00 0xDE 
read to 0x2A ack data: 0x00 0x26
write to 0x2A ack data: 0x00 0x06 
read to 0x2A ack data: 0xBC 0x00
write to 0x2A ack data: 0x00 0x5E 0x02 0xC0 << write range config A
write to 0x2A ack data: 0x00 0x61 0x03 0x80 << write range config B
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x02
write to 0x2A ack data: 0x00 0x89 
read to 0x2A ack data: 0x08
write to 0x2A ack data: 0x00 0x8C 
read to 0x2A ack data: 0x04 0x02
write to 0x2A ack data: 0x00 0x8E 
read to 0x2A ack data: 0x00 0x54
write to 0x2A ack data: 0x00 0x90 
read to 0x2A ack data: 0x00 0x02
write to 0x2A ack data: 0x00 0x92 
read to 0x2A ack data: 0x00 0x06
write to 0x2A ack data: 0x00 0x96 << reading the first distance
read to 0x2A ack data: 0x00 0x46
write to 0x2A ack data: 0x00 0x86 0x01 
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x02
write to 0x2A ack data: 0x00 0x89 
read to 0x2A ack data: 0x08
write to 0x2A ack data: 0x00 0x8C 
read to 0x2A ack data: 0x04 0x02
write to 0x2A ack data: 0x00 0x8E 
read to 0x2A ack data: 0x00 0x00
write to 0x2A ack data: 0x00 0x90 
read to 0x2A ack data: 0x00 0x02
write to 0x2A ack data: 0x00 0x92 
read to 0x2A ack data: 0x00 0x00
write to 0x2A ack data: 0x00 0x96 
read to 0x2A ack data: 0x00 0x46
write to 0x2A ack data: 0x00 0x86 0x01 
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x03
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x03
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x02
write to 0x2A ack data: 0x00 0x89 
read to 0x2A ack data: 0x08
write to 0x2A ack data: 0x00 0x8C 
read to 0x2A ack data: 0x04 0x02
write to 0x2A ack data: 0x00 0x8E 
read to 0x2A ack data: 0x00 0x0A
write to 0x2A ack data: 0x00 0x90 
read to 0x2A ack data: 0x00 0x00
write to 0x2A ack data: 0x00 0x92 
read to 0x2A ack data: 0x00 0x06
write to 0x2A ack data: 0x00 0x96 
read to 0x2A ack data: 0x00 0x46
write to 0x2A ack data: 0x00 0x86 0x01 
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x03
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x03
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x02
write to 0x2A ack data: 0x00 0x89 
read to 0x2A ack data: 0x08
write to 0x2A ack data: 0x00 0x8C 
read to 0x2A ack data: 0x04 0x02
write to 0x2A ack data: 0x00 0x8E 
read to 0x2A ack data: 0x00 0x48
write to 0x2A ack data: 0x00 0x90 
read to 0x2A ack data: 0x00 0x00
write to 0x2A ack data: 0x00 0x92 
read to 0x2A ack data: 0x00 0x06
write to 0x2A ack data: 0x00 0x96 
read to 0x2A ack data: 0x00 0x46
write to 0x2A ack data: 0x00 0x86 0x01 
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x03
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x03
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x03
write to 0x2A ack data: 0x00 0x30 
read to 0x2A ack data: 0x11
write to 0x2A ack data: 0x00 0x31 
read to 0x2A ack data: 0x02
write to 0x2A ack data: 0x00 0x89 
read to 0x2A ack data: 0x08
write to 0x2A ack data: 0x00 0x8C 
read to 0x2A ack data: 0x04 0x02
write to 0x2A ack data: 0x00 0x8E 
read to 0x2A ack data: 0x00 0x00
write to 0x2A ack data: 0x00 0x90 
read to 0x2A ack data: 0x00 0x02
write to 0x2A ack data: 0x00 0x92 
read to 0x2A ack data: 0x00 0x04
write to 0x2A ack data: 0x00 0x96 
read to 0x2A ack data: 0x00 0x46
write to 0x2A ack data: 0x00 0x86 0x01 
write to 0x2A ack data: 0x00 0x87 0x00

 

The Sensor is now pointing down onto a white paper because to read the I2C I had to turn the device around. 
It returns a distance of 0 if it points into the room (no object)

 



John E KVAM
ST Employee

It bothers me that you are getting some 1600 mm when you say there is no object in front of your sensors. With no object you should be getting a 'no signal' Range Status =2. That means any range information is probably suspect. 

It looks to me like there is an object at 1.6 meters or so. Your ceiling perhaps?

Most MCUs are a lot faster than that tiny sensor. If you toggle the Xshut at MCU speeds you could well get the sensor into a half-reset state. When restarting, give it a few milliseconds between lower and raising the XShut pin. 

Rather than look at the I2C, gather up the range_status, the distance, the signal strength and the ambient. Look for your clues in that data. 

The VL53L4CD is limited to about 1.3M. Yet you are getting 1.6M. This means that your ceiling is, perhaps, a nice reflective white. But I'm guessing you are getting a Range status of 4. This happens when one of the two sub-ranges does not return a result and the other does. It's a warning that something odd is going on. (You can get it with motion or if you target starts to wrap around and a 2M target shows up as a 40cm target. Radar aliasing is what this wrap condition is called.)

-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.

Maybe my exprectations are wrong and the device works way different then I thought. 
I thought the device will not detect anything further then ~15cm. Of course it is pointing to the ceiling and the ceiling is shiny white! 

My goal is a sensor which - when started - reads the distance multiple times (30 times). The distance value will be averaged and set as threshold (minus 10%). In a real world use-case the sensor will point down to the ground propably. What ever will pass this sensor (lowering the distance) will trigger an interrupt.
But what also might happen is: the sensor is higher, pointing into the distance - then the threashold will be the maximum distance or whatever makes sense (what would that be then? 1.3m?) The problem here is, that the sensor sometimes delivers 0 or 1600mm or something around that (when pointing towards my ceiling). Tbh I was not expecting it to actually "see" the ceiling)

So my guess was - if it points into the distance "without" an object (within 15cm or so) it will give me ~1600. But I guess I was totaly wrong about thst one. That means I really can ONLY take values into account, when they are valid (status == 0).

But then I have this issue, where one sensor returns a wrong value even tho I am pointing it at something (like my table). In the log below you can see the sensor returns weird values.
This is causing the device to end up in a interrupt loop where it can never escape from.

 

E (299) quad_psram: PSRAM ID read error: 0x00ffffff, PSRAM chip not found or not supported, or wrong PSRAM line mode
E (299) esp_psram: PSRAM enabled but initialization failed. Bailing out.
[toit] INFO: starting <v2.0.0-alpha.145>
[toit] DEBUG: clearing RTC memory: invalid checksum
[toit] INFO: running on ESP32S3 - revision 0.2
[rep-trap] INFO: Starting RepTrap...
[app] DEBUG: Starting VL53L4CD Sensor Array 1
[app] DEBUG: Initializing BLE API
[app] ERROR: BLE API Service unavailable
I2C address changed from 42 to 42
I2C address changed from 43 to 43
I2C address changed from 44 to 44
I2C address changed from 45 to 45
---------- VL53_1 ------------
Continuous Mode
Setting offset for VL53_1 to -132
Setting xtalk for VL53_1 to 127.0
Error setting xtalk for VL53_1
Signal Threashold: 1496
Autonomous Mode
Autonomous Mode
distance: 126 [✓ Valid measurement]
distance: 127 [✓ Valid measurement]
distance: 128 [✓ Valid measurement]
distance: 127 [✓ Valid measurement]
distance: 128 [✓ Valid measurement]
distance: 125 [✓ Valid measurement]
distance: 125 [✓ Valid measurement]
distance: 125 [✓ Valid measurement]
distance: 126 [✓ Valid measurement]
distance: 126 [✓ Valid measurement]
distance: 126 [✓ Valid measurement]
distance: 126 [✓ Valid measurement]
distance: 124 [✓ Valid measurement]
distance: 124 [✓ Valid measurement]
distance: 125 [✓ Valid measurement]
distance: 126 [✓ Valid measurement]
distance: 125 [✓ Valid measurement]
distance: 126 [✓ Valid measurement]
distance: 125 [✓ Valid measurement]
distance: 127 [✓ Valid measurement]
distance: 124 [✓ Valid measurement]
distance: 128 [✓ Valid measurement]
distance: 126 [✓ Valid measurement]
distance: 125 [✓ Valid measurement]
distance: 125 [✓ Valid measurement]
distance: 126 [✓ Valid measurement]
distance: 124 [✓ Valid measurement]
distance: 125 [✓ Valid measurement]
distance: 125 [✓ Valid measurement]
distance: 124 [✓ Valid measurement]
Average: 125
Threshold percentage: 10
Threshold: 113
Signal Threashold: 5000
Sigma mm: 10
Autonomous Mode
System Status: 3
result-range-status: 0
---------- VL53_2 ------------
Continuous Mode
Setting offset for VL53_2 to -160
Signal Threashold: 1496
Autonomous Mode
Autonomous Mode
distance: 104 [- : Warning! Signal is below the defined threshold]
distance: 77 [- : Warning! Signal is below the defined threshold]
distance: 75 [- : Warning! Signal is below the defined threshold]
distance: 59 [- : Warning! Signal is below the defined threshold]
distance: 59 [- : Warning! Signal is below the defined threshold]
distance: 90 [- : Warning! Signal is below the defined threshold]
distance: 87 [- : Warning! Signal is below the defined threshold]
distance: 67 [- : Warning! Signal is below the defined threshold]
distance: 94 [- : Warning! Signal is below the defined threshold]
distance: 107 [- : Warning! Signal is below the defined threshold]
distance: 105 [- : Warning! Signal is below the defined threshold]
distance: 52 [- : Warning! Signal is below the defined threshold]
distance: 77 [- : Warning! Signal is below the defined threshold]
distance: 76 [- : Warning! Signal is below the defined threshold]
distance: 110 [- : Warning! Signal is below the defined threshold]
distance: 89 [- : Warning! Signal is below the defined threshold]
distance: 91 [- : Warning! Signal is below the defined threshold]
distance: 82 [- : Warning! Signal is below the defined threshold]
distance: 98 [- : Warning! Signal is below the defined threshold]
distance: 83 [- : Warning! Signal is below the defined threshold]
distance: 89 [- : Warning! Signal is below the defined threshold]
distance: 110 [- : Warning! Signal is below the defined threshold]
distance: 99 [- : Warning! Signal is below the defined threshold]
distance: 123 [- : Warning! Signal is below the defined threshold]
distance: 66 [- : Warning! Signal is below the defined threshold]
distance: 101 [- : Warning! Signal is below the defined threshold]
distance: 86 [- : Warning! Signal is below the defined threshold]
distance: 67 [- : Warning! Signal is below the defined threshold]
distance: 83 [- : Warning! Signal is below the defined threshold]
distance: 92 [- : Warning! Signal is below the defined threshold]
Average: 86
Threshold percentage: 10
Threshold: 77
Signal Threashold: 5000
Sigma mm: 10
Autonomous Mode
System Status: 3
result-range-status: 2
---------- VL53_3 ------------
Continuous Mode
Setting offset for VL53_3 to -184
Signal Threashold: 1496
Autonomous Mode
Autonomous Mode
distance: 124 [✓ Valid measurement]
distance: 122 [✓ Valid measurement]
distance: 122 [✓ Valid measurement]
distance: 122 [✓ Valid measurement]
distance: 123 [✓ Valid measurement]
distance: 121 [✓ Valid measurement]
distance: 123 [✓ Valid measurement]
distance: 124 [✓ Valid measurement]
distance: 124 [✓ Valid measurement]
distance: 123 [✓ Valid measurement]
distance: 122 [✓ Valid measurement]
distance: 125 [✓ Valid measurement]
distance: 122 [✓ Valid measurement]
distance: 123 [✓ Valid measurement]
distance: 123 [✓ Valid measurement]
distance: 124 [✓ Valid measurement]
distance: 122 [✓ Valid measurement]
distance: 121 [✓ Valid measurement]
distance: 124 [✓ Valid measurement]
distance: 122 [✓ Valid measurement]
distance: 122 [✓ Valid measurement]
distance: 121 [✓ Valid measurement]
distance: 122 [✓ Valid measurement]
distance: 122 [✓ Valid measurement]
distance: 120 [✓ Valid measurement]
distance: 123 [✓ Valid measurement]
distance: 123 [✓ Valid measurement]
distance: 123 [✓ Valid measurement]
distance: 120 [✓ Valid measurement]
distance: 118 [✓ Valid measurement]
Average: 122
Threshold percentage: 10
Threshold: 110
Signal Threashold: 5000
Sigma mm: 10
Autonomous Mode
System Status: 3
result-range-status: 0
---------- VL53_4 ------------
Continuous Mode
Setting offset for VL53_4 to -160
Signal Threashold: 1496
Autonomous Mode
Autonomous Mode
distance: 119 [✓ Valid measurement]
distance: 121 [✓ Valid measurement]
distance: 119 [✓ Valid measurement]
distance: 121 [✓ Valid measurement]
distance: 119 [✓ Valid measurement]
distance: 117 [✓ Valid measurement]
distance: 119 [✓ Valid measurement]
distance: 120 [✓ Valid measurement]
distance: 120 [✓ Valid measurement]
distance: 121 [✓ Valid measurement]
distance: 123 [✓ Valid measurement]
distance: 120 [✓ Valid measurement]
distance: 124 [✓ Valid measurement]
distance: 121 [✓ Valid measurement]
distance: 121 [✓ Valid measurement]
distance: 122 [✓ Valid measurement]
distance: 119 [✓ Valid measurement]
distance: 121 [✓ Valid measurement]
distance: 123 [✓ Valid measurement]
distance: 120 [✓ Valid measurement]
distance: 119 [✓ Valid measurement]
distance: 121 [✓ Valid measurement]
distance: 122 [✓ Valid measurement]
distance: 120 [✓ Valid measurement]
distance: 121 [✓ Valid measurement]
distance: 121 [✓ Valid measurement]
distance: 120 [✓ Valid measurement]
distance: 119 [✓ Valid measurement]
distance: 118 [✓ Valid measurement]
distance: 119 [✓ Valid measurement]
Average: 120
Threshold percentage: 10
Threshold: 108
Signal Threashold: 5000
Sigma mm: 10
Autonomous Mode
System Status: 3
result-range-status: 0
[toit] INFO: entering deep sleep for 43200000ms

 

 

I also checked my code again with the "config". I was writing 91 bytes to 0x002d without going one by one, assuming that this is not an issue. I am still not sure if it is tho. I changed that to write them one by one increasing the register. 

Writing in a block is fine. We were trying to write the most basic code we could and write_multi() was dropped as one generally does not initialize the sensor very often and it's one less function a user has to migrate. 

The sensor is going to return anything it can. 

What you want is a threshold.

It says, 'Don't generate an interrupt unless the status is good, the signal is strong, the sigma is low, and the distance is below this level.

In Autonomous mode, you set the integration period (timing budget) and how often you range (Inter-measurement period).

If you want to eliminate the ceiling, set the signal threshold high, so that only near, bright objects can be seen. 

(But not too high as you will lose your required target.)

 


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.