TOP Contributors

  1. MIKROE (2779 codes)
  2. Alcides Ramos (376 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139563 times)
  2. FAT32 Library (72041 times)
  3. Network Ethernet Library (57254 times)
  4. USB Device Library (47614 times)
  5. Network WiFi Library (43219 times)
  6. FT800 Library (42556 times)
  7. GSM click (29930 times)
  8. mikroSDK (28292 times)
  9. PID Library (26930 times)
  10. microSD click (26309 times)
Libstock prefers package manager

Package Manager

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]

< Back
mikroSDK Library

LightRanger 8 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.12

mikroSDK Library: 2.0.0.0

Category: Optical

Downloaded: 234 times

Not followed.

License: MIT license  

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.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "LightRanger 8 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "LightRanger 8 Click" changes.

Do you want to report abuse regarding "LightRanger 8 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


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.

lightranger8_click.png

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 );
  • lightranger8_init Initialization function.

    err_t lightranger8_init ( lightranger8_t *ctx, lightranger8_cfg_t *cfg );
  • lightranger8_default_cfg Click Default Configuration function.

    err_t lightranger8_default_cfg ( lightranger8_t *ctx );

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 );
  • 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 );
  • 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 );

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.


void application_init ( void ) {
    log_cfg_t log_cfg;                           /**< Logger config object. */
    lightranger8_cfg_t lightranger8_cfg;         /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.

    lightranger8_cfg_setup( &lightranger8_cfg );
    LIGHTRANGER8_MAP_MIKROBUS( lightranger8_cfg, MIKROBUS_1 );
    err_t init_flag = lightranger8_init( &lightranger8, &lightranger8_cfg );
    if ( init_flag == I2C_MASTER_ERROR ) {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    lightranger8_power_on( &lightranger8 );
    log_printf( &logger, " Wait until the configuration of the chip is completed...\r\n" );
    if ( lightranger8_default_cfg( &lightranger8 ) != 0 ) {
        log_error( &logger, " Sensor config error. " );
        for ( ; ; );
    }
    lightranger8_set_distance_mode( &lightranger8, LIGHTRANGER8_DISTANCE_MODE_MEDIUM );
    lightranger8_set_measurement_timing_budget( &lightranger8, budget_us );
    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 );
    lightranger8_calibrate_offset( &lightranger8, calibration_distance_mm, period_ms, &offset );
    Delay_ms ( 500 );

    lightranger8_start_measurement( &lightranger8, period_ms );
    log_printf( &logger, " -------------------------------------------------------------------------\r\n" );
    log_printf( &logger, " -------------    Sensor measurement commencing...    -------------\r\n" );
    Delay_ms ( 100 );
}

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.


void application_task ( void ) {
    uint16_t distance;

    while ( lightranger8_get_interrupt_state( &lightranger8 ) != 0 ) {
        Delay_1ms();
    }

    distance = lightranger8_get_distance( &lightranger8 );
    log_printf( &logger, " ----------------------\r\n" );
    log_printf( &logger, " Distance: %.1f cm \r\n", ( float )distance / 10 );
    lightranger8_system_interrupt_clear ( &lightranger8 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
}

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.


ALSO FROM THIS AUTHOR

LTE Cat.1 3 AUX Click

0

LTE Cat.1 3 Click (for Australia) is a compact add-on board for reliable 4G wireless communication. This board features the EG91AUXGA-128-SGNS, an LTE Cat 1 IoT module that meets the 3GPP Release 11 standard from Quectel. It supports multiple wireless standards, including LTE-FDD, WCDMA, and GSM, ensuring broad network compatibility. Key features include multi-band LTE support (B1/B2/B3/B4/B5/B7/B8/B28/B66), RX diversity for bands B1, B2, B5, and B8, and multi-constellation GNSS (GPS, GLONASS, BeiDou/Compass, Galileo, QZSS). It also integrates a 16-bit mono audio codec for voice functionality with support for CTIA standard headphones.

[Learn More]

DAC 14 Click

0

DAC 14 Click is a compact add-on board providing highly accurate digital-to-analog conversion. This board features the DAC53202, a 10-bit dual-channel programmable voltage/current-output DAC from Texas Instruments. The DAC53202 supports high-speed I2C and SPI serial interface alongside Hi-Z Power-Down mode and Hi-Z output during Power-OFF conditions. It has a programmable comparator mode for both DAC channels and one general-purpose I/O pin configurable as multiple functions allowing this smart DAC for processor-less applications.

[Learn More]

DSP Click

0

DSP Click is a compact add-on board that contains a multi-effects digital signal processor. This board features the V1000, a complete multi-effects audio DSP with ultra-high quality audio performance in a rapid ‘time-to-market’ solution from Coolaudio. The V1000 includes its integrated RAM with 16 built-in multi-effects and reverb controlled via I/O pins or I2C interface. Combined with a low-cost A/D-D/A codec like the V4220, this Click board™ provides an ultra-low cost FX solution. This Click board™ is suitable for applications as a standalone audio player, PC accessories, and Hi-Tech toys, conventional consumer electronic devices, and many more.

[Learn More]