fixes on small furnace
This commit is contained in:
@ -66,8 +66,9 @@ class Power(HasIO, Readable):
|
||||
|
||||
|
||||
class Output(HasIO, Writable):
|
||||
value = Parameter(datatype=FloatRange(0,100,unit='%'))
|
||||
value = Parameter(datatype=FloatRange(0,100,unit='%'), default=0)
|
||||
target = Parameter(datatype=FloatRange(0,100,unit='%'))
|
||||
p_value = Parameter(datatype=FloatRange(0,100,unit='%'), default=0)
|
||||
maxvolt = Parameter('voltage at 100%',datatype=FloatRange(0,60,unit='V'),default=50,readonly=False)
|
||||
maxcurrent = Parameter('current at 100%',datatype=FloatRange(0,5,unit='A'),default=2,readonly=False)
|
||||
output_enable = Parameter('control on/off', BoolType(), readonly=False)
|
||||
@ -78,8 +79,10 @@ class Output(HasIO, Writable):
|
||||
|
||||
def write_target(self, target):
|
||||
self.write_output_enable(target != 0)
|
||||
self.communicate(f'VOLT{round(max(8,target*self.maxvolt/10)):03d}')
|
||||
self.communicate(f'CURR{round(target*self.maxcurrent):03d}')
|
||||
self.communicate(f'VOLT{round(max(8,(target)**0.5 * self.maxvolt)):03d}')
|
||||
self.communicate(f'CURR{round((target)**0.5* 10 * self.maxcurrent):03d}')
|
||||
#self.communicate(f'VOLT{round(max(8,target*self.maxvolt/10)):03d}')
|
||||
#self.communicate(f'CURR{round(target*self.maxcurrent):03d}')
|
||||
self.value = target
|
||||
|
||||
def write_output_enable(self, value):
|
||||
|
@ -27,25 +27,51 @@ from frappy_psi.picontrol import PImixin
|
||||
|
||||
class Interlocks(Module):
|
||||
input = Attached(Readable, 'the input module')
|
||||
vacuum = Attached (Readable, 'the vacuum pressure')
|
||||
wall_T = Attached (Readable, 'the wall temperature')
|
||||
vacuum = Attached(Readable, 'the vacuum pressure')
|
||||
wall_T = Attached(Readable, 'the wall temperature')
|
||||
htr_T = Attached(Readable, 'the heater temperature')
|
||||
main_T = Attached(Readable, 'the main temperature')
|
||||
extra_T = Attached(Readable, 'the extra temperature')
|
||||
control = Attached(Module, 'the control module')
|
||||
relais = Attached(Writable, 'the interlock relais')
|
||||
wall_limit = Parameter('maximum wall temperature', FloatRange(0, unit='degC'),
|
||||
default = 50, readonly = False)
|
||||
vacuum_limit = Parameter('maximum vacuum pressure', FloatRange(0, unit='mbar'),
|
||||
default = 0.1, readonly = False)
|
||||
|
||||
htr_T_limit = Parameter('maximum htr temperature', FloatRange(0, unit='degC'),
|
||||
default = 530, readonly = False)
|
||||
main_T_limit = Parameter('maximum main temperature', FloatRange(0, unit='degC'),
|
||||
default = 530, readonly = False)
|
||||
extra_T_limit = Parameter('maximum extra temperature', FloatRange(0, unit='degC'),
|
||||
default = 530, readonly = False)
|
||||
|
||||
def initModule(self):
|
||||
super().initModule()
|
||||
self._sensor_checks = [
|
||||
(self.wall_T, 'wall_limit'),
|
||||
(self.main_T, 'main_T_limit'),
|
||||
(self.extra_T, 'extra_T_limit'),
|
||||
(self.htr_T, 'htr_T_limit'),
|
||||
(self.vacuum, 'vacuum_limit'),
|
||||
]
|
||||
|
||||
def doPoll(self):
|
||||
# TODO: check channels are valid
|
||||
super().doPoll()
|
||||
newstatus = None
|
||||
if self.input.status[0] >= ERROR:
|
||||
self.control.status = self.input.status
|
||||
elif self.vacuum.value > self.vacuum_limit:
|
||||
self.control.status = ERROR, 'bad vacuum'
|
||||
elif self.wall_T.value > self.wall_limit:
|
||||
self.control.status = ERROR, 'wall overheat'
|
||||
newstatus = self.input.status
|
||||
else:
|
||||
for sensor, limitname in self._sensor_checks:
|
||||
if sensor.value > getattr(self, limitname):
|
||||
newstatus = f'above {sensor.name} limit'
|
||||
break
|
||||
if sensor.status[0] >= ERROR:
|
||||
newstatus = f'error at {sensor.name}: {sensor.status[1]}'
|
||||
return
|
||||
self.control.status = newstatus
|
||||
if self.control.control_active:
|
||||
self.log.error('switch control off %r', self.control.status)
|
||||
self.control.write_control_active(False)
|
||||
self.relais.write_target(False)
|
||||
|
||||
|
@ -22,7 +22,7 @@ import os
|
||||
from glob import glob
|
||||
from frappy.core import Readable, Writable, Parameter, BoolType, StringType,\
|
||||
FloatRange, Property, TupleOf, ERROR, IDLE
|
||||
from frappy.errors import ConfigError
|
||||
from frappy.errors import ConfigError, OutOfRangeError
|
||||
from math import log
|
||||
|
||||
basepaths = '/sys/class/ionopimax', '/sys/class/ionopi'
|
||||
@ -121,8 +121,8 @@ class CurrentInput(AnalogInput):
|
||||
result = super().read_value()
|
||||
if self.x > 0.021:
|
||||
self.status = ERROR, 'sensor broken'
|
||||
else:
|
||||
self.status = IDLE, ''
|
||||
raise OutOfRangeError('sensor broken')
|
||||
self.status = IDLE, ''
|
||||
return result
|
||||
|
||||
|
||||
@ -146,3 +146,18 @@ class VoltageOutput(AnalogOutput):
|
||||
self.write(f'{self.addr}_mode', 'V')
|
||||
self.write(f'{self.addr}', '0')
|
||||
self.write(f'{self.addr}_enabled', '1')
|
||||
|
||||
|
||||
class VoltagePower(Base, Writable):
|
||||
devclass = 'power_out'
|
||||
target = Parameter(datatype=FloatRange(0, 24.5, unit='V'), default=12)
|
||||
addr = 'vso'
|
||||
|
||||
def write_target(self, value):
|
||||
if value:
|
||||
self.write(self.addr, value, 1000)
|
||||
self.write(f'{self.addr}_enabled', 1)
|
||||
else:
|
||||
self.write(f'{self.addr}_enabled', 0)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user