From e34fb4e1a69e96a91e248101cd0f120b99ad2b56 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Tue, 10 Oct 2023 16:13:54 +0200
Subject: [PATCH] Searches for run_measurement error

---
 ohmpi/hardware_system.py | 4 ++--
 ohmpi/ohmpi.py           | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index 4a89b18e..6c38b4a6 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -400,10 +400,10 @@ class OhmPiHardware:
     def vab_square_wave(self, vab, cycle_duration, sampling_rate=None, cycles=3, polarity=1, duty_cycle=1.,
                         append=False):
         self.exec_logger.event(f'OhmPiHardware\tvab_square_wave\tbegin\t{datetime.datetime.utcnow()}')
-        # self._gain_auto()  # TODO: Uncomment me
+        self._gain_auto()
         assert 0. <= duty_cycle <= 1.
         if duty_cycle < 1.:
-            durations = [cycle_duration/2 * duty_cycle, cycle_duration/2*(1.-duty_cycle)] * 2 * cycles
+            durations = [cycle_duration/2 * duty_cycle, cycle_duration/2 * (1.-duty_cycle)] * 2 * cycles
             pol = [-int(polarity * np.heaviside(i % 2, -1.)) for i in range(2 * cycles)]
             # pol = [-int(self.tx.polarity * np.heaviside(i % 2, -1.)) for i in range(2 * cycles)]
             polarities = [0] * (len(pol) * 2)
diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py
index 8d43293f..e9c49cc7 100644
--- a/ohmpi/ohmpi.py
+++ b/ohmpi/ohmpi.py
@@ -456,7 +456,8 @@ class OhmPi(object):
         tx_volt = float(tx_volt)
         bypass_check = kwargs['bypass_check'] if 'bypass_check' in kwargs.keys() else False
         if self.switch_mux_on(quad, bypass_check=bypass_check, cmd_id=cmd_id):
-            self._hw.vab_square_wave(tx_volt, cycle_duration=injection_duration*2, cycles=nb_stack, duty_cycle=kwargs.pop('duty_cycle', 1.))
+            duty_cycle = kwargs.pop('duty_cycle', 1.)
+            self._hw.vab_square_wave(tx_volt, cycle_duration=injection_duration*2/duty_cycle, cycles=nb_stack, duty_cycle=duty_cycle)
             if 'delay' in kwargs.keys():
                 delay = kwargs['delay']
             else:
-- 
GitLab