Distance sensors

Anyone using any TOF I2C distance sensors? Looking for some JAVA code for APIs…

We used the TFMini last year. Our code is in github here:

1 Like

Anyone try the VL53L1X?

We have been selling ST ToF sensors for several years now in a “breakout board” form factor, but the VL53L1 had high enough specs we decided to integrate it into a proper module. This includes an injection molded plastic housing with integrated lenses to protect the delicate sensor and maintain signal integrity, 12V supply, and CAN interface. We have LabVIEW VIs available to configure and read these devices, and they’re already set up (speed, etc) to plug into the FRC CAN network. Check it out on the PwF website.

We haven’t put together C++ or Java code yet, but the interface spec is significantly simpler than trying to integrate a breakout board using I2C. Max sample rate is 24ms. CAN ID is configurable, so multiple sensors can easily be added to a single network.

Owner, Playing With Fusion, Inc


Any issue with can bus overruns if you have say 4 of these? I’d like to see java code on how to implement the reads off CAN.

Why am I JUST seeing this? This seems to be the answer to one of our perennially biggest problems - simple integration of an accurate distance sensor. I wish the update rate was higher, but it’s better than trying to use angle on a vision target, or trying to integrate an i2c lidar, or trying to use an inaccurate / noisy ultrasonic sensor.

I got four of these working via arduino, which reported results via USB serial to the roborio. But was kind of a pain.

No issues with CAN bus loading - should be able to mount dozens of these without bus issues. I’ve got four on a test chassis with 6 CAN motor drivers, bus loading is very low (using built-in CAN bus loading blocks).

We definitely wanted to get these out earlier, but we also didn’t want to announce vaporware or ship a mountain of issue-ridden product. We’ll definitely be around next year! This includes full Java, LabVIEW, and C++ support.

For now, you can get these running with 2-3 CAN commands and 3-4 CAN reads, called in the proper sequence. We have a CAN interface spec on the product page that describes how this works and what the CAN messages are.

Owner, Playing With Fusion, Inc

That looks really cool.

What is the effective minimum ranging distance in each of the distance modes? Section 3.3 of the VL53L1 datasheet states “The minimum ranging distance is 4 cm. Under this minimum distance, the sensor will detect a target, but the measurement will not be accurate.” What sort of resolution does one get in each of the distance modes?

You have no idea how much I appreciate this statement. If this is around with LabVIEW support for next season I pretty much guarantee we will be buying it for distance measurements it the game requires it.

I did some testing and was seeing readings down to ~2.5cm in both short and medium ranging mode. Long ranging mode does not work well for shorter distances, and from my experience, you probably want to use it for measurements over 1m. Anything shorter just wasn’t reliable.

All of the ranges report with 1mm resolution and a couple of cm accuracy. It’s worth mentioning that short mode can get down to ~25ms update rates, whereas medium and long need 100-150ms to complete measurements.

Owner, Playing With Fusion, Inc

Thanks, Justin.

That looks like it will be very useful. It is good to hear that it works down to around an inch. The ultrasonic sensors and LIDARs I have looked at before could not sense below about 12 inches.

How repeatable would a reading be over time, i.e. how different would the reading be 1 hour later, 1 day later, 1 week later and 1 month later?

Is there any problem installing two of them 12 to 18 inches appart and aimed in the same direction? I seem to recall that ultrasonic sensors can interfere with each other when used like this and have to be sequenced.

There is crosstalk between sensors. The arduino API has commands to stop/start “ranging” which turns off the laser when you want to read from the other sensor. Hopefully this product has something similar via the CAN interface.

Measurement accuracy and repeatability is most affected by timing budget (sample rate). In our experience, we have seen virtually no drift over the few months we’ve had these sensors, though the datasheet actually has no spec on long-term stability.

There is currently no start/stop ranging command over the CAN interface, so adjacent sensors with very close proximity may see crosstalk in certain situations. Any crosstalk would be a result of the overlap between the VCSEL broadcast cones of the sensors (27 degree total cone width).

For reference, I have 4 sensors installed across a 28" wide bumper (evenly spaced), all pointed in the same direction, and have not seen any issues during any operation. As these units have a built-in CAN bootloader, this is something we will add in the future, if needed.

Owner, Playing With Fusion, Inc

Any update when the Java support will release?

Yeah, waiting to hear about Java too…

Ok, we have one of your modules…

  1. Any java code examples?

  2. This is the first CAN device I’ve seen with only a single CAN line. All others have an IN and OUT can line. Can these be put in parallel (instead of in series) on the can bus?

Hi Guys,

We don’t have Java libraries yet, it’s something I expect to be released in October based on our current project load. However, we do have a CAN interface doc on our product page, if you’ve done anything with the CAN interface before. Just a few messages to be sent and received to configure and read the sensor. Under “Related Files” on our ToF product page

That’s correct. The CAN line on this is short and should be put in parallel with the bus. It should not be placed at the very “end” of a long bus without an even longer terminating resistor being placed along with it (and then you need to remove one of your other terminating resistors).

As a side note, the housing for this part is now injection molded instead of 3D printed. It has a slightly different contour but the same footprint, and will allow a slightly thinner installation.

Owner, Playing With Fusion, Inc

Attached is some java code for the CAN sensor that we had working on the bench earlier this year, but haven’t tried on a robot at this point.
CanbusDistanceSensor.txt (5.7 KB) CANSendReceive.txt (2.1 KB)

This is a VSCode project using one Playing With Fusion sensor at address zero.

It does the following.

Reads sensor address, part and serial numbers
Flashes sensor light
Reads distance, calibration and quality values
Configures modes and time intervals
Allows sensor re- addressing

We wanted to try it at our last offseason competition this weekend but ran out of time.