2023-01-11 12:09 AM
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();
2023-01-11 4:47 AM
It does work when I reset my microprocessor. Any idea what causes it to be ignored until I reset?
2023-01-11 6:45 AM
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?
2023-01-11 6:47 AM
Custom board with a ATSAM4LS2B. I think it's probably caused by a wrong order of method calls.
2023-01-11 8:42 AM
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?
2023-01-12 5:30 AM
Code is written by me. I can reach the i2c configuration of the ULD.
2023-01-12 5:47 AM
@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?
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.