ionopimax: Add LogVoltageInput

This commit is contained in:
l_samenv
2024-01-18 08:40:33 +01:00
parent 9e000528d2
commit 99a58933ec

View File

@ -20,6 +20,7 @@
from frappy.core import Readable, Writable, Parameter, BoolType, StringType,\ from frappy.core import Readable, Writable, Parameter, BoolType, StringType,\
FloatRange, Property, TupleOf, ERROR, IDLE FloatRange, Property, TupleOf, ERROR, IDLE
from math import log
class Base: class Base:
@ -73,6 +74,15 @@ class VoltageInput(AnalogInput):
def initModule(self): def initModule(self):
super().initModule() super().initModule()
self.write(f'{self.addr}_mode','U') self.write(f'{self.addr}_mode','U')
class LogVoltageInput(VoltageInput):
def read_value(self):
x0, x1 = self.rawrange
y0, y1 = self.valuerange
self.x = self.read(self.addr, self.scale)
a = (x1-x0)/log(y1/y0,10)
return 10**((self.x-x1)/a)*y1
class CurrentInput(AnalogInput): class CurrentInput(AnalogInput):