How to Quickly Launch 3D Optical Time-of-Flight Sensing Designs

Optical time-of-flight (ToF) distance measurement plays a fundamental role in diverse applications ranging from industrial sensing to gesture-based user interfaces. With the availability of accurate, high-speed multipixel ToF sensors, developers can implement more sophisticated three-dimensional (3D) sensing algorithms needed in these applications. However, development time is slowed due to the complexity of the multipixel optical sensing subsystem.

This article discusses the basic principles of ToF. It then introduces an optical ToF evaluation kit from Broadcom that enables developers to rapidly prototype accurate 1D and 3D distance measurement applications, as well as quickly implement custom optical ToF sensing solutions.

The basics of optical ToF technology

Used to obtain accurate distance needed in multiple applications, optical ToF technology enables measurements based on the time needed for light to travel through air. The specific calculations used to perform these measurements rely in general on two different approaches – direct and indirect ToF. In direct ToF, also known as pulse ranging, a device measures the time between transmission and reception of a particular light pulse by a ToF sensor using Equation 1:

How to Quickly Launch 3D Optical Time-of-Flight Sensing Designs Equation 1


c0 = Velocity of light in vacuum

∆T = Elapsed time between transmitting and receiving

Although simple in concept, the ability to perform accurate measurements with this approach faces a number of challenges, including the need for sufficiently powerful transmitters and receivers, signal-to-noise enhancement, and precise pulse edge detection.

In contrast, indirect ToF methods use a modulated continuous wave and measure the phase difference between transmitted and received signals according to Equation 2:

How to Quickly Launch 3D Optical Time-of-Flight Sensing Designs Equation 2


c0 = Velocity of light in vacuum

fmod = Laser modulation frequency

∆φ = Determined phase difference

Besides reducing transmitter and receiver power requirements, the indirect ToF approach relaxes requirements for pulse shaping, simplifying design complexity to perform 3D ranging and motion detection.

Both direct and indirect methods require careful design of the optical front-end and precise control of transmitter and receiver signals. For years, developers have been able to take advantage of integrated optical ToF sensors that combine transmitting devices and receiving sensors in a single package. Nevertheless, previous generations of these devices have typically required developers to trade off some combination of performance or operating characteristics such as power consumption, range, accuracy, and speed. Such compromises have emerged as a key impediment to a growing set of industrial sensing applications that need to operate at medium distances ranging up to 10 meters (m).

More advanced indirect ToF sensor modules like Broadcom’s AFBR-S50MV85G are designed specifically to address the growing need for high-speed, accurate results at medium distance ranges while maintaining minimum package size and power consumption. Based on this sensor, Broadcom’s AFBR-S50MV85G-EK evaluation kit and associated software development kit (SDK) provide a multipixel ToF sensor development platform that enables developers to rapidly implement 3D ToF sensing applications.

How an integrated module simplifies ToF distance measurement

Developed for industrial sensing applications, the AFBR-S50MV85G module provides a complete optical ToF sensing solution in a single package. Its integrated components include an 850 nanometer (nm) vertical-cavity surface-emitting laser (VCSEL) for infrared (IR) illumination, a hexagonal 32-pixel sensor matrix, integrated lenses for VCSEL and sensor optics, and an application-specific integrated circuit (ASIC).

Positioned in a fixed alignment with respect to the sensing matrix, the transmitter illuminates a target object, causing some number of pixels in the sensing matrix to detect the reflected IR signal. In basic operation, this enables the module to support accurate distance measurement from white, black, colored, metallic, or retroreflective surfaces—even in direct sunlight—thanks to its built-in ambient light suppression capabilities.

As the distance to an object decreases, automatic compensation for parallax errors allows measurements with virtually no lower limit of distance. At the same time, the combination of IR illumination and the sensing matrix enables availability of additional information about the object including its motion, speed, tilt angle, or lateral alignment. As a result, the module can provide data needed to determine direction and speed of a passing or approaching target object (Figure 1).

