Here, we detail how to set up a laptop with a Windows 10 OS to interface with several pieces of lab equipment (Zaber translation stage, CornerStone monochromator, Keysight B2987A ammeter, …) that we use for solar cell characterization measurements. Here are steps:
Working with Python in Windows:
(we know - Windows command line options are frustratingly minimal. But it can be made to work)
- Open the Command Prompt
- searching in the taskbar should bring it up
- I recommend pinning the Command Prompt to the taskbar (right-click on it, select pin to taskbar)
- Type py or python in the Command Prompt. One of these should launch python.
- If neither of these launch Python, you'll need to install Python yourself. As of yet, we do not have instructions for how to do this.
- From here on, we'll assume that py is the correct syntax for running Python from the command line. Replace with python on your system, as necessary
- To enter the Python environment to do Python work, type py
- To run a Python script from the Command Prompt (how we typically operate), type py NAME_OF_PYTHON_SCRIPT.py
- The python script will either need to be in the Python path or in the directory from where the Command Prompt is run
Installing necessary Python libraries:
We have several Python libraries to install. Let's get those out of the way now.
- First off, we need to install pip to install everything else
- [These instructions could be superseded if the method for installing pip gets updated. Pay attention to instructions at provided link]
- Download the get-pip.py script from:
- In the directory where you downloaded get-py.py, run it (from the Command Prompt) as
- py get-py.py
- You may need to update the Windows path (pip told me so - basically yellow script saying such and such was not in path). To do so:
- Search in search bar for: Advanced system settings
- Click: Environment Variables
- Under System variables, click on: Path
- Click Edit...
- Click New
- Enter path, as printed by pip on your command prompt, C: and all
- In our case, this was: C:\Users\LabUser\AppData\Local\Programs\Python\Python39\Scripts
- pip should now be working
- Now time to use pip to install a bunch of important Python libraries. Run all of these, from the command prompt :
- pip install numpy
- pip install scipy
- pip install matplotlib
- pip install astropy
- pip install pyvisa
- pip install pyvisa-py
- Yes, you must do this IN ADDITION to just pyvisa
- pip install pyserial
- DO NOT install the serial library. This confuses python when you say 'import serial' (we want it to import pyserial)
- pip install zaber-motion
- pip install pyusb
- In one installation, I started getting the following error with pyusb:
- ValueError: PyUSB does not appear to be properly installed Please refer to PyUSB documentation and install suitable backend like libusb 0.1, libusb 1.0, libusbx, libusb-win32 or OpenUSB. No backend available.
- BEFORE YOU CONTINUE WITH BELOW SOLUTION, CONTINUE WITH REST OF DOWNLOAD (point j. below). Continuing on may get things where they need to be.
- Solving this was a little tricky:
- Solved with the help of this page on stack overflow: https://stackoverflow.com/questions/33972145/pyusb-on-windows-8-1-no-backend-available-how-to-install-libusb
- Download pyusb from this link: http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.20/libusb-1.0.20.7z/download
- To unpack it, you need to be able to open .7z files.
- Install 7-zip from here: https://www.7-zip.org/
- move downloaded libusb-1.0.20.7z into its own directory called libusb
- right-click on libusb-1.0.20.7z, find the 7-zip option, place cursor over it, and select Extract Here from the menu
- Copy the file libusb-1.0.dll (in the libusb\MS64\dll directory) to C:\Windows\System32 (may require admin permission to do so - but just try copy and past in the Windows finder system)
- Now Keysight I/O libraries
- (sadly, cannot be done from command line)
- Go to: http://www.keysight.com/find/iosuite
- Scroll down, make sure "Current Version" and "Windows" are selected
- Scroll down and click on Download IOSL 2022 (or whatever year is)
- Run the downloaded .exe file.
- You should now be able to talk to the monochromator, the translation stages, and the Keysight current meters/volt meters/voltage sources. Let's test that: