Using the Protocol Analyzer
Introduction
Protocol Analyzers are used to send, receive, and spy on transactions in a variety of different digital communication protocols. This guide explains the use of WaveForms' Protocol Analyzer instrument. This instrument is also referred to as Protocol within WaveForms.
Prerequisites
- A Digilent Test & Measurement Device with Digital Input/Output Channels:
-
- Only the SPI and I2C protocols in Primary/Master mode are supported
- A Computer with WaveForms Software Installed
- Arduino UNO, or other microcontroller - optional, for testing
- Pmod AD5 - optional, for testing
Guide
1. Opening the Protocol Analyzer
1.1
Plug in the Test & Measurement Device, then start WaveForms and make sure the device is connected.
If no device is connected to the host computer when WaveForms launches, the Device Manager will be launched. Make sure that the device is plugged in and turned on, at which point it will appear in the Device Manager's device list (1). Click on the device in the list to select it, then click the Select button (2) to close the Device Manager.
Note: “DEMO” devices are also listed, which allow the user to use WaveForms and create projects without a physical device.
Note: The Device Manager can be opened by clicking on the “Connected Device” button in the bottom right corner of the screen (3), or by selecting “Device Manager” from the “Settings” menu at the top of the screen.
1.2
Once the Welcome page loads, in the instrument panel at the left side of the window, click on the Protocol button to open the Protocol Analyzer instrument.
1.3
Once the Protocol Analyzer instrument opens, the window contains the spy panel (1.) showing captured data, the configuration panel (2.) above the spy panel, and the control toolbar (3.) at the top of the window.
2. Using the Protocol Analyzer
The Protocol Analyzer can be used to spy on protocol communications to validate data flow. It may also be used to drive protocol communication to verify peripheral functionality. This section explains how to spy and then drive communication.
2.1 Hardware Setup
To demonstrate the capabilities of the Protocol Analyzer instrument, this guide uses a PmodAD5 and an Arduino UNO to spy on the SPI communications taking place between the host and peripheral. Afterwards, the Test and Measurement device will be used as the SPI master to drive communications with the PmodAD5. Make the pin connections as seen in each row of the table below:
Test & Measurement Device | Arduino Uno | Pmod AD5 |
---|---|---|
DIO 0 | Digital Pin 10 | CS |
DIO 1 | Digital Pin 13 | SCK |
DIO 2 | Digital Pin 11 | MOSI |
DIO 3 | Digital Pin 12 | MISO |
Ground (down arrow) | GND | GND |
N/A | 5V | VCC |
2.2 Arduino Setup
Note: This guide assumes the Arduino IDE is already installed.
Click Sketch>Include Library>Manage Libraries. In the search filter type AD7193 and install the library by Anne Mahaffey. Once the download has finished, close the Library Manager window, then click File>Examples>AD7193>AD7193_VoltageMeasure_Example. Click Upload to program the Arduino with the example sketch.
When the SPI tab is opened, it is initially set to spy on the data sent on MISO and MOSI, however it must be configured to match the PmodAD5 SPI communication properties. In the configuration panel, set the frequency to 1 MHz, the clock polarity to 1 and the clock phase to 1 (SPI Mode 3).
2.4 Protocol Spying
Click Receive () to begin spying on the data transmission between the Arduino and PmodAD5. The capture panel will start populating with data sent between the Arduino and the PmodAD5. Each line beginning with “Data:” represents a stream of data from when chip select goes low to when it goes high (in an Active Low Chip Select configuration, each line is measured by Chip Select going high then low). Each 8 bit packet is separated by a comma, with the MOSI and MISO data printed respectively, separated by a “|”.
2.5 Logic Analyzer
The Logic Analyzer can be used alongside the Protocol Analyzer to visualize the timing of the data being sent. In the Protocol Analyzer click the Logic Analyzer button in the top right corner, which opens the Logic Analyzer instrument.
In order to show both the Protocol Analyzer and the Logic Analyzer instruments on the screen at once, click on the Docking Windows button () in the top right corner of the screen.
Note: To return to the default tabbed view later, click on the “Tabbed Windows” button () adjacent to the Docking Windows button.
Click the Protocol button near the right side of the control the control bar, then SPI MOSI to set a trigger on the MOSI pin. A trigger configuration popup window will open. Change the Value setting to “h58” to observe the PmodAD5 sample data being sent.
Note: The Protocol Analyzer can't be used for spying if the Logic Analyzer is enabled.
Close the Logic Analyzer by clicking the X in the top right corner of the instrument.
2.6 Driving Communications
The Protocol Analyzer may also be used to drive peripheral communications. To begin, remove the 4 data connections between the Arduino and PmodAD5, keeping the 5V and GND pins connected. Next, click open the Master tab.
Set mode to Read Write. Next, in the Write (DQ0) text box, enter the sequence of bytes below:
h08 h38 h00 h64 h58 h00 h00 h00 h00
Clicking the Execute button will execute the SPI transmission, populating the Read (DQ1) section with the response, as well as outputting the write and read packets in the text box below.
Note: Using Multiple Instruments
The Protocol Analyzer instrument can be used with other WaveForms instruments. Using multiple instuments at the same time is helpful in a wide variety of situations. One example would be to use the Protocol Analyzer to configure a device under test, the Pattern Generator or Protocol Analyzer to stimulate the device, and capturing the result in the Logic Analyzer, all at the same time. More information on how instruments can be operated together can be found in the Using Cross Triggering guide.
It should be noted that while multiple instruments can use any Digital Input pin, and those pins can be used as Digital Outputs, no more than one instrument can control a Digital Output pin at a time. WaveForms accounts for this by disabling instruments using a shared output, or by displaying a message stating that a shared output is currently used by a different instrument.
3. Protocol Analyzer User Interface Overview
This section describes the various controls present in the Protocol Analyzer instrument.
The Protocol Analyzer interface is separated into a settings panel and a communication panel. The settings panel is used to configure which pins will be used for a protocol’s transmission and the protocol’s properties. The communication panel is where data may be inputted for transmission and incoming data is displayed. Each protocol has different settings and communication panels which will be discussed in the following sections.
3.1 UART Interface
The Settings panel is used to assign TX and RX to DIO pins. The settings panel is also used to configure the UART protocol properties: polarity, parity, baud rate, number of data bits, number of stop bits, and end-of-line character(s).
Spy mode configures the instrument to listen for incoming data. In the TX & RX field, controls and configuration are as follows:
- Clicking Cancel stops this process.
- Checking TX Echo causes any data transmitted using the TX field with also be displayed within the RX field.
The size of the text in the RX field may be adjusted with () and () above and to the right of the text field. The field may be cleared () and its contents saved () or appended () to a file.
The communications panel in Send & Receive mode, contains a TX field and a RX field.
The TX field has a text box where characters to be sent may be typed in. With the Auto option checked, characters are sent as they are typed. Otherwise, characters may be sent by clicking Send or by hitting the Enter key. When Escape is checked, escaped characters (\t, \n, \0, etc.) will be accepted. Clicking the Send File button, to the right of the Escape box, will transmit the contents of a chosen file.
The RX field in this mode contains the same settings as the TX & RX field in Spy mode.
3.2 SPI Interface
The Settings panel is used to configure which pins are used for chip select, clock, MOSI, and MISO, as well as to choose the chip select active level, clock frequency, polarity, phase, bit transmission order, and word transmission order.
The communications panel exposes four different modes of functionality, selected using the tabs at the top of the panel.
Spy mode simply configures the instrument to listen for incoming data on the MISO pin. The Mode dropdown allows selection between Three-wire, Standard, Dual and Quad modes. Checking the Command box tells the instrument to interpret the first N bits of a transaction as a command. The Data Bits field specifies the expected length of a SPI transaction.
Master mode allows the instrument to act as a SPI master.
- Mode allows selection of transmission mode.
- Command bits specifies command word length.
- Command specifies the command word which is sent before the read and/or write operation.
- Word bits specifies the word length. Words is the number of words for the next transmission.
- Write specifies the words to send and Read shows the read words.
When writing, data can be represented in binary, decimal or hexadecimal format, and may be imported from a binary or text file using the Open button. Likewise, data can be saved to a binary or text file using Save or Append when reading.
Custom mode allows a communication script to be written. Please see the Protocol page within WaveForms' Help tab for available functions and their descriptions.
Sensor mode also allows for a communication script to be written. It allows for more precise timing of repeated transactions than in Custom mode. The Iterations and Rate fields specifies the number of times and rate at which, respectively, that the loop function is called.
3.3 I2C Interface
The Settings panel allows the user to select which DIO pins are to be used as SCL and SDA, and to select a clock frequency and to enable support for I2C clock stretching. Specifying a frequency allows the device to filter glitches occurring for times shorter than 10% of the corresponding period.
Spy mode configures the instrument to listen for incoming data. Clicking Receive () causes the instrument to begin listening for incoming data, echoing it in the text box. Reception of data is stopped by clicking the Stop button (). Displayed data can be filtered according to address and direction.
Master mode allows the instrument to act as an I2C master. The Address and SubAddress are specified within the respective text boxes. The message to be sent may be typed within the Write text input, or by loading a binary file. Bytes displays the number of bytes that will be written. Clicking the Write button transmits the data. The number of Bytes to read is specified by the input next to the Read button. Clicking the Read button executes a read operation which is shown in the text field below the button. Read data bytes may be saved or appended to a binary or text file using the buttons to the right side of the window.
Custom mode allows a communication script to be written. Please see the Protocol page within WaveForms' Help tab for available functions and their descriptions.
Sensor mode also allows for a communication script to be written. It allows for more precise timing of repeated transactions than in Custom mode. The Iterations and Rate fields specify the number of times and rate at which, respectively, the loop function is called.
3.4 CAN Interface
The Settings panel allows the selection of the digital pins that are used for the CAN interface's TX and RX signals, the data polarity, and the data rate.
The communication panel contains a TX and an RX field. The TX field has a text box where the data to be transmitted can be entered. Clicking the Execute button sends the data. The TX field also has an ID input for the device identifier. Checking the Extended box will make the CAN packets use an extended device identifier. Checking the Remote box will instruct the instrument to send a Remote Frame, while leaving it unchecked instructs the instrument to send a Data Frame. The DLC field specifies the number of data bytes for a Remote transmission request, and is disabled when sending a Data Frame. Received data will be displayed in the RX field.
3.5 AVR Protocol
The AVR tab provides an interface for interacting with and programming AVR microcontrollers. As with other protocols, each of the signals associated with the protocol can be assigned to any of the device's digital I/O pins. Note that the “Chip” dropdown fills in many of the settings needed by other sections of the UI, specifically for the microcontroller being used. Additional information is printed in the text window at the bottom of the window.
3.6 Menu Bar
The File Menu contains options for saving/loading Protocol Analyzer configurations, exporting an image of the Protocol Analyzer and closing the instrument.
The Control menu contains options for starting and halting the instrument also listing hotkeys for the operations and a button for opening the Logic Analyzer.
The View menu contains a drop-down menu for setting the maximum number of lines, a drop-down menu for selecting a timestamp format to be prepended to the data and a checkbox which enables/disables line wrap.
From the Window menu other opened WaveForms instruments, the Welcome page and the Help page can be accessed.
Next Steps
For more guides on how to use the Digilent Test and Measurement Device, return to the device's Resource Center, linked from the Test and Measurement page of this wiki.
For more information on WaveForms visit the WaveForms Reference Manual.
For technical support, please visit the Test and Measurement section of the Digilent Forums.