Added tc for the Ametek 7265
Change-Id: Ifd8e55b2da14cb41391f72787cd726951192ec95
This commit is contained in:
parent
161fb7b2ca
commit
dc59906c8a
180
frappy_psi/SR.py
180
frappy_psi/SR.py
@ -29,7 +29,7 @@ from frappy.errors import RangeError
|
|||||||
|
|
||||||
class SR_IO(StringIO):
|
class SR_IO(StringIO):
|
||||||
end_of_line = b'\x00'
|
end_of_line = b'\x00'
|
||||||
identification = [('ID', r'.*')] # Identification; causes the lock-in amplifier to respond with the number 7270
|
identification = [('ID', r'72.*')] # Identification; causes the lock-in amplifier to respond with the model number
|
||||||
|
|
||||||
def communicate(self, cmd): # remove dash from terminator
|
def communicate(self, cmd): # remove dash from terminator
|
||||||
reply = super().communicate(cmd)
|
reply = super().communicate(cmd)
|
||||||
@ -39,7 +39,7 @@ class SR_IO(StringIO):
|
|||||||
|
|
||||||
class XY(HasIO, Readable):
|
class XY(HasIO, Readable):
|
||||||
value = Parameter('X, Y', datatype=TupleOf(FloatRange(unit='V'), FloatRange(unit='V')))
|
value = Parameter('X, Y', datatype=TupleOf(FloatRange(unit='V'), FloatRange(unit='V')))
|
||||||
freq = Parameter('oscill. frequen. control', FloatRange(0.001, 250e3), unit='Hz', readonly=False)
|
freq = Parameter('oscill. frequen. control', FloatRange(0, 250e3), unit='Hz', readonly=False)
|
||||||
amp = Parameter('oscill. amplit. control', FloatRange(0.00, 5), unit='V_rms', readonly=False)
|
amp = Parameter('oscill. amplit. control', FloatRange(0.00, 5), unit='V_rms', readonly=False)
|
||||||
range = Parameter('sensitivity value', FloatRange(0.00, 1), unit='V', default=1, readonly=False)
|
range = Parameter('sensitivity value', FloatRange(0.00, 1), unit='V', default=1, readonly=False)
|
||||||
autorange = Parameter('autorange_on', EnumType('autorange', off=0, soft=1, hard=2),
|
autorange = Parameter('autorange_on', EnumType('autorange', off=0, soft=1, hard=2),
|
||||||
@ -52,53 +52,37 @@ class XY(HasIO, Readable):
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
irange = Parameter('sensitivity index', EnumType('sensitivity index range', sen_range), readonly=False)
|
irange = Parameter('sensitivity index', EnumType('sensitivity index range', sen_range), readonly=False)
|
||||||
|
|
||||||
time_const = {name: value for value, name in enumerate(
|
|
||||||
['10us', '20us', '50us', '100us', '200us', '500us', '1ms', '2ms', '5ms', '10ms',
|
|
||||||
'20ms', '50ms', '100ms', '200ms', '500ms', '1s', '2s', '5s', '10s', '20s', '50s',
|
|
||||||
'100s', '200s', '500s', '1ks', '2ks', '5ks', '10ks', '20ks', '50ks', '100ks']
|
|
||||||
)}
|
|
||||||
|
|
||||||
tc = Parameter('time const. value', FloatRange(0.00001, 100000), unit='s', readonly=False)
|
|
||||||
itc = Parameter('time const. index', EnumType('time const. index range', time_const), readonly=False)
|
|
||||||
nm = Parameter('noise mode on', BoolType(), readonly=False)
|
nm = Parameter('noise mode on', BoolType(), readonly=False)
|
||||||
phase = Parameter('reference phase control', FloatRange(-360, 360), unit='deg', readonly=False)
|
phase = Parameter('reference phase control', FloatRange(-360, 360), unit='deg', readonly=False)
|
||||||
vmode = Parameter('control mode', EnumType(both_grounded=0, A=1, B=2, A_B_diff=3), readonly=False)
|
vmode = Parameter('control mode', EnumType(both_grounded=0, A=1, B=2, A_B_diff=3), readonly=False)
|
||||||
# filter = Parameter('line frequency filter', unit='Hz')
|
|
||||||
# dac = Parameter('output DAC channel value', datatype=TupleOf(IntRange(1, 4), FloatRange(0.0, 5000, unit='mV')),
|
|
||||||
# readonly=False, initwrite=True, default=(3,0))
|
|
||||||
# dac = Parameter('output DAC channel value', FloatRange(-10000, 10000, unit='mV'),
|
|
||||||
# readonly=False, initwrite=True, default=0)
|
|
||||||
|
|
||||||
ioClass = SR_IO
|
ioClass = SR_IO
|
||||||
|
|
||||||
def string_to_value(self, value):
|
def read_status(self):
|
||||||
value_with_unit = re.compile(r'(\d+)([pnumkMG]?)')
|
pass
|
||||||
value, pfx = value_with_unit.match(value).groups()
|
|
||||||
pfx_dict = {'p': 1e-12, 'n': 1e-9, 'u': 1e-6, 'm': 1e-3, 'k': 1e3, 'M': 1e6, 'G':1e9}
|
|
||||||
if pfx in pfx_dict:
|
|
||||||
value = round(float(value) * pfx_dict[pfx], 12)
|
|
||||||
return float(value)
|
|
||||||
|
|
||||||
def comm(self, cmd):
|
def comm(self, cmd):
|
||||||
reply, status, overload = self.communicate(cmd).split(';')
|
reply, status, overload = self.communicate(cmd).split(';') # try/except
|
||||||
reply = reply.rstrip('\n')
|
reply = reply.rstrip('\n')
|
||||||
if overload != '0':
|
if overload != '0':
|
||||||
self.status = (self.Status.WARN, f'overload {overload}')
|
self.status = (self.Status.WARN, f'overload {overload}')
|
||||||
self.status = (self.Status.IDLE, '')
|
self.status = (self.Status.IDLE, '')
|
||||||
return reply
|
return reply
|
||||||
|
|
||||||
def comparison(self, curr_value, new_value, value_dict):
|
def string_to_value(self, value):
|
||||||
c_ind = None # closest index
|
"""
|
||||||
c_diff = None # closets difference
|
This method is used for writing methods (sensitivity range and time constant in particular). As the dictionaries
|
||||||
|
with names were used (pop-up list in gui) this method transforms names into float values, that can be used
|
||||||
for index, value in value_dict.items():
|
further.
|
||||||
if c_diff is None or abs(new_value - value) < c_diff:
|
:param value:
|
||||||
c_ind = index
|
:return:
|
||||||
c_diff = abs(new_value - value)
|
"""
|
||||||
|
value_with_unit = re.compile(r'(\d+)([pnumkMG]?)')
|
||||||
if abs(curr_value - new_value) < c_diff:
|
value, pfx = value_with_unit.match(value).groups()
|
||||||
return c_ind
|
pfx_dict = {'p': 1e-12, 'n': 1e-9, 'u': 1e-6, 'm': 1e-3, 'k': 1e3, 'M': 1e6, 'G':1e9}
|
||||||
|
if pfx in pfx_dict:
|
||||||
|
value = round(float(value) * pfx_dict[pfx], 12)
|
||||||
|
return float(value)
|
||||||
|
|
||||||
def read_value(self):
|
def read_value(self):
|
||||||
reply = self.comm('XY.').split(',')
|
reply = self.comm('XY.').split(',')
|
||||||
@ -158,14 +142,13 @@ class XY(HasIO, Readable):
|
|||||||
|
|
||||||
def write_range(self, target):
|
def write_range(self, target):
|
||||||
cl_idx = None
|
cl_idx = None
|
||||||
cl_diff = float('inf')
|
|
||||||
|
|
||||||
for name, idx in self.sen_range.items():
|
for name, idx in self.sen_range.items():
|
||||||
value = self.string_to_value(name)
|
value = self.string_to_value(name)
|
||||||
diff = abs(value - target)
|
if value < target < self.sen_range.get(idx + 1, float('inf')):
|
||||||
if diff < cl_diff:
|
cl_idx = idx + 1
|
||||||
|
elif value == target:
|
||||||
cl_idx = idx
|
cl_idx = idx
|
||||||
cl_diff = diff
|
|
||||||
self.write_irange(cl_idx)
|
self.write_irange(cl_idx)
|
||||||
return self.read_range()
|
return self.read_range()
|
||||||
|
|
||||||
@ -178,36 +161,6 @@ class XY(HasIO, Readable):
|
|||||||
self.read_nm()
|
self.read_nm()
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def read_tc(self):
|
|
||||||
reply = self.comm('TC.')
|
|
||||||
return float(reply)
|
|
||||||
|
|
||||||
def write_tc(self, target):
|
|
||||||
cl_idx = None
|
|
||||||
cl_diff = float('inf')
|
|
||||||
|
|
||||||
for name, idx in self.time_const.items():
|
|
||||||
value = self.string_to_value(name)
|
|
||||||
diff = abs(value - target) # range is the actual value, like SEN.
|
|
||||||
if diff < cl_diff:
|
|
||||||
cl_idx = idx
|
|
||||||
cl_diff = diff
|
|
||||||
if self.nm:
|
|
||||||
if cl_idx < 5 or cl_idx > 9:
|
|
||||||
idx = self.read_tc()
|
|
||||||
raise RangeError('Not allowed with noisemode=1')
|
|
||||||
self.comm(f'TC {cl_idx}')
|
|
||||||
return self.read_tc()
|
|
||||||
|
|
||||||
def read_itc(self):
|
|
||||||
return int(self.comm('TC'))
|
|
||||||
|
|
||||||
def write_itc(self, itc):
|
|
||||||
value = int(itc)
|
|
||||||
self.comm(f'TC {value}')
|
|
||||||
self.read_tc()
|
|
||||||
return value
|
|
||||||
|
|
||||||
# phase and autophase
|
# phase and autophase
|
||||||
def read_phase(self):
|
def read_phase(self):
|
||||||
reply = self.comm('REFP.')
|
reply = self.comm('REFP.')
|
||||||
@ -230,3 +183,92 @@ class XY(HasIO, Readable):
|
|||||||
value = int(vmode)
|
value = int(vmode)
|
||||||
self.comm(f'VMODE {value}')
|
self.comm(f'VMODE {value}')
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
class XY70(XY):
|
||||||
|
|
||||||
|
time_const = {name: value for value, name in enumerate(
|
||||||
|
['10us', '20us', '50us', '100us', '200us', '500us', '1ms', '2ms', '5ms', '10ms',
|
||||||
|
'20ms', '50ms', '100ms', '200ms', '500ms', '1s', '2s', '5s', '10s', '20s', '50s',
|
||||||
|
'100s', '200s', '500s', '1ks', '2ks', '5ks', '10ks', '20ks', '50ks', '100ks']
|
||||||
|
)}
|
||||||
|
|
||||||
|
tc = Parameter('time const. value', FloatRange(0.00001, 100000), unit='s', readonly=False)
|
||||||
|
itc = Parameter('time const. index', EnumType('time const. index range', time_const), readonly=False)
|
||||||
|
|
||||||
|
ioClass = SR_IO
|
||||||
|
|
||||||
|
def comm(self, cmd):
|
||||||
|
reply, status, overload = self.communicate(cmd).split(';')
|
||||||
|
reply = reply.rstrip('\n')
|
||||||
|
if overload != '0':
|
||||||
|
self.status = (self.Status.WARN, f'overload {overload}')
|
||||||
|
self.status = (self.Status.IDLE, '')
|
||||||
|
return reply
|
||||||
|
|
||||||
|
def read_tc(self):
|
||||||
|
reply = self.comm('TC.')
|
||||||
|
return float(reply)
|
||||||
|
|
||||||
|
def write_tc(self, target):
|
||||||
|
cl_idx = None
|
||||||
|
cl_diff = float('inf')
|
||||||
|
|
||||||
|
for name, idx in self.time_const.items():
|
||||||
|
value = self.string_to_value(name)
|
||||||
|
diff = abs(value - target) # range is the actual value, like SEN.
|
||||||
|
if diff < cl_diff:
|
||||||
|
cl_idx = idx
|
||||||
|
cl_diff = diff
|
||||||
|
|
||||||
|
if self.nm is False or (self.nm is True and 5 <= cl_idx <= 9):
|
||||||
|
self.comm(f'TC {cl_idx}')
|
||||||
|
return self.read_tc()
|
||||||
|
raise RangeError('Not allowed with noisemode=1')
|
||||||
|
|
||||||
|
def read_itc(self):
|
||||||
|
return int(self.comm('TC'))
|
||||||
|
|
||||||
|
def write_itc(self, itc):
|
||||||
|
value = int(itc)
|
||||||
|
self.comm(f'TC {value}')
|
||||||
|
self.read_tc()
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
class XY65(XY):
|
||||||
|
|
||||||
|
time_const = {name: value for value, name in enumerate(
|
||||||
|
['10us', '20us', '40us', '80us', '160us', '320us', '640us', '5ms', '10ms', '20ms',
|
||||||
|
'50ms', '100ms', '200ms', '500ms', '1s', '2s', '5s', '10s', '20s', '50s', '100s',
|
||||||
|
'200s', '500s', '1ks', '2ks', '5ks', '10ks', '20ks', '50ks', '100ks']
|
||||||
|
)}
|
||||||
|
|
||||||
|
def read_tc(self):
|
||||||
|
reply = self.comm('TC.')
|
||||||
|
return float(reply)
|
||||||
|
|
||||||
|
def write_tc(self, target):
|
||||||
|
cl_idx = None
|
||||||
|
cl_diff = float('inf')
|
||||||
|
|
||||||
|
for name, idx in self.time_const.items():
|
||||||
|
value = self.string_to_value(name)
|
||||||
|
diff = abs(value - target) # range is the actual value, like SEN.
|
||||||
|
if diff < cl_diff:
|
||||||
|
cl_idx = idx
|
||||||
|
cl_diff = diff
|
||||||
|
|
||||||
|
if self.nm is False or (self.nm is True and 5 <= cl_idx <= 9):
|
||||||
|
self.comm(f'TC {cl_idx}')
|
||||||
|
return self.read_tc()
|
||||||
|
raise RangeError('Not allowed with noisemode=1')
|
||||||
|
|
||||||
|
def read_itc(self):
|
||||||
|
return int(self.comm('TC'))
|
||||||
|
|
||||||
|
def write_itc(self, itc):
|
||||||
|
value = int(itc)
|
||||||
|
self.comm(f'TC {value}')
|
||||||
|
self.read_tc()
|
||||||
|
return value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user