Learn / Tools and measurement / Oscilloscope basics

Using a Logic Analyser

ReviewedIntermediate MakerAbout 6 min
4.98V
In short

Using a Logic Analyser: the short answer

A logic analyser records many digital lines at once as highs and lows over time. A low-cost 8-channel, 24 MHz USB analyser works with the free PulseView software (from the sigrok project) and is one of the most useful tools for firmware work.

Level
Intermediate
Time
About 6 min
Topic
Tools and measurement
You will learn to

Capture digital signals with a low-cost logic analyser, decode UART, I2C and SPI, and find timing bugs.

Before this: I²C Addressing & Shared Buses, SPI, UART & Interface Trade-offs

A logic analyser records many digital lines at once as highs and lows over time. A low-cost 8-channel, 24 MHz USB analyser works with the free PulseView software (from the sigrok project) and is one of the most useful tools for firmware work. Unlike an oscilloscope, it does not show voltage levels or ringing, but it captures long sequences on several channels and decodes protocols into readable bytes.

Connect the analyser's ground to the circuit's ground first, then clip channels onto the signals: for I2C, SDA and SCL; for SPI, SCLK, MOSI, MISO and CS; for UART, TX and RX. Choose a sample rate at least four times the fastest signal, preferably more: a 400 kHz I2C bus needs at least 2 MHz, and 4 MHz gives cleaner timing. Set a trigger on a falling edge of CS or SDA so the capture starts when the transfer does. These cheap analysers are usually rated for 0 to 5 V inputs; never connect them to higher voltages.

Add a protocol decoder in PulseView and the waveform turns into annotated bytes: addresses, ACK or NACK, register values. Now you can check what your code really sends. A missing ACK after an address means the device is not answering (wrong address or wiring); data sent in the wrong bit order points to an SPI mode mismatch; a UART decode full of garbage usually means the wrong baud rate. Use the timing cursors to measure delays, such as how long a sensor takes between a start command and data ready.

Sample fast enough

A logic analyser records digital levels over time. Its sample rate should be at least four times the signal's fastest edge rate, and ten times is better. A 1 MHz SPI clock needs at least 4 MS/s. Too slow and edges are missed or shifted, and the decoder shows errors that are really a sampling problem.

Common low-cost analysers handle 8 channels at 24 MHz, which suits UART, I²C and SPI on a hobby project.

Decoding a protocol

Connect a ground, then each signal, and give each channel a name. Set the trigger to a falling edge of the chip-select, the I²C start or the UART's first start bit. Add a decoder, such as UART with the right baud rate, or I²C, and the software shows bytes, addresses and acknowledgements.

For UART, a wrong baud rate gives garbled bytes, so try the common ones. For I²C, a missing acknowledge after the address means the device did not answer, which points to wiring, power or the wrong address.

What it does not show

A logic analyser shows only high or low, not whether the voltage level is correct or the edges are clean. If the data looks right but the system fails, use an oscilloscope to check the levels, the rise time and ringing.

Common mistakes
  • Sampling too slowly and blaming the protocol for errors.
  • Forgetting to connect the analyser's ground to the circuit's ground.
  • Using a logic analyser to judge signal quality that needs an oscilloscope.
Intermediate lesson · Maker plan

Practise this lesson with Maker

The explanation above is free for everyone. The practice for Intermediate lessons in every domain are part of the Maker plan at ₹499 a month, and Pro includes them too.

With Maker you also get: a worked example, a hands-on task, a 3-question check.

Common questions

What will I learn in "Using a Logic Analyser"?

Capture digital signals with a low-cost logic analyser, decode UART, I2C and SPI, and find timing bugs.