cancel
Showing results for 
Search instead for 
Did you mean: 

Signal threshold not working as expected?

SBann.1
Associate II

I'm using a VL53L1X ToF sensor to measure distance with the Ultra Lite driver. I've lowered the signal threshold to 400 because that value seems to cover most valid measurements. When I read the current signal value using GetSignalRate(). When my signal rate is, for example, 600, I still get range status 2 (signalfail). What causes this?

Code I use to measure:

Sensor->Begin();
Sensor->SetTimingBudgetInMs(500);
Sensor->SetSignalThreshold(400);
Sensor->StartRanging();
Sensor->getDistanceOptimal(DistanceMM, SensorStatus);
Sensor->StopRanging();

And my getDistanceOptimal() method:

this->SetDistanceMode(EDistanceMode::Short);
 
uint8_t dataReady = false;
while(!dataReady) {
	this->CheckForDataReady(&dataReady);
	//code for 5 ms delay here
}
 
this->GetDistanceInMm(&distance);
this->GetRangeStatus(&status);
	
//Retry with higher distancemode
if(status != ERangeStatus::RangeValid) {
	this->SetDistanceMode(EDistanceMode::Long);
	//code for 100ms delay here
	this->ClearInterrupt();
 
	while(!dataReady) {
		this->CheckForDataReady(&dataReady);
		//code for 5ms delay here
	}
 
	this->GetDistanceInMm(&distance);
	this->GetRangeStatus(&status);	
}
 
this->ClearInterrupt();

6 REPLIES 6
SBann.1
Associate II

It does work when I reset my microprocessor. Any idea what causes it to be ignored until I reset?

Javier1
Principal

Oooh boy, good old abstracted from the real world C++.

Have you tried Sensor->PleaseWork()?

Just kidding

which mcu are you using to read the sensor? Is it a custom board or a ST's nucleo/discovery?

we dont need to firmware by ourselves, lets talk

Custom board with a ATSAM4LS2B. I think it's probably caused by a wrong order of method calls.

Okay its a microchip mcu then.

>>wrong order of method calls.

Maybe, where did you took this code from?

If you dig long enough , are you able to get to the C(baremetal) I2c configuration and operation routines?

we dont need to firmware by ourselves, lets talk

Code is written by me. I can reach the i2c configuration of the ULD.

SBann.1
Associate II

@John E KVAM​ Can you maybe help me further? I'm thinking the setsignalthreshold and getsignalrate represent different values? And does changing setsignalthreshold even help (for removing status 2) when using my code?