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

---
 ohmpi/hardware_components/pwr_dps5005.py | 1 -
 ohmpi/hardware_system.py                 | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/ohmpi/hardware_components/pwr_dps5005.py b/ohmpi/hardware_components/pwr_dps5005.py
index 36853786..cc12fc3e 100644
--- a/ohmpi/hardware_components/pwr_dps5005.py
+++ b/ohmpi/hardware_components/pwr_dps5005.py
@@ -91,7 +91,6 @@ class Pwr(PwrAbstract):
         if state == 'on':
             self.connection.write_register(0x09, 1)
             self.current_max(self._current_max)
-            print(self._current_max)
             self._pwr_state = 'on'
             self.exec_logger.debug(f'{self.model} is on')
             time.sleep(self._pwr_latency) # from pwr specs
diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index 23b08b3d..6e79220a 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -430,7 +430,7 @@ class OhmPiHardware:
                 sampling_rate = self.rx.sampling_rate
             current, voltage = 0., 0.
             diff_vab = np.inf
-            while (k < n_steps) and (diff_vab > diff_vab_lim):
+            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])
                 for pulse in range(2):
-- 
GitLab