How to Quickly Launch 3D Optical Time-of-Flight Sensing DesignsFigure 1: Using data acquired from the AFBR-S50MV85G module’s 8 x 4 pixel sensing matrix, developers can implement 3D applications able to measure object movement characteristics. (Image source: Broadcom)

Orchestrating precise operation of its VCSEL and sensing matrix, the module’s built-in ASIC provides all the circuitry required for driving the VCSEL, analog signal capture from the sensing matrix, and digital signal conditioning (Figure 2).

How to Quickly Launch 3D Optical Time-of-Flight Sensing DesignsFigure 2: An ASIC integrated in the AFBR-S50MV85G module includes all the circuitry required to drive the module’s VCSEL light source, acquire received signals from the sensing matrix, and generate digital data for transfer across an SPI bus. (Image source: Broadcom)

The ASIC’s integrated supply circuitry enables the module to run off a single 5-volt supply, while its integrated factory-calibrated and temperature-compensated resistor-capacitor (RC) oscillator and digital phase locked loop (PLL) provide all the required clock signals. Due to this integration, developers can easily incorporate the module into their designs using a microcontroller unit (MCU) and a few additional external components. The interface with the MCU requires only a general-purpose input/output (GPIO) pin for a data-ready signal from the module, along with a connection through the module’s digital Serial Peripheral Interface (SPI) (Figure 3).

How to Quickly Launch 3D Optical Time-of-Flight Sensing DesignsFigure 3: Broadcom’s AFBR-S50MV85G module requires only an MCU and a few additional components for implementation of a complete ToF sensing system. (Image source: Broadcom)

Complementing this straightforward hardware design, the associated software functionality needed to implement distance measuring is all provided in Broadcom’s ToF driver software. While the module handles the optical data collection for distance measurement applications, the Broadcom ToF driver software included in the company-provided AFBR-S50 SDK performs all hardware configuration, calibration, and measurement steps. During measurement, the driver software extracts both the distance and amplitude values of the pixels.

How to rapidly develop a distance measurement application

Combined with the AFBR-S50 SDK, Broadcom’s AFBR-S50MV85G-EK evaluation kit provides a comprehensive platform for rapidly prototyping and developing distance measurement applications. The kit comes with an adapter board containing the AFBR-S50MV85G module, NXP’s FRDM-KL46Z evaluation board based on an Arm Cortex-M0+ MCU, and a mini-USB cable for connecting the evaluation board assembly to a laptop or other embedded system (Figure 4).

How to Quickly Launch 3D Optical Time-of-Flight Sensing DesignsFigure 4: Broadcom’s AFBR-S50MV85G-EK evaluation kit and associated software provide a complete platform for evaluating and prototyping ToF distance measurement applications. (Image source: Broadcom)

Performing ToF distance measurement with the evaluation kit requires only a few steps to get started. After downloading the AFBR-S50 SDK, a setup wizard guides the developer through a quick installation procedure. After the developer starts Broadcom’s AFBR-S50 Explorer software application included in the SDK package, the software connects to the AFBR-S50 evaluation board through the USB interface, receives the measurement data through the driver software running on the NXP board’s MCU, and allows the user to display the results in a 1D or 3D plot (Figure 5).

How to Quickly Launch 3D Optical Time-of-Flight Sensing DesignsFigure 5: The AFBR-S50 Explorer software simplifies evaluation of ToF measurements through 3D plots showing received illumination amplitude for each pixel in the ToF sensor matrix. (Image source: Broadcom)

As shown in Figure 5, the 3D plot view displays readings from each pixel, but the software provides an alternate view that allows developers to see only the pixels considered valid for measurement. In this alternate view, pixels that do not meet defined criteria are removed from the plot (Figure 6).

How to Quickly Launch 3D Optical Time-of-Flight Sensing DesignsFigure 6: With Broadcom’s AFBR-S50 Explorer software, developers can view streamlined measurement 3D plots that eliminate pixels not meeting predefined criteria. (Image source: Broadcom)

To explore measurement accuracy and performance in different application scenarios like lighting, reflectivity, and surface type, developers can view the impact of different sensing configurations such as using more pixels for enhanced 3D applications, or fewer pixels for 1D applications requiring more precise measurement. After evaluating measurement methods in their prototypes, developers can build on the sample software included in Broadcom’s AFBR-S50 SDK to quickly implement custom ToF sensing applications.

