Linux Logic Analyser - sigrok

I recently acquired an XZL_studio AX logic analyser from a friend, this is a clone of the USBee-AX device with a much lower price, ~£50. I had previously used this device with the USBee software but always found it to be buggy, infact, it was almost unusable. I tried to get this running on a virtual machine without joy, in the end, I had to install Windows XP on an old machine I had lying around, and even then, I found the software was constantly crashing. At the time I was looking for a Linux replacement, but found none, that is, until recently.


After I acquired this device nothing was holding me back, I had to find a suitable piece of Linux software that would allow to use the logic analyser without having to virtual-boot a Windows partion, or even worse, a windows machine - something I don't even own anymore!. I soon found the sigrok project which provided exactly what I was looking for.

At present the sigrok support for my device is somewhat limited; based on my model, the analogue channels are currently not working, but everything else should be okay. Also, there doesn't seem to be a sound GUI application as yet, that said, I did have some success with PulseView, and with two more apps on the way, it shouldn't be too long before a stable GUI app is released. Until such a time, I will settle for the command line utility, sigrok-cli (man page). I am a Linux user after all.

picture of pulseview


So just some basics at this stage, I have been using sigrok-cli for all of a day, and it certainly seems much more stable that the propriety USBee software I was using on Windows. Some example commands are presented below

Capturing a trace

Okay, so let's start with a simple one, capture a single trace from a RS232 line converter IC, specifically, a MAX232 IC connected to my PC serial port. The following command captures data from a single probe connected to the TTL, R1OUT(12) pin of the MAX232. The command to start the capture is as follows, along with the output when we send a 'U' character to the serial port (We send a 'U' since this provides a nice symmetric 01010101 bit pattern).

$ sigrok-cli -l 2 --driver=fx2lafw --output-format bits --probes 0 --triggers 0=0 --wait-trigger --samples 50 --device samplerate=25k
libsigrok 0.2.0
Acquisition with 1/8 probes at 25 kHz
0:00011000 11000111 00111001 11111111 11111111 11111111 11

Command Flags:

  • -l 2 - Only report errors and warnings;
  • --driver=fx2lafw - Use the fx2lafw driver;
  • --output-format - bits Output the data in bit format;
  • --probes 0 - Only capture probe 0;
  • --triggers 0=0 - Trigger when trigger probe 0 is LOW;
  • --wait-trigger - Wait for trigger before printing data;
  • --device samplerate=25k - Set the sample rate for the device to 25 KHz;
  • --samples 50 - Only capture 50 samples.

From the output above we can clearly see the changes that we would expect from sending the 'U' character. What we do notice is that there is a slight mismatch between sampling frequency and the bits actually changing, this is due to us not being able to perfectly match the sampling frequency with the bit rate of the serial port, 115200, in this case. We can get further details on the supported sampling frequencies for our device, along with some additional data using the '--show' flag as follows:

$ sigrok-cli --driver fx2lafw --show
CWAV USBee AX with 8 probes: 0 1 2 3 4 5 6 7
Supported triggers: 0 1 
Supported device options:
    samplerate - supported samplerates:
      20 kHz
      25 kHz
      50 kHz
      100 kHz
      200 kHz
      250 kHz
      500 kHz
      1 MHz
      2 MHz
      3 MHz
      4 MHz
      6 MHz
      8 MHz
      12 MHz
      16 MHz
      24 MHz

Output formats

As I already mentioned above, there are a number of limitations with the current GUI applications that can be installed with sigrok, however, we can still get "pretty" visual outputs when using sigrok-cli, see Output Formats for more info.

ASCII Output

The simplest method of getting a visual output is to use the 'ASCII' output format as follows:

$ sigrok-cli -l 2 --driver=fx2lafw --output-format ascii --probes 0 --wait-trigger --triggers 0=0 --samples 50 --device samplerate=25k 
libsigrok 0.2.0
Acquisition with 1/8 probes at 25 kHz

While very basic, it still provides some visual output, however, it gets better still


pulseview is a QT based GUI for sigrok. In these early stages of its lifecycle I did find a number of basic issues, specifically, 1)I found the GUI would often crash when obtaining a trace, and 2) one is not able to select a trigger when performing a capture. However, it is still perfectly usable for graphically viewing a trace when using sigrok-cli to perform the actual capture.

So, first things first, we need to grab a capture using sigrok-cli and output the trace to a file using the sigrok-cli default output format, '.sr' as follows - This '.sr' format it is a binary format. It can be reloaded into sigrok-cli as an input file at any time, allow one to change to a different output format.

sigrok-cli -l 2 --driver=fx2lafw  --wait-trigger --triggers 0=1 --samples 50000000 --device samplerate=8m -o

I had the analyser hooked up to an ATmega48 AVR running the following code to simulate an 8-bit counter:

 *                      divide_8.c
 *              Created on:             07/03/2013
 *              Created by:             Steven Swann -
 *              Completion:             07/03/2013
 *              Device:                 ATmega48/162
#include <avr/io.h>
#if !defined F_CPU
  #define F_CPU = 8000000
#include <util/delay.h>
 *      Macro Definitions
#define SETBIT(x,y) (x |= (y))          // Set bit y in byte 
#define CLEARBIT(x,y) (x &= (~y))       // Clear bit y in byte x
#define CHECKBIT(x,y) (x & (y))         // Check bit y in byte x
int main(void)
        int i = 0x00;
        DDRB = 0xff;                                                    //Setup of DDRs
        DDRC = 0x0f;                                                    //Setup of DDRs
          PORTC = i;
          PORTB = i;

Once complete, we can then start up pulseview - just type 'pulseview &' from the command line - and load the newly generated '.sr' file to get an output similer to the following:

Pulseview output

As I mentioned above, pulseview does have its limitations, however, the interface iteslf is extrememly smooth and stable, and perfect for viewing the outputs from sigrok-cli.

Other output formats

There are a number of other output formats to choose from. Along with a number of GUI viewers that can be used, check out Output Formats wiki for more info.


When I get some more spare time I will try to see how accurate the timings from the device are by capturing the output from a traditional oscilloscope and comparing the two results.


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Enter the characters shown in the image.
By submitting this form, you accept the Mollom privacy policy.