We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2018-09-30
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Optical
Downloaded: 4906 times
Not followed.
License: MIT license
Light Ranger 4 click is an accurate distance measurement Click boardâ„¢ based on a ToF (Time of Flight) measurement principle. The FlightSense enabled VL53L1X rangefinder module from STMicroelectronics is a complete measurement stack on the chip.
Do you want to subscribe in order to receive notifications regarding "LightRanger 4 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "LightRanger 4 click" changes.
Do you want to report abuse regarding "LightRanger 4 click".
Library Description
The library initializes and defines the I2C bus driver and drivers that offer a choice for writing data in registers and reading data from registers. The library includes functions for full Configuration chip, sets measurement distance mode, inter measurement period, timing budget and user Roi. The user has the functions available for softReset, power on procedure, read distance of the object in front of the sensor
Key functions:
uint8_t lightranger4_deviceConfiguration()
- Functions for device configurationvoid lightranger4_startMeasurement(uint32_t period_ms)
- Functions for start measurementuint16_t lightranger4_getDistance()
- Function reads distance of the object in front of the sensorExample description
The application is composed of three sections:
void applicationTask()
{
while(lightranger4_newDataReady() != 0)
{
Delay_1ms();
}
distance = lightranger4_getDistance();
IntToStr(distance, demoText);
mikrobus_logWrite(" - Distance : ", _LOG_TEXT);
mikrobus_logWrite(demoText, _LOG_TEXT);
mikrobus_logWrite(" mm ", _LOG_LINE);
measurementStatus = lightranger4_getRangeStatus();
switch (measurementStatus)
{
case _LR4_MRESP_SIGNAL_FAIL:
{
mikrobus_logWrite( "Signal fail.", _LOG_LINE);
break;
}
case _LR4_MRESP_PHASE_OUT_OF_VALID_LIMITS:
{
mikrobus_logWrite( "Phase out of valid limits", _LOG_LINE);
break;
}
case _LR4_MRESP_SIGMA_FAIL:
{
mikrobus_logWrite( "Sigma Fail. ", _LOG_LINE);
break;
}
case _LR4_MRESP_WRAP_TARGET_FAIL:
{
mikrobus_logWrite( "Wrap target fail.", _LOG_LINE);
break;
}
case _LR4_MRESP_MINIMUM_DETECTION_THRESHOLD:
{
mikrobus_logWrite( "Target is below minimum detection threshold. ", _LOG_LINE);
break;
}
default:
{
break;
}
}
Delay_ms( 500 );
}
Other mikroE Libraries used in the example:
Additional notes and information
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.