Skip to content

Commit

Permalink
enable beam blanking for ngx
Browse files Browse the repository at this point in the history
  • Loading branch information
jirhiker committed Oct 10, 2024
1 parent 56a8cd5 commit 0c1697b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
13 changes: 12 additions & 1 deletion pychron/spectrometer/base_magnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from math import pi

from numpy import arange, sin
from traits.api import Property, Float, Event, Instance
from traits.api import Property, Float, Event, Instance, Bool

from pychron.core.yaml import yload
from pychron.paths import paths
Expand Down Expand Up @@ -52,6 +52,9 @@ class BaseMagnet(SpectrometerDevice, FieldMixin):

_suppress_mass_update = False

use_beam_blank = Bool(False)
beam_blank_threshold = Float(0.5)

# def __init__(self, *args, **kw):
# super(BaseMagnet, self).__init__(*args, **kw)
# self._lock = threading.Lock()
Expand Down Expand Up @@ -86,6 +89,14 @@ def finish_loading(self):
# load af demag
self._load_af_demag_configuration()

def load_beam_blank(self, config):
pd = "Protection"
self.use_beam_blank = self.config_get(
config, pd, "use_beam_blank", cast="boolean", default=False
)
self.beam_blank_threshold = self.config_get(
config, pd, "beam_blank_threshold", cast="float", default=0.1
)
# ===============================================================================
# mapping
# ===============================================================================
Expand Down
2 changes: 2 additions & 0 deletions pychron/spectrometer/base_spectrometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ def load(self):
p = get_spectrometer_config_path(name)
config = self.get_configuration_writer(p)

self.magnet.load_beam_blank(config)

return config

def load_molecular_weights(self):
Expand Down
16 changes: 10 additions & 6 deletions pychron/spectrometer/isotopx/magnet/ngx.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@


class NGXMagnet(IsotopxMagnet):
_protect_detector = False

def read_dac(self):
return self.read_mass()

def set_dac(self, v, *args, **kw):
return self.set_mass(v, deflect=self.microcontroller.protect_detector)
return self.set_mass(v, **kw)

@get_float()
def read_mass(self):
Expand All @@ -50,12 +48,18 @@ def set_mass(self, v, delay=None, deflect=False):
self.microcontroller.stop_acquisition()
# self.microcontroller.triggered = False

deflect = ",deflect" if deflect else ""
self.ask("SetMass {},{}{}".format(v, delay, deflect))
dv = abs(self._dac - v)
self._dac = v
change = dv > 1e-7

if self.use_beam_blank:
deflect = dv > self.beam_blank_threshold

self.debug(f'use beam blank={deflect}. dv={dv}, threshold={self.beam_blank_threshold}')

deflect = ",deflect" if deflect else ""
self.ask(f"SetMass {v},{delay}{deflect}")

change = dv > 1e-7
return change


Expand Down
8 changes: 2 additions & 6 deletions pychron/spectrometer/thermo/spectrometer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,9 @@ def load(self):

pd = "Protection"
if config.has_section(pd):
self.magnet.use_beam_blank = self.config_get(
config, pd, "use_beam_blank", cast="boolean", default=False
)
self.magnet.use_detector_protection = self.config_get(
config, pd, "use_detector_protection", cast="boolean", default=False
)
self.magnet.beam_blank_threshold = self.config_get(
config, pd, "beam_blank_threshold", cast="float", default=0.1
)

# self.magnet.detector_protection_threshold = self.config_get(config, pd,
# 'detector_protection_threshold',
Expand All @@ -369,6 +363,8 @@ def load(self):
for d in self.detectors:
d.load_deflection_coefficients()

return config

def start(self):
self.debug(
"********** Spectrometer start. send configuration: {}".format(
Expand Down

0 comments on commit 0c1697b

Please sign in to comment.