From 448644702aa0bb8f39e98a718b6eb93c66805f73 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Thu, 19 Oct 2023 23:47:52 +0200
Subject: [PATCH] Adds constant strategy

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

diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index 60a4c64d..4b97919f 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -412,7 +412,7 @@ class OhmPiHardware:
 
             # Set gain at min
             self.rx.reset_gain()
-
+            vab_opt = tx_volt
             vab_max = np.abs(vab_max)
             vmn_min = np.abs(vmn_min)
             k = 0
@@ -434,7 +434,9 @@ class OhmPiHardware:
                 sampling_rate = self.rx.sampling_rate
             current, voltage = 0., 0.
             diff_vab = np.inf
-            if strategy=='vmax':
+            if strategy == 'constant':
+                tx_volt = vab_max*.9
+            if strategy == 'vmax':
                 while (k < n_steps) and (diff_vab > diff_vab_lim) and (vab_list[k] < vab_max):
                     vabs = []
                     self._vab_pulses(vab_list[k], sampling_rate=self.rx.sampling_rate, durations=[0.2, 0.2], polarities=[1, -1])
@@ -459,8 +461,7 @@ class OhmPiHardware:
                 # print(f'Selected Vab: {vab_opt:.2f}')
                 # if switch_pwr_off:
                 #     self.tx.pwr.pwr_state = 'off'
-        else:
-            vab_opt = tx_volt
+
 
         # if strategy == 'vmax':
         #     # implement different strategies
-- 
GitLab