From baf987005074bb97c96cf5c65c00da6be298d38a Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Thu, 5 Oct 2023 16:57:10 +0200
Subject: [PATCH] Modifies the way gains are auto set

---
 ohmpi/hardware_components/mb_2023_0_X.py | 2 +-
 ohmpi/hardware_system.py                 | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ohmpi/hardware_components/mb_2023_0_X.py b/ohmpi/hardware_components/mb_2023_0_X.py
index b900f80f..3ef4fe87 100644
--- a/ohmpi/hardware_components/mb_2023_0_X.py
+++ b/ohmpi/hardware_components/mb_2023_0_X.py
@@ -191,7 +191,7 @@ class Tx(TxAbstract):
         assert self.adc_voltage_min / (50 * self.r_shunt)  <= value <= self.adc_voltage_max / (50 * self.r_shunt)
         self.exec_logger.warning(f'Current pulse is not implemented for the {self.board_name} board')
 
-    def gain_auto(self, value):
+    def gain_auto(self):
         self._adc_gain_auto()
 
     def inject(self, polarity=1, injection_duration=None):
diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index cce7c793..1c94aa2e 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -179,12 +179,12 @@ class OhmPiHardware:
             # self.tx_sync.wait()
             # set gains automatically
             injection = Thread(target=self._inject, kwargs={'injection_duration': 0.2, 'polarity': pol})
-            self.tx.gain_auto()
             tx_gains.append(self.tx.gain)
-            readings = Thread(target=self._read_values)
-            readings.start()
+            # readings = Thread(target=self._read_values)
+            get_gain = Thread(target=self.tx.gain_auto)
+            get_gain.start()
             injection.start()
-            readings.join()
+            get_gain.join()
             injection.join()
             v = self.readings[:, 2] != 0
             current = max(current, np.mean(self.readings[v, 3]))
-- 
GitLab