Logic Analyzer – basics, how to use

Table of content:

  1. Introduction and potential use cases for Logic Analyzers;
  2. How to handle logic analyzer
    1. from HW side
    2. from SW side
  3. Usage examples

Introduction and use cases

Logic Analyzer is a tool which is extremely useful (almost necessary) during debugging of digital communication. With this component we are able to decode what happens during message exchanging between two IC’s.

You can imagine that you are implementing inside your project handling of a new protocol to your new chip, but you are observing that your device is not working in a proper way. First what to you will do is starting to analyze what your code is doing. Unfortunately it may be insufficient. Especially in cases that you can’t find any bug in the code.

In such situations the best idea is to connect logic analyzer between your two devices and listen in (overhear) the communication process. This way you can assure that your microcontroller (or any kind other device) is sending proper messages. In similar way you can check that other communication member is responding in a proper way.

Generally logic analyzer is a method to check on HW side that communication works ok.

Disadvantages of Logic Analyzer

  • Logic analyzer is not able to measure analog signals
    • for such purposes you should use oscilloscope;
  • Logic Analyzers are designed to operate with specified maximal frequency
    • if your communication uses higher frequency signals you have to buy another (most expensive also) logic analyzer

Presentation usage of Logic Analyzer

In this article I want to present clone of Salae Logic analyzer.

Logic Analyzer
Logic Analyzer

Key features of presented logic analyzer:

  • price – about 10$
  • number of channels: 8 inputs
  • 24MHz sampling frequency
    • it is possible to reduce sampling frequency (between 25kHz and 24MHz)
  • 2 LEDs (red for power indication, green for connected CH1)
  • max nr of samples 1G
  • possibility to chose method of sampling:
    • rising edge
    • falling edge
    • high level
    • low level
  • powered over USB
  • ability to decode following protocols:
    • UART (RS232)
    • SPI
    • I2C
    • CAN
    • 1Wire
    • Manchester
    • … many more over additional plugins
  • at purchasing you receive USB cable and connecting cables

In case of decoded protocols we are receiving not only the course of the signal, but also data are already translated either to ASCII or HEX form.

Hardware connection

In order to perform measurement we have to connect:

  • GND of the logic analyzer with GND of measured device;
  • Suitable channel to measured line.
    • When we need to measure more signals at the same time we have to also connect other channels.

When multiple channels are measured from different devices then GND have to be common.

Example with schematic will be presented later in this article.

Software usage

In order to be able to see results of a measurement we have to install proper program to handle data acquisition.

Logic analyzer presented here can be operated over to different programs:

  • Salae Software
    • This is official software of company SALAE. In this article I will show you how to use it.
    • Curiosity – SW was developed in Python with GUI Qt framework.
  • Open Source – Sigrok
    • This is free software which is also operable with this logic analyzer. In next article I plan to describe how to work with Sigrok.

Installation process

Here you have link to download Salae software. After installation you can find launcher in specified folder or in windows 10 just type “Logic” to search pan.

Searching of Salae SW on windows machine
Searching of Salae SW

Using the program

After connecting logic analyzer to the PC open “Logic” program. After it you should see following screen:

Salae Logic - after opening
Salae Logic – after opening

In order to present functionalities I will introduce you two logic analysis examples:

  1. UART communication sent from Arduino Leonardo to PC;
  2. Temperature measurement over 1-Wire communication (usage DS18B20 sensor);

1. Analysis of UART communication

To execute this exercise you will need:

  • Arduino Leonardo / Nano
    • or any other microcontroller capable to send UART messages like STM, AVR, PIC, 8051, etc.
  • UART TTL adapter;
  • Logic Analyzer
Exercise 1 - connection schema
Exercise 1 – connection schema
Exercise 1 - connection photo

Exercise 1 – connection photo

Perform following steps:

  1. Connect HW as on above schema and photo;
  2. Open Arduino studio and flash following program
    • hint: to perform this example you can also use Arduino Nano (or any clone of it);
    • copy code and paste to your Arduino IDE;
  3. Open terminal to observe UART communication and assure that everything works fine
    • Assure that settings are properly set (baudrate 9600, 8 data bit, no partity and one stop bit) – see photo below;
 Exercise 1 - Terminal settings
Exercise 1 – Terminal settings

Steps in Salae Software

1.Open Salae Logic;

2. Choose type of protocol (Async Serial for UART)

Exercise 1 -  Choose protocol type
Exercise 1 – Choose protocol type

3. In appeared window choose UART configuration – then click save

Exercise 1 -  Set UART properties
Exercise 1 – Set UART properties

4. Choose sampling rate and how long measurement should take. (click on green arrow next to Start button);

Exercise 1 -  Set sampling-rate and measurement duration
Exercise 1 – Set sampling-rate and measurement duration

in some cases when measured signals are to high frequency Salae Logic will suggest to increase sampling time;

5. at the final stage you can set how big should be presented measured signal (only to analyze comfort)

Set size of signal view
Set size of signal view

Start data acquisition;

  • click big green button Start;
  • you should observe result similar as on below photo:
Exercise 1 -  Measured Signal
Exercise 1 – Measured Signal

In order to zoom-in the view – press ctrl and mouse scroll mouse

Analyze the data

Exercise 1 -  Data Analysis
Exercise 1 – Data Analysis

It is possible also to choose type of decoding (like ASCII or HEX) – as in the picture above.

2. Temperature measurement – sensor DS18B20 over 1Wire

In the second exercise I will show You how to work with analyzing 1Wire communication;

To execute this exercise you will need:

  • Arduino Leonardo / Nano
    • or any other microcontroller capable to send UART messages like STM, AVR, PIC, 8051, etc.
  • DS18B20 temperature sensor;
  • Resistor 4.7kOhm (in case that you are not using any special kit / board with sensor where such resistor is already embedded)
  • Logic Analyzer
Exercise 2 -  connection schema
Exercise 2 – connection schema
Exercise 2 -  connection photo
Exercise 2 – connection photo

Perform following steps:

  1. Connect HW as on above schema and photo;
  2. Open Arduino studio and flash following program
    • hint: to perform this example you can also use Arduino Nano (or any clone of it);
    • copy code and paste to your Arduino IDE;
  3. Open terminal to in Arduino studio – you should receive communication messages like on below photo;
Exercise 2 -  Arduino terminal messages
Exercise 2 – Arduino terminal messages

Steps in Salae Software

1.Open Salae Logic;

If you have other analyzer already configured – click on settings window and click “Remove Analyzer”

Exercise 2 -  remove old analyzer
Exercise 2 – remove old analyzer

2. Choose type of protocol – Check 1Wire

Exercise 2 – choose 1Wire protocol

3. Choose channel 1

Exercise 2 -  choose channel
Exercise 2 – choose channel

4. Analog like in previous exercise:

  • choose sampling rate – 2Ms/s
  • measurement duration – 8s

and then click Start button

5. You should observe measurement like that:

Exercise 2 – results

Conclusions

That all for this presentations of possibilities to use Logic Analyzer.

If you have any question – feel free to share it in comment below.

Leave a Reply

Your e-mail address will not be published. Required fields are marked *