Debian Codegraph @

pymeasure/instruments/thermotron/thermotron3800.py

raw
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 from pymeasure.instruments import Instrument
25 from pymeasure.instruments.validators import strict_range
26 from time import sleep
27 from enum import IntFlag
28
29
30 class Thermotron3800(Instrument):
31 """ Represents the Thermotron 3800 Oven.
32 For now, this driver only supports using Control Channel 1.
33 There is a 1000ms built in wait time after all write commands.
34 """
35
36 def __init__(self, adapter, name="Thermotron 3800", **kwargs):
37 super().__init__(
38 adapter,
39 name,
40 includeSCPI=False,
41 **kwargs
42 )
43
44 def write(self, command):
45 super().write(command)
46 # Insert wait time after sending command.
47 # This wait time should be >1000ms for consistent results.
48 sleep(1)
49
50 id = Instrument.measurement(
51 "IDEN?", """ Get the instrument identification
52
53 :return: String
54 """
55 )
56
57 temperature = Instrument.measurement(
58 "PVAR1?", """ Get the current temperature of the oven
59 via built in thermocouple. Default unit is Celsius, unless
60 changed by the user.
61
62 :return: float
63 """
64 )
65
66 mode = Instrument.measurement(
67 "MODE?", """ Get the operating mode of the oven.
68
69 :return: Tuple(String, int)
70 """,
71 get_process=lambda mode: Thermotron3800.__translate_mode(mode)
72 )
73
74 setpoint = Instrument.control(
75 "SETP1?", "SETP1,%g",
76 """Control the setpoint of the oven in Celsius. (float)
77 "setpoint" will not update until the "run()" command is called.
78 After setpoint is set to a new value, the "run()" command
79 must be called to tell the oven to run to the new temperature.
80
81 :return: None
82 """,
83 validator=strict_range,
84 values=[-55, 150]
85 )
86
87 def run(self):
88 '''
89 Starts temperature forcing. The oven will ramp to the setpoint.
90
91 :return: None
92 '''
93 self.write("RUNM")
94
95 def stop(self):
96 '''
97 Stops temperature forcing on the oven.
98
99 :return: None
100 '''
101 self.write("STOP")
102
103 def initalize_oven(self, wait=True):
104 '''
105 The manufacturer recommends a 3 second wait time after after initializing the oven.
106 The optional "wait" variable should remain true, unless the 3 second wait time is
107 taken care of on the user end. The wait time is split up in the following way:
108 1 second (built into the write function) +
109 2 seconds (optional wait time from this function (initialize_oven)).
110
111 :return: None
112 '''
113 self.write("INIT")
114 if wait:
115 sleep(2)
116
117 class Thermotron3800Mode(IntFlag):
118 """
119 +--------+--------------------------------------+
120 | Bit | Mode |
121 +========+======================================+
122 | 0 | Program mode |
123 +--------+--------------------------------------+
124 | 1 | Edit mode (controller in stop mode) |
125 +--------+--------------------------------------+
126 | 2 | View program mode |
127 +--------+--------------------------------------+
128 | 3 | Edit mode (controller in hold mode) |
129 +--------+--------------------------------------+
130 | 4 | Manual mode |
131 +--------+--------------------------------------+
132 | 5 | Delayed start mode |
133 +--------+--------------------------------------+
134 | 6 | Unused |
135 +--------+--------------------------------------+
136 | 7 | Calibration mode |
137 +--------+--------------------------------------+
138 """
139 PROGRAM_MODE = 1
140 EDIT_MODE_STOP = 2
141 VIEW_PROGRAM_MODE = 4
142 EDIT_MODE_HOLD = 8
143 MANUAL_MODE = 16
144 DELAYED_START_MODE = 32
145 UNUSED = 64
146 CALIBRATION_MODE = 128
147
148 @staticmethod
149 def __translate_mode(mode_coded_integer):
150
151 mode = Thermotron3800.Thermotron3800Mode(int(mode_coded_integer))
152
153 return mode