mp-extras / vl53l5cx

MicroPython and CircuitPython support for ST VL53L5CX TOF sensor
MIT License
13 stars 4 forks source link

Possible odd and even column swap and VL53L8CX #6

Open psturgeon54 opened 6 months ago

psturgeon54 commented 6 months ago

Hello,

Thanks for a great library.

We are using it in a person presence detection application and it works great in room lighting but there are a couple of issues we need to address.

(1) Our application works fine when we use it indoors with the window curtains closed, but as soon as we open the curtains on even a slightly bright day otuside, we find that our sensors only work with limited range. I see that this is a well understod problem in applications where the sensor may be expsoed to daylight, and we now hear that ST have a new model, the VL53L8CX, which claims to have improved daylight perfromance. I'm wordering if your library will work with the new sensor. Of course we could try it, but I haven't yet got delivery of samples from Polulu and I'd like to have an idea about what we can expect. One might suppose that the VL53L8CX would be software compatible with the VL53L5CX, but a deep study of the data sheets might be necessary to confirm.

(2) When we test with our current sensor driven from your library we seem to be finding that the odd and even columns in each row of the 8x8 matrix are swapped relative to their actual position. We checked this by moving a small target around a chess board positioned underneath a VL53L5CX at the appropriate height to get the chessboard to fill the FOV. We have put in a fix in our higher level software to correct the apparent swap, but I wonder if perhaps I have not properly understood your documentation

Phil S

mgsb commented 6 months ago

Thanks for the feedback. I waited til I got a VL53L8CX so I could try to answer your first question.

  1. VL53L8CX: I got the breakout board from ST (SATEL-VL53L8). After reviewing the ULD code and the latest ULD for the VL53L5CX, I updated the MP code to support both. In my limited testing, they both appear to be working. I do notice a better behavior in daylight with the VL53L8CX.

  2. Data out-of-order problem. I have noticed this, too, but have not figured out where the problem is. Probably in my MP code. Unfortunately, it's still there with the VL53L8CX. I'll try studying the ULD C code and see if I can spot the problem. There is no real documentation (IMHO) with the ULD, and the examples just dump the ranging data as a linear array. But, looking at some app notes, it appears it should be be in row order.

You can try the "vl53l8cx" branch. Note that the VL53L5CX is using the newest ULD and associated firmware, so there could be some noticeable differences. The ULD and FW are coupled, so you cannot change one without the other.

I added a MP mip installation package.json file, so you can install directly on a board using:

mpremote mip install --mpy github:mp-extras/vl53l5cx@vl53l8cx
mgsb commented 6 months ago

I figured out one bug with the swapped data. I was not accounting for adjacent samples being swapped since I skipped the 32-bit swapping step from the ULD C code. I changed the distance_mm method and now the data is right on the VL53L8CX (to my eyes :). There is another different problem with the VL53L5CX distance_mm data. It looks reflected around the Y-axis. I pushed a change in the mean time that looks good on the VL53L8CX.

psturgeon54 commented 6 months ago

Thanks very much indeed for looking into my questions. We are still waiting for the Polulu PCB with the VL53L8CX on it that we have ordered, but when we get it, we will have another go with your updated library. In the meantime, we are also looking at the Osram TMF8821 and TMF8828. On paper these look at least as good or even better than the ST VL53Lx TOF sensors. The TMF8821 is supported by an Arduino library, but no support so far under Micropython I think.