Anyone used the VL53L0X time of flight sensor with Propeller/Spin? Can pay for code.

varnonvarnon Posts: 171
edited November 6 in Accessories Vote Up0Vote Down
Hi all,

I'm looking at using ST's VL53L0X time of flight sensor with some of my projects. It looks pretty interesting. But the data sheet and documentation are not great. Before I get too deep into translating ST's api or Pololu's Arduino code, I was curious to see if any one had already gone through the process. I saw a few posts on the VL6180X, but I need a little more range than that can offer.

Comments

  • 7 Comments sorted by Date Added Votes
  • Well I am swamped, and have had almost no time to look at the code this weekend. I'll get to it when I have the time and post something when I get it working. But as an alternative, if someone is interested in coding a spin driver, I would be willing to pay for your time.
  • I did a driver for the brother chip VL6180X. Havent checked how much is similar and how much is different, but I would think it could be a place to start.
    obex.parallax.com/object/852

    Erlend
    21st century - when everything changes
    "Better with a DAT and a COG than with a CAT and a DOG"
  • Yeah, I saw that code earlier, thanks. It has been a bit of a reference. The VL53L0X is very similar, but there is a lot more upfront set up. I don't quite understand why ST set up these sensors this way. Unfortunately, I'm starting to think I am over my head with this one. It is more complicated than I anticipated, and I am not that great with C. It is also frustrating because it is so hard to test to see where my errors are.

    Also, I just discovered that the VL6180X has a range scaling factor (not described in the data sheet) that will let you increase the range from 200 mm with a 1 mm resolution, to 400 mm with a 2 mm resolution, or 600 mm with a 3 mm resolution. That would actually be fine for my purposes. So I might end up going that way.

  • varnon wrote: »
    ...

    Also, I just discovered that the VL6180X has a range scaling factor (not described in the data sheet) that will let you increase the range from 200 mm with a 1 mm resolution, to 400 mm with a 2 mm resolution, or 600 mm with a 3 mm resolution. That would actually be fine for my purposes. So I might end up going that way.

    I would appreciate if you would share the details of this scaling factor with me.
    Erlend
    21st century - when everything changes
    "Better with a DAT and a COG than with a CAT and a DOG"
  • I first saw it described on pololu's website:
    https://www.pololu.com/product/2489

    Their Arduino code contains some instructions. Looks pretty easy to execute.
    ST has a description of it on a document for one of their eval boards. I haven't looked for it in their API manual yet, but I assume it is there as well.
    // Set range scaling factor. The sensor uses 1x scaling by default, giving range
    // measurements in units of mm. Increasing the scaling to 2x or 3x makes it give
    // raw values in units of 2 mm or 3 mm instead. In other words, a bigger scaling
    // factor increases the sensor's potential maximum range but reduces its
    // resolution.
    
    // Implemented using ST's VL6180X API as a reference (STSW-IMG003); see
    // VL6180x_UpscaleSetScaling() in vl6180x_api.c.
    void VL6180X::setScaling(uint8_t new_scaling)
    {
      uint8_t const DefaultCrosstalkValidHeight = 20; // default value of SYSRANGE__CROSSTALK_VALID_HEIGHT
    
      // do nothing if scaling value is invalid
      if (new_scaling < 1 || new_scaling > 3) { return; }
    
      scaling = new_scaling;
      writeReg16Bit(RANGE_SCALER, ScalerValues[scaling]);
    
      // apply scaling on part-to-part offset
      writeReg(VL6180X::SYSRANGE__PART_TO_PART_RANGE_OFFSET, ptp_offset / scaling);
    
      // apply scaling on CrossTalkValidHeight
      writeReg(VL6180X::SYSRANGE__CROSSTALK_VALID_HEIGHT, DefaultCrosstalkValidHeight / scaling);
    
      // This function does not apply scaling to RANGE_IGNORE_VALID_HEIGHT.
    
      // enable early convergence estimate only at 1x scaling
      uint8_t rce = readReg(VL6180X::SYSRANGE__RANGE_CHECK_ENABLES);
      writeReg(VL6180X::SYSRANGE__RANGE_CHECK_ENABLES, (rce & 0xFE) | (scaling == 1));
    }
    
  • Well, I didn't have any luck setting the range scaling factor using this method.

    But, it looks like you can set it during the init method. The fourth register written, $97 is the range scale. The application notes tell you to write $FD, but you can write $7F for the 40 mm range, or $54 for the 60 mm range. Everything seems to work exactly as suggested if you do that. I'm just not able to change the range scaling after initialization.
  • OK, thanks, I'll try that change to my Spin driver next time I tinker with the VL.

    Erlend
    21st century - when everything changes
    "Better with a DAT and a COG than with a CAT and a DOG"
Sign In or Register to comment.