2018-05-31 03:07 AM
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.
2018-06-06 04:00 PM
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:
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);2018-06-08 04:27 AM
Thank you john kvam
it was useful