frappy_psi.bkpower: improve doc
Change-Id: I0736d1d8a40b0140bfdbf5aca189b8ddc5b22973
This commit is contained in:
parent
f1b59e4150
commit
5b9e36180e
@ -17,51 +17,80 @@
|
||||
# Markus Zolliker <markus.zolliker@psi.ch>
|
||||
# Jael Celia Lorenzana <jael-celia.lorenzana@psi.ch>
|
||||
# *****************************************************************************
|
||||
"""Powersupply B&K Precision BK168xB"""
|
||||
"""Powersupply B&K Precision BK168xB
|
||||
|
||||
The following lines are part of a config file for the frappy-server process
|
||||
The frappy server creates the following modules and refreshes the values with a refresh rate of 1 sec.
|
||||
The communication with the powersupply is established via serial over USB.
|
||||
The manual can be found here https://www.vectortechnologies.gr/images/products/2022/02/168xB_programming_manual.pdf
|
||||
|
||||
Mod('htr_io',
|
||||
'frappy_psi.bkpower.IO',
|
||||
'powersupply communicator',
|
||||
uri = 'serial:///dev/ttyUSBupper',
|
||||
)
|
||||
|
||||
Mod('htr',
|
||||
'frappy_psi.bkpower.Power',
|
||||
'heater power',
|
||||
io= 'htr_io',
|
||||
)
|
||||
|
||||
Mod('out',
|
||||
'frappy_psi.bkpower.Output',
|
||||
'heater output',
|
||||
io = 'htr_io',
|
||||
maxvolt = 50,
|
||||
maxcurrent = 2,
|
||||
)
|
||||
"""
|
||||
|
||||
|
||||
from frappy.core import StringIO, Readable, Parameter, FloatRange, Writable, HasIO, BoolType
|
||||
|
||||
|
||||
# define the IO class
|
||||
class IO(StringIO):
|
||||
end_of_line = ('OK\r', '\r')
|
||||
default_settings = {'baudrate': 9600}
|
||||
|
||||
|
||||
|
||||
|
||||
class Power(HasIO, Readable):
|
||||
value = Parameter(datatype=FloatRange(0,300,unit='W'))
|
||||
|
||||
|
||||
def read_value(self):
|
||||
reply = self.communicate('GETD')
|
||||
volt = float(reply[0:4])/100
|
||||
current = float(reply[4:8])/100
|
||||
return volt*current
|
||||
|
||||
|
||||
|
||||
class Output(HasIO, Writable):
|
||||
value = Parameter(datatype=FloatRange(0,100,unit='%'))
|
||||
target = Parameter(datatype=FloatRange(0,100,unit='%'))
|
||||
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)
|
||||
|
||||
|
||||
def initModule(self):
|
||||
super().initModule()
|
||||
self.write_output_enable(False)
|
||||
|
||||
|
||||
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.value = target
|
||||
|
||||
|
||||
def write_output_enable(self, value):
|
||||
self.communicate(f'SOUT{int(not value)}')
|
||||
|
||||
|
||||
def write_maxvolt(self, maxvolt):
|
||||
self.communicate(f'SOVP{round(maxvolt*10):03d}')
|
||||
|
||||
|
||||
def write_maxcurrent(self, maxcurrent):
|
||||
self.communicate(f'SOCP{round(maxcurrent*100):03d}')
|
||||
|
||||
|
||||
def shutdown(self):
|
||||
self.write_target(0)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user