logo

Setting up your development environment

Disclaimer

This module assumes you are on either a Linux or Windows operating system (OS). macOS will work for GPIB via the VISA library, but will not work for DAQ cards; this is due to neither the official NI python module nor the open source PyDAQmx module working under macOS. As of now (2022) you must still use LabVIEW to do research on macOS for any DAQ card experiments.

Introuction

We need a few items here, a Python development environment and hardware drivers for interfacing with the hardware. To get the NI drivers you will need to navigate to NIs website, or use a search engine to find the following download pages,

You may need to make an account to download the drivers, but read the README to ensure your hardware is supported, as some equipment becomes legacy and can be removed. Installing older drivers can help with that.

The NI-VISA driver isn't necessary as Python has their own, but you can tell Python to use the NI-VISA if so desired.

Installation of drivers

Windows

This is trivial, once you have downloaded the drivers installing is as simple as clicking next and answering a few questions.

Linux

Note be aware of what versions of Linux NI supports. You can try to use others, but if things break you are on your own.

You will download the drivers as above, but for Linux. Please read the install instructions provided by NI for installing the drivers. Each Linux system uses different tools for package management.

I personally use Debian for Linux, and had to manually install the opensource linux-gpib driver instead – as the NI-488.2 isn't supported for Debain – and some updates to the install are necessary.

Install Python environment

The easiest way for most students to get a Python environment is through Anaconda. Either through the GUI version, or through Miniconda. Please follow the instructions there, as they will be the most up to date.

Your package manager may be able to give you an environment, but I leave that up to you. What I will tell you is the main packages we need.

A default install from Anaconda will give most of those packages, but you may need to add some manually via pip. From commandline you could do,

pip install pyvisa nidaqmx

Once you have the NI drivers installed and the Python development environment, we can start coding. I will not go over how to code in python here, or use the IDE you chose. There are many youtube tutorials and blogs on how to do that if you need too.

You may want to use an IDE like Spyder, PyCharm, Sublime, or VSCode. You could also use a plain text editor like Notepad++, or Kate. Even commandline ones like Emacs and vim. The commandline editors are out of the scope of this document, please see other modules posted on that.

If you want a recommendation, I suggest using Anaconda and Spyder; you will not need to do much configuring. Spyder comes with Anaconda. You could use jupyter notebook/lab if you prefer.

See the next module for more.

© 2017–2022 David Kalliecharan