changes after testing

This commit is contained in:
stark_a committed 2026-09-02 15:50:57 +02:00
1 parent 2e0b800d0c
commit 6b4383cffc
4 files changed
+164 -168

No files matched your search

+26 -8
View File
@@ -30,19 +30,30 @@ Mod('ch1',
io = 'io_tmon',
channel = 1,
switcher = 'switcher',
calcurve = 'rx078',
enabled = False, # disable when used as heater
calcurve = 'rx198', #'rx262', #'rx078',
enabled = True, # disable when used as heater
)
Mod('ch3',
'frappy_psi.lakeshore370.Sensor',
# Mod('ch3',
# 'frappy_psi.lakeshore370.Sensor',
# 'tmon sample',
# io = 'io_tmon',
# channel = 3,
# switcher = 'switcher',
# calcurve = 'cx198', #'cx262', #rx078',
# enabled = True,
# )
Mod('sample',
'frappy_psi.lakeshore370.TemperatureLoop',
'tmon sample',
io = 'io_tmon',
io = 'io_treg',
channel = 3,
switcher = 'switcher',
calcurve = 'rx078',
output_module = 'htr',
enabled = True,
)
calcurve = 'cx078',
)
Mod('ch4',
'frappy_psi.lakeshore370.Sensor',
@@ -61,7 +72,7 @@ Mod('ch10',
channel = 10,
switcher = 'switcher',
calcurve = 'ruoxm0',
enabled = True,
enabled = False,
)
Mod('ch11',
@@ -84,6 +95,13 @@ Mod('ch12',
enabled = True,
)
Mod('htr',
'frappy_psi.lakeshore370.MainOutput',
'htr main output',
io = 'io_tmon',
max_heater = Param('0W')
)
# ### temperature regulating lakeshore (treg) ###
+17 -3
View File
@@ -636,6 +636,7 @@ class SensorBase(Base, Readable):
status = Parameter(datatype=StatusType(Readable, 'DISABLED', 'BUSY'))
channel = Property('used channel', StringType()) # input
enabled = Parameter('enable flag', BoolType(), readonly=False)
filter = Parameter('no. of filter points', datatype=FloatRange(2, 64, unit='points'), readonly=False)
curve_no = None
STATUS_BIT_LABELS = 'invalid_reading old_reading b2 b3 t_under t_over units_zero units_overrange'.split()
_value_error = None
@@ -680,6 +681,18 @@ class SensorBase(Base, Readable):
self._raw_error = raw_error
return status, value, raw
def read_filter(self):
on, settle = self.query(f'FILTER?{self.channel}', int, int)
return settle if on else 0
def write_filter(self, value):
on = 1 if value else 0
value = max(1, value)
on, settle, _ = self.command(f'FILTER {self.channel}', on, value, self.channel)
if not on:
settle = 0
return settle
class RawSensor(SensorBase):
"""class for sensors using raw value (w/o calibration curve)"""
@@ -711,6 +724,7 @@ class Sensor(SensorBase):
raw = Parameter('raw', datatype=FloatRange(unit='Ohm'))
calcurve = Parameter('calibration curve name', StringType(), readonly=False)
curve_no = None
intype = None
_curve_handling = False # True when a device is present and device.curve_handling is True
DISPLAY_UNIT = 1 # number as for DISPFLD command
# TODO: implement alarms
@@ -941,7 +955,7 @@ class MainOutput(Output):
self.log.info('configure %r', control_loop)
# self.command(f'CDISP {self.output_no}', 1, self.resistance, 1, 0)
if control_loop is None:
mode = self.query(f'OUTMODE?{self.output_no}', int)
mode = self.query(f'OUTMODE? {self.output_no}', int)
if mode != 3: # open loop
self.command(f'OUTMODE {self.output_no}', 3) # control off
# self.command(f'OUTMODE {self.output_no}', 3, self.channel, 0) # control off
@@ -953,10 +967,10 @@ class MainOutput(Output):
self.put_manual_power(control_loop.power_offset)
def read_max_power(self):
curidx, self._user_current = self.query(f'HTRSET? {self.output_no}', int, int, float)[1:3] # ! cmd not found in ls370 manual (HTRRNG?)
curidx, self._user_current = self.query(f'HTRSET? {self.output_no}', int, int, float)[1:3]
if not self._user_current:
self._user_current = 2.0 ** (curidx * 0.5 - 1)
self._htr_range = self.query(f'RANGE?{self.output_no}', int) or self._htr_range # ! cmd not found in ls370 manual (HTRRNG?)
self._htr_range = self.query(f'RANGE?{self.output_no}', int) or self._htr_range
self._power_scale = self.imax ** 2 * self.heater_ranges[self._htr_range] / 1e4
return self.calc_power(100)
+20 -26
View File
@@ -20,7 +20,7 @@
"""LakeShore 370"""
import time
from math import sqrt
import math
from frappy.datatypes import BoolType, EnumType, FloatRange, IntRange, StatusType
from frappy.core import Done, Drivable, Parameter, Property, CommonReadHandler, CommonWriteHandler, Writable, \
IDLE, ERROR, DISABLED, Command, Attached
@@ -422,7 +422,7 @@ class Sensor(SensorBase, ls.Sensor):
def install_curve(self):
"""already done in install_sensor()"""
reply = self.query(f'INSET?{self.channel}', int, int, int, int, int)
self.log.warn('install curve %r %r %r', reply, self.curve_no, self.enabled)
self.log.info('install curve %r %r', self.curve_no, self.enabled)
if reply[3] != self.curve_no:
self.enabled, self.dwell, self.pause, _, _ = self.command(
f'INSET {self.channel}', self.enabled, self.dwell, self.pause,
@@ -454,7 +454,7 @@ class SorbHeater(ls.HasLscIO, Writable):
fullpower = Parameter('power at 100 %', FloatRange(0, unit='$'), readonly=False, default=5)
def write_target(self, value):
percent = 100 * sqrt(value / self.fullpower)
percent = 100 * math.sqrt(value / self.fullpower)
on = bool(value)
if on != bool(self.heater_range):
self.write_heater_range(on)
@@ -521,31 +521,23 @@ class TemperatureLoop(ls.Loop, Sensor, Drivable):
return target
HEATER_RANGES = {8 - i: 10 ** -i for i in range(8)}
class MainOutput(ls.MainOutput):
ioClass = IO
model = 370
output_no = Parameter('output number', datatype=IntRange(0))
HTRRNG = {n: i for i, n in enumerate(['off', '31.6uA', '100uA', '316uA', '1mA', '3.16mA', '10mA', '31.6mA', '100mA'])}
# htrrng = Parameter('', EnumType(HTRRNG), readonly=False)
htr = Parameter('heater percentage', FloatRange(unit='%'))
minheater = Parameter('minimal heater current', FloatRange(0, 0.01, unit='A'), readonly=False, default=0)
resistance = Parameter(datatype=FloatRange(1,100000, unit='Ohm'))
heater_ranges = HEATER_RANGES
heater_ranges = {8 - i: 10 ** -i for i in range(8)}
sorted_factors = sorted((v, i) for i, v in heater_ranges.items())
HTRST_MAP = {
0: (IDLE, ''),
1: (ERROR, 'Open heater load'),
}
_manual_output = 0.0 # TODO: check how to set this
vmax = 50
imax = 2
max_currents = {4 - i: 2 ** (1 - i) for i in range(4)}
SETPOINTLIMS = 1500.0
sorted_factors = sorted([(fhtr * fcur ** 2, (i, h))
for i, fcur in max_currents.items()
for h, fhtr in HEATER_RANGES.items()
])
vmax = 10
imax = 0.1
def get_status(self):
st = self.query(f'HTRST?', int)
@@ -555,21 +547,23 @@ class MainOutput(ls.MainOutput):
if self._desired_max_power is None:
self.log.info(f'max_heater {self.writeDict} {self.max_heater}')
self.write_max_heater(self.max_heater)
icurrent, htr_range = self.get_best_power_idx(self._desired_max_power, 1.1)
self._power_scale = self.max_currents[icurrent] ** 2 * self.heater_ranges[htr_range] / 1e4
self._htr_range = htr_range
self._htr_range = irng = self.get_best_power_idx(self._desired_max_power)
self.log.info('htr rng %r', self.heater_ranges)
user_current = max(0.1, min(self.imax, 2 * math.sqrt(self._desired_max_power /
self.heater_ranges[irng] / self.resistance)))
self._power_scale = user_current ** 2 * self.heater_ranges[irng] / 1e4
control_loop = self.get_control_loop()
ch, filt, unit, delay, curr, _, _ = self.query(f'CSET?', int, int, int, int, float, float, float) # control on
if control_loop is None:
mode = self.query(f'CMODE?', int)
if mode != 3: # open loop
self.command(f'CSET', '0', 1, 1, 1, 1, self._htr_range, self.resistance) # control off
self.command(f'CSET', ch, filt, unit, delay, curr, self._htr_range, self.resistance)
self.command(f'CMODE', 3) # open loop
self.command('HTRRNG', self._htr_range)
self.put_manual_power(self._manual_output)
self.put_manual_power(0) # for security, we don't want to increase the output power
else:
self.log.info('control_loop %r, %r', control_loop, control_loop.channel)
self.command(f'CSET', control_loop.channel, 1, 1, 1, 1, self._htr_range, self.resistance) # control on
self.command(f'CSET', control_loop.channel, filt, unit, delay, curr, self._htr_range, self.resistance)
self.command(f'CMODE', 1) # pid
self.command('HTRRNG', self._htr_range)
self.put_manual_power(control_loop.power_offset)
@@ -622,10 +616,9 @@ class MainOutput(ls.MainOutput):
class AnalogOutput(ls.HasLscIO, Writable):
target = Parameter('target', datatype=FloatRange(0, 100, unit='%'))
value = Parameter('value', datatype=FloatRange(0, 100, unit='%'))
output_no = Property('output number', datatype=IntRange(1, 2))
output_no = Parameter('output number', datatype=IntRange(1, 2))
def write_target(self, target):
if target > 0:
@@ -634,4 +627,5 @@ class AnalogOutput(ls.HasLscIO, Writable):
self.command(f'ANALOG {self.output_no}', 1, 0, 1, 1, 0.0, 0.0, target) # off (0)
def read_value(self):
return self.query(f'ANALOG? {self.output_no}', int, int, int, int, float, float, float)[6]
# return self.query(f'ANALOG? {self.output_no}', int, int, int, int, float, float, float)[6]
return self.query(f'AOUT? {self.output_no}', float)
+101 -131
View File
@@ -52,8 +52,7 @@ class Device(ls.Device):
channels = list(range(1, 17))
user_curves = (21, 60) # the last curve is 20
log_formats = True, True # log Ohm / log K is supported
cmds_per_line = 1
_crvsav_deadline = None
cmds_per_line = 5
def disable_channel(self, channel):
self.command(f'INSET {channel}', 0, 1, 3, 0, 1)
@@ -99,6 +98,7 @@ class Device(ls.Device):
if loc > 8:
return
self.command(f'DISPFLD {loc}', ch, sens.DISPLAY_UNIT)
self.command('INNAME', sens.name)
class Switcher(ls.HasLscIO, ChannelSwitcher):
@@ -263,7 +263,6 @@ class SensorBase(Ls372, ls.SensorBase, Channel):
else:
lim = 0.2
while rng > self.minrange and abs(raw) < lim * self.RES_SCALE[rng]:
# self.log.info('%r < %r, %r', raw, lim * self.RES_SCALE[rng], rng)
rng -= 1
direction = -1
lim -= 0.05 # not more than 4 steps at once
@@ -298,7 +297,7 @@ class SensorBase(Ls372, ls.SensorBase, Channel):
@CommonReadHandler(rdgrng_params)
def read_rdgrng(self):
# rdgrng_params = 'range', 'iexc', 'vexc'
# rdgrng_params = 'range', 'iexc', 'vexc' -> read_range(), read_iexc(), read_vexc()
iscur, exc, autorange, rng, excoff, units = self.query(f'INTYPE?{self.channel}',
int, int, int, int, int, int)
self._prev_rdgrng = iscur, exc
@@ -321,6 +320,7 @@ class SensorBase(Ls372, ls.SensorBase, Channel):
@CommonWriteHandler(rdgrng_params)
def write_rdgrng(self, change):
# rdgrng_params = 'range', 'iexc', 'vexc' -> write_range(), write_iexc(), write_vexc()
self.read_range() # make sure autorange is handled
if 'vexc' in change: # in case vext is changed, do not consider iexc
change['iexc'] = 0
@@ -339,24 +339,23 @@ class SensorBase(Ls372, ls.SensorBase, Channel):
if self.autorange:
rng = max(rng, self.minrange)
self.command(f'INTYPE {self.channel}', iscur, exc, 0, rng, excoff, 2)
# self.log.info('write_intype %g', rng)
self.read_range()
@CommonReadHandler(inset_params)
def read_inset(self):
# self.log.info('read_inset %r, %x', self.write_enabled, id(type(self).write_enabled))
# inset_params = 'enabled', 'pause', 'dwell' -> read_enabled(), read_pause(), read_dwell()
# ignore curve no and temperature coefficient
self.enabled, self.dwell, self.pause, self.curve_no, self.tempco \
= self.query(f'INSET?{self.channel}', int, int, int, int, int)
@CommonWriteHandler(inset_params)
def write_inset(self, change):
# inset_params = 'enabled', 'pause', 'dwell' -> write_enabled(), write_pause(), write_dwell()
_, _, _, curve_no, tempco = self.query(f'INSET?{self.channel}', int, int, int, int, int)
self.enabled, self.dwell, self.pause, _, _ = self.command(
f'INSET {self.channel}', change['enabled'], change['dwell'], change['pause'],
curve_no, tempco)
if 'enabled' in change:
# self.log.info('channel %r, enable %r', self.channel, change['enabled'])
if change['enabled']:
# switch to enabled channel
self.switcher.write_target(self.channel)
@@ -365,18 +364,6 @@ class SensorBase(Ls372, ls.SensorBase, Channel):
elif self.switcher.target == self.channel:
self.switcher.set_delays(self)
def read_filter(self):
on, settle = self.query(f'FILTER?{self.channel}', int, int)
return settle if on else 0
def write_filter(self, value):
on = 1 if value else 0
value = max(1, value)
on, settle, _ = self.command(f'FILTER {self.channel}', on, value, self.channel)
if not on:
settle = 0
return settle
class RawSensor(SensorBase, ls.RawSensor):
DISPLAY_UNIT = 2 # number as for DISPLOC command
@@ -406,7 +393,7 @@ class Sensor(SensorBase, ls.Sensor):
raw = self.query(f'RDGR?{ch}', float)
value = self.query(f'RDGK?{ch}', float)
return rdgst, raw, value
def get_data(self):
if not self.enabled:
self.status = DISABLED, 'disabled'
@@ -416,12 +403,14 @@ class Sensor(SensorBase, ls.Sensor):
def install_sensor(self):
if self.query(f'INSET?{self.channel}', int, int, int, int, int)[4] != self.tempco:
# we have to call write_inset() (CommonWriteHandler)
# as self.tempco is not a Parameter
self.write_enabled(self.enabled)
def install_curve(self):
"""already done in install_sensor()"""
reply = self.query(f'INSET?{self.channel}', int, int, int, int, int)
self.log.warn('install curve %r %r %r', reply, self.curve_no, self.enabled)
self.log.info('install curve %r %r', self.curve_no, self.enabled)
if reply[3] != self.curve_no:
self.enabled, self.dwell, self.pause, _, _ = self.command(
f'INSET {self.channel}', self.enabled, self.dwell, self.pause,
@@ -437,12 +426,45 @@ class Sensor(SensorBase, ls.Sensor):
else:
self.tempco = 1 # NTC
return logformat, range_limit
def announce_data(self, raw, value):
self.announceUpdate('value', value, self._value_error)
self.announceUpdate('raw', raw, self._raw_error)
class SensorA(ls.Sensor):
channel = 'A'
status = Parameter(datatype=StatusType(Drivable, 'DISABLED'))
enabled = Parameter('is this channel enabled?', datatype=BoolType(), readonly=False)
filter = Parameter('filter time', datatype=FloatRange(0, 200, unit='s'), readonly=False)
tempco = None
install_sensor = Sensor.install_sensor
get_curve_type = Sensor.get_curve_type
announce_data = Sensor.announce_data
def get_internal_data(self):
ch = self.channel
rdgst = self.query(f'RDGST?{ch}', int)
raw = self.query(f'RDGR?{ch}', float)
value = self.query(f'RDGK?{ch}', float)
return rdgst, raw, value
def get_data(self):
if not self.enabled:
self.status = DISABLED, 'disabled'
return self.status, self.value, self.raw
def install_curve(self):
"""already done in install_sensor()"""
reply = self.query(f'INSET?{self.channel}', int, int, int, int, int)
self.log.info('install curve %r %r', self.curve_no, self.enabled)
if reply[3] != self.curve_no:
self.enabled, _, _, _, _ = self.command(
f'INSET {self.channel}', self.enabled, reply[1], reply[2],
self.curve_no, self.tempco)
class SorbHeater(ls.HasLscIO, Writable):
value = Parameter('heater output', FloatRange(0, unit='W'))
target = Parameter('heater output', FloatRange(0, unit='$'), readonly=False, default=0)
@@ -518,117 +540,65 @@ class TemperatureLoop(ls.Loop, Sensor, Drivable):
return target
HEATER_RANGES = {8 - i: 10 ** -i for i in range(8)}
class MainOutput(ls.MainOutput):
"""Sample heater"""
ioClass = IO
model = 372
output_no = Property('output number', datatype=IntRange(0))
HTRRNG = {n: i for i, n in enumerate(['off', '31.6uA', '100uA', '316uA', '1mA', '3.16mA', '10mA', '31.6mA', '100mA'])}
# htrrng = Parameter('', EnumType(HTRRNG), readonly=False)
htr = Parameter('heater percentage', FloatRange(unit='%'))
minheater = Parameter('minimal heater current', FloatRange(0, 0.01, unit='A'), readonly=False, default=0)
resistance = Parameter(datatype=FloatRange(1,100000, unit='Ohm'))
heater_ranges = {8 - i: 10 ** -i for i in range(8)}
sorted_factors = sorted((v, i) for i, v in heater_ranges.items())
HTRST_MAP = {
0: (IDLE, ''),
1: (ERROR, 'Open heater load'),
2: (ERROR, 'Heater short circuit'),
3: (ERROR, 'Voltage compliance'),
}
vmax = 10
imax = 0.1
@Command
def control_off(self):
"""switch control off"""
self._control_active = False
self.command(f'RANGE', 0)
self.read_control_active()
def set_htrrng(self):
if self._control_active:
newhtr = int(self.htrrng) if self._control_active else 0
htrrng = self.query('RANGE?', int)
if htrrng != newhtr:
if newhtr:
self.log.info('switched heater on %d', newhtr)
self.command('RANGE', newhtr)
def put_manual_power(self, value):
self.command(f'MOUT ', value)
# def write_htrrng(self, value):
# if self._control_active:
# self.command('RANGE', int(value))
# return value
# class MainOutput(ls.MainOutput):
# ioClass = IO
# model = 372
# HTRRNG = {n: i for i, n in enumerate(['off', '31.6uA', '100uA', '316uA', '1mA', '3.16mA', '10mA', '31.6mA', '100mA'])}
# # htrrng = Parameter('', EnumType(HTRRNG), readonly=False)
# htr = Parameter('heater percentage', FloatRange(unit='%'))
# minheater = Parameter('minimal heater current', FloatRange(0, 0.01, unit='A'), readonly=False, default=0)
# resistance = Parameter(datatype=FloatRange(1,100000, unit='Ohm'))
# heater_ranges = HEATER_RANGES
# HTRST_MAP = {
# 0: (IDLE, ''),
# 1: (ERROR, 'Open heater load'),
# }
# _manual_output = 0.0 # TODO: check how to set this
# vmax = 50
# imax = 2
# max_currents = {4 - i: 2 ** (1 - i) for i in range(4)}
# SETPOINTLIMS = 1500.0
# sorted_factors = sorted([(fhtr * fcur ** 2, (i, h))
# for i, fcur in max_currents.items()
# for h, fhtr in HEATER_RANGES.items()
# ])
class AnalogOutput(ls.HasLscIO, Writable):
"""Output 1 (warm-up heater) and Output 2 (analog/still)"""
# def get_status(self):
# st = self.query(f'HTRST?', int)
# return self.HTRST_MAP[st]
target = Parameter('target', datatype=FloatRange(0, 100, unit='%'))
value = Parameter('value', datatype=FloatRange(0, 100, unit='%'))
output_no = Property('output number', datatype=IntRange(1, 2))
# def configure(self):
# if self._desired_max_power is None:
# self.log.info(f'max_heater {self.writeDict} {self.max_heater}')
# self.write_max_heater(self.max_heater)
# icurrent, htr_range = self.get_best_power_idx(self._desired_max_power, 1.1)
# self._power_scale = self.max_currents[icurrent] ** 2 * self.heater_ranges[htr_range] / 1e4
# self._htr_range = htr_range
def write_target(self, target):
if target > 0:
self.command(f'ANALOG {self.output_no}', 1, 2, 1, 1, 0.0, 0.0, target) # manual (2)
return
self.command(f'ANALOG {self.output_no}', 1, 0, 1, 1, 0.0, 0.0, target) # off (0)
# control_loop = self.get_control_loop()
# if control_loop is None:
# mode = self.query(f'CMODE?', int)
# if mode != 3: # open loop
# self.command(f'CSET', '0', 1, 1, 1, 1, self._htr_range, self.resistance) # control off
# self.command(f'CMODE', 3) # open loop
# self.command('HTRRNG', self._htr_range)
# self.put_manual_power(self._manual_output)
# else:
# self.log.info('control_loop %r, %r', control_loop, control_loop.channel)
# self.command(f'CSET', control_loop.channel, 1, 1, 1, 1, self._htr_range, self.resistance) # control on
# self.command(f'CMODE', 1) # pid
# self.command('HTRRNG', self._htr_range)
# self.put_manual_power(control_loop.power_offset)
# def fix_heater_range(self):
# # switch heater range on, if needed
# irng = self.query('HTRRNG?', int)
# if irng != self._htr_range:
# if irng:
# self.log.info('output range was changed manually')
# self._htr_range = irng
# else:
# self.log.info('output was off - switch on again')
# self.command('HTRRNG', self._htr_range)
# def read_max_power(self):
# htr_range = self.query(f'CSET?', int, int, int, int, int, int, float)[5]
# htr_range = self.query('HTRRNG?', int) or htr_range
# self._htr_range = htr_range
# self._power_scale = 0.1 ** 2 * self.heater_ranges[htr_range] / 1e4
# return self.calc_power(100)
# def read_htr(self):
# """read heater output in percent or power depending on the heater output selection"""
# return self.query('HTR?', float)
# @Command
# def control_off(self):
# """switch control off"""
# self._control_active = False
# self.command(f'HTRRNG', 0)
# self.read_control_active()
# def set_htrrng(self):
# if self._control_active:
# newhtr = int(self.htrrng) if self._control_active else 0
# htrrng = self.query('HTRRNG?', int)
# if htrrng != newhtr:
# if newhtr:
# self.log.info('switched heater on %d', newhtr)
# self.command('HTRRNG', newhtr)
# def put_manual_power(self, value):
# self.command(f'MOUT ', value)
# # def write_htrrng(self, value):
# # if self._control_active:
# # self.command('HTRRNG', int(value))
# # return value
# class AnalogOutput(ls.HasLscIO, Writable):
# target = Parameter('target', datatype=FloatRange(0, 100, unit='%'))
# value = Parameter('value', datatype=FloatRange(0, 100, unit='%'))
# output_no = Property('output number', datatype=IntRange(1, 2))
# def write_target(self, target):
# if target > 0:
# self.command(f'ANALOG {self.output_no}', 1, 2, 1, 1, 0.0, 0.0, target) # manual (2)
# return
# self.command(f'ANALOG {self.output_no}', 1, 0, 1, 1, 0.0, 0.0, target) # off (0)
# def read_value(self):
# return self.query(f'ANALOG? {self.output_no}', int, int, int, int, float, float, float)[6]
def read_value(self):
return self.query(f'AOUT? {self.output_no}', float)