Please update your browser. For the best Liquid Instruments experience, update to the latest version of Chrome, Edge, Firefox, or Safari. Update Microsoft Edge.
Liquid Instruments Logo
Products
Hardware Platforms
Moku:Delta
Moku:Delta
New
For advanced design and validation
Moku:Pro
Moku:ProFor versatile test and measurement
Moku:Lab
Moku:LabFor experimental research labs
Moku:Go
Moku:GoFor quick testing and debugging
Compare Hardware
Compare HardwareView a side-by-side of all Moku hardware
Technologies
GenInst Studio
New
Generate personalized instruments
Integrated InstrumentsProfessional-grade instruments at your fingertips
Neural NetworkFPGA-powered neural network integration
Multi-Instrument ModeCombine instruments to create a customized test system
Moku CompileCode, compile, and deploy to your Moku's FPGA
Software
MokuOSDownload the Moku app for Windows, macOS, iPadOS & visionOS
APIsPython, MATLAB, LabVIEW
UtilitiesCommand line and graphical tools for file conversion
Instruments
Analysis
Oscilloscope
Spectrum Analyzer
Frequency Response Analyzer
Lock-in Amplifier
Phasemeter
Logic Analyzer / Pattern Generator
Time & Frequency Analyzer
Data Logger
Generation
Waveform Generator
Arbitrary Waveform Generator
Control & Conditioning
PID Controller
Digital Filter Box
FIR Filter Builder
Laser Lock Box
Custom & Utility
GenInst Studio
New
Gigabit Streamer
Custom Instrument
Neural Network
Multi-Instrument Mode
Applications
Optics and Photonics
Microscopy and Spectroscopy
Photon Counting
Quantum Optics
Aerospace and defense
A&D Instrumentation
Component Test
Automated Testing
Semiconductor Test
Control Systems and Bode Analysis
MEMS Testing
AI and Machine Learning
Generative Instrumentation
New
Neural Networks
Education
Education and Research
Resources
App Notes
Blog
Case Studies
Coursework
Guides
Product Documentation
Publications
Webinars
White Papers
Support
Company
Contact Us
About Us
Leadership
Partners
News & Updates
Press
Events Calendar
Careers
Store
Moku:Delta
Moku:Pro
Moku:Go
Upgrade Moku:Pro
Upgrade Moku:Lab
Upgrade Moku:Go
0
Get a quote Buy Now
Build personalized instruments with GenInst Studio in minutes, not months. | Register for the webinar
White papers

Analyzing time-of-flight data from a LiDAR distance sensor

