Differences
This shows you the differences between two versions of the page.
| test-and-measurement:guides:waveforms-sdk-getting-started [2022/09/12 18:23] – changed forum.digilentinc.com to forum.digilent.com jeff.greenberg_ni.com | test-and-measurement:guides:waveforms-sdk-getting-started [2022/10/04 11:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Getting Started with WaveForms SDK ====== | ||
| + | <WRAP group> | ||
| + | WaveForms SDK is a set of tools provided within the WaveForms installation that are used to develop custom software solutions that use Digilent Test and Measurement devices. The WaveForms SDK API is available in several programming languages, making it easy to use across many different platforms. | ||
| + | Normally, Test and Measurement devices are controlled and configured through the WaveForms application with a personal computer. Such a setup may be impossible in a given context, or an amount of automated signal measurement may be required beyond what WaveForms' | ||
| + | |||
| + | This guide demonstrates the usage of some basic instruments and presents some patterns to help develop your own application. It is written with Python in mind, but users of other languages will still find it useful to illustrate the principles of working with the SDK. | ||
| + | </ | ||
| + | ---- | ||
| + | |||
| + | ===== Inventory ===== | ||
| + | <WRAP group> | ||
| + | * A Digilent Test & Measurement Device | ||
| + | * [[test-and-measurement: | ||
| + | * [[test-and-measurement: | ||
| + | * [[test-and-measurement: | ||
| + | * [[test-and-measurement: | ||
| + | * [[test-and-measurement: | ||
| + | * [[test-and-measurement: | ||
| + | * A Computer with WaveForms Installed | ||
| + | * Both the WaveForms application and WaveForms SDK can be installed by following the [[software: | ||
| + | </ | ||
| + | ---- | ||
| + | |||
| + | ===== SDK Overview ===== | ||
| + | <WRAP group> | ||
| + | WaveForms SDK is included with WaveForms and is installed alongside the application. The SDK is available to use with C/C++, C#, Python, and Visual Basic through a dynamic library (a module that contains data that can be used by other applications). | ||
| + | |||
| + | Another important file is the one that contains the definition of all constants. If you want to use the SDK from Python, this file is a Python module, while for C/C++ applications, | ||
| + | |||
| + | Working code examples for each supported programming language are provided with the SDK and may be found at the following locations: | ||
| + | * Windows 32-bit: **C: | ||
| + | * Windows 64-bit: **C: | ||
| + | * Linux: **/ | ||
| + | * macOS: **/ | ||
| + | |||
| + | </ | ||
| + | ---- | ||
| + | |||
| + | ===== Workflow ===== | ||
| + | ==== 1. Importing the Constants and Loading the Dynamic Library ==== | ||
| + | <WRAP group>< | ||
| + | The WaveForms SDK Python functions use C-compatible data types, so along with the dynamic library and the module containing the constants, you will also need the **ctypes** module, which is installed together with Python by default. | ||
| + | |||
| + | As the first step of your project import the **dwfconstants.py** file to your project directory (it is located among the sample codes, in the **py** folder), then load the necessary modules and the dynamic library. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | --> Optional: Importing the Constants from the Project Directory # | ||
| + | <WRAP group>< | ||
| + | Alternatively, | ||
| + | </ | ||
| + | < | ||
| + | <script src=" | ||
| + | </ | ||
| + | </ | ||
| + | <-- | ||
| + | ---- | ||
| + | |||
| + | ==== 2. Connecting the Test & Measurement Device ==== | ||
| + | <WRAP group>< | ||
| + | The next step is to " | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | --> Optional: Connecting to a Specific Device # | ||
| + | <WRAP group>< | ||
| + | If you have multiple Test & Measurement devices connected, opening the first available device might not be the best option. If you want to open a specific type of device, use the function presented to the right. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Optional: Error Checking # | ||
| + | <WRAP group>< | ||
| + | You can check for errors, to know whether your device was connected to or not. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | ---- | ||
| + | |||
| + | ==== 3. Using Instruments ==== | ||
| + | --> Oscilloscope # | ||
| + | <WRAP group> | ||
| + | === 3.1 Initialize the Scope === | ||
| + | <WRAP group>< | ||
| + | Before measuring with the oscilloscope, | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.2 Measure a Voltage === | ||
| + | <WRAP group>< | ||
| + | You can measure voltages, like with the Voltmeter instrument in WaveForms. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.3 Record a Signal === | ||
| + | <WRAP group>< | ||
| + | The most important feature of the oscilloscope is, that it can record signals. The recorded voltages can be stored in a list. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.4 Reset the Scope === | ||
| + | <WRAP group>< | ||
| + | After usage, reset the oscilloscope to the default settings. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | --> Optional: Triggering # | ||
| + | <WRAP group>< | ||
| + | Before recording a signal, you might want to set up triggering. Set the trigger parameters to fit your needs. | ||
| + | |||
| + | <WRAP center round tip 80%> | ||
| + | You can define custom trigger source names, to make the usage of the function easier. | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | <script src=" | ||
| + | </ | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | ---- | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Waveform Generator # | ||
| + | <WRAP group> | ||
| + | === 3.1 Generate a Signal === | ||
| + | <WRAP group>< | ||
| + | Use the waveform generator to generate different signals. | ||
| + | |||
| + | <WRAP center round tip 80%> | ||
| + | You can define custom function names, to make the usage of the function easier. | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | <script src=" | ||
| + | </ | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.2 Reset the Wavegen === | ||
| + | <WRAP group>< | ||
| + | After usage, reset the wavegen to the default settings. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | ---- | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Power Supplies # | ||
| + | <WRAP group> | ||
| + | --> 3.1 Analog Discovery Supplies # | ||
| + | <WRAP group>< | ||
| + | The Analog Discovery has only fixed supplies, so just a limited number of functions are available. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> 3.1 Analog Discovery 2 and Analog Discovery Studio Supplies # | ||
| + | <WRAP group>< | ||
| + | These devices have variable positive and negative supplies, so a voltage level can also be set. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> 3.1 Analog Discovery Pro 3X50 and Digital Discovery Supplies # | ||
| + | <WRAP group>< | ||
| + | Devices with digital supplies have only positive voltage supplies with a variable voltage level between 1.2 and 3.3 Volts. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> 3.1 Analog Discovery Pro 5250 6V Power Supply # | ||
| + | <WRAP group>< | ||
| + | You can set not only the voltage for the 6V power supply on the Analog Discovery 5250, but also the current limit, up to 1A. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> 3.1 Analog Discovery Pro 5250 25V Power Supplies # | ||
| + | <WRAP group>< | ||
| + | The positive and negative isolated 25V power supplies are similar to the 6V one, but with a maximum current limit of 500mA. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Optional: Power Supplies Wrapper Function # | ||
| + | <WRAP group>< | ||
| + | To make the usage of the above functions easier, you can create a wrapper function, which is able to call the function you need. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | === 3.2 Reset the Supplies === | ||
| + | <WRAP group>< | ||
| + | After usage, reset the supplies to the default settings. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | ---- | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Digital Multimeter - Only on ADP5250 # | ||
| + | <WRAP group> | ||
| + | === 3.1 Initialize the DMM === | ||
| + | <WRAP group>< | ||
| + | Before measuring with the digital multimeter, it must be enabled. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.2 Measure With the DMM === | ||
| + | <WRAP group>< | ||
| + | <WRAP center round important 60%> | ||
| + | This function was not tested. | ||
| + | </ | ||
| + | |||
| + | You can use the digital multimeter to measure AC, or DC voltages (in Volts), with an input impedance of 10MΩ, or 10GΩ, low (< | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.3 Reset the DMM === | ||
| + | <WRAP group>< | ||
| + | After usage, reset the instrument to the default settings. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | ---- | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Logic Analyzer # | ||
| + | <WRAP group> | ||
| + | === 3.1 Initialize the Logic Analyzer === | ||
| + | <WRAP group>< | ||
| + | Before measuring with the logic analyzer, it must be set up. Change the values to fit your needs. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.2 Record Logic Signals === | ||
| + | <WRAP group>< | ||
| + | Record logic signals in a list of lists, then select the one specific for the required DIO line. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.3 Reset the Logic Analyzer === | ||
| + | <WRAP group>< | ||
| + | After usage, reset the logic analyzer to the default settings. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | --> Optional: Triggering # | ||
| + | <WRAP group>< | ||
| + | Before recording a signal, you might want to set up triggering. Set the trigger parameters to fit your needs. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | ---- | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Pattern Generator # | ||
| + | <WRAP group> | ||
| + | === 3.1 Generate Logic Signals === | ||
| + | <WRAP group>< | ||
| + | Configure the pattern generator to generate logic signals. | ||
| + | |||
| + | <WRAP center round important 80%> | ||
| + | You can use a DIO line for pattern generation only if the respective line is configured as input and set to LOW state by the static I/O instrument (these are the default settings for all lines). | ||
| + | </ | ||
| + | |||
| + | <WRAP center round tip 80%> | ||
| + | You can define custom function and trigger source names, to make the usage of the function easier. | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | <script src=" | ||
| + | </ | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.2 Reset the Pattern Generator === | ||
| + | <WRAP group>< | ||
| + | After usage, reset the pattern generator to the default settings. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | ---- | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Static I/O # | ||
| + | <WRAP group> | ||
| + | === 3.1 Set Pins As Input Or As Output === | ||
| + | <WRAP group>< | ||
| + | Each digital pin of the Test & Measurement device can be used only as input, or as output at a time. The default settings for each line are input states. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.2 Get Pin State === | ||
| + | <WRAP group>< | ||
| + | Read the state of a DIO line with the following code snippet: | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.3 Set Pin State === | ||
| + | <WRAP group>< | ||
| + | To set the state of a DIO line, it must be set as output! | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.4 Reset the Static I/O === | ||
| + | <WRAP group>< | ||
| + | After usage, reset the instrument to the default settings. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | --> Optional: Limiting DIO Channel Current # | ||
| + | <WRAP group>< | ||
| + | Test & Measurement devices with digital supplies (the Digital Discovery and the Analog Discovery Pro 3X50) also have options to limit the output current of a DIO channel. | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | This function was not tested. | ||
| + | </ | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Optional: DIO Channel Pull Up/Down # | ||
| + | <WRAP group>< | ||
| + | Test & Measurement devices with digital supplies (the Digital Discovery and the Analog Discovery Pro 3X50) also have options to pull a DIO channel up, or down. | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | This function was not tested. | ||
| + | </ | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | ---- | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Protocol: UART # | ||
| + | <WRAP group> | ||
| + | === 3.1 Initialize the Interface === | ||
| + | <WRAP group>< | ||
| + | Before using a communication interface, it must be initialized by setting the communication parameters to the desired values. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.2 Receive Data === | ||
| + | <WRAP group>< | ||
| + | Use the function to the right to read data on an initialized UART interface. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.3 Send Data === | ||
| + | <WRAP group>< | ||
| + | Use the function to the right to send data on an initialized UART interface to another device. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.4 Reset the Interface === | ||
| + | <WRAP group>< | ||
| + | After usage, reset the instrument to the default settings. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | ---- | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Protocol: SPI # | ||
| + | <WRAP group> | ||
| + | === 3.1 Initialize the Interface === | ||
| + | <WRAP group>< | ||
| + | Before using a communication interface, it must be initialized by setting the communication parameters to the desired values. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.2 Receive Data === | ||
| + | <WRAP group>< | ||
| + | Use the function to the right to read data on an initialized SPI interface. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.3 Send Data === | ||
| + | <WRAP group>< | ||
| + | Use the function to the right to send data on an initialized SPI interface to another device. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.4 Exchange Data === | ||
| + | <WRAP group>< | ||
| + | You might want to receive data from a slave device while you are sending commands to it. In this case the data exchanging function can be used. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.5 Spy on SPI communication === | ||
| + | <WRAP group>< | ||
| + | If two other devices, a master and a slave, are communicating using the initialized communication interface, the Test & Measurement device can be used to spy on this communication (record both incoming and outgoing data). | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | This function was not tested. | ||
| + | </ | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.6 Reset the Interface === | ||
| + | <WRAP group>< | ||
| + | After usage, reset the instrument to the default settings. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | ---- | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Protocol: I2C # | ||
| + | <WRAP group> | ||
| + | === 3.1 Initialize the Interface === | ||
| + | <WRAP group>< | ||
| + | Before using a communication interface, it must be initialized by setting the communication parameters to the desired values. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.2 Receive Data === | ||
| + | <WRAP group>< | ||
| + | Use the function to the right to read data on an initialized I2C interface. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.3 Send Data === | ||
| + | <WRAP group>< | ||
| + | Use the function to the right to send data on an initialized I2C interface to another device. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.4 Exchange Data === | ||
| + | <WRAP group>< | ||
| + | You might want to receive data from a slave device while you are sending commands to it. In this case the data exchanging function can be used. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.5 Spy on I2C communication === | ||
| + | <WRAP group>< | ||
| + | If two other devices, a master and a slave, are communicating using the initialized communication interface, the Test & Measurement device can be used to spy on this communication (record both incoming and outgoing data). | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | This function was not tested. | ||
| + | </ | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | |||
| + | === 3.6 Reset the Interface === | ||
| + | <WRAP group>< | ||
| + | After usage, reset the instrument to the default settings. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | ---- | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | <WRAP group> | ||
| + | The code snippets above present basic functionality of some instruments. For more possibilities (advanced features and more instruments) check the documentation of the WaveForms SDK and the available sample scripts. | ||
| + | </ | ||
| + | ---- | ||
| + | ==== 4. Disconnecting the Device ==== | ||
| + | <WRAP group>< | ||
| + | When your script is exiting, it is very important to close the opened connections, | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | ---- | ||
| + | ===== Creating Modules ===== | ||
| + | <WRAP group> | ||
| + | To avoid copying several hundred lines of code into every project, you can create Python modules from the functions controlling the instruments. These modules then can be imported in your project. | ||
| + | |||
| + | To create a module, create a new file with the desired name and the extension ***.py**, then copy the respective functions into that file. Don't forget to also import the dwfconstants file into every module. | ||
| + | |||
| + | Place your modules in a separate folder, name this folder (for example WF_SDK is a good name as it is suggestive), | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | Don't forget to correct the import path of the **dwfconstants.py** file, if you import it from the project directory. The name of the parent directory (WF_SDK), followed by a dot must be added before the file name. | ||
| + | |||
| + | If you import the file from the installation folder, no changes have to be made. | ||
| + | </ | ||
| + | |||
| + | You can download the archive containing the module and some test files [[https:// | ||
| + | |||
| + | Open the drop-downs below to see the content of the created modules. | ||
| + | </ | ||
| + | |||
| + | --> Device Control - device.py # | ||
| + | <WRAP group>< | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Oscilloscope Control - scope.py # | ||
| + | <WRAP group>< | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Waveform Generator Control - wavegen.py # | ||
| + | <WRAP group>< | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Power Supplies Control - supplies.py # | ||
| + | <WRAP group>< | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Digital Multimeter Control - supplies.py # | ||
| + | <WRAP group> | ||
| + | <WRAP center round important 60%> | ||
| + | This module contains untested functions. | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Logic Analyzer Control - logic.py # | ||
| + | <WRAP group>< | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Pattern Generator Control - pattern.py # | ||
| + | <WRAP group>< | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Static I/O Control - static.py # | ||
| + | <WRAP group> | ||
| + | <WRAP center round important 60%> | ||
| + | This module contains untested functions. | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Protocol: UART Interface - protocol/ | ||
| + | <WRAP group> | ||
| + | < | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Protocol: SPI Interface - protocol/ | ||
| + | <WRAP group> | ||
| + | <WRAP center round important 60%> | ||
| + | This module contains untested functions. | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Protocol: I2C Interface - protocol/ | ||
| + | <WRAP group> | ||
| + | <WRAP center round important 60%> | ||
| + | This module contains untested functions. | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | <WRAP group> | ||
| + | As the created function set will be used as a module, an initializer is needed, to let the text editors recognize the module. This file contains only the description of the module and imports every file in the module, to make the functions accessible. The created file has to be named < | ||
| + | |||
| + | After the file is created, your module will be recognized: the module name in the text editor will be colored (this depends on the editor) and if you hover the mouse on the module name, the module description appears. | ||
| + | |||
| + | < | ||
| + | <script src=" | ||
| + | |||
| + | Remember, that any submodule (the protocol folder in this case) also needs initialization: | ||
| + | < | ||
| + | <script src=" | ||
| + | </ | ||
| + | ---- | ||
| + | |||
| + | ==== Testing ==== | ||
| + | <WRAP group> | ||
| + | Copy your module folder (WF_SDK in this case) into the project directory, then create a new Python script. Import the necessary modules, then use your functions to control the Test & Measurement device. | ||
| + | |||
| + | In the drop-downs below, several examples and a project template will be presented. | ||
| + | |||
| + | **Note: ** //The example using the oscilloscope and the waveform generator won't work on devices without analog I/O capability (Digital Discovery).// | ||
| + | |||
| + | **Note: ** //Name your test scripts " | ||
| + | </ | ||
| + | |||
| + | --> Empty Project Template # | ||
| + | <WRAP group>< | ||
| + | Fill in this template. Be creative, use any instrument in any configuration. | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Using the Oscilloscope and the Waveform Generator # | ||
| + | <WRAP group>< | ||
| + | This example generates a sinusoidal signal on a wavegen channel, then records it on a scope channel. Connect the respective channels together on your device! | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | {{ : | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Using the Logic Analyzer and the Pattern Generator # | ||
| + | <WRAP group>< | ||
| + | This example generates a PWM signal on a DIO line and reads it back with the logic analyzer. As the same line is used both as input and as output, no external connections have to be made. | ||
| + | |||
| + | {{ : | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Using the Static I/O and the Power Supplies # | ||
| + | <WRAP group>< | ||
| + | Connect LEDs and series resistors to each DIO channel of your device. Use the positive, or the digital power supply to provide current to the LEDs, then use the Static I/O instrument to sink the currents (turn the LEDs on/off). | ||
| + | |||
| + | {{ : | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Controlling the Pmod CLS and the Pmod MAXSonar with UART # | ||
| + | <WRAP group>< | ||
| + | Connect the UART interface of both Pmods to your Test & Measurement device as presented below. Pay special attention to the jumpers on the Pmod CLS. Use the positive, or the digital power supply to provide current to the Pmods, then receive and send data with the protocol instrument. | ||
| + | |||
| + | {{ : | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Controlling the Pmod CLS and the Pmod ALS with SPI # | ||
| + | <WRAP group>< | ||
| + | Connect the SPI interface of both Pmods to your Test & Measurement device as presented below. Pay special attention to the jumpers on the Pmod CLS. Use the positive, or the digital power supply to provide current to the Pmods, then receive and send data with the protocol instrument. | ||
| + | |||
| + | {{ : | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | |||
| + | --> Controlling the Pmod CLS and the Pmod TMP2 with I2C # | ||
| + | <WRAP group>< | ||
| + | Connect the I2C interface of both Pmods to your Test & Measurement device as presented below. Pay special attention to the jumpers on the Pmod CLS. Use the positive, or the digital power supply to provide current to the Pmods, then receive and send data with the protocol instrument. | ||
| + | |||
| + | {{ : | ||
| + | </ | ||
| + | <script src=" | ||
| + | </ | ||
| + | <-- | ||
| + | ---- | ||
| + | |||
| + | ==== Installing the Package ==== | ||
| + | <WRAP group> | ||
| + | Once you completed the package, you might want to install it, like other Python packages and use it on new projects as well. To do so, you must create some additional files in the project folder. | ||
| + | |||
| + | First, exclude the test scripts from the final package. Create a file named **MANIFEST.in**, | ||
| + | < | ||
| + | |||
| + | The installer needs the list of dependencies to install your package. Specify this list on a file called **requirements.txt**: | ||
| + | < | ||
| + | setuptools==58.1.0 | ||
| + | wheel==0.37.1</ | ||
| + | |||
| + | Finally, create a **README.md** file with the description of your package, then create the installer. The installer is the file named **setup.py**, | ||
| + | <code python> | ||
| + | from setuptools import setup | ||
| + | |||
| + | with open(" | ||
| + | long_description = f.read() | ||
| + | |||
| + | setup( | ||
| + | name = " | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | url = " | ||
| + | | ||
| + | ) | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <WRAP group> | ||
| + | Once the necessary files are created, open a terminal, go to the project folder and install your package with the following command: | ||
| + | < | ||
| + | |||
| + | Alternatively, | ||
| + | < | ||
| + | |||
| + | **Note:** //Use " | ||
| + | </ | ||
| + | ---- | ||
| + | |||
| + | ===== Other Programming Languages ===== | ||
| + | <WRAP group> | ||
| + | Realizing the same package in other programming languages is also possible. To check the C++ version of the package and some test programs, follow [[https:// | ||
| + | </ | ||
| + | ---- | ||
| + | ===== Next Steps ===== | ||
| + | <WRAP group> | ||
| + | For more guides on how to use your Digilent Test & Measurement Device, return to the device' | ||
| + | |||
| + | For more information on the WaveForms SDK visit the [[software: | ||
| + | |||
| + | For more information on WaveForms visit the [[software: | ||
| + | |||
| + | For technical support, please visit the [[https:// | ||
| + | </ | ||

