Setting up Python API with Anaconda
-
Moku:Go
Moku:Go Arbitrary Waveform Generator Moku:Go Data Logger Moku:Go Frequency Response Analyzer Moku:Go Logic Analyzer & Pattern Generator Moku:Go Oscilloscope & Voltmeter Moku:Go PID Controller Moku:Go Spectrum Analyzer Moku:Go Waveform Generator Moku:Go Power Supplies Moku:Go Digital Filter Box Moku:Go FIR Filter Builder Moku:Go Lock-in Amplifier Moku:Go General Moku:Go Logic Analyzer/Pattern Generator Moku:Go Time & Frequency Analyzer Moku:Go Laser Lock Box Moku:Go Phasemeter
-
Moku:Lab
Moku:Lab General Moku:Lab Arbitrary Waveform Generator Moku:Lab Data Logger Moku:Lab Digital Filter Box Moku:Lab FIR Filter Builder Moku:Lab Frequency Response Analyzer Moku:Lab Laser Lock Box Moku:Lab Lock-in Amplifier Moku:Lab Oscilloscope Moku:Lab Phasemeter Moku:Lab PID Controller Moku:Lab Spectrum Analyzer Moku:Lab Waveform Generator Moku:Lab Time & Frequency Analyzer Moku:Lab Logic Analyzer/Pattern Generator
-
Moku:Pro
Moku:Pro Arbitrary Waveform Generator Moku:Pro Data Logger Moku:Pro Frequency Response Analyzer Moku:Pro Oscilloscope Moku:Pro PID Controller Moku:Pro Spectrum Analyzer Moku:Pro Waveform Generator Moku:Pro Lock-in Amplifier Moku:Pro Digital Filter Box Moku:Pro FIR Filter Builder Moku:Pro Phasemeter Moku:Pro Multi-instrument Mode Moku:Pro General Moku:Pro Logic Analyzer/Pattern Generator Moku:Pro Time & Frequency Analyzer
- Python API
- MATLAB API
- Arbitrary Waveform Generator
- Data Logger
- Digital Filter Box
- FIR Filter Builder
- Frequency Response Analyzer
- Laser Lock Box
- Lock-in Amplifier
- Oscilloscope
- Phasemeter
- PID Controller
- Spectrum Analyzer
- Time & Frequency Analyzer
- Waveform Generator
- Logic Analyzer & Pattern Generator
- Multi Instrument Mode
- Moku Cloud Compile
- Moku general
- LabVIEW
You can use APIs for commanding, controlling, and monitoring Moku devices. This guide will walk you through the installation and configuration process of Python APIs using Anaconda on both Windows and Mac operating systems.
→ For Windows system
Downloading Moku CLI and setting environment variables
Moku CLI (mokucli
) is a command line utility to quickly access various features of the Moku hardware. It is also used internally by various client driver packages for multiple functions such as decoding data streams.
- The latest Moku CLI packages are available to download from Utilities. The installation wizard will configure everything needed to launch the CLI.
- Then we will need to manually set
MOKU_CLI_PATH
environment variable to the absolute path ofmokucli
.
- On the Windows taskbar, right-click the Windows icon and select System.
- In the Settings window, under Related links, click Advanced system settings.
- On the Advanced tab, click Environment Variables.
- For System variables, click New to create a new environment variable for
MOKU_CLI_PATH
.
- Find the Moku CLI path by clicking Browse File…, and the Variable name is set as MOKU_CLI_PATH.
- After creating the Moku CLI environment variable, click OK to have the change take effect. Now you will see Moku CLI is in the list of System variables.
Installing Anaconda, Moku library, and Moku data files
- Download Anaconda and follow the installation setup instructions.
- When the installation is complete, open Anaconda Navigator (version 2.5.1 in this demo) and launch CMD.exe Prompt.
- At the command prompt, install the
moku
library usingpip
. A successful installation will be indicated as shown in the screenshot.
- At the command prompt, issue the
download
command. This step downloads Moku data files for all instruments, and it is only required to be run whenever you install or upgrade the Moku library.
- From the command line, execute
moku list
command. This step automatically displays all Moku devices on your network, and it also helps identify Moku's IP addresses. For more detail and other options, see Finding your IP Address.
Running your first program
To validate the successful installation of Moku package, we now run a Python example of Moku Oscilloscope.
- From the Anaconda Navigator, launch Spyder.
- Paste the example Python code for Moku Oscilloscope into the workspace. Don't forget to modify the IP address to the specific ones of your devices, and change the value of
force_connect
toTrue
. Then click “Run file” highlighted in red in the screenshot to execute the code.
- Check the Console window for the Python script output.
Explore additional Python examples available here.
→ For Mac OS
Downloading Moku CLI
Moku CLI (mokucli
) is a command line utility to quickly access various features of the Moku hardware. It is also used internally by various client driver packages for multiple functions such as decoding data streams. The latest Moku CLI packages are available to download from Utilities. The installation wizard will configure everything needed to launch the CLI.
Installing Anaconda, Moku library, and Moku data files
- Download Anaconda installer compatible with your Mac processor (Intel or M1/M2/M3). Then launch the installer and follow the setup instructions. Under Installation Type, select “Install for me only”. Wait until the installation is complete.
- Quit and re-open Mac Terminal , install the
moku
library usingpip
. A successful installation will be indicated as shown in the screenshot.
- In Terminal window, issue the
download
command. This step downloads Moku data files for all instruments, and it is only required to be run whenever you install or upgrade the Moku library.
Note: The specified firmware version "587" is the latest as of the creation of this article (Dec 12th, 2023). Please replace this version number with any newer releases if available at the time of your installation.
-
From the command line, execute
moku list
command. This step automatically displays all Moku devices on your network, and it also helps identify Moku's IP addresses. For more detail and other options, see Finding your IP Address.
Running your first program
To validate the successful installation of Moku package, we now run a Python example of Moku Oscilloscope.
- From the Anaconda Navigator, launch Spyder.
- Paste the example Python code for Moku Oscilloscope into the workspace. Don't forget to modify the IP address to the specific ones of your devices, and change the value of
force_connect
toTrue
. Then click “Run file” highlighted in red in the screenshot to execute the code.
- Check the Console window for the Python script output.
Explore additional Python examples available here.