pyopticon.majumdar_lab_widgets.mks_mfc_widget module
- class pyopticon.majumdar_lab_widgets.mks_mfc_widget.MksMFCWidget(parent_dashboard, name, nickname, channel, **kwargs)
Bases:
GenericWidgetWidget to control MKS ‘mass flo controllers’ (MFCs), which are themselves controlled by an MKS ‘vacuum controller’.
A control box like an MKS ‘946 Vacuum System Controller’ converts digital signals or manual inputs into the actual voltage and/or current signals that control MKS mass flo controllers. One 946 control box can control up to 6 mass flo controllers at once, with some trickery required (described below) to let multiple widgets share a single serial connection.
Each control box has a 3-digit ID number, e.g. 001, which can be configured on the box. Each MFC on the box has a channel, which is one of {A1, A2, B1, B2, C1, C2}. These are fixed when you initialize a widget and can’t be changed from the GUI.
Each mass flo controller on the same vacuum controller gets its own widget, even though they all share the same control box and hence the same serial connection. The first MFC widget is initialized normally, and then for every subsequent widget representing an MFC on the same control box, the constructor is called with the first widget passed as the keyword argument ‘widget_to_share_serial_with’. The later widgets then know to share the serial connection with the first widget, rather than trying to initialize a new one, which would fail because that serial port is already in use by the first widget.
One can also set a ‘scale factor,’ which adjusts for different gas types (e.g. air is usually a conversion factor of 1.0). Refer to the MKS MFC documentation for what scale factor to use for a particular gas. One can optionally lock the scale factor for a certain widget.
Finally, one can add a manual calibration curve independent of the scale factor. This is done by tabulating the commanded flow (i.e., the value sent to the MFC) and the actual flow (according to an external flow meter) at various flow conditions, then feeding the resulting tuples of flows to the constructor for this class.
- Parameters:
parent_dashboard (richardview.dashboard.RichardViewDashboard) – The dashboard object to which this device will be added
name (str) – The name that the widget will be labeled with, and under which its data will be logged, e.g. “Methane Mass Flow Controller”
nickname (str) – A shortened nickname that can be used to identify the widget in automation scripts, e.g. “CH4 MFC”
channel (str) – A string representing which channel on the control box the MFC is connected to. One of (A1,A2,B1,B2,C1,C2).
widget_to_share_serial_with (richardview.majumdar_lab_widgets.mks_mfc_widget.MksMFCWidget, optional) – If this is the 2nd-6th MFC sharing the same control box, pass the widget for the first MFC on that control box as this argument. If not, the arguments device_ID and default_serial_port are required.
device_ID (str, optional) – The ID of the MKS control box / vacuum system controller, which is a string of a 3-digit number, e.g. ‘001’. Can be set on the control box.
default_serial_port (str, optional) – The name of the default selected serial port, e.g. ‘COM9’
force_scale_factor (float, optional) – Optionally set a certain scale factor and disable adjusting the scale factor via the interface. See the MKS manual to select factors for different gases.
calibration (tuple, optional) – a tuple containing two tuples of ints or floats with the results of calibrating the MFC. The first should contain a range of flow commands sent to the MFC. The second should contain the result flows according to an external flow meter. (0,0) should be included, as should a value above the highest flow you expect to use. For example, ( (0,10,20,30), (0,11.5,20.7,33.4) ).
- on_failed_serial_open()
If serial opened unsuccessfully, set readouts to ‘No Reading’
- on_handshake()
This function gets called whenever the widget is initialized. If the widget uses a Serial connection, you can assume that the serial connection was already initialized successfully. If not, you’ll need to initialize whatever objects are needed to update the widget in this method (say, an OEM Python driver).
By default, it just calls on_update(), assuming that the handshake was successful if (and only if) no exception was raised.
- on_update()
Send four queries to the serial device asking for the gas scale factor, mode, setpoint, and actual flow rate. Mode refers to open, closed, or setpoint. Process the results.
- on_serial_close()
When serial is closed, set all readouts to ‘None’.
- on_confirm()
When ‘confirm’ is pressed, send the appropriate commands to the MFC. Prints warnings to console if the entered parameters are invalid.