Commit 8ff664b6 authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Fixes bug with hardware_system _inject

Showing with 6 additions and 22 deletions
+6 -22
...@@ -87,9 +87,9 @@ class OhmPiHardware: ...@@ -87,9 +87,9 @@ class OhmPiHardware:
self._start_time = None self._start_time = None
self._pulse = 0 self._pulse = 0
def _inject(self, duration): def _inject(self, polarity=1, inj_time=None):
self.tx_sync.set() self.tx_sync.set()
self.tx.voltage_pulse(length=duration) self.tx.voltage_pulse(length=inj_time, polarity=polarity)
self.tx_sync.clear() self.tx_sync.clear()
def _set_mux_barrier(self): def _set_mux_barrier(self):
...@@ -234,7 +234,7 @@ class OhmPiHardware: ...@@ -234,7 +234,7 @@ class OhmPiHardware:
lengths = [cycle_length/2]*2*cycles lengths = [cycle_length/2]*2*cycles
self._vab_pulses(vab, lengths, sampling_rate, append=append) self._vab_pulses(vab, lengths, sampling_rate, append=append)
def _vab_pulse(self, vab, length, sampling_rate=None, polarity=None, append=False): def _vab_pulse(self, vab, length, sampling_rate=None, polarity=1, append=False):
""" Gets VMN and IAB from a single voltage pulse """ Gets VMN and IAB from a single voltage pulse
""" """
...@@ -242,8 +242,8 @@ class OhmPiHardware: ...@@ -242,8 +242,8 @@ class OhmPiHardware:
sampling_rate = RX_CONFIG['sampling_rate'] sampling_rate = RX_CONFIG['sampling_rate']
if polarity is not None and polarity != self.tx.polarity: if polarity is not None and polarity != self.tx.polarity:
self.tx.polarity = polarity self.tx.polarity = polarity
if self.tx.voltage_adjustable: if self.tx.pwr.voltage_adjustable:
self.tx.voltage = vab self.tx.pwr.voltage = vab
else: else:
vab = self.tx.voltage vab = self.tx.voltage
injection = Thread(target=self._inject, kwargs={'duration':length}) injection = Thread(target=self._inject, kwargs={'duration':length})
...@@ -263,28 +263,12 @@ class OhmPiHardware: ...@@ -263,28 +263,12 @@ class OhmPiHardware:
if polarities is not None: if polarities is not None:
assert len(polarities)==n_pulses assert len(polarities)==n_pulses
else: else:
polarities = [-self.tx.polarity * np.heaviside(i % 2, -1.) for i in range(n_pulses)] polarities = [-1 * np.heaviside(i % 2, -1.) for i in range(n_pulses)]
if not append: if not append:
self._clear_values() self._clear_values()
for i in range(n_pulses): for i in range(n_pulses):
self._vab_pulse(self, length=lengths[i], sampling_rate=sampling_rate, polarity=polarities[i], append=True) self._vab_pulse(self, length=lengths[i], sampling_rate=sampling_rate, polarity=polarities[i], append=True)
# _______________________________________________
def switch_dps(self, state='off'):
"""Switches DPS on or off.
Parameters
----------
state : str
'on', 'off'
"""
if state == 'on':
self.tx.turn_on()
else:
self.tx.turn_off()
if state != 'off':
self.exec_logger.warning(f'Unknown state {state} for DPS switching. switching off...')
def switch_mux(self, electrodes, roles=None, state='off'): def switch_mux(self, electrodes, roles=None, state='off'):
"""Switches on multiplexer relays for given quadrupole. """Switches on multiplexer relays for given quadrupole.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment