WIP frappy_psi/tdkpower
Change-Id: I80d1beb0fae2a1cdd2aa5fabc5d31c651c2cb3e7
This commit is contained in:
parent
343ce90321
commit
42e40db14b
@ -17,9 +17,11 @@
|
||||
# Markus Zolliker <markus.zolliker@psi.ch>
|
||||
# Leon Zimmermann <leon.zimmermann@psi.ch>
|
||||
# *****************************************************************************
|
||||
"""Powersupply TDK-Lambda GEN8-400-1P230"""
|
||||
"""Powersupply TDK-Lambda GEN8-400-3P400"""
|
||||
|
||||
from frappy.core import StringIO, Readable, Parameter, Writable, HasIO
|
||||
from frappy.datatypes import BoolType, EnumType, FloatRange
|
||||
|
||||
from frappy.core import StringIO, Readable, Parameter, FloatRange, Writable, HasIO, BoolType
|
||||
|
||||
class IO(StringIO):
|
||||
end_of_line = ('OK\r', '\r')
|
||||
@ -40,8 +42,12 @@ class Power(HasIO, Readable):
|
||||
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,8,unit='V'),readonly=False)
|
||||
maxcurrent = Parameter('current at 100%',datatype=FloatRange(0,400,unit='A'),readonly=False)
|
||||
mode = Parameter('regulation mode', EnumType(voltage=1, current=2, both=3),
|
||||
default='voltage', readonly=False)
|
||||
maxvolt = Parameter('voltage at 100%',
|
||||
datatype=FloatRange(0,8,unit='V'), readonly=False)
|
||||
maxcurrent = Parameter('current at 100%',
|
||||
datatype=FloatRange(0,400,unit='A'), readonly=False)
|
||||
output_enable = Parameter('control on/off', BoolType(), readonly=False)
|
||||
|
||||
def initModule(self):
|
||||
@ -49,11 +55,22 @@ class Output(HasIO, Writable):
|
||||
self.write_output_enable(False)
|
||||
|
||||
def write_target(self, target):
|
||||
self.write_output_enable(target != 0)
|
||||
self.communicate(f'PV {target*self.maxvolt:.5f}')
|
||||
self.communicate(f'PC {target*self.maxcurrent:.5f}')
|
||||
# take care of proper order
|
||||
if target == 0:
|
||||
self.write_output_enable(False)
|
||||
prev_curr = self.communicate(f'PC?')
|
||||
volt = self.maxvolt if self.mode == 'current' else self.maxvolt * 0.01 * target
|
||||
curr = self.maxcurrent if self.mode == 'voltage' else self.maxcurrent * 0.01 * target
|
||||
if curr < prev_curr:
|
||||
self.communicate(f'PC {curr:.6g}')
|
||||
self.communicate(f'PV {volt:.6g}')
|
||||
else:
|
||||
self.communicate(f'PV {volt:.6g}')
|
||||
self.communicate(f'PC {curr:.6g}')
|
||||
if target:
|
||||
self.write_output_enable(True)
|
||||
self.value = target
|
||||
|
||||
|
||||
def write_output_enable(self, value):
|
||||
self.communicate(f'OUT {int(value)}')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user