Analyzing DAC, ADC, and SPI Data with the Analog Discovery Studio

Overview

The Analog Discovery Studio functions as a mixed signal oscilloscope, and in this demo, uses the Oscilloscope to view analog data from a resistor ladder DAC, the Logic Analyzer to view and decode an ADC's SPI bus, and the Waveform Generator to stimulate the ADC's analog inputs. For this demonstration the Cmod S7 will be used, but the same principles and instruments can be used to decode any SPI bus or analog signal. The variety of signal types and directions demonstrate how the Analog Discovery Studio can be used to interact with many different signals.


The FPGA on the Cmod S7 (a Xilinx Spartan 7 chip) is used in this project to implement a SPI master module, repeatedly sending data captured by the FPGA's onboard two-channel analog-to-digital converter (ADC). This data is also sent to the Pmod R2R, a resistor ladder digital-to-analog converter (DAC), to be converted back to analog data. The Analog Discovery Studio is used to provide analog signals to the Cmod S7's analog input pins, capture analog voltages from the Pmod R2R, and to control and capture data from the SPI module implemented in the Cmod S7's FPGA.

The block diagram to the right illustrates how data moves through the demo.


Inventory


Demo Setup

Hardware Setup

1. Attach the Cmod S7 to the breadboard.

2. Connect the following pins of the Cmod S7 to the respective pins of the Analog Discovery Studio using the MTE Cables, as in the table below.

Cmod S7 Pin Analog Discovery Studio Pin MTE Cable Color
AIN 32 Wavegen W1 Yellow
AIN 33 Wavegen W2 Yellow with White Stripes
PIO 1 DIO 0 Pink
PIO 2 DIO 1 Green
PIO 3 DIO 2 Purple
PIO 4 DIO 3 Brown
PIO 45 DIO 4 Pink
PIO 46 DIO 5 Green
PIO 47 DIO 6 Purple
PIO 48 DIO 7 Brown
Ground Ground Black

3. Plug the Pmod R2R into the Cmod S7's Pmod Port, then connect the following pins of the Pmod R2R to the respective pins of the Analog Discovery Studio, as in the table below.

Pmod R2R Pin Analog Discovery Studio Pin MTE Cable Color
VOUT Scope 1+ Orange
GND Ground, Scope 1- Black, Orange with White Stripes

4. Plug the Cmod S7 into the Analog Discovery Studio's USB port using the MicroUSB cable.

5. Connect the Analog Discovery Studio to the host computer using the USB A to B cable.

6. Plug in the Analog Discovery Studio to wall power. Flip its power switch to turn it on.


Software Setup

1. Download and extract the demo files: ZIP Download

2. Open Adept, and connect to the Cmod S7. Under the Config tab, click Browse, then navigate to the file “top.bit” in the folder extracted from the demo archive. Click the Program button to load the bit file onto the FPGA.

Note: Alternatively, the Cmod S7's flash can be programmed using Xilinx Vivado 2019.1. In Vivado's TCL Console, sourcing the “program_flash.tcl” script will connect to the Cmod S7 and program the “top.bin” file into flash, so that the demo will begin running whenever the Cmod S7 is powered on.

Note: The full Vivado project used in this demo, written primarily in Verilog, is hosted on Github in this repository. In addition, a release is contained within the demo archive linked above.

3. Open WaveForms, then open the workspace, “spi.dwf3work”, included in the folder extraced from the demo archive. Click the “Docking Windows” button () at the top right corner of the screen, to present all of the open instruments on the same screen.

4. To begin applying analog signals to the Cmod S7's analog input pins, capturing analog data from the R2R VOUT pin, and capturing SPI transactions generated by the Cmod S7, click the Run button in the Scope 1 and Wavegen 1 panes.


Operating the Demo

The analog signals generated on the Wavegen pins can be modified by changing the configurations of each channel in the Wavegen 1 pane. By default, channel 1 is set to output 0 Volts DC, and channel 2 is set to ramp from 0 to 3 Volts over 200 microseconds. These waveforms can be seen in the sequence output by the Cmod S7 in the Scope 1 pane. Both the SPI module and the R2R alternate between outputting data captured from channel 1 and channel 2, switching the channel every 20 microseconds.

By default, the demo uses SPI mode 0. This can be changed by changing the state of the CPOL and CPHA buttons in the StaticIO instrument. When changing the SPI mode, make sure to also modify the Active and Sample settings of the SPI bus in the Scope 1 pane.

The RESET button and ENABLE switch in the StaticIO instrument are used to control the SPI module programmed into the Cmod S7, resetting the module, and enabling/disabling it, respectively.

In the Scope 1 instrument, the yellow plot line, Channel 1, represents voltage data captured from Scope channel 1. The red plot line, Math 1, represents the data transferred over SPI from the Cmod S7, converted into voltage from raw 8-bit digital samples.


Final Notes

For more guides and example projects for your Analog Discovery Studio, please visit its Resource Center.

For more information about how to use the other Digilent products featured in this demo, please visit their respective Resource Centers: Cmod S7, Pmod R2R.

For technical support, please visit the Digilent Forums.