Added alarms
Change-Id: Idd06278e44e01522ddf904b56a452ce8c704b5a6
This commit is contained in:
parent
d62076128a
commit
69dd011260
@ -2,6 +2,7 @@ Node('ls340test.psi.ch',
|
|||||||
'ls340 test',
|
'ls340 test',
|
||||||
'tcp://5000',
|
'tcp://5000',
|
||||||
)
|
)
|
||||||
|
|
||||||
Mod('io',
|
Mod('io',
|
||||||
'frappy_psi.lakeshore.Ls340IO',
|
'frappy_psi.lakeshore.Ls340IO',
|
||||||
'communication to ls340',
|
'communication to ls340',
|
||||||
|
@ -22,7 +22,8 @@ from math import log2
|
|||||||
|
|
||||||
from frappy.core import Readable, Parameter, IntRange, EnumType, FloatRange, \
|
from frappy.core import Readable, Parameter, IntRange, EnumType, FloatRange, \
|
||||||
StringIO, HasIO, StringType, Property, Writable, Drivable, IDLE, ERROR, \
|
StringIO, HasIO, StringType, Property, Writable, Drivable, IDLE, ERROR, \
|
||||||
Attached, StructOf
|
Attached, StructOf, WARN
|
||||||
|
|
||||||
from frappy_psi.mixins import HasOutputModule, HasControlledBy
|
from frappy_psi.mixins import HasOutputModule, HasControlledBy
|
||||||
|
|
||||||
|
|
||||||
@ -45,14 +46,16 @@ class LakeShore(HasIO):
|
|||||||
return [float(num) for num in reply.split(',')]
|
return [float(num) for num in reply.split(',')]
|
||||||
|
|
||||||
|
|
||||||
class Sensor340(HasIO, Readable):
|
class Sensor340(LakeShore, Readable):
|
||||||
"""A channel of 340TC"""
|
"""A channel of 340TC"""
|
||||||
|
|
||||||
# define the communication class to create the IO module
|
# define the communication class to create the IO module
|
||||||
ioClass = Ls340IO
|
ioClass = Ls340IO
|
||||||
|
|
||||||
channel = Property('lakeshore channel', StringType())
|
channel = Property('lakeshore channel', StringType())
|
||||||
# define or alter the parameters
|
# relay_mode = Property('relay setting mode', IntRange(0, 2))
|
||||||
|
# relay = Property('relay high/low', IntRange(1, 2))
|
||||||
|
alarm = Parameter('alarm limits', FloatRange(unit='K'), readonly=False)
|
||||||
|
# # define or alter the parameters
|
||||||
# as Readable.value exists already, we give only the modified property 'unit'
|
# as Readable.value exists already, we give only the modified property 'unit'
|
||||||
value = Parameter(unit='K')
|
value = Parameter(unit='K')
|
||||||
|
|
||||||
@ -70,18 +73,27 @@ class Sensor340(HasIO, Readable):
|
|||||||
return ERROR, 'temperature overrange'
|
return ERROR, 'temperature overrange'
|
||||||
if c >= 16:
|
if c >= 16:
|
||||||
return ERROR, 'temperature underrange'
|
return ERROR, 'temperature underrange'
|
||||||
# do not check for old reading -> this happens regularely on NTCs with T comp
|
# do not check for old reading -> this happens regularly on NTCs with T comp
|
||||||
if c % 2:
|
if c % 2:
|
||||||
return ERROR, 'invalid reading'
|
return ERROR, 'invalid reading'
|
||||||
|
# ask for high alarm status and return warning
|
||||||
|
if '1' in str(self.communicate(f'ALARMST? {self.channel}')):
|
||||||
|
return Warning
|
||||||
return IDLE, ''
|
return IDLE, ''
|
||||||
|
|
||||||
|
def write_alarm(self):
|
||||||
|
return self.set_par(f'ALARM {self.channel}, 1, 1, {self.alarm}, 0, 0, 2')
|
||||||
|
|
||||||
|
def read_alarm(self):
|
||||||
|
return self.get_par(f'ALARM? {self.channel}')[0]
|
||||||
|
|
||||||
|
|
||||||
class HeaterOutput(LakeShore, HasControlledBy, HasIO, Writable):
|
class HeaterOutput(LakeShore, HasControlledBy, HasIO, Writable):
|
||||||
loop = Property('lakeshore loop', IntRange(1, 2), default=1)
|
|
||||||
channel = Property('attached channel', StringType())
|
|
||||||
max_power = Parameter('max heater power', datatype=FloatRange(0, 100), unit='W', readonly=False)
|
max_power = Parameter('max heater power', datatype=FloatRange(0, 100), unit='W', readonly=False)
|
||||||
value = Parameter('heater output', datatype=FloatRange(0, 100), unit='W')
|
value = Parameter('heater output', datatype=FloatRange(0, 100), unit='W')
|
||||||
target = Parameter('manual heater output', datatype=FloatRange(0, 100), unit='W')
|
target = Parameter('manual heater output', datatype=FloatRange(0, 100), unit='W')
|
||||||
|
loop = Property('lakeshore loop', IntRange(1, 2), default=1)
|
||||||
|
channel = Property('attached channel', StringType())
|
||||||
resistance = Property('heater resistance', datatype=FloatRange(10, 1000))
|
resistance = Property('heater resistance', datatype=FloatRange(10, 1000))
|
||||||
current = Property('heater current', datatype=FloatRange(0, 2))
|
current = Property('heater current', datatype=FloatRange(0, 2))
|
||||||
_range = 0
|
_range = 0
|
||||||
@ -120,7 +132,8 @@ class HeaterOutput(LakeShore, HasControlledBy, HasIO, Writable):
|
|||||||
self._range = irange
|
self._range = irange
|
||||||
self.communicate(f'CLIMIT {self.loop},{self.SETPOINTLIMS},0,0,{icurrent},{irange};'
|
self.communicate(f'CLIMIT {self.loop},{self.SETPOINTLIMS},0,0,{icurrent},{irange};'
|
||||||
f'RANGE {irange};'
|
f'RANGE {irange};'
|
||||||
f'CDISP {self.loop},1,{self.resistance},0;RANGE?')
|
f'CDISP {self.loop},1,{self.resistance},0;RANGE?;'
|
||||||
|
f'RELAY? 1') #only high relay
|
||||||
return self.read_max_power()
|
return self.read_max_power()
|
||||||
|
|
||||||
def read_max_power(self):
|
def read_max_power(self):
|
||||||
@ -142,9 +155,6 @@ class HeaterOutput(LakeShore, HasControlledBy, HasIO, Writable):
|
|||||||
def power_to_percent(self, power):
|
def power_to_percent(self, power):
|
||||||
return (power / self._max_power) ** (1 / 2) * 100 # limit
|
return (power / self._max_power) ** (1 / 2) * 100 # limit
|
||||||
|
|
||||||
def read_value(self):
|
|
||||||
return self.percent_to_power(float(self.communicate(f'HTR?')))
|
|
||||||
|
|
||||||
def read_status(self):
|
def read_status(self):
|
||||||
return self.STATUS_MAP[int(self.communicate(f'HTRST?'))]
|
return self.STATUS_MAP[int(self.communicate(f'HTRST?'))]
|
||||||
|
|
||||||
@ -162,6 +172,9 @@ class HeaterOutput(LakeShore, HasControlledBy, HasIO, Writable):
|
|||||||
f'CMODE {self.loop}, {int(mode)};'
|
f'CMODE {self.loop}, {int(mode)};'
|
||||||
f'RANGE?')
|
f'RANGE?')
|
||||||
|
|
||||||
|
def read_value(self):
|
||||||
|
return self.percent_to_power(float(self.communicate(f'HTR?')))
|
||||||
|
|
||||||
|
|
||||||
class TemperatureLoop340(HasOutputModule, Sensor340, Drivable, LakeShore):
|
class TemperatureLoop340(HasOutputModule, Sensor340, Drivable, LakeShore):
|
||||||
target = Parameter(unit='K')
|
target = Parameter(unit='K')
|
||||||
@ -196,3 +209,5 @@ class TemperatureLoop340(HasOutputModule, Sensor340, Drivable, LakeShore):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user