From 12f54e1615cb0975f0fab4abed07d6277e390817 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Fri, 20 Oct 2023 00:01:35 +0200
Subject: [PATCH] Adds constant strategy

---
 ohmpi/hardware_system.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index 603dce28..8d4b1cee 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -413,6 +413,10 @@ class OhmPiHardware:
             # Set gain at min
             self.rx.reset_gain()
             vab_opt = tx_volt
+            if strategy == 'constant':
+                vab_max = tx_volt
+                tx_volt = tx_volt * .9
+                strategy = 'vmax'
             vab_max = np.abs(vab_max)
             vmn_min = np.abs(vmn_min)
             k = 0
@@ -434,10 +438,6 @@ class OhmPiHardware:
                 sampling_rate = self.rx.sampling_rate
             current, voltage = 0., 0.
             diff_vab = np.inf
-            if strategy == 'constant':
-                vab_max = tx_volt
-                tx_volt = tx_volt * .9
-                strategy = 'vmax'
             if strategy == 'vmax':
                 while (k < n_steps) and (diff_vab > diff_vab_lim) and (vab_list[k] < vab_max):
                     vabs = []
-- 
GitLab