Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative Distance Value -1185 #26

Open
klausberger1707 opened this issue Nov 22, 2019 · 5 comments
Open

Negative Distance Value -1185 #26

klausberger1707 opened this issue Nov 22, 2019 · 5 comments

Comments

@klausberger1707
Copy link

Hey,

I have been trying to test my code on a raspberrypi (archlinux 64 architecture). However, I always get a negative distance value of -1185. Also, while debugging the VL531LX.c file, I also noticed that the error code returned for both postive and negative values is 0. Has anyone faced a similar issue.

Thanks

@nav2u
Copy link

nav2u commented Mar 3, 2020

Hello,

Similar issue here, different setup however.

I have 5x VL53L1X connected to a TCA9548A multiplexer on channels 0 through to 4. I modified the Distance_multiplexer.py to read all 5 sensors with 100ms sleep between each read. Running on Raspbian Buster Lite, Raspberry Pi 3 B+, setup on a breadboard, facing the cealing (~1.6m from the breadboard).

Issue: Random sensors will randomly give me -1185mm readings or other random values and sometimes even just a 0mm reading.

Troubleshooting I've done so far: Tested with long, medium and short ranging options, increased the time between measurements, ran the program multiple times to ensure that all sensors at some stage or the other provided correct measurements (I was trying to check that the sensors aren't faulty), changed lighting conditions.

Looking for help/clues/ideas in figuring out whats going on. Thanks!

A few example measurements:

Example 1

Display the distance read from the sensor.
Press Ctrl+C to exit.

VL53L1X Start Ranging Address 0x29 TCA9548A Device 0 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
VL53L1X Start Ranging Address 0x29 TCA9548A Device 1 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
VL53L1X Start Ranging Address 0x29 TCA9548A Device 2 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
VL53L1X Start Ranging Address 0x29 TCA9548A Device 3 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
VL53L1X Start Ranging Address 0x29 TCA9548A Device 4 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
Sensor 1 distance: 1578mm
Sensor 2 distance: 1116mm
Sensor 3 distance: 1634mm
Sensor 4 distance: 1574mm
Sensor 5 distance: 659mm
Sensor 1 distance: 1572mm
Sensor 2 distance: 1196mm
Sensor 3 distance: 1630mm
Sensor 4 distance: 1569mm
Sensor 5 distance: 741mm
Sensor 1 distance: 1565mm
Sensor 2 distance: 1092mm
Sensor 3 distance: 1633mm
Sensor 4 distance: 1572mm
Sensor 5 distance: 1434mm
Sensor 1 distance: 1563mm
Sensor 2 distance: 1136mm
Sensor 3 distance: 1633mm
Sensor 4 distance: 1569mm
Sensor 5 distance: 732mm
Sensor 1 distance: 1554mm
Sensor 2 distance: 1196mm
Sensor 3 distance: 1631mm
Sensor 4 distance: -1185mm
Sensor 5 distance: 716mm
Sensor 1 distance: 1565mm
Sensor 2 distance: -1185mm
Sensor 3 distance: 1626mm
Sensor 4 distance: -1185mm
Sensor 5 distance: 1406mm
Sensor 1 distance: 1568mm
Sensor 2 distance: -1185mm
Sensor 3 distance: 1626mm
Sensor 4 distance: -1185mm
Sensor 5 distance: 1462mm

Example 2

Display the distance read from the sensor.
Press Ctrl+C to exit.

