Tutorial: Next Steps#

There are several ways to go forward after finishing the tutorial.

The most practical way may be to try to build your own system. If you have enough time or interest, try to understand mahos further.

Building your own system#

Writing Instrument#

If you want to build your own system, the first step might be preparing the Instrument class for your instrument. You are very lucky if you can find corresponding class in mahos.inst package. Even when this is not the case, writing your own Instrument is not very difficult; you can use existing classes in mahos.inst as examples. Following subsections explain several methods to write Instrument. It depends on the real instrument’s interface / driver provided by the manufacturer, but most of the instruments will fit into (at least) one of these.

VISA#

VISA (Virtual Instrument Software Architecture) is a standardized communication library for measurement instruments. VISA is an abstraction layer above GPIB, RS232 (Serial), Ethernet or USB. We can use PyVISA library to communicate with the instruments following this standard. VisaInstrument serves as a base class which implements a few convenient methods.

Wrapping Python library#

Some (rather modern) instruments provide libraries for Python. You are lucky! This is usually the easiest case.

Wrapping C library#

We can use Python standard ctypes library to wrap the library for C.

Wrapping C# (.NET) library#

We can use pythonnet library to wrap the library for C# (.NET). The example can be found in implementation of LightField or Thorlabs_KCube_DCServo.

NI-DAQ#

We can use PyDAQmx library to implement Instrument based on National Instruments DAQ. There are several classes in mahos.inst.daq module.

Writing meas Node#

If your measurement is not very complex, the easiest way to write a meas node is to subclass BasicMeasNode. We have already seen an example in Tutorial 2: Basic Measurement.

Writing gui Node#

If a GUI is necessary, you can try writing a GUINode. Since the existing implementations are based on PyQt, you will need some experience or practice to use it.

If you are familiar with other UI (either native / web-based) technologies, it is also possible to implement a GUI node with those technologies. In that case, your node will not be based on GUINode (because this is for PyQt).

Understanding mahos further#

  • Architecture explains the architecture of the mahos system.

  • Configuration file provides a more detailed specification of configuration files.

  • Command Line Interface is a list of CLI commands, but mahos [subcommand] -h may provide more information. You can also read the code in the mahos.cli package, which is not very large.

Reading the codes#

API Reference is not perfect for the time being: not everything is listed, and some classes are undocumented. But we are working toward better documentation. It could be used at least to discover which module or class is important.

You will eventually need to read the code to fully understand mahos internals. We would be very happy if you could report/fix bugs, add missing code/documentation, or give us feedback.