Building custom ToF sensing software applications

Broadcom builds support for ToF sensing applications around an efficient architecture based on the AFBR-S50 core library comprising sensor hardware-specific code, an application programming interface (API), and hardware abstraction layers (HAL) (Figure 7).

How to Quickly Launch 3D Optical Time-of-Flight Sensing DesignsFigure 7: Within Broadcom’s ToF operating environment, the ToF driver API provides user application code with access to calibration, measurement, and evaluation functions in the precompiled ToF driver core library. (Image source: Broadcom)

As part of the AFBR-S50 SDK package, Broadcom provides the core library as a pre-compiled ANSI-C library file that embeds all the data and algorithms needed to run the AFBR-S50MV85G hardware. Running on the distance measurement system’s MCU, the core library provides functionality including calibration, measurement, and evaluation to perform distance measurement with minimal processing load or power consumption. Because the core library functions handle all the underlying details, the basic measurement cycle seen by the developer is straightforward (Figure 8).

How to Quickly Launch 3D Optical Time-of-Flight Sensing DesignsFigure 8: The AFBR-S50 SDK ToF software minimizes processor workload using interrupts and callbacks. (Image source: Broadcom)

At the start of each measurement cycle (initiated by a periodic timer interrupt, or IRQ), the MCU initiates the measurement and immediately returns to an idle state (or continues processing some application code). After the measurement is completed, the AFBR-S50MV85G module uses the connected GPIO line to signal an interrupt, waking the MCU to initiate a data readout on the SPI bus before returning to its previous state. After the data readout is completed (signaled by an SPI done IRQ), the MCU executes code to evaluate the acquired ToF sensor data.

To prevent losing measurement data, the core library prevents the start of a new measurement cycle by blocking the data buffer until the evaluation routine is called. As such, developers would typically include a double buffer for raw data to permit interleaved execution of measurement and evaluation tasks.

For application software developers, the core library routines shield the details of calibration, measurement, and evaluation. In fact, developers can use the evaluation kit and AFBR-S50 Explorer application as a complete prototyping platform to deliver measurement data to high-level software application code.

For developers that need to implement custom application software, the AFBR-S50 SDK package combines the pre-compiled core library modules with several software examples. As a result, developers can quickly create their own ToF sensing applications by building on the sample applications provided in the SDK. Developers can access AFBR-S50MV85G hardware and AFBR-S50 core library functionality in their application-specific software code by calling functions in the AFBR-S50 SDK API and specifying their own functions for the various callbacks supported by the core library (see Figure 7 again).

Broadcom provides extensive documentation on the API and sample software, allowing developers to move quickly in adapting the software examples to their needs or start from scratch. In fact, the basic measurement and evaluation cycle is straightforward, simply matching custom functions and API calls to the measurement cycle (see Figure 8 again). For example, a measurement cycle as discussed earlier includes three phases: ToF device integration, data readout, and evaluation. The core library API calls needed to initiate these three phases include:

  • Argus_TriggerMeasurement(), which triggers a single measurement frame asynchronously
  • Argus_GetStatus(), which returns STATUS_OK on successful completion of the measurement
  • Argus_EvaluateData(), which evaluates useful information from the raw measurement data

Broadcom demonstrates this fundamental measurement loop in a sample application included in the SDK distribution, shown in Listing 1.

