added calculation for Hallprobe calibrated Field offsets

This commit is contained in:
2026-05-21 10:50:12 +02:00
committed by zolliker
co-authored by zolliker
parent 5829ec6474
commit 4ae0041421
2 changed files with 41 additions and 1 deletions
+11
View File
@@ -224,3 +224,14 @@ Mod('T_main_switch',
channel='Main Coil Switch',
main='main',
)
Mod('Calib',
'frappy_psi.cryoltd.Absfield', '',
main='B',
bx='Bx',
by='By',
bz='Bz',
bx_offset=0.0,
by_offset=0.0,
bz_offset=0.0,
)
+30 -1
View File
@@ -27,7 +27,7 @@ changed from the client is fixed for at least 10 seconds.
"""
import re
import time
from math import copysign
from math import copysign, sqrt
from frappy.core import HasIO, StringIO, Readable, Drivable, Parameter, Command, \
Module, Property, Attached, Enum, IDLE, BUSY, ERROR
from frappy.errors import ConfigError, BadValueError, HardwareError
@@ -603,3 +603,32 @@ class Compressor(Channel, Drivable):
"""reset error"""
self.sendcmd('Set:Compressor:Reset <CH>')
self._error_text = ''
class Absfield(Readable):
"""
Keep track of the magnet hysteresis and provide corrected readbacks
"""
main = Attached()
bx = Attached()
by = Attached()
bz = Attached()
bx_offset = Parameter('Hysteresis offset for Bx', FloatRange(unit='G'),
readonly=False, default=0.0)
by_offset = Parameter('Hysteresis offset for By', FloatRange(unit='G'),
readonly=False, default=0.0)
bz_offset = Parameter('Hysteresis offset for Bz', FloatRange(unit='G'),
readonly=False, default=0.0)
calib_bx = Parameter('hysteresis-corrected Bx', FloatRange(unit='G'))
calib_by = Parameter('hysteresis-corrected By', FloatRange(unit='G'))
calib_bz = Parameter('hysteresis-corrected Bz+B', FloatRange(unit='G'))
value = Parameter('hysteresis-corrected total magnitude of the field', FloatRange(unit='G'))
def read_value(self):
self.calib_bx = self.bx.value - self.bx_offset
self.calib_by = self.by.value - self.by_offset
self.calib_bz = self.bz.value+self.main.value - self.bz_offset
return sqrt(self.calib_bz ** 2 + self.calib_by** 2 + self.calib_bx** 2)