The purpose of this section is to demonstrate the connection process for specific pieces of equipment. This is less so a tutorial on how to use different code interfaces, and more about how we connect to the hardware in the first place. This section will describe the required python packages, external software, and source code edits necessary to connect to instruments. In nearly every circumstance, this initial connection is then wrapped by a new python class which provides slightly more convenient functions that can then interface with the rest of the package. Look out for the “Making the Connection” tips that describe the requirements for using each specific instrument!

Alicat MFCs

Alicat brand MFCs are accessed utilizing the Alicat python package developed by Patrick Fuller and Numat.

For proper gas monitoring, many mass flow controllers need to be supplied with the appropriate process gas composition. Alicat flow controllers are capable of creating custom gas mixtures comprised of some combination of the gas library hosted by the device. This feature is implemented in the gas_system class of catalight for creating calibration gasses, and output gas compositions when using a flow meters after gas mixing. The following links provide additional information for Alicat systems:

Warning

This automated gas system has no ability to check gas mixing safety! It is your responsibility to ensure chemical compatibility before mixing gasses. Always check for leaks and ensure the system is free of pressure build ups before leaving the system unattended or flowing hazardous gasses.

Making the Connection

The COM ports for the individual MFC addresses are currently hard coded into the Gas_System.__init__ method. New users need to edit these addresses in a forked version of the source code for successful connection. Additionally, the MFC count is hard coded for 4 MFCs and one output flow meter at the moment and code changes need to make a number of updates to the source code to change the MFC count. This will soon be updated such that the user only has to specify the number of MFCs in the init method. Eventually this will be replaced with a single configuration file. See Areas for Future Development for more details. Additional software shouldn’t be necessary.

Harrick Heater/Watlow

The Harrick reaction chamber’s heating system is controlled by a Watlow temperature controller. In place of using the EZ-ZONE configurator software, we utilize the pywatlow package developed by Brendan Sweeny and Joe Reckwalder. Brendan has an excellent write up describing the creation of the project. Our Heater class simply add some additional utilities on top of the pywatlow project, such as unit conversions, and ramped heating. In theory, the Heater class should work with any Watlow controlled heater, but we have only tested it with the Harrick system.

Tip

Other parameters are accessible using pywatlow. See the “Operations” section of the manual located in the catalight/equipment/harrick_watlow directory.

Making the Connection

The COM ports for the Watlow heater are currently hard coded into the Heater.__init__ method. New users need to edit these addresses in a forked version of the source code for successful connection. Eventually this will be replaced with a single configuration file. See Areas for Future Development for more details. Additional software should not be needed, though testing your connection with the EZ zone configurator software can be helpful for troubleshooting.

ThorLabs Laser Diode Driver

Warning

Lasers present serious safety hazards, even in lab environments. This is especially true when software is used to automatically control them. Always take abundant safety precautions to ensure laser beams are physically contained. Never assume the code is working properly. Don’t rely on the software to turn the laser off and assume you can enter the laser lab without safety glasses on. Always be in the room when engaging the laser via code, and always use safety interlocks and message boards to alert other users that an unattended laser is active.

We use the LDC200C Series Laser Diode Driver to control our diode laser excitation source. The driver does not have a computer interface, but supports current modulation via a 10 Volt analog signal supplied by a BNC connection at the rear of the device. To supply an analog signal to the current controller, we utilize a USB-231 DAQ card from Measurment Computing Corporation (MCC). MCC publishes a Python API for their Universal Library (mcculw). We also utilize their instacal software for installing the DAQ and setting the board number, though this may not be strictly necessary when using the mcculw library. Our Diode_Laser class hides interaction with the mcculw from the user, favoring method calls such as “Diode_Laser.set_power()” over interacting directly with the DAQ board. The intention is to ignore the existence of the DAQ interface when operating the laser programmatically. In fact, this makes some troubleshooting activities a bit easier for the Diode_Laser class as the laser can remain off (by unplugging or pressing the physical off switch) while the user interacts safely with the DAQ board. All commands will remain functional, though voltage readings from the current driver output won’t return realistic values.

Making the Connection

It isn’t completely necessary to install additional software before using a Diode_Laser instance, but you will need to install the MCC DAQ board in some way. We suggest you install and use instacal, but there is a command line method documented in the mcculw library

_images/thorlabs_diode_driver.png

Screenshot from Thorlabs current driver manual showing where BNC connections need to be made along with the voltage to current conversion factors used. Note that these values may need to change if you have a different model number!

_images/DAQ.png

Screenshot of product page for the DAQ board used in D-Lab hardware configuration

Power meter