Copy int main(void) {    status_t status = STATUS_OK;        /* Initialize the platform hardware including the required peripherals    * for the API. */    hardware_init();        /* The API module handle that contains all data definitions that is    * required within the API module for the corresponding hardware device.    * Every call to an API function requires the passing of a pointer to this    * data structure. */    argus_hnd_t * hnd = Argus_CreateHandle();    handle_error(hnd ? STATUS_OK : ERROR_FAIL, "Argus_CreateHandle failed!");        /* Initialize the API with default values.    * This implicitly calls the initialization functions    * of the underlying API modules.    *    * The second parameter is stored and passed to all function calls    * to the S2PI module. This piece of information can be utilized in    * order to determine the addressed SPI slave and enabled the usage    * of multiple devices on a single SPI peripheral. */        status = Argus_Init(hnd, SPI_SLAVE);    handle_error(status, "Argus_Init failed!");        /* Print some information about current API and connected device. */    uint32_t value = Argus_GetAPIVersion();    uint8_t a = (value >> 24) & 0xFFU;    uint8_t b = (value >> 16) & 0xFFU;    uint8_t c = value & 0xFFFFU;    uint32_t id = Argus_GetChipID(hnd);    argus_module_version_t mv = Argus_GetModuleVersion(hnd);    print("n##### AFBR-S50 API - Simple Example ##############n"    " API Version: v%d.%d.%dn"    " Chip ID: %dn"    " Module: %sn"    "##################################################n",    a, b, c, id,    mv == AFBR_S50MV85G_V1 ? "AFBR-S50MV85G (v1)" :    mv == AFBR_S50MV85G_V2 ? "AFBR-S50MV85G (v2)" :    mv == AFBR_S50MV85G_V3 ? "AFBR-S50MV85G (v3)" :    mv == AFBR_S50LV85D_V1 ? "AFBR-S50LV85D (v1)" :    mv == AFBR_S50MV68B_V1 ? "AFBR-S50MV68B (v1)" :    mv == AFBR_S50MV85I_V1 ? "AFBR-S50MV85I (v1)" :    mv == AFBR_S50SV85K_V1 ? "AFBR-S50SV85K (v1)" :    "unknown");        /* Adjust some configuration parameters by invoking the dedicated API methods. */    status = Argus_SetConfigurationFrameTime( hnd, 100000 ); // 0.1 second = 10 Hz    handle_error(status, "Argus_SetConfigurationFrameTime failed!");        /* The program loop ... */    for (;;)    {       myData = 0;       /* Triggers a single measurement.       * Note that due to the laser safety algorithms, the method might refuse       * to restart a measurement when the appropriate time has not been elapsed       * right now. The function returns with status #STATUS_ARGUS_POWERLIMIT and       * the function must be called again later. Use the frame time configuration       * in order to adjust the timing between two measurement frames. */       Argus_TriggerMeasurement(hnd, measurement_ready_callback);       handle_error(status, "Argus_StartMeasurementTimer failed!");       STATUS_ARGUS_POWERLIMIT)       {          /* Not ready (due to laser safety) to restart the measurement yet.          * Come back later. */          continue;       }       else       {          /* Wait until measurement data is ready. */       do          {             status = Argus_GetStatus(hnd);          }          while (status == STATUS_BUSY);          handle_error(status, "Waiting for measurement data ready (Argus_GetStatus) failed!");          /* The measurement data structure. */          argus_results_t res;                    /* Evaluate the raw measurement results. */          status = Argus_EvaluateData(hnd, &res, (void*) myData);          handle_error(status, "Argus_EvaluateData failed!");                    /* Use the obtain results, e.g. print via UART. */          print_results(&res);          }       } } 

Listing 1: Sample code in the Broadcom AFBR-S50 SDK distribution demonstrates the basic design pattern for acquiring and evaluating ToF data from the AFBR-S50MV85G module. (Code source: Broadcom)

As shown in the listing, the three API function calls mentioned earlier form the backbone of the execution of a measurement cycle. By studying the API documentation and other sample applications in the SDK, developers can quickly implement complex 3D applications using the module’s ability to provide the data needed to determine advanced characteristics such as speed, direction, and tilt angle of a target object.


Optical ToF sensing devices have enabled applications in diverse segments requiring precise distance measurement, but limitations in measurement range, accuracy, or reliability have curbed expansion into applications like industrial sensing systems that require low-power devices able to deliver accurate results at longer ranges. An integrated optical ToF subsystem from Broadcom meets these emerging requirements for next-generation sensing applications. Using an evaluation kit based on this device, developers can rapidly implement systems for precision measurement in 1D ranging applications, and for complex object movement tracking in 3D applications.