Differences
This shows you the differences between two versions of the page.
| test-and-measurement:guides:waveforms-sdk-getting-started [2021/12/07 10:09] – [4. Disconnecting the Device] Álmos Veres-Vitályos | 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 the WaveForms SDK ====== | + | ====== Getting Started with WaveForms SDK ====== |
| - | + | ||
| - | <WRAP center round todo 60%> | + | |
| - | This page is under construction. | + | |
| - | </ | + | |
| <WRAP group> | <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. | 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. | ||
| Line 40: | Line 35: | ||
| * macOS: **/ | * macOS: **/ | ||
| - | For other examples, check: [[test-and-measurement: | ||
| </ | </ | ||
| ---- | ---- | ||
| Line 96: | Line 90: | ||
| Before measuring with the oscilloscope, | Before measuring with the oscilloscope, | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 103: | Line 97: | ||
| You can measure voltages, like with the Voltmeter instrument in WaveForms. | You can measure voltages, like with the Voltmeter instrument in WaveForms. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 110: | Line 104: | ||
| The most important feature of the oscilloscope is, that it can record signals. The recorded voltages can be stored in a list. | The most important feature of the oscilloscope is, that it can record signals. The recorded voltages can be stored in a list. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 117: | Line 111: | ||
| After usage, reset the oscilloscope to the default settings. | After usage, reset the oscilloscope to the default settings. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 129: | Line 123: | ||
| < | < | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 150: | Line 144: | ||
| < | < | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 160: | Line 154: | ||
| After usage, reset the wavegen to the default settings. | After usage, reset the wavegen to the default settings. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| ---- | ---- | ||
| Line 172: | Line 166: | ||
| The Analog Discovery has only fixed supplies, so just a limited number of functions are available. | The Analog Discovery has only fixed supplies, so just a limited number of functions are available. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 180: | Line 174: | ||
| These devices have variable positive and negative supplies, so a voltage level can also be set. | These devices have variable positive and negative supplies, so a voltage level can also be set. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 188: | Line 182: | ||
| Devices with digital supplies have only positive voltage supplies with a variable voltage level between 1.2 and 3.3 Volts. | Devices with digital supplies have only positive voltage supplies with a variable voltage level between 1.2 and 3.3 Volts. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 195: | Line 189: | ||
| <WRAP group>< | <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. | 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. | ||
| - | |||
| - | <WRAP center round important 60%> | ||
| - | This function was not tested. | ||
| - | </ | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 207: | Line 197: | ||
| <WRAP group>< | <WRAP group>< | ||
| The positive and negative isolated 25V power supplies are similar to the 6V one, but with a maximum current limit of 500mA. | The positive and negative isolated 25V power supplies are similar to the 6V one, but with a maximum current limit of 500mA. | ||
| - | |||
| - | <WRAP center round important 60%> | ||
| - | This function was not tested. | ||
| - | </ | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 220: | Line 206: | ||
| To make the usage of the above functions easier, you can create a wrapper function, which is able to call the function you need. | 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=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 228: | Line 214: | ||
| After usage, reset the supplies to the default settings. | After usage, reset the supplies to the default settings. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| ---- | ---- | ||
| Line 240: | Line 226: | ||
| Before measuring with the digital multimeter, it must be enabled. | Before measuring with the digital multimeter, it must be enabled. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 251: | Line 237: | ||
| You can use the digital multimeter to measure AC, or DC voltages (in Volts), with an input impedance of 10MΩ, or 10GΩ, low (< | 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=" | + | <script src=" |
| </ | </ | ||
| Line 258: | Line 244: | ||
| After usage, reset the instrument to the default settings. | After usage, reset the instrument to the default settings. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| ---- | ---- | ||
| Line 270: | Line 256: | ||
| Before measuring with the logic analyzer, it must be set up. Change the values to fit your needs. | Before measuring with the logic analyzer, it must be set up. Change the values to fit your needs. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 277: | Line 263: | ||
| Record logic signals in a list of lists, then select the one specific for the required DIO line. | Record logic signals in a list of lists, then select the one specific for the required DIO line. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 284: | Line 270: | ||
| After usage, reset the logic analyzer to the default settings. | After usage, reset the logic analyzer to the default settings. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 291: | Line 277: | ||
| Before recording a signal, you might want to set up triggering. Set the trigger parameters to fit your needs. | Before recording a signal, you might want to set up triggering. Set the trigger parameters to fit your needs. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 313: | Line 299: | ||
| < | < | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| < | < | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 327: | Line 313: | ||
| After usage, reset the pattern generator to the default settings. | After usage, reset the pattern generator to the default settings. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| ---- | ---- | ||
| Line 339: | Line 325: | ||
| 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. | 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=" | + | <script src=" |
| </ | </ | ||
| Line 346: | Line 332: | ||
| Read the state of a DIO line with the following code snippet: | Read the state of a DIO line with the following code snippet: | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 353: | Line 339: | ||
| To set the state of a DIO line, it must be set as output! | To set the state of a DIO line, it must be set as output! | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 360: | Line 346: | ||
| After usage, reset the instrument to the default settings. | After usage, reset the instrument to the default settings. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 371: | Line 357: | ||
| </ | </ | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 383: | Line 369: | ||
| </ | </ | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 396: | Line 382: | ||
| Before using a communication interface, it must be initialized by setting the communication parameters to the desired values. | Before using a communication interface, it must be initialized by setting the communication parameters to the desired values. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 403: | Line 389: | ||
| Use the function to the right to read data on an initialized UART interface. | Use the function to the right to read data on an initialized UART interface. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 410: | Line 396: | ||
| Use the function to the right to send data on an initialized UART interface to another device. | Use the function to the right to send data on an initialized UART interface to another device. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 417: | Line 403: | ||
| After usage, reset the instrument to the default settings. | After usage, reset the instrument to the default settings. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| ---- | ---- | ||
| Line 429: | Line 415: | ||
| Before using a communication interface, it must be initialized by setting the communication parameters to the desired values. | Before using a communication interface, it must be initialized by setting the communication parameters to the desired values. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 436: | Line 422: | ||
| Use the function to the right to read data on an initialized SPI interface. | Use the function to the right to read data on an initialized SPI interface. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 443: | Line 429: | ||
| Use the function to the right to send data on an initialized SPI interface to another device. | Use the function to the right to send data on an initialized SPI interface to another device. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 450: | Line 436: | ||
| 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. | 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=" | + | <script src=" |
| </ | </ | ||
| Line 461: | Line 447: | ||
| </ | </ | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 468: | Line 454: | ||
| After usage, reset the instrument to the default settings. | After usage, reset the instrument to the default settings. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| ---- | ---- | ||
| Line 480: | Line 466: | ||
| Before using a communication interface, it must be initialized by setting the communication parameters to the desired values. | Before using a communication interface, it must be initialized by setting the communication parameters to the desired values. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 487: | Line 473: | ||
| Use the function to the right to read data on an initialized I2C interface. | Use the function to the right to read data on an initialized I2C interface. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 494: | Line 480: | ||
| Use the function to the right to send data on an initialized I2C interface to another device. | Use the function to the right to send data on an initialized I2C interface to another device. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 501: | Line 487: | ||
| 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. | 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=" | + | <script src=" |
| </ | </ | ||
| Line 512: | Line 498: | ||
| </ | </ | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| Line 519: | Line 505: | ||
| After usage, reset the instrument to the default settings. | After usage, reset the instrument to the default settings. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| ---- | ---- | ||
| Line 550: | Line 536: | ||
| </ | </ | ||
| - | You can download the archive containing the module and some test files [[https:// | + | 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. | Open the drop-downs below to see the content of the created modules. | ||
| Line 557: | Line 543: | ||
| --> Device Control - device.py # | --> Device Control - device.py # | ||
| <WRAP group>< | <WRAP group>< | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 563: | Line 549: | ||
| --> Oscilloscope Control - scope.py # | --> Oscilloscope Control - scope.py # | ||
| <WRAP group>< | <WRAP group>< | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 569: | Line 555: | ||
| --> Waveform Generator Control - wavegen.py # | --> Waveform Generator Control - wavegen.py # | ||
| <WRAP group>< | <WRAP group>< | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 575: | Line 561: | ||
| --> Power Supplies Control - supplies.py # | --> Power Supplies Control - supplies.py # | ||
| <WRAP group>< | <WRAP group>< | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 586: | Line 572: | ||
| < | < | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 592: | Line 578: | ||
| --> Logic Analyzer Control - logic.py # | --> Logic Analyzer Control - logic.py # | ||
| <WRAP group>< | <WRAP group>< | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 598: | Line 584: | ||
| --> Pattern Generator Control - pattern.py # | --> Pattern Generator Control - pattern.py # | ||
| <WRAP group>< | <WRAP group>< | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 609: | Line 595: | ||
| < | < | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 616: | Line 602: | ||
| <WRAP group> | <WRAP group> | ||
| < | < | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 627: | Line 613: | ||
| < | < | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 638: | Line 624: | ||
| < | < | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 648: | Line 634: | ||
| < | < | ||
| - | <script src=" | + | <script src=" |
| + | |||
| + | Remember, that any submodule (the protocol folder in this case) also needs initialization: | ||
| + | < | ||
| + | <script src=" | ||
| </ | </ | ||
| ---- | ---- | ||
| - | ===== Testing | + | ==== Testing ==== |
| <WRAP group> | <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. | 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. | ||
| Line 659: | Line 649: | ||
| **Note: ** //The example using the oscilloscope and the waveform generator won't work on devices without analog I/O capability (Digital Discovery).// | **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 " | ||
| </ | </ | ||
| Line 665: | Line 657: | ||
| Fill in this template. Be creative, use any instrument in any configuration. | Fill in this template. Be creative, use any instrument in any configuration. | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 677: | Line 669: | ||
| {{ : | {{ : | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 687: | Line 679: | ||
| {{ : | {{ : | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 697: | Line 689: | ||
| {{ : | {{ : | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 707: | Line 699: | ||
| {{ : | {{ : | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 717: | Line 709: | ||
| {{ : | {{ : | ||
| </ | </ | ||
| - | <script src=" | + | <script src=" |
| </ | </ | ||
| <-- | <-- | ||
| Line 727: | Line 719: | ||
| {{ : | {{ : | ||
| </ | </ | ||
| - | <script src=" | + | <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 ===== | ===== Next Steps ===== | ||
| <WRAP group> | <WRAP group> | ||

