Skip to main content
Visitor II
May 31, 2018
Question

VL53L1X with atmega328

  • May 31, 2018
  • 1 reply
  • 1131 views
Posted on May 31, 2018 at 12:07

Hi,

I have project for obstacle distance measurement where VL53L1X sensor is used and the microcontroller is Atmeag 328. I have downloaded API reference code. But there are lot of files which is really confusing me. I have used single sensor in my project. I have written software I2C to read basic register information from VL53L1X. I am able read the following registers properly.

Model ID - 0x010F - Am reading 0xEA which is correct

Model Type - 0x0110 - Am reading 0xCC which is correct

Mask Revision - 0x0111 - Am reading 0x10 which is correct

But to measure the distance there are lot of API's. It would be really helpful if i get any sample code or example code with atmel Microcontroller.

Kindly help me.

    This topic has been closed for replies.

    1 reply

    ST Employee
    June 6, 2018
    Posted on June 07, 2018 at 01:00

    You are most of the way there. Don't quit now. There is a bit of code called X-Cube-vl53l1x. It's available at:

    http://www.st.com/content/st_com/en/products/ecosystems/stm32-open-development-environment/stm32cube-expansion-software/stm32-ode-sense-sw/x-cube-53l1a1.html

    With the code you have written, you are all set. Copy the calls from the main.c and it will just work for you.

    And this code makes a pretty handy reference - even if you don't use an ST processor.

    For example:

     status = VL53L1_WaitDeviceBooted(Dev);

     status += VL53L1_DataInit(Dev);

     status += VL53L1_StaticInit(Dev);

     status += VL53L1_SetPresetMode(Dev,VL53L1_PRESETMODE_LITE_RANGING);

     status += VL53L1_SetDistanceMode(Dev, VL53L1_DISTANCEMODE_MEDIUM);

     status += VL53L1_SetMeasurementTimingBudgetMicroSeconds(Dev,20000);

     //status += VL53L1_SetInterMeasurementPeriodMilliSeconds(Dev, 100);

     status += VL53L1_GetMeasurementTimingBudgetMicroSeconds(Dev, &pMeasurementTimingBudgetMicroSeconds);

     printf('Timing Budget = %d\n', pMeasurementTimingBudgetMicroSeconds);

    status += VL53L1_StartMeasurement(Dev);

     if(status){

      printf('YOU DID SOMETHING WRONG \n');

      while(1);

     } 

     if (isInterrupt){

      do // interrupt mode

      {

       __WFI();

       if(IntCount !=0 ){

        IntCount=0;

        status = VL53L1_GetRangingMeasurementData(Dev, &RangingData);

        if(status==0){

         printf('%d,%d,%.2f,%.2f,%d\n', RangingData.RangeStatus,RangingData.RangeMilliMeter,

          RangingData.SignalRateRtnMegaCps/65536.0,RangingData.AmbientRateRtnMegaCps/65336.0,HAL_GetTick());

        }

        status = VL53L1_ClearInterruptAndStartMeasurement(Dev);

       }

      }

      while(1);
    manjesh nAuthor
    Visitor II
    June 8, 2018
    Posted on June 08, 2018 at 11:27

    Thank you john kvam

    it was useful