====== Using the Logic Analyzer====== ~~TechArticle~~ {{test-and-measurement/analog-discovery-pro-2230/logic-screenshot.png?nolink|}} ===== Introduction ===== Logic Analyzers are used to capture and view digital signals. This guide explains the use of WaveForms' //Logic Analyzer// instrument. The instrument is also referred to as //Logic// in WaveForms. ---- ===== Prerequisites ===== * A Digilent Test & Measurement Device with Digital Inputs: * [[test-and-measurement:analog-discovery-3:start|Analog Discovery 3]] * [[test-and-measurement:analog-discovery-pro-5250:start|Analog Discovery Pro (ADP5250)]] * [[test-and-measurement:analog-discovery-pro-3x50:start|Analog Discovery Pro (ADP3450/ADP3250)]] * [[test-and-measurement:analog-discovery-pro-2230:start|Analog Discovery Pro (ADP2230)]] * [[test-and-measurement:analog-discovery-studio:start|Analog Discovery Studio]] * [[test-and-measurement:digital-discovery:start|Digital Discovery]] * [[test-and-measurement:analog-discovery-2:start|Analog Discovery 2]] * [[test-and-measurement:analog-discovery:start|Analog Discovery (Legacy)]] * A Computer with WaveForms Software Installed ---- ===== Guide ===== ==== 1. Opening the Logic 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 reopened 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.// {{ reference:test-and-measurement:guides:waveforms-oscilloscope-device-manager.png?600 |}} === 1.2 === Once the Welcome page loads, in the instrument panel at the left side of the window, click on the **Logic** button to open the //Logic Analyzer// instrument. {{learn:instrumentation:tutorials:waveforms-instrument-panel:waveforms-instrument-panel-logic.png?600}} === 1.3 === Once the //Logic Analyzer// instrument opens, the window contains the data plot (1) showing captured data, the configuration panel (2) to left of the plot, and the control toolbar (3) at the top of the window. {{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:1.3.png?600}} ---- ==== 2. Using the Logic Analyzer==== //This section walks through setting up the //Logic Analyzer// to capture an incoming data signal// === 2.1 Hardware Setup === Choose two of your device's digital pins, one of which will act as an input, and one of which will act as output. Connect these two pins together to create a simple loopback, as seen in the image to the right. Take note of which pins are used, as WaveForms must be told which pins it is to use. **Note:** //Digital pins that work as both input and output can be used in both modes at the same time. If desired, one such pin can be chosen for both input and output for this guide. In this situation, no additional hardware setup is required.// {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:default-hardware.png?nolink&600 |}} ---- A [[https://digilent.com/shop/digital-discovery-high-speed-adapter-and-logic-probes/|High Speed Adapter]] is available for the Digital Discovery which can be used to take advantage of the highest sampling frequencies the device offers. --> Click here if using the Digital Discovery High Speed Adapter # This adapter should be connected to the Digital Discovery's "HIGH SPEED INPUTS" pin group with the Ground symbols (downward facing arrows) pointing to the bottom of the device. While the adapter can be connected "upside down", doing so will result in the pin names shown in the [[test-and-measurement/digital-discovery/reference-manual#accessories|Digital Discovery Reference Manual]] not matching the actual pin names. Note that these pins cannot be used for digital output. If desired, one of these input pins can be used in this guide, along with any of the Digital Discovery's output-capable pins. Connect one of the provided black/red differential probes to the High Speed Adapter. Make sure that the black cable is connected to the side with the ground arrow. The black cable should be connected to the ground of the device under test (in this case, the Digital Discovery's ground). The red cable (the positive side of the p/n differential pair) should be connected to the chosen digital output. {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:high-speed-hardware.png?nolink&600 |}} <-- ---- === 2.2 Software Setup === In the //Logic Analyzer// instrument that was previously opened, in the left panel, select "Click to Add channels" or the green plus button ({{:learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:symbol_plus.png?nolink}}). The menu that pops up allows signals to be added as individual lines, a bus, a standard protocol, or a custom protocol. To add individual pins as their own lines, select "Signal" and use CTRL and/or SHIFT to select multiple pins from the list that pops up. For now, select only the pin you chose as input and click the **Add** button. {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:add-channels.png?nolink&600 |}} Next, check the sampling frequency which will be used for the digital input. Depending on the Test and Measurement device used, some frequencies may only be available with certain groups of pins. These frequency and pin requirements can be discovered through dropdowns in the Logic Analyzer instrument's toolbar, pictured to the right, as well as through the device's Reference Manual. If the device used does not support variable sampling frequencies, these dropdowns will be grayed out. {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:frequency-selection.png?nolink&600 |}} {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:pin-selection.png?nolink&600 |}} To use the //Logic Analyzer//, some signal/s must be applied to the digital input/s used. This guide uses the device's //Pattern Generator// instrument to apply a signal to the chosen digital input pin through the chosen digital output pin. For a detailed tutorial on using the //Pattern Generator// instrument, please see the [[test-and-measurement:guides:waveforms-pattern-generator]] guide. Return to WaveForms' Welcome page by clicking on its tab at the top left of the window and click the //Patterns// button. Alternatively, press the green plus button next to "Welcome" in the tabs list to add the instrument. {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:add-patterns.png?nolink&600 |}} As before, in the left pane, click the "Click to Add channels" button or the green plus button ({{:learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:symbol_plus.png?nolink}}). From "Signal" select the pin chosen as digital output and click the **Add** button. Under the **Type** column, choose //Clock// and leave the other settings in their default state. {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:choose-type.png?nolink&600 |}} ---- === 2.3 Capture Data === Click the //Pattern Generator's// Run button ({{:learn:instrumentation:tutorials:waveforms-buttons:waveforms-run.png?nolink}}) in the control bar (1 in the image to the right) to begin outputting the signal on digital input/output pin 0. Return to the //Logic Analyzer// instrument, then click the Run button (2). The signal being generated by the //Patterns// instruments will appear in the plot. Change the time scaling by selecting a different value in **Base** (3), located in the top right of the instrument (see [[#time_configuration|Section 3.4]] for more on this). To save the captured data, select "File" (4) from the top of the window and choose either "Save Acquisition" (allows for WaveForms to reopen the instrument with the data preloaded) or "Export" (allows export of a .csv file or a screenshot). {{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:2.2.png?600}} ---- --> Click here for an example of decoding a Digital Protocol # From the WaveForms home page, open the //Pattern Generator// instrument, then click on the **Click to Add channels** button. From the list that opens , select **Signal**, then add **DIO 0**. {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:protocol_add_channel.png?nolink&400 |}} Set **Output** to **PP**, **Type** to **Custom** and **Parameter 1** to **1.2 kHz**, then open the signal editor (for more details see: [[test-and-measurement:guides:waveforms-pattern-generator]]). {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:protocol_channel_properties.png?nolink&400 |}} In the signal editor, click on the **Import** button, select txt as file type then download, unzip and select the example file provided here: {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:uart_example.zip |}}. On the pop up window, leave everything as it is. Accept the changes and start the //Pattern Generator// with the **Run** button. {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:protocol_import.png?nolink&400 |}} With the green plus button on the Welcome tab ({{:learn:instrumentation:tutorials:symbol_plus.png?nolink|}}), open the //Logic Analyzer// instrument, then click on the **Click to Add channels** button. From the list that opens , select **UART**, then add **DIO 0** with the default settings. {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:logic_add_channel.png?nolink&200 |}} At the trigger options, choose **Auto** and **Protocol**, select **UART** and set **Trigger** to **Value** and **Value** to **02[STX]** (start of text character), then accept the changes. Set the **Base** to **10 ms/div** and the **Position** to **30 ms** to make the message easily readable (You might need to play around with the Position value, to see the message). {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:logic_add_trigger1.png?nolink&200 |}} {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:logic_add_trigger2.png?nolink&600 |}} Start the //Logic Analyzer// with the **Run** button to display the message. Once the UART transactions are generated by the //Pattern Generator//, and captured by the //Logic Analyzer//, you will be able to see the data captured. This includes both the input signal's waveform, as well as the data encoded in the transactions, as both hexadecimal numbers and the ASCII representations. {{ :learn:instrumentation:tutorials:waveforms-logic-analyzer:protocol_output.png?nolink&600 |}} <-- ---- ==== Note: Variable Digital Supplies ==== {{section>test-and-measurement:guides:waveforms-digital-supplies&noheader}} ==== Note: Analog Discovery Pro (ADP3450/ADP3250) Sample Rate ==== {{section>test-and-measurement:analog-discovery-pro-3x50:change-max-sample-rate&noheader}} ==== Note: Using Multiple Instruments ==== The //Logic 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 [[test-and-measurement:guides:waveforms-cross-triggers]] 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. Logic Analyzer User Interface Overview ==== //This section walks through the wide variety of controls and features available in the //Logic Analyzer// instrument// === 3.1 Control Buttons === The control bar near the top of the instrument window contains two buttons used to start/stop the capture of data. The Run button continues capturing data until it is stopped. The Single button will fill a buffer based around a pre-defined trigger (explained in following sections). The buffer size and position relative to the trigger are set by the **Position** and **Base** options (explained in [[#time_configuration|Section 3.4]]). {{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:control_buttons.png}} === 3.2 Buffer Configuration=== To the right of the control buttons are various options for filling the buffer and selecting which buffer to look at. The **Mode** drop-down changes between the five acquisition modes: //Repeated//, //Screen//, //Shift//, //Record//, and //Sync//. //Record// mode repeatedly fills buffers with data and displays them on the screen as they're filled until the Stop button is pressed. //Screen// and //Shift// modes continuously add new data to the screen as it streams in instead of showing full buffers as in //Record//. //Screen// will fill the screen from left to right and then add new data on the left, overwriting the previous data set. //Shift// will show new data as it comes in from the right, in effect scrolling the data from right to left. //Record// allows for large amounts of data to be captured at a lower sample rate. This can be used for recording data from a sensor that needs to be monitored for several minutes or hours. //Sync// offers the ability to use an external clock to control when the //Logic Analyzer// records samples. Useful with communication protocols such as SPI, I2C, and UART. The **Buffer** option allows for selection of buffers, as each acquisition fills a new one (except in //Repeat// mode, where buffers are sequentially filled). The green plus button ({{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:symbol_plus.png?nolink}}) creates tabs for each buffer for easy switching. {{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:buffer_control.png}} === 3.3 Trigger Configuration=== The **Trigger** drop-down allows for selection of the trigger type: //None//, //Auto//, and //Normal//. //None// starts the acquisition immediately after Run is clicked. //Auto// starts the acquisition either on the trigger event, or approximately 2 seconds after Run is pressed if the trigger event doesn't occur. //Normal// starts the acquisition only on the trigger event. The **Source** drop-down allows the user to trigger the oscilloscope based on events in other instruments. /*For more information, please see the **Cross-Triggering Guide** FIXME link.*/ The **Inputs** drop-down (pictured on the right) is available for Digilent's **Digital Discovery** to specify which DIO pins to use at a specified frequency. {{learn:instrumentation:tutorials:analog-discovery-studio-pattern-generator:dd_sample_rate.png}} The three buttons labeled "Simple", "Pulse", and "Protocol" allow for customization of trigger conditions. //Simple// is used in conjunction with the Trigger column (labeled T in the //Logic Analyzer// instrument, see image at right). Each channel can be set to trigger on various events: Ignore ({{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:x.png?nolink}}), Low ({{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:0.png?nolink}}), High ({{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:1.png?nolink}}), Rise ({{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:rising.png?nolink}}), Fall ({{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:falling.png?nolink}}), and Edge ({{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:edge.png?nolink}}). //Pulse// opens a menu to configure a trigger on a pulse that is either shorter than a specified time (**Glitch**), longer than a specified time (**Timeout**), the exact length of specified time (**Length**), or after a specified number of edges (**Counter**). //Protocol// is used in conjunction with a Bus configuration or one of the standard protocols (SPI, I2C, UART, CAN, I2S, and 1Wire) available when adding channels to the //Logic Analyzer// instrument. A protocol-specific menu will pop up to configure the trigger. {{:learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:trig_config.png}} === 3.4 Time Configuration=== By default, the Time group in the Configuration panel contains the **Position** and **Base** fields. The **Position** field centers the plot on the selected time, measured from the trigger. This can be used to view data captured before and after the trigger event. The **Base** field configures the scale used for the horizontal axis of the plot. Using these two settings can be thought of as “panning” and “zooming” the plot. The gear button ({{:learn:instrumentation:tutorials:waveforms-buttons:waveforms-gear.png?nolink}}) opens a menu (pictured on the right) that can be used to modify the Position and Base field units, and the acquisition behavior. //Position as a division// toggles the position units between seconds and divisions. **Range Mode** drop-down has the options //Full//, //Division//, and //PlusMinus//. //Full// changes the units in Base to the full length of the buffer in seconds. //Division// changes the unis in Base to the number of seconds per division (note there are always 10 divisions in the //Logic Analyzer// instrument). //PlusMinus// changes the units in Base to the number of seconds before and after the Position point. The **Clock** drop-down changes between the //Internal// and //External// clocks. This option is only available for certain pieces of hardware, and therefore may be grayed out. //Noise// toggles the option to acquire noise samples in half of the buffer. The **Edge** drop-down allows for selection of the rising, falling, or edge for the external or internal trigger signals. The **Buffers** drop-down selects the number of buffers to store in the PC. This changes the maximum value in **Buffer** in [[#control_buttons|Section 3.1]]. The "Clear buffers" button ({{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:symbol_clear.png?nolink}}) clears all the PC buffers. //Draw while recording// toggles drawing while in //Record// and //Sync// modes, somewhat resembling //Scan// and //Screen// behavior while collecting data over a long period The **Update** drop-down sets the update rate of the //Logic Analyzer// instrument display. {{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:time_config.png}} === 3.5 Additional Configuration Options === Pressing the green arrow ({{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:arrow.png}}) below the gear icon will display options for setting the number of samples to collect and sample rate. Changing these options overrides the Base selections **Samples** selects the number of data points to collect. **Rate** selects the sampling rate. Together with the values selected in the Samples drop-down, this will determine the Base value. {{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:addtnl_config.png}} === 3.6 Adding Protocol Channels === Protocol channels can be used to aid interpretation of digital communication protocol transactions. For example, SPI, UART, I2C, and other protocol channels can be used to represent data words in a variety of different formats (including binary, decimal, hexadecimal, ASCII, and many others). Data words are aligned with the appropriate flags (start, select, acknowledge, etc), based on user-defined settings. In order to add a protocol channel to the plot, follow the steps in [[#software_setup|Section 2.1]] of this guide and select the appropriate protocol from the list. This will cause a menu with settings specific to that protocol to pop up, allowing for selection of DIO channels for each signal line. Protocol-specific options such as endianness, polarity, bit order, etc can also be defined. After being added to the plot, protocol channel settings can be modified by clicking the Properties icon ({{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:symbol_properties.png?nolink}}) for that channel (1 in the image at right). The Protocol and Bus modes will display the data seen on each individual line, as well as the overall value of that combination of channels. These values are marked by 2's in the image at right. {{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:protocol_channels.png}} === 3.7 View Options === The **View** menu is located at the top of the //Logic Analyzer// instrument window, right above Run. Selecting any of the views in that menu will open a tabbed window on the right side of the instrument window. The available views are //Data//, //Events//, //Logging//, //Measurements//, //Cursors//, and //Notes// (see image at right). //Data// displays a table of all acquired samples. If using the Bus or a protocol, only the overall values (as discussed in 3.5) are displayed. //Events// only displays data when it changes. This provides a more compact view than Data, but only displays one channel at a time. Channels can be selected in the drop-down presented at the top of the Events view, as well as filtered by various methods. //Measurements// shows the list of selected measurements. These available measurements are cycles, frequency, period, positive/negative duty cycles, and positive/negative pulse widths. //Logging// uses scripts to automate the capture of multiple data sequences, and save the captured data to file/s. //Cursors// are used to display time reference markers with respect to the capture-triggering event. The drop-down menus contain adjustment controls for the position, reference cursor, and delta x value. //Notes// allows for adding of notes and descriptions into projects. {{learn:instrumentation:tutorials:analog-discovery-studio-logic-analyzer:view_options.png}} ---- ==== Next Steps ==== For more guides on how to use the Digilent Test & Measurement Device, return to the device's Resource Center, linked from the [[test-and-measurement:start]] page of this wiki. For more information on WaveForms visit the [[software:waveforms:waveforms-3:reference-manual|WaveForms Reference Manual]]. For technical support, please visit the [[https://forum.digilent.com/forum/8-test-and-measurement/|Test and Measurement]] section of the Digilent Forums.