Driver and cfg file for ac resistance bridge
Change-Id: I77b2294b57315fcf7d94996a2a68fcac72866710
This commit is contained in:
parent
95ca85fd9c
commit
41ed82e72e
32
cfg/SIM921_cfg.py
Normal file
32
cfg/SIM921_cfg.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
Node('bridge.psi.ch',
|
||||||
|
'ac resistance bridge',
|
||||||
|
'tcp://5000'
|
||||||
|
)
|
||||||
|
|
||||||
|
Mod('io',
|
||||||
|
'frappy_psi.bridge.BridgeIO',
|
||||||
|
'communication to sim900',
|
||||||
|
uri='serial:///dev/cu.usbserial-21440'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Mod('SIM921_A',
|
||||||
|
# 'frappy_psi.bridge.SIM921',
|
||||||
|
# 'module communication',
|
||||||
|
# io='io',
|
||||||
|
# channel='A'
|
||||||
|
# )
|
||||||
|
|
||||||
|
# Mod('SIM921_B',
|
||||||
|
# 'frappy_psi.bridge.SIM921',
|
||||||
|
# 'module communication',
|
||||||
|
# io='io',
|
||||||
|
# channel='B'
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# Mod('SIM921_C',
|
||||||
|
# 'frappy_psi.bridge.SIM921',
|
||||||
|
# 'module communication',
|
||||||
|
# io='io',
|
||||||
|
# channel='C'
|
||||||
|
# )
|
||||||
|
|
@ -18,7 +18,8 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
from frappy.core import HasIO, Readable, Drivable, Parameter, FloatRange, IntRange, EnumType, \
|
from frappy.core import HasIO, Readable, Drivable, Parameter, FloatRange, IntRange, EnumType, \
|
||||||
Enum
|
Enum, Property, StringType
|
||||||
|
from SR830 import string_to_value
|
||||||
|
|
||||||
|
|
||||||
class BridgeIO(HasIO):
|
class BridgeIO(HasIO):
|
||||||
@ -29,54 +30,62 @@ class BridgeIO(HasIO):
|
|||||||
self.communicate(f'conn {port}')
|
self.communicate(f'conn {port}')
|
||||||
return self.communicate(f'send {port}, "{cmd}\r"')
|
return self.communicate(f'send {port}, "{cmd}\r"')
|
||||||
|
|
||||||
def set_par(self, cmd, *args):
|
# def set_par(self, cmd, *args):
|
||||||
head = ','.join([cmd] + [a if isinstance(a, str) else f'{a:g}' for a in args])
|
# head = ','.join([cmd] + [a if isinstance(a, str) else f'{a:g}' for a in args])
|
||||||
tail = cmd.replace(' ', '? ')
|
# tail = cmd.replace(' ', '? ')
|
||||||
new_tail = re.sub(r'[0-9.]+', '', tail)
|
# new_tail = re.sub(r'[0-9.]+', '', tail)
|
||||||
|
#
|
||||||
reply = self.comm(f'{head};{new_tail}')
|
# reply = self.comm(f'{head};{new_tail}')
|
||||||
result = []
|
# result = []
|
||||||
for num in reply.split(','):
|
# for num in reply.split(','):
|
||||||
try:
|
# try:
|
||||||
result.append(float(num))
|
# result.append(float(num))
|
||||||
except ValueError:
|
# except ValueError:
|
||||||
result.append(num)
|
# result.append(num)
|
||||||
if len(result) == 1:
|
# if len(result) == 1:
|
||||||
return result[0]
|
# return result[0]
|
||||||
return result
|
# return result
|
||||||
|
#
|
||||||
def get_par(self, cmd):
|
# def get_par(self, cmd):
|
||||||
reply = self.comm(cmd)
|
# reply = self.comm(cmd)
|
||||||
result = []
|
# result = []
|
||||||
for num in reply.split(','):
|
# for num in reply.split(','):
|
||||||
try:
|
# try:
|
||||||
result.append(float(num))
|
# result.append(float(num))
|
||||||
except ValueError:
|
# except ValueError:
|
||||||
result.append(num)
|
# result.append(num)
|
||||||
if len(result) == 1:
|
# if len(result) == 1:
|
||||||
return result[0]
|
# return result[0]
|
||||||
return result
|
# return result
|
||||||
|
|
||||||
|
|
||||||
class SIM921(BridgeIO, Readable, Drivable):
|
class SIM921(BridgeIO, Readable, Drivable):
|
||||||
#port = Parameter()
|
channel = Property('sim921 module', StringType())
|
||||||
value = Parameter('temperature', unit='K')
|
|
||||||
setpoint = Parameter('temperature deviation', datatype=FloatRange, unit='K')
|
setpoint = Parameter('temperature deviation', datatype=FloatRange, unit='K')
|
||||||
resistance = Parameter('resistance', datatype=FloatRange, unit='ohm')
|
value = Parameter('resistance', datatype=FloatRange, unit='ohm')
|
||||||
irange = Parameter('resistance range index', IntRange)
|
dev = Property('resistance deviation', FloatRange())
|
||||||
|
|
||||||
|
RES_RANGE = ['20mOhm', '200mOhm', '2Ohm', '20Ohm', '200Ohm', '2kOhm', '20kOhm', '200kOhm',
|
||||||
|
'2MOhm', '20MOhm']
|
||||||
|
|
||||||
|
irange = Parameter('range index', EnumType('resistance range index',
|
||||||
|
{name: idx for idx, name in enumerate(RES_RANGE)}), readonly=False)
|
||||||
|
|
||||||
phase = Parameter('phase', FloatRange, unit='ang')
|
phase = Parameter('phase', FloatRange, unit='ang')
|
||||||
tc = Parameter('time constant', FloatRange)
|
|
||||||
|
TIME_CONST = ['0.3s', '1s', '3s', '10s', '30s', '100s', '300s']
|
||||||
|
|
||||||
|
tc = Parameter('time constant value', FloatRange(1e-1, 3e2), unit='s', readonly=False)
|
||||||
|
itc = Parameter('time constant index',
|
||||||
|
EnumType('time const. index range',
|
||||||
|
{name: value for value, name in enumerate(TIME_CONST)}), 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),
|
||||||
readonly=False, default=0)
|
readonly=False, default=0)
|
||||||
|
|
||||||
|
|
||||||
ioClass = BridgeIO
|
ioClass = BridgeIO
|
||||||
|
|
||||||
def read_resistance(self):
|
|
||||||
return self.get_par('rval')
|
|
||||||
|
|
||||||
def read_value(self):
|
def read_value(self):
|
||||||
return self.get_par('tval')
|
return self.get_par('rval?')
|
||||||
|
|
||||||
def read_phase(self):
|
def read_phase(self):
|
||||||
return self.get_par('phase')
|
return self.get_par('phase')
|
||||||
@ -93,23 +102,8 @@ class SIM921(BridgeIO, Readable, Drivable):
|
|||||||
def write_tc(self, tc):
|
def write_tc(self, tc):
|
||||||
return self.set_par(f'tcon {tc}')
|
return self.set_par(f'tcon {tc}')
|
||||||
|
|
||||||
|
def read_dev(self):
|
||||||
|
return self.comm('rdev?')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user