A power meter is programmatically controlled in order to run laser power calibrations. We currently use the Newport 843-R-USB accessed via Newports' PMManager's COM object. This method should also allow the user to control the 1919-R, 843-R-USB , 844-PE-USB , 845-PE-RS, 1938-R, and 2938-R models with no additional changes, but these models have not been tested. Additional commands could be accessed via the provided COM object if desired. See the user commands manual for more information.

Making the Connection

A version of Newport’s PMManager COM object is required and needs to be installed in order to use the NewportMeter class. This can be installed from https://www.newport.com/t/PMManager-power-meter-application-software. Installing the full PMManager software includes the COM object, and no additional code changes should be needed after the installation.

SRI Gas chromatograph

In our lab, we use the 8610C MULTIPLE GAS ANALYZER #5 GC from SRI instruments with an FID and TCD detector. There is no python package available to control SRI GCs as far as we know (2023/02/16). However, SRI provides a remote control interface in the form of an “API provided through a .NET assembly”. This is downloaded when you install a version of peaksimple onto your lab computer within a zip file called PeaksimpleConnectorTestClient.zip. We include an unzipped version of this package within the catalight/equipment/gc_control directory. The end-user does not need to install PeaksimpleConnector files, but will need an instance of peaksimple installed on the computer. The official documentation file from the SRI website is also stored in this directory as PeakSimpleRemoteControlJune2014.pdf if a user would like to see more information about SRI’s API.

What does this mean and what is a “.NET assembly”? Essentially, .NET is a way of writing code that makes it accessible across multiple languages. Tools can be built using Visual Basic or C then accessed elsewhere in a different language through the “Common Language Runtime” so long as they are built using .NET principles. For us, this means we can access the SRI API by loading it into python with a package called python.NET. This interface works a bit differently from the other tools in this package, like those for controlling MFCs and the Watlow heater, because the API connects us to peaksimple, the GC’s software, rather than directly connecting us to the instrument. In practice, this means that an instance of peaksimple must be installed and running whenever python calls to the instrument are made.

Note

There is a documented bug in SRI’s “PeakSimpleRemoteControlJune2014” instructions stating that

“Once a connection has been broken by stopping either Peaksimple or the calling program, the other must be restarted also before another connection can be made.”

This means that Peaksimple must be manually closed and reopened each time the catalight GUI or scripted interface is closed. If you are using this package with an interactive python kernel, you may also have to restart the kernel before reconnecting to peaksimple. The catalight GUI will attempt to open Peaksimple automatically if it isn’t already, but the user must close Peaksimple after closing the catalight GUI.

_images/peaksimple_client_contents.png

The contents of the PeaksimpleClient folder installed with Peaksimple. The three most important files are highlighted.

_images/peaksimple_client_executable.png

Running PeaksimpleClient.exe

_images/peaksimpleconnectortestclient_contents.png

PeaksimpleConnectorTestClient.sln file contents from Visual Studio

Now that we understand the files inside of SRI’s automation toolkit, lets look at how we can import these tools into python. This is accomplished utilizing the python.NET package, which gives us access to every method you see within the PeaksimpleConnector.TestClient.sln file above.

Import the python.NET package by typing ‘import clr’
import os
import clr  # Essentially python.NET
Reference the PeaksimpleConnector.dll file in the clr. Not these paths are show relative to our gc_control.py file.
dir_path = os.path.dirname(os.path.realpath(__file__))
assemblydir = os.path.join(dir_path, 'PeaksimpleClient', 'PeaksimpleConnector.dll')

clr.AddReference(assmblydir) # Add the assembly to python.NET
Once the reference has been added, simply import the Peaksimple namespace
# Now that the assembly has been added to python.NET,
# it can be imported like a normal module
import Peaksimple  # Import the assembly namespace, which has a different name
You can now create a PeaksimpleConnector object which has access to all the methods provided in the .NET assembly
Connector = Peaksimple.PeaksimpleConnector()  # This class has all the functions

Connector.Connect() # Connect to running instance of peaksimple using class method
Connector.LoadControlFile(ctrl_file)  # Load ctrl file using class method

That pretty much gives you complete control over the GC. Notice that there are not a ton of attributes or methods within the PeaksimpleConnector class. The main interaction the user has with the equipment is achieved by editing the control files. Through editing the control file, the user can change many definitions that would usually be controlled by the peaksimple GUI, but programmatically. Most importantly, you can now set the filename, save location, number of repeats, and use Connector.SetRunning() to start connection. These interactions get wrapped for the user in the GC_Connector() class. See Examples for details on using the class.

_images/control_file_editing.png

The abbreviated contents of the .CON files, which you can open in a text editor. We edit key lines with the GC_Connector() class, which is the same as clicking check boxes and buttons in the editing window used by Peaksimple itself.

Making the Connection

You shouldn’t need to change source code to connect with an SRI GC, but you will need to download Peaksimple from SRI’s website and open the program before launching GC_Connector()