| 1 |
# |
| 2 |
# This file is part of the PyMeasure package. |
| 3 |
# |
| 4 |
# Copyright (c) 2013-2024 PyMeasure Developers |
| 5 |
# |
| 6 |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 |
# of this software and associated documentation files (the "Software"), to deal |
| 8 |
# in the Software without restriction, including without limitation the rights |
| 9 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 |
# copies of the Software, and to permit persons to whom the Software is |
| 11 |
# furnished to do so, subject to the following conditions: |
| 12 |
# |
| 13 |
# The above copyright notice and this permission notice shall be included in |
| 14 |
# all copies or substantial portions of the Software. |
| 15 |
# |
| 16 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 |
# THE SOFTWARE. |
| 23 |
# |
| 24 |
|
| 25 |
import logging |
| 26 |
|
| 27 |
from pymeasure.instruments import Instrument, Channel |
| 28 |
from pymeasure.instruments.validators import (truncated_range, |
| 29 |
strict_discrete_set) |
| 30 |
|
| 31 |
|
| 32 |
log = logging.getLogger(__name__) |
| 33 |
log.addHandler(logging.NullHandler()) |
| 34 |
|
| 35 |
|
| 36 |
class ROD4Channel(Channel): |
| 37 |
"""Implementation of a ROD-4 MFC channel.""" |
| 38 |
|
| 39 |
actual_flow = Channel.measurement( |
| 40 |
"\x020{ch}RFX", |
| 41 |
"""Measure the actual flow in %.""" |
| 42 |
) |
| 43 |
|
| 44 |
setpoint = Channel.control( |
| 45 |
"\x020{ch}RFD", "\x020{ch}SFD%.1f", |
| 46 |
"""Control the setpoint in % of MFC range.""", |
| 47 |
validator=truncated_range, |
| 48 |
values=[0, 100], |
| 49 |
check_set_errors=True |
| 50 |
) |
| 51 |
|
| 52 |
mfc_range = Channel.control( |
| 53 |
"\x020{ch}RFK", "\x020{ch}SFK%d", |
| 54 |
"""Control the MFC range in sccm. |
| 55 |
Upper limit is 200 slm.""", |
| 56 |
validator=truncated_range, |
| 57 |
values=[0, 200000], |
| 58 |
check_set_errors=True |
| 59 |
) |
| 60 |
|
| 61 |
ramp_time = Channel.control( |
| 62 |
"\x020{ch}RRT", "\x020{ch}SRT%.1f", |
| 63 |
"""Control the MFC setpoint ramping time in seconds.""", |
| 64 |
validator=truncated_range, |
| 65 |
values=[0, 200000], |
| 66 |
check_set_errors=True |
| 67 |
) |
| 68 |
|
| 69 |
valve_mode = Channel.control( |
| 70 |
"\x020{ch}RVM", "\x020{ch}SVM%d", |
| 71 |
"""Control the MFC valve mode. |
| 72 |
Valid options are `flow`, `close`, and `open`. """, |
| 73 |
validator=strict_discrete_set, |
| 74 |
values={'flow': 0, 'close': 1, 'open': 2}, |
| 75 |
map_values=True, |
| 76 |
check_set_errors=True |
| 77 |
) |
| 78 |
|
| 79 |
flow_unit_display = Channel.setting( |
| 80 |
"\x020{ch}SFU%d", |
| 81 |
"""Set the flow units on the front display. |
| 82 |
Valid options are %, sccm, or slm. |
| 83 |
Display in absolute units is in sccm for control range < 10 slm.""", |
| 84 |
validator=strict_discrete_set, |
| 85 |
values={'%': 0, 'sccm': 1, 'slm': 1}, |
| 86 |
map_values=True, |
| 87 |
check_set_errors=True |
| 88 |
) |
| 89 |
|
| 90 |
|
| 91 |
class ROD4(Instrument): |
| 92 |
"""Represents the Proterial ROD-4(A) operator for mass flow controllers |
| 93 |
and provides a high-level interface for interacting with the instrument. |
| 94 |
User must specify which channel to control (1-4). |
| 95 |
|
| 96 |
.. code-block:: python |
| 97 |
|
| 98 |
rod4 = ROD4("ASRL1::INSTR") |
| 99 |
|
| 100 |
print(rod4.version) # Print version and series number |
| 101 |
rod4.ch_1.mfc_range = 500 # Sets Channel 1 MFC range to 500 sccm |
| 102 |
rod4.ch_2.valve_mode = 'flow' # Sets Channel 2 MFC to flow control |
| 103 |
rod4.ch_3.setpoint = 50 # Sets Channel 3 MFC to flow at 50% of full range |
| 104 |
print(rod4.ch_4.actual_flow) # Prints Channel 4 actual MFC flow in % |
| 105 |
|
| 106 |
""" |
| 107 |
|
| 108 |
def __init__(self, adapter, name="ROD-4 MFC Controller", **kwargs): |
| 109 |
super().__init__( |
| 110 |
adapter, name, read_termination='\r', write_termination='\r', |
| 111 |
includeSCPI=False, **kwargs |
| 112 |
) |
| 113 |
|
| 114 |
ch_1 = Instrument.ChannelCreator(ROD4Channel, 1) |
| 115 |
ch_2 = Instrument.ChannelCreator(ROD4Channel, 2) |
| 116 |
ch_3 = Instrument.ChannelCreator(ROD4Channel, 3) |
| 117 |
ch_4 = Instrument.ChannelCreator(ROD4Channel, 4) |
| 118 |
|
| 119 |
version = Instrument.measurement( |
| 120 |
"\x0201RVN", |
| 121 |
"""Get the version and series number. Returns x.xx<TAB>S/N """ |
| 122 |
) |
| 123 |
|
| 124 |
keyboard_locked = Instrument.setting( |
| 125 |
"\x0201SKO%d", |
| 126 |
"""Set the front keyboard lock status.""", |
| 127 |
validator=strict_discrete_set, |
| 128 |
values={False: 0, True: 1}, |
| 129 |
map_values=True, |
| 130 |
check_set_errors=True |
| 131 |
) |
| 132 |
|
| 133 |
def check_set_errors(self): |
| 134 |
"""Read 'OK' from ROD-4 after setting.""" |
| 135 |
response = self.read() |
| 136 |
if response != 'OK': |
| 137 |
errors = ["Error setting ROD-4.",] |
| 138 |
else: |
| 139 |
errors = [] |
| 140 |
return errors |