Using Jupyter Notebooks with WaveForms SDK

Introduction

Jupyter notebooks are interactive documents that contain Python code and descriptions of what the code is doing that can be run step-by-step. The example notebooks, listed below, contains explanations and examples of how to use the WaveForms Python SDK functions to activate the device, configure the necessary instruments, collect data, and plot it. You may be interested in using a Jupyter notebook if you want to present Python code, data, and documentation in a clear and concise way, whether it be for a class, lab, or collaboration with colleagues.


Example Notebooks

To use these example notebooks, download the ZIP Archive associated with a notebook, then follow the instructions found in Using a Jupyter Notebook, below.

  • Mixed Signals - Download ZIP Archive
    • Description: This notebook demonstrates how to use the WaveForms Python SDK to generate, record, and plot mixed analog/digital signals.
    • Requirements:
      • An Analog Discovery Studio, Analog Discovery 2, or Analog Discovery (Legacy)
      • A resistor ladder (either a Pmod R2R or a breadboard and several resistors). Further hardware setup instructions can be found within the notebook.


Using a Jupyter Notebook

Install Jupyter Notebooks

Two options for installing Jupyter Notebooks on your system are presented here:

1. Anaconda installer

Note: This method may result in second Python installation, if one is already present on the system.

Go to https://www.anaconda.com/download/ and follow the instructions to install Anaconda for the correct OS.

Once Anaconda is installed, open the program and click the “Launch” button under Jupyter.


2. Command Line

Note: This method requires an existing Python installation.

Find the directory in which Python is installed. From the Python install directory, open a terminal window and run the following commands. This will install Jupyter into Python's “Scripts” directory:

python -m pip install --upgrade pip --user
python -m pip install jupyter --user

Allow the installation to take place. To run Jupyter Notebooks, type the following command (in the same directory as before):

jupyter notebook

The system's default browser should now open an instance of Jupyter.


Opening and Running the Notebook

Depending on the method used above, download and unzip an example notebook, and place the *.ipynb and dwfconstants.py files into the following location: 1. Anaconda installer (run the program at least once before this step): Directory chosen during installation. Place the files on the same level as the “.acanconda” directory. 2. Command line: “Scripts” subdirectory in the Python install directory.

The *.ipynb file should now appear in the Jupyter tab in the browser. Double click it and the file will open in a new tab.

Read the instructions/comments present in the notebook and press the “Run” button for each block of code.


Final Notes

For more guides and example projects for your Test and Measurement device, please visit its Resource Center, which can be found through this wiki's Instrumentation page.

For technical support, please visit the Digilent Forums.