VL53L1X Start Ranging Address 0x29 TCA9548A Device 0 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
VL53L1X Start Ranging Address 0x29 TCA9548A Device 1 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
VL53L1X Start Ranging Address 0x29 TCA9548A Device 2 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
VL53L1X Start Ranging Address 0x29 TCA9548A Device 3 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
VL53L1X Start Ranging Address 0x29 TCA9548A Device 4 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
Sensor 1 distance: 1617mm
Sensor 2 distance: 1558mm
Sensor 3 distance: 1627mm
Sensor 4 distance: 1636mm
Sensor 5 distance: 794mm
Sensor 1 distance: 1625mm
Sensor 2 distance: 1581mm
Sensor 3 distance: 1617mm
Sensor 4 distance: 1635mm
Sensor 5 distance: 1604mm
Sensor 1 distance: 1629mm
Sensor 2 distance: 1578mm
Sensor 3 distance: 1625mm
Sensor 4 distance: 1636mm
Sensor 5 distance: 1571mm
Sensor 1 distance: 1625mm
Sensor 2 distance: 1583mm
Sensor 3 distance: -1185mm
Sensor 4 distance: 1637mm
Sensor 5 distance: 1529mm
Sensor 1 distance: 1623mm
Sensor 2 distance: 1581mm
Sensor 3 distance: -1185mm
Sensor 4 distance: 1637mm
Sensor 5 distance: 1605mm
Sensor 1 distance: 1623mm
Sensor 2 distance: 1568mm
Sensor 3 distance: -1185mm
Sensor 4 distance: 1634mm
Sensor 5 distance: 1579mm

Example 3

Display the distance read from the sensor.
Press Ctrl+C to exit.

VL53L1X Start Ranging Address 0x29 TCA9548A Device 0 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
VL53L1X Start Ranging Address 0x29 TCA9548A Device 1 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
VL53L1X Start Ranging Address 0x29 TCA9548A Device 2 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
VL53L1X Start Ranging Address 0x29 TCA9548A Device 3 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
VL53L1X Start Ranging Address 0x29 TCA9548A Device 4 TCA9548A Address 0x70

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID : 
ProductRevisionMajor : 1
ProductRevisionMinor : 15
Sensor 1 distance: -1185mm
Sensor 2 distance: 1640mm
Sensor 3 distance: 1612mm
Sensor 4 distance: 1641mm
Sensor 5 distance: 1641mm
Sensor 1 distance: 1625mm
Sensor 2 distance: 1638mm
Sensor 3 distance: -1185mm
Sensor 4 distance: -1185mm
Sensor 5 distance: 1628mm
Sensor 1 distance: 1627mm
Sensor 2 distance: 1637mm
Sensor 3 distance: -1185mm
Sensor 4 distance: -1185mm
Sensor 5 distance: -1185mm
Sensor 1 distance: -1185mm
Sensor 2 distance: 1637mm
Sensor 3 distance: -1185mm
Sensor 4 distance: -1185mm
Sensor 5 distance: -1185mm
Sensor 1 distance: -1185mm
Sensor 2 distance: 1638mm
Sensor 3 distance: -1185mm
Sensor 4 distance: -1185mm
Sensor 5 distance: -1185mm
Sensor 1 distance: -1185mm
Sensor 2 distance: 1639mm
Sensor 3 distance: -1185mm
Sensor 4 distance: -1185mm
Sensor 5 distance: 1611mm

@Gadgetoid
Copy link
Member

The spurious negative readings look suspiciously like an overflow, but it's bizarre that they are always the same value. It could be a silent read error that's then being converted into a distance.

The measurement data struct which we're currently jus tpulling RangeMilliMeter from also hs a RangeStatus that's not being checked. It's possible in the case of these errant readings the RangeStatus is 1 (invalid) and the reading should be rejected.

The get_distance method in Python calls getDistance in the C bindings which is defined here:

int32_t getDistance(VL53L1_Dev_t *dev)
{
VL53L1_Error Status = VL53L1_ERROR_NONE;
int32_t current_distance = -1;
Status = VL53L1_WaitMeasurementDataReady(dev);
Status = VL53L1_GetRangingMeasurementData(dev, pRangingMeasurementData);
current_distance = pRangingMeasurementData->RangeMilliMeter;
VL53L1_ClearInterruptAndStartMeasurement(dev);
return current_distance;
}

@mglowinski93
Copy link

mglowinski93 commented Dec 3, 2021

I've similar issue with single device connected to I2C network:
image

Might it be due to I2C noise?
image

@Gadgetoid is there any feedback on that?

@Sarra776
Copy link

Hello, I have the same error.... can someone help me?
error

@soerenbrockmann
Copy link

For me the error value was gone when setting a timer time.sleep(0.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants