Using a VL53l5cx on a Teensy Micromod

mjs513

Senior Member+
Recently I got interested in the ST Time of Flight sensors, specifically the VL53l5cx from Sparkfun after seeing a youtube video (VL53L7CX MultiZone TOF Sensor - Simple Demo) showing a visualization using LabView. Since I am a glutton for punishment wanted to see if something similar could be done using one of our displays.

Hardware:
1. @PaulStoffregen Micromod Breakout
2. ST7796 - picked up from amazon
3. VL53l5cx from Sparkfun

Software Libraries:
1. ST7735_t3 - installed with board manager or Teensyduino
2. Modified version of @KrisKasprzak ILI9341_t3_controls library: https://github.com/mjs513/ILI9341_t3_controls/tree/ILI9341_t3_controls_mods
3. Sparkfun VL53l5cx library: https://github.com/sparkfun/SparkFun_VL53L5CX_Arduino_Library

IMG_1618.png


The test was basically point the sensor a few objects sitting on my messy desk:
IMG_1608.png


The sensor allow you to set several options that will affect the quality of the results (see A guide to using the VL53L5CX multizone Time-of-Flight ranging sensor from ST Micro)
1. Sharpener percentage:
The signal returned from a target is not a clean pulse with sharp edges. The edges slope away and may affect the distances reported in adjacent zones. The sharpener is used to remove some or all of the signal caused by a veiling glare
2. Ranging_freq: the measurement frequency for the sensor. In 8x8 mode you can go from 1hz to 15hz max.
3. Integration Time: defines how long the sensor collects photon data before producing a measurement — longer times improve signal quality but reduce update rate. If I am interpreting the spec right when in continuous mode not used.

One of the things that I did in the sketch was allow me to set the grid size on the display, use 8, 16, 32, 64 - right now I default to 64.
C++:
#define default_grid_size 64

With that out of the way when the sketch first starts you will see the grid you selected and the menu:
IMG_1613.png


The sketch allows you to try BiLinear or BiCubic Interpolation which are the first 2 buttons.

You pretty much can display all the outputs from the sensor. With the following caveats. Distance, Reflectance all display in 64x64 grid. For Signal spad, range_sigma, target status it switches to 8x8 sensor grid. Made more sense to me. There is also the option "RawData" to dump the sensor data to the serial monitor.

Here are some images
Distance and Reflectance:
IMG_1609.png
IMG_1610.png


Sketch is attached
 

Attachments

  • st7796_vl53l5_visualization_v3-250801a.zip
    7.6 KB · Views: 73
Here are a few more notes for using these type of sensors.

When you first fire up the example you will see some of the sensor zones (8x8 elements) jump all over the place. After you dig deeper into the sensor you will find that one of the things that is dumped by the sensor is the target status. When you look into the Guide you see under data interpretation:

To have consistent data, the user needs to filter invalid target status. To give a confidence rating, a target with status 5 is considered as 100% valid. A status of 6 or 9 can be considered with a confidence value of 50%. All other statuses are below the 50% confidence level

Also not necessarily mentioned you can using Range sigma and Signal per SPAD to filter the data. So in the end, I set up the following filter for valid data:
C++:
         if(currentDataMode == DISTANCE) {
            if((status == 5 || status == 6 || status == 9)
             && (float)measurementData.range_sigma_mm[x + y] < 4
             &&  (float)measurementData.signal_per_spad[x + y] > 25 )
            {
              sensor_data[i][j] = (float)measurementData.distance_mm[x + y];
            } else {
              sensor_data[i][j] = 2048;
            }

Definitions:
Range Sigma mm: "Sigma estimator for the noise in the reported target distance"
Signal per SPAD: "Quantity of photons measured during the VCSEL pulse"

There are other things that can be done but that is for another day.
 
Back
Top