LightRanger 8 click
LightRanger 8 Click is a compact add-on board that contains a ranging sensor with multi-target detection. This board features the VL53L3CX, the latest Time-of-Flight (ToF) product that embeds third-generation FlightSense patented technology from STMicroelectronics.
click Product page
Click library
- Author : Stefan Nikolic
- Date : jan 2021.
- Type : I2C type
Software Support
We provide a library for the LightRanger8 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on mikroE github account.
Library Description
This library contains API for LightRanger8 Click driver.
Standard key functions :
lightranger8_cfg_setup
Config Object Initialization function.
void lightranger8_cfg_setup(lightranger8_cfg_t *cfg)
LightRanger 8 configuration object setup function.
LightRanger 8 Click configuration object.
Definition lightranger8.h:1399
lightranger8_init
Initialization function.
err_t lightranger8_init(lightranger8_t *ctx, lightranger8_cfg_t *cfg)
LightRanger 8 initialization function.
LightRanger 8 Click context object.
Definition lightranger8.h:1372
lightranger8_default_cfg
Click Default Configuration function.
err_t lightranger8_default_cfg(lightranger8_t *ctx)
LightRanger 8 default configuration function.
Example key functions :
lightranger8_set_measurement_timing_budget
This function sets the timing budget of the VL53Lx ranging sensor.
err_t lightranger8_set_measurement_timing_budget(lightranger8_t *ctx, uint32_t budget_us)
LightRanger 8 set measurement timing budget function.
lightranger8_start_measurement
This function enables the range measuring with the adjusted intermeasurement period.
void lightranger8_start_measurement(lightranger8_t *ctx, uint32_t period_ms)
LightRanger 8 start measurement function.
lightranger8_get_distance
This function returns the corrected measured distance from the VL53Lx ranging sensor described in milimeters.
uint16_t lightranger8_get_distance(lightranger8_t *ctx)
LightRanger 8 get distance function.
Example Description
This demo application shows an example of distance measurement via VL53L3 ranging sensor.
The demo application is composed of two sections :
Application Init
Initialization of I2C module, log UART and additional pins.
After driver init, the app powers the device and performs default settings of the ranging sensor including distance mode and timing budget. The optional calibration helps improvement of the accuracy on the targeted distance. This process takes 10 second ( which can by modifed by simply lowering the Delay_ms ( ) value ) so the user can place an object on the exact location. When calibration is finished, device starts the measurement with intermeasurement period set by the user.
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( init_flag == I2C_MASTER_ERROR ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_printf( &logger, " Wait until the configuration of the chip is completed...\r\n" );
log_error( &logger, " Sensor config error. " );
for ( ; ; );
}
Delay_ms ( 1000 );
log_printf( &logger, " -------------------------------------------------------------------------\r\n" );
log_printf( &logger, " For calibration place an object at %.1f cm distance from sensor.\r\n", ( float )calibration_distance_mm / 10 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &logger, " -------------------------------------------------------------------------\r\n" );
log_printf( &logger, " --------------- Sensor calibration is in progress... ---------------\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 500 );
log_printf( &logger, " -------------------------------------------------------------------------\r\n" );
log_printf( &logger, " ------------- Sensor measurement commencing... -------------\r\n" );
Delay_ms ( 100 );
}
#define LIGHTRANGER8_DISTANCE_MODE_MEDIUM
Definition lightranger8.h:1284
#define LIGHTRANGER8_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition lightranger8.h:1358
void lightranger8_calibrate_offset(lightranger8_t *ctx, uint16_t target_distance_mm, uint32_t period_ms, int16_t *offset)
LightRanger 8 calibrate offset function.
uint8_t lightranger8_set_distance_mode(lightranger8_t *ctx, uint8_t mode)
LightRanger 8 set distance mode function.
void lightranger8_power_on(lightranger8_t *ctx)
LightRanger 8 power on function.
void application_init(void)
Definition main.c:45
Application Task
A new data ready is checked as soon as possible which signals
the time required for the ranging sensor to perform the measurement. An acqured distance is shown on the LOG with the 2 seconds delay so the terminal is possible to read.
uint16_t distance;
Delay_1ms();
}
log_printf( &logger, " ----------------------\r\n" );
log_printf( &logger, " Distance: %.1f cm \r\n", ( float )distance / 10 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
void lightranger8_system_interrupt_clear(lightranger8_t *ctx)
LightRanger 8 system interrupt clear function.
uint8_t lightranger8_get_interrupt_state(lightranger8_t *ctx)
LightRanger 8 get int pin state function.
void application_task(void)
Definition main.c:107
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on mikroE github account.
Other mikroE Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.LightRanger8
Additional notes and informations
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. UART terminal is available in all Mikroelektronika compilers.