From 4e4317b2c42db1e0ced372daa31cc23ca84f94f5 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Fri, 20 Oct 2023 00:24:00 +0200
Subject: [PATCH] Searches why vab > vab_max

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

diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index 694e1425..47f6344c 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -342,7 +342,7 @@ class OhmPiHardware:
         cond_p_max = np.sqrt(p_max * rab_lower_bound)
         cond_iab_max = rab_lower_bound * iab_max
         # print(f'Rab: [{rab_lower_bound:.1f}, {rab_upper_bound:.1f}], R: [{r_lower_bound:.1f},{r_upper_bound:.1f}]')
-        # print(f'{k}: [{vab_max:.1f}, {cond_vmn_max:.1f}, {cond_p_max:.1f}, {cond_iab_max:.1f}]')
+        print(f'{k}: [{vab_max:.1f}, {cond_vmn_max:.1f}, {cond_p_max:.1f}, {cond_iab_max:.1f}]')
         new_vab = np.min([vab_max, cond_vmn_max, cond_p_max, cond_iab_max])
         if new_vab == vab_max:
             print(f'Vab {new_vab} bounded by Vab max')
@@ -410,6 +410,8 @@ class OhmPiHardware:
             if p_max is None:
                 p_max = vab_max * iab_max
 
+            vab_max = np.abs(vab_max)
+            vmn_min = np.abs(vmn_min)
             # Set gain at min
             self.rx.reset_gain()
             vab_opt = tx_volt
@@ -418,8 +420,7 @@ class OhmPiHardware:
                 vab_max = vab
                 vab = vab * .9
                 strategy = 'vmax'
-            vab_max = np.abs(vab_max)
-            vmn_min = np.abs(vmn_min)
+
             k = 0
             vab_list = np.zeros(n_steps + 1) * np.nan
 
-- 
GitLab