Skip to main content
Associate
February 24, 2025
Solved

VL53L8CH histogram extraction with multiple configurations

  • February 24, 2025
  • 2 replies
  • 582 views

I'm extracting the histogram data from the VL53L8CH. In the 8x8 mode, we are limited to few bins (~18) per reading. Is there a way to configure the sensor to oscillate the starting bin configuration so that I can get better range with the same bin precision? For example, in a cycle read bins 0-17, then bin 18-35, etc. If this is possible, is there guidance for how this can be done? Following the code from Example_12_cnh_data.c, is it possible to setup multiple configurations within a loop, such as vl53lmz_cnh_init_config(&cnh_config, 0, 18, 1), vl53lmz_cnh_init_config(&cnh_config, 18, 18, 1), etc?

Best answer by RogerM

WSUN,

What you want to do, a sequence of different configurations, is not a feature we have.
However, it should be possible to dynamically change some CNH parameter settings while the sensor is ranging.

Some parameters are only read when the ranging starts, specifically parameters which define the memory layout of the CNH data passed back to the host, and as such these can't be changed while ranging.

But, since the StartBin parameter does not affect the memory layout it should be possible to change while ranging.
With reference to the code in the vl53lmz_plugin_cnh.c file:
-- It should be enough to modify the ref_bin_offset field of the VL53LMZ_Motion_Configuration structure based on the new StartBin value required and then resending this to the device with the function vl53lmz_cnh_send_config()

BUT...you must be aware that the new value will be used immediately, there is no syncronisation mechanism to ensure the new value gets applied at the start of the next frame, so you may receive a frame of CNH data in which the setting changes part way through the data.
So the safest policy will be to write the change, discard one frame of data, then take the second frame of data after change was written.

Hope this helps.

Roger

2 replies

RogerMBest answer
ST Employee
March 7, 2025

WSUN,

What you want to do, a sequence of different configurations, is not a feature we have.
However, it should be possible to dynamically change some CNH parameter settings while the sensor is ranging.

Some parameters are only read when the ranging starts, specifically parameters which define the memory layout of the CNH data passed back to the host, and as such these can't be changed while ranging.

But, since the StartBin parameter does not affect the memory layout it should be possible to change while ranging.
With reference to the code in the vl53lmz_plugin_cnh.c file:
-- It should be enough to modify the ref_bin_offset field of the VL53LMZ_Motion_Configuration structure based on the new StartBin value required and then resending this to the device with the function vl53lmz_cnh_send_config()

BUT...you must be aware that the new value will be used immediately, there is no syncronisation mechanism to ensure the new value gets applied at the start of the next frame, so you may receive a frame of CNH data in which the setting changes part way through the data.
So the safest policy will be to write the change, discard one frame of data, then take the second frame of data after change was written.

Hope this helps.

Roger

wsunAuthor
Associate
March 12, 2025

Thank you, this works. However just for reference, it seems that the update only synchronizes consistently after throwing away two (or more) full frames of data.