infinite quanta, inc., a 501(c)(3) NonProfit Scientific Research Organization Home Page The Peptide Reseach Project Our Organization Our Associates Collaboration News & Events [ Log In | Sign Up | Lost password? ]

GPIB, VISA, and Python on MacOSX

Monday, February 01, 2021 - GPIB is quite an old communication bus and protocol. But in many ways, its superior to TCP/IP and other modern communication systems. Plus, most of my instruments all have GPIB and its really the only common interface and consistent protocol among them all. I've documented the setup and configuration of GPIB, IEEE488.2, interfacing on a Macintosh for both the NI PCIe-GPIB and NI GPIB-USB-HS interfaces.


This is for Macintosh MacPro hardware versions Mid 2009 and Mid 2012. The highest version of MacOSX for both is 10.14 Mojave. Start with a fresh install of Mojave by creating a bootable 8 to 10 GB (6.4 GB required) thumb drive by copying Mojave from a Mac to the thumb drive by:

> cd /Volumes/OSs/ISOs/macosx
> sudo /Volumes/OSs/ISOs/macosx/10.14\ Mojave/Install\ macOS\ Mojave.app/Contents/Resources/createinstallmedia --volume /Volumes/thumbdrive_destination

where thumbdrive_destination is the label under Mac Finder for the destination thumb drive. Press and hold the "Option" key on the Mac when it is rebooting to boot to the Mojave thumb drive. Install a fresh copy of Mojave on the hard drive of the MacPro. Go through the Mac setup prompts, clean up the dock, and setup the mouse tracking, the displays, and the network accordingly.

Python requires PyVisa to connect to instruments. PyVisa needs a visa backend and on Windows, MacOSX, and traditional Linux, National Instruments (NI) provides those binary installs for the public. Install the NI GPIB (IEEE 488.2) drivers for the MacPro Mojave which is for sure NI-488.2 19.5.dmg version 19.5, which you should be able to directly download from NI also. Install the dmg and ensure that you "Allow" the '..."National Instruments"...' notification under System Preferences, Security & Privacy, the General tab, and "Allow apps downloaded from:". Once you reboot you'll find the National Instruments folder under Applications and it will contain NI MAX, NI VISA Configuration, GPIB Explorer, and NI-488.2 Troubleshooting Wizard, everything NI to confirm the presence of the PCIe-GPIB board and the GPIB-USB-HS dongle. NI LabView can also be installed at this point.

Once the GPIB boards are confirmed recognized and working through he NI MAX, etc., driver software, then it's time to install Python. Installing the latest version of Python can be a little tricky on the MacPro but HomeBrew installer helps a lot. First install gcc via Xcode command-line tools, or:

> xcode-select --install

and then HomeBrew and the latest version of Python, or:

> /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
> export PATH="/usr/local/opt/python/libexec/bin:$PATH"
> brew install python
> python3 -V
Python 3.9.7

which at the time of writing this was Python 3.9.7. And, installing the python packages as needed:

> pip3 install --upgrade pip wheel setuptools
> pip3 install virtualenv 
> virtualenv -p /usr/local/bin/python3 .virtualenvs/psql-env
> pip3 install psycopg2-binary
> pip3 install pyvisa requests-toolbelt netifaces lxml beautifulsoup4 numpy scipy mpmath
> python3 -c "import pyvisa; visa = pyvisa.ResourceManager(); dmm = visa.open_resource(\"GPIB0::20\"); dmm.write(\"*idn?\"); print(dmm.read().replace(\"\n\", \"\"))"
KEITHLEY INSTRUMENTS INC.,MODEL 2000,0687508,A07  /A02

Please Register / Login here to post or edit comments or questions to our blog.

Back to the Main Blog Page