2016-09-21 07:19 AM
Hello,
I have some questions to the developers of the API of the VL53L0X (Help from fellow users of this sensor is also highly appreciated). In the next paragraph you find the text which I already shared with customer technical support, from which I got no answer. Finally they appointed me to this forum. My request:In order to use the above mentioned sensor and get the best results out of it I am intending to use the delivered API instead of having to deal with all numerous registers of the sensor. This proposal is made open your recommendation to use the API (and since there is no real ma of the registers).
My only problem is to adapt (modify) the API to match the microcontroller I want to use, namely the Amel ARM Cortex-M7. In my opinion the most important part to modify is the I2C communication interface. My question is: - I would like to have some headlines from your software developers. I would like to know what are the important spots of the software which have be modified in order to get the API working without having to rewrite the API and having to deal with the sensor at the lowest register level. The API should be adjustable for all platforms, at least it is written so on your website. I'd be very pleased if you would answer quickly. Thanks in advance #cortex-m #vl53l0x #atmel-studio2016-10-05 05:26 AM
Hy Manuel,
I just went through porting the software to my target hardware (TI ARM). It was pretty straightforward: I just needed to adjust the vl53l0x_platform.c and vl53l0x_platform.h to my system.
Actually, there is one pitfall: Apparently there are two different philosopies about I2C addresses: The 7 bit address appears in the control word on bit 7..1, so in the control word the address is shifted one bit left. ST.com names the I2C address as it appears on the bus (0x52), my I2C interface expects the real I2C address (0x29).
Anything else works just fine.
Best regards
Harald
2017-02-17 02:25 AM
From Soren Karlsen:
Hi Harald, I'm sitting with the same problem about adapting platform code for VL53L0X as you answered in this thread:
When you say you just needed to adjust the files to your system, what did you actually do, and is it possible that you can show me and example? Best regards Søren2017-02-17 02:52 AM
Hy Soren,
during the development I had a working
, that helped a lot.To port it into my own system (TI ARM, 3 x VL53L0X, discrete shut down pins) I first copied all files from vl53l0x folder into my project
vl53l0x
Release_Notes.htmlVL53L0X_API_v1.0.0.4570_externalx.chmVL53L0X_API_v1.0.0.4570_externalx.chwvl53l0x_api.cvl53l0x_api.hvl53l0x_api_calibration.cvl53l0x_api_calibration.hvl53l0x_api_core.cvl53l0x_api_core.hvl53l0x_api_ranging.cvl53l0x_api_ranging.hvl53l0x_api_strings.cvl53l0x_api_strings.hvl53l0x_def.hvl53l0x_device.hvl53l0x_interrupt_threshold_settings.hvl53l0x_platform.cvl53l0x_platform.hvl53l0x_platform_log.cvl53l0x_platform_log.hvl53l0x_tuning.hvl53l0x_types.hThen I needed to do adjust only the file 'vl53l0x_platform.c' and rewrite all functions in there to suit my own hardware. There is this one pitfall with the different interpretation of I2C addresses, but all the rest worked quite smoothly.
Then I tested and implemented step by step the functionality: Test shutdown pins, test read of the signature byte, test changing the I2C address, test start a measurement and the read the result. I ended up using two functions: startSingleMeas
VL53L0X_Error startSingleMeas(VL53L0X_DEV Dev)
{ VL53L0X_Error Status = VL53L0X_ERROR_NONE; VL53L0X_DeviceModes DeviceMode; /* This function will do a complete single ranging * Here we fix the mode! */ Status = VL53L0X_SetDeviceMode(Dev, VL53L0X_DEVICEMODE_SINGLE_RANGING); /* Get Current DeviceMode */ if (Status == VL53L0X_ERROR_NONE) Status = VL53L0X_GetDeviceMode(Dev, &DeviceMode);/* Start immediately to run a single ranging measurement in case of
* single ranging or single histogram */ if (Status == VL53L0X_ERROR_NONE && DeviceMode == VL53L0X_DEVICEMODE_SINGLE_RANGING) Status = VL53L0X_StartMeasurement(Dev);return Status;
}and pollAndReadMeasurement
/**
* polls for data ready and reads data if ready * returns 0 if data was read, 100 if still busy and negative on error */VL53L0X_Error pollAndReadMeasurement(VL53L0X_DEV Dev, VL53L0X_RangingMeasurementData_t *pRangingMeasurementData){ VL53L0X_Error Status = VL53L0X_ERROR_NONE; if (Status == VL53L0X_ERROR_NONE) { uint8_t NewDataReady = 0;Status = VL53L0X_GetMeasurementDataReady(Dev, &NewDataReady);
if ((Status == VL53L0X_ERROR_NONE) && (NewDataReady == 0))
{ Status = 100; // still measuring } } if (Status == VL53L0X_ERROR_NONE) { // measurement done, read out values PALDevDataSet(Dev, PalState, VL53L0X_STATE_IDLE); Status = VL53L0X_GetRangingMeasurementData(Dev, pRangingMeasurementData);if (Status == VL53L0X_ERROR_NONE)
Status = VL53L0X_ClearInterruptMask(Dev, 0);}
return Status;}Maybe that helps...
Best regards
Harald
2017-02-27 07:17 AM
Well, my first attempts didn't work anyway (even though the code works, it takes too much space). But when you say that you 'adjust vl53l0x_platform.c and rewrite all functions in there to suit my own hardware' what do you actually do? what do you adjust?
2017-03-29 01:44 PM
Hello guys. Let me ask you maybe a silly question but I just can't get my program even building with the VL53L0X API. I downloaded it from the ST website (v 1.0.2) and included all .h and .c files into the project workspace (from the 'Api' folder). I currently work with the Nucleo F103 board, using the Ac6 IDE. All I need is just to perform a single ranging measurement and perform a certain action depending on the results, I do not care about some fancy serial communication with any GUI app. While building I get an error that the <Windows.h> in vl53l0x.c library cannot be found... Well, even if I resolve this issue I get exponentially more errors than in the very beginning. Do I really need to somehow adjust this API to proceed through a simplest functionality? Is there any description how to do it? In my opinion I have checked everywhere, in sensor and api documentation...
2017-10-14 09:35 AM
HI Harald,
Your code
startSingleMeas and
pollAndReadMeasurement nearly works. Im starting and after some time the poll gets true. Now i printed the whole output structure:
TimeStamp 0
MeasurementTimeUsec 0RangeMilliMeter 0RangeDMaxMilliMeter 2048SignalRateRtnMegaCps 33553920AmbientRateRtnMegaCps 33553920EffectiveSpadRtnCount 65535RangeFractionalPart 0ZoneId 0RangeStatus 5And rangeStatus has to be 0 to have a valid measurement. Any idea why this happens?