From ab9c4fa76a19bc75e4f2ab135d6ef3e588b02786 Mon Sep 17 00:00:00 2001
From: Arnaud Watlet <arnaud.watlet@umons.ac.be>
Date: Fri, 1 Dec 2023 15:37:49 +0100
Subject: [PATCH] Adds condition on delay

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

diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py
index c77b2540..46b242dd 100644
--- a/ohmpi/ohmpi.py
+++ b/ohmpi/ohmpi.py
@@ -522,6 +522,8 @@ class OhmPi(object):
             self._hw.vab_square_wave(tx_volt, cycle_duration=injection_duration*2/duty_cycle, cycles=nb_stack, duty_cycle=duty_cycle)
             if 'delay' in kwargs.keys():
                 delay = kwargs['delay']
+                if delay > injection_duration:
+                    delay = injection_duration
             else:
                 delay = injection_duration * 2/3  # TODO: check if this is ok and if last point is not taken the end of injection
             x = np.where((self._hw.readings[:, 0] >= delay) & (self._hw.readings[:, 2] != 0))[0]
-- 
GitLab