January 28, 2025

    One method for determining the distance to an unknown object involves reflecting pulses of light off the object and detecting the reflection. The time difference between the transmitted and received pulses is then calculated and multiplied by the speed of light, giving the total distance that the light traveled back and forth from the object. This method, called a time-of-flight measurement, is often used in radar and LiDAR applications. 

    In this application note, we use Moku:Go, an FPGA-based device from Liquid Instruments that offers a reconfigurable suite of test and measurement instruments, in conjunction with a commercial range finder to perform precise time-of-flight measurements. The range finder will emit and detect infrared pulses and provide a stream of serial data to the Moku:Go device. Moku:Go also serves as the power source and the decoder for the serial data provided by the range sensor. We will demonstrate how to visualize this serial data using both the Moku Oscilloscope and Logic Analyzer / Pattern Generator instruments. Finally, we will automate the measurement using the Moku Python API.  

    Required materials

    To perform this experiment, you will need the equipment listed below. See Figure 1 for a visual guide.

    Moku:Go: This setup specifically calls for a Moku:Go device because it offers a built-in programmable power supply. Here, we use it to power the LiDAR distance sensor. If you have different Moku hardware, then you will also need a 5V DC power supply. 

    Two banana-plug-to-alligator-clip wires: These will connect to the Moku:Go and provide 5 V of DC power to the range finder. 

    One BNC-to-alligator clip wire: This will be used for passing the serial data from the range finder to the input of the Moku:Go.

    LiDAR distance sensor: The range finder that we are using for this experiment is the TF Luna from Benewake. The TF Luna measures distance by calculating the time-of-flight of a pulse train of infrared light. This data is then sent to the receiver via UART serial encoding. A link to the documentation for this device is available in the References section at the end of the article. The TF Luna has six connecting wires; here, we use only the power, ground, and Tx wires. These connections are labeled in Figure 1. 

    Equipment required for the time-of-flight demo. Left: TF Luna, with the three connections labeled. Center: BNC-to-alligator connection wire. Right: Banana plug-to-alligator clip connection wires

    Figure 1: Equipment required for the time-of-flight demo. Left: TF Luna, with the three connections labeled. Center: BNC-to-alligator connection wire. Right: Banana plug-to-alligator clip connection wires.

    Setting up the equipment

    These steps outline all of the connections to be made between the instruments. The full schematic is shown in Figure 2. 

    • Prepare the LiDAR range sensor. With the TF Luna, you will need to remove one end of the connector, and then use wire strippers to expose a section where the alligator clips can connect. If you are using a different sensor, make sure you have its documentation on hand when following the subsequent steps. 

     

    • Connect the range sensor to the power supply. Attach an alligator clip to the Vpp wire (red), and insert the banana plug into Power 1 on the back side of Moku:Go.Repeat with the next wire, fixing the clip to the GND wire (black) and connecting the banana plug into the shared ground between Power 1 and Power 2. 

     

    • Connect the data transmission cable. Plug the BNC end of the data transmission cable into Input 1 on Moku:Go. Connect the red alligator clip (or probe, depending on your cable) to the Tx wire on the range sensor. If there is also a grounding clip on the cable, you can fix it to the GND pin on the range sensor, so that it and the power supply share a common ground. 

     

    Diagram depicting connection between a LiDAR distance sensor and Moku:Go

    Figure 2: Connections between the range sensor and Moku:Go. The device’s built-in power supply provides a 5 V power signal to the sensor. The Tx pin of the sensor provides serial data to Input 1 on Moku:Go.

    Verifying and viewing the output 

    These steps will outline how to set up the Moku Oscilloscope to view the transmitted signal from the range sensor. 

    1.  Launch the Moku Oscilloscope. From the main screen of the Moku software, click on the Oscilloscope to launch it in single-instrument mode. On the main Oscilloscope screen, there should be no signal on Channel A, as power has not yet been provided to the sensor.

    2. Enable the power supply. On the Moku screen, click on the menu icon in the upper left corner (three parallel lines). Then click “Power Supply.” A new menu window will appear on-screen. Click the slider next to PPSU 1 to enable it, then change the voltage value to “5.000.” You should see the range sensor begin to draw current (~50 mA) from Moku:Go, as shown in Figure 3.

    3. View the output on the Oscilloscope. Once power is enabled, return to the Oscilloscope screen. You should see a repeated pattern similar to the example shown in Figure 3. This is the serial data that is being transmitted by the range sensor, encoded in UART format. Each packet contains a number of bits of data, with the value of the bit determined by whether the voltage is high (3.3 V) or low (~200 mV). Having confirmed that the range sensor is functioning correctly, we will now use the Moku Logic Analyzer / Pattern Generator to interpret this serial data.

    The Moku Oscilloscope and Power Supply, showing bursts of UART serial data

    Figure 3: The Moku Oscilloscope and Power Supply, showing bursts of UART serial data.

    Decoding the serial output 

    We will now set up the Moku Logic Analyzer / Pattern Generator to decode the UART serial data. 

    1. Launch the Moku Logic Analyzer / Pattern Generator From the main screen of the Moku software, click on Logic Analyzer / Pattern Generator to launch it in single-instrument mode. Since this reconfigures the Moku:Go FPGA, you must re-enable the device’s Power Supply to power the range sensor. To do so, follow the steps outlined in the section above.

    2. Set up the acquisition. On the right-hand side of the screen, you will see the Acquisition menu. Change the source to “Analog inputs,” which will bypass the 16-bit digital I/O and use the analog inputs 1 and 2 as two-bit data. Since UART is a binary format, this is acceptable. Remove the Bit 1 display by clicking the “X” to the right of the plot. Under the “Timebase setting,” set the time span to 1.5 ms and the offset to -300 𝛍s. If the range sensor is powered on, you should see the serial pattern appear on the Bit 0 plot, as shown in Figure 4.

    The Moku Logic Analyzer / Pattern Generator, showing a sequence of UART serial data

    Figure 4: The Moku Logic Analyzer / Pattern Generator, showing a sequence of UART serial data, similar to the example shown in Figure 3.

    3. Add the protocol decoder. The Moku Logic Analyzer / Pattern Generator can decode a number of standard protocols, including UART, which converts the serial data into hexadecimal format. To add a decoder, click the plus sign in the top left of the screen, as shown in Figure 5.

    Figure 5: Adding the protocol decoder for the UART serial data.

    4. Configure the protocol decoder. For the data to be properly decoded, the instrument must know how many bits of information are contained in the UART sequence, as well as the rate at which the information is arriving (also known as the Baud rate). This will depend on the exact nature of your range finder. If you are using the TF Luna, the configuration is shown in Figure 6. The data width is 8 bits with 1 stop bit, there is no parity check, and the default Baud rate is 115200. If the decoder settings match with those of the transmitter, you will see the hexadecimal numbers appear in the UART decoder line, as shown in Figure 6.

    UART serial data converted to hexadecimal numbers

    Figure 6: UART serial data converted to hexadecimal numbers. 

    7. Interpret the data. Refer to the documentation of your range sensor to make sense of the numerical data decoded by Moku:Go. In the case of the TF Luna, the default 9-byte data sequence is shown in Figure 7. The first two bytes are always 59, which is confirmed by the decoded data. Bytes 2 and 3 in this case provide the distance information in centimeters. If you put your hand over the range sensor, you can see this value change appropriately.

    TF Luna datasheet excerpt

    Figure 7: An excerpt from the TF Luna datasheet helps us interpret the results. 

    Automating the measurement with Python 

    Unfortunately, hexadecimal numbers are not intuitive for the perception of distance. In this section, we will use the Moku Python API to create an automated distance measurement tool that will continuously refresh the data. The following script is available from the Liquid Instruments Github page. A tutorial for setting up the Moku Python API is available here. 

    1. Import and connect. In addition to any “standard” imports that are needed, you must import any instruments you plan to deploy onto Moku:Go, as shown in Figure 8. In this example, we create an instance of the Moku Logic Analyzer / Pattern Generator and specify the device’s IP address. 

    Python code to import and connect the Moku Logic Analyzer, specifying the device's IP address.

    Figure 8: Import and connect the code.

    2. Set up the power supply. Any function of Moku software can also be performed using the API, including the DC power supply. Specify your desired supply, as well as the maximum voltage and current values, as shown in Figure 9.

    Setting up a DC power supply with Python.

    Figure 9: Set up the DC power supply. 

    3. Set up the Moku Logic Analyzer / Pattern Generator. This simply requires using a number of commands to provide the same information to the protocol decoder that we specified earlier, including the data width, stop width, Baud rate, and channel number. Note that “get_data” returns the entire trace of raw data, so we only ask it for the protocol analyzer data, labeled ‘pa1.’

    Set up a protocol decoder with Python.

    Figure 10: Set up the protocol decoder.

    4. Display the data. Within the data array, we can see that the state variable alternates between “idle” and “data.” We want to look at the 3rd data bit, which corresponds to the 5th element in the array. Within this dictionary, we want the value attached to the ‘data’ key, which gives us our distance value in centimeters. After recovering this value, we use the tkinter package to create a display that updates with the most recent measured distance value. The code, along with an example window, is shown in Figure 11.    

    Figure 11: The Python code for an array for a continuously updating display, along with the display itself. 

    Figure 11: The code for a continuously updating display, along with the display itself. 

    Conclusion

    Moku:Go is a powerful and flexible multi-tool for electronic test and measurement applications. In this demonstration, we used Moku:Go in conjunction with a range sensor to perform a time-of-flight distance measurement. Thanks to the flexibility of Moku:Go, we can power the sensor with the device’s programmable power supply, as well as view and decode the serial data using the Moku Oscilloscope and Logic Analyzer / Pattern Generator instruments. We also implemented a continuously updating range measurement script using the Moku Python API. 

    To learn more about the Moku platform, click here. To explore the instruments cost-free, download our desktop app and select demo mode. 

    Questions?

    Get answers to FAQs in our Knowledge Base

    If you have a question about a device feature or instrument function, check out our extensive Knowledge Base to find the answers you’re looking for. You can also quickly see popular articles and refine your search by product or topic.

    Join our User Forum to stay connected

    Want to request a new feature? Have a support tip to share? From use case examples to new feature announcements and more, the User Forum is your one-stop shop for product updates, as well as connection to Liquid Instruments and our global user community.

    References

    Benewake TF Luna documentation: https://en.benewake.com/DataDownload/index_pid_20_lcid_21.html

    Try Moku in demo mode Download the Moku app → Get answers to FAQs Visit Knowledge Base → Connect with Moku users Join the user forum →

    Other Recommended White papers

    White papers
    Building advanced triggers for test using AI-enabled tools

    Compressing weeks of custom development and replacing fixed Oscilloscope trigger modes with Generative Instrumentation

    Date: July 14, 2026

    White papers
    Scaling parallel device testing with Python and FPGA-based tools

    How combining software flexibility with hardware determinism increases test throughput and reliability in R&D and production

    Featuring: Moku:Delta, Spectrum Analyzer, Oscilloscope, Python

    White papers
    Visualizing and characterizing qubit states in quantum systems

    Learn about the representing qubit states with the Bloch sphere, along with common pulse sequences and tips for implementation with Moku

    Featuring: Arbitrary Waveform Generator, Lock-in Amplifier, Moku:Delta, Moku:Pro

    Date: August 6th, 2025

    Back to all White papers

    Nav

    • Products
    • Instruments
    • Resources
    • Support
    • Company
    • Contact Us
    • Privacy Policy
    • Terms of Use

    Offices

    United States
    (619) 332-6230
    12526 High Bluff Dr.
    Suite 150
    San Diego, CA 92130

    Australia
    +61 2 6171 9730
    243 Northbourne Avenue
    Suite 1, Level 1
    Lyneham, ACT 2602

    Australia
    +61 3 7073 3594
    Suite 5C, Level 5,
    700 Swanston Street,
    Carlton, VIC – 3058

     

     

    Follow us

    LinkedIn YouTube X Facebook Instagram

    官方微信

    © 2026 Liquid Instruments. All rights reserved.