From ceb3bd7f12343d1fc3532bc1bcb124bae224f158 Mon Sep 17 00:00:00 2001 From: cgriffin Date: Thu, 19 Jun 2025 14:37:15 -0400 Subject: [PATCH 1/5] Small kik load sequence updates Allow list of floats to be used as well for configure sequence Fix trigger pulse timing error in configure_pulse_sequence --- .../sink/_kikusui_plz1004wh.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py b/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py index 48d5274..4324e8f 100644 --- a/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py +++ b/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py @@ -389,7 +389,7 @@ def measure_power(self) -> float: def configure_sequence( self, - steps: list["Kikusui_PLZ1004WH.SequenceStep"], + steps: list["Kikusui_PLZ1004WH.SequenceStep" | float], current_range: str = "HIGH", step_size: float = 1e-3, initialize: bool = True, @@ -399,11 +399,12 @@ def configure_sequence( includes a current value and whether or not a trigger pulse should be emitted. Args: - steps (list[Kikusui_PLZ1004WH.SequenceStep]): A list of SequenceSteps - describing the sequence to be executed. Each step has a load setting and - the option to emit a trigger pulse. A maximum of 1024 steps can be used - but note that transmitting a large number of steps takes significant - time. + steps (list[Kikusui_PLZ1004WH.SequenceStep | float]): A list of SequenceSteps + or floats describing the sequence to be executed. Each step has a load + setting and the option to emit a trigger pulse. A maximum of 1024 steps + can be used but note that transmitting a large number of steps takes + significant time. If floats are supplied then there is assumed to be + no trigger pulse. current_range (str, optional): Range setting to use (LOW, MED, HIGH). Refer to manual for the maximum current that each range is capable of. Typically LOW = 1.32A, MED = 13.2A, and HIGH = 132A. Defaults to "HIGH". @@ -419,6 +420,8 @@ def configure_sequence( MAX_SEQ_LENGTH = 1024 sequence_len = len(steps) + if not isinstance(steps[0], SequenceStep): + steps = [SequenceStep(current) for current in steps] # validate the inputs if sequence_len > MAX_SEQ_LENGTH: @@ -525,8 +528,7 @@ def configure_pulse_seqeunce( (SequenceStep(idle_current) for _ in range(round(END_IDLE_TIME / step_size))), ) ) - # +1 since trigger occurs at the beginning of a step - trigger_idx = round((initial_idle_time + trig_delay) / step_size + 1) + trigger_idx = round((initial_idle_time + trig_delay) / step_size) steps[trigger_idx].trigger = True self.configure_sequence(steps, current_range, step_size) if keep_load_on: From 4a250005b2593b03a3a43d12e73b34c3dfca7fdd Mon Sep 17 00:00:00 2001 From: cgriffin Date: Mon, 30 Mar 2026 11:13:14 -0400 Subject: [PATCH 2/5] Refactor configure_pulse_seqeunce method --- .../sink/_kikusui_plz1004wh.py | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py b/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py index 3885b77..5444385 100644 --- a/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py +++ b/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py @@ -400,10 +400,10 @@ def configure_sequence( Args: steps (list[Kikusui_PLZ1004WH.SequenceStep | float]): A list of SequenceSteps - or floats describing the sequence to be executed. Each step has a load + or floats describing the sequence to be executed. Each step has a load setting and the option to emit a trigger pulse. A maximum of 1024 steps - can be used but note that transmitting a large number of steps takes - significant time. If floats are supplied then there is assumed to be + can be used but note that transmitting a large number of steps takes + significant time. If floats are supplied then there is assumed to be no trigger pulse. current_range (str, optional): Range setting to use (LOW, MED, HIGH). Refer to manual for the maximum current that each range is capable of. @@ -521,21 +521,25 @@ def configure_pulse_seqeunce( steps = list( itertools.chain( ( - SequenceStep(idle_current) - for _ in range(round(initial_idle_time / step_size)) + itertools.repeat( + SequenceStep(idle_current), round(initial_idle_time / step_size) + ) ), ( - SequenceStep(pulse_current) - for _ in range(round(pulse_width / step_size)) + itertools.repeat( + SequenceStep(pulse_current), round(pulse_width / step_size) + ) ), ( - SequenceStep(idle_current) - for _ in range(round(END_IDLE_TIME / step_size)) + itertools.repeat( + SequenceStep(idle_current), round(END_IDLE_TIME / step_size) + ) ), ) ) + # replace regular step with a step that emits a trigger pulse trigger_idx = round((initial_idle_time + trig_delay) / step_size) - steps[trigger_idx].trigger = True + steps[trigger_idx] = SequenceStep(steps[trigger_idx].current, trigger=True) self.configure_sequence(steps, current_range, step_size) if keep_load_on: self.write_resource(f"prog:linp {1 if idle_current else 0}") From bf2b34e20922af34806aee731d80c4d1c868dead Mon Sep 17 00:00:00 2001 From: cgriffin Date: Mon, 30 Mar 2026 11:22:44 -0400 Subject: [PATCH 3/5] Ran tests and fixed some errors --- src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py | 2 +- tests/sink_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py b/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py index 5444385..1068d40 100644 --- a/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py +++ b/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py @@ -389,7 +389,7 @@ def measure_power(self) -> float: def configure_sequence( self, - steps: list["Kikusui_PLZ1004WH.SequenceStep" | float], + steps: list[SequenceStep | float], current_range: str = "HIGH", step_size: float = 1e-3, initialize: bool = True, diff --git a/tests/sink_test.py b/tests/sink_test.py index 5fd048b..3cafc3c 100644 --- a/tests/sink_test.py +++ b/tests/sink_test.py @@ -96,6 +96,6 @@ def test_configure_pulse_sequence(self, configure_seq_mock: MagicMock): (self.inst.SequenceStep(0) for _ in range(1)), ) ) - steps[13].trigger = True + steps[12].trigger = True configure_seq_mock.assert_called_once_with(steps, "HIGH", 1e-3) From 3bca5daf7195bae647c1e174ee9ae03afa48f175 Mon Sep 17 00:00:00 2001 From: cgriffin Date: Mon, 30 Mar 2026 11:25:20 -0400 Subject: [PATCH 4/5] Update version to 2.12.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 055658d..74a2caa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pythonequipmentdrivers" -version = "2.12.0" +version = "2.12.1" authors = [ { name="Anna Giasson", email="AnnaGraceGiasson@GMail.com" }, ] From db9c0f9bc575b6ef80f3fd77631a7d6623a9792d Mon Sep 17 00:00:00 2001 From: cgriffin Date: Tue, 31 Mar 2026 17:27:20 -0400 Subject: [PATCH 5/5] Change to logic during pulse sequence Changed to a more rubust implementation --- src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py b/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py index 1068d40..b71e196 100644 --- a/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py +++ b/src/pythonequipmentdrivers/sink/_kikusui_plz1004wh.py @@ -541,6 +541,5 @@ def configure_pulse_seqeunce( trigger_idx = round((initial_idle_time + trig_delay) / step_size) steps[trigger_idx] = SequenceStep(steps[trigger_idx].current, trigger=True) self.configure_sequence(steps, current_range, step_size) - if keep_load_on: - self.write_resource(f"prog:linp {1 if idle_current else 0}") - self.write_resource(f"prog:lval {idle_current}") + self.write_resource(f"prog:linp {1 if idle_current and keep_load_on else 0}") + self.write_resource(f"prog:lval {idle_current}")