From 7db2f7f28f9ef17b446a027a8e4fd85998ddbee2 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Thu, 19 Oct 2023 23:07:28 +0200
Subject: [PATCH] Fixes n_step bug

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

diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index 0307270c..23b08b3d 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -443,13 +443,13 @@ class OhmPiHardware:
                     # print(f'new_vab: {new_vab}, diff_vab: {diff_vab}\n')
                     if diff_vab < diff_vab_lim:
                         print('stopped on vab increase too small')
-                    else:
-                        print('stopped on maximum number of steps reached')
                 k = k + 1
                 vab_list[k] = np.min(vabs)
                 time.sleep(0.5)
                 if self.tx.pwr.voltage_adjustable:
                     self.tx.voltage = vab_list[k]
+            if k > n_steps:
+                print('stopped on maximum number of steps reached')
             vab_opt = vab_list[k]
             # print(f'Selected Vab: {vab_opt:.2f}')
             # if switch_pwr_off:
-- 
GitLab