Skip to content

Commit ac6f0b6

Browse files
ni-juocaJustin Oca
andauthored
[NI-DCPower] Address timeout issues with nidcpower_advanced_sequence.py (#2052)
* initial changes detailed in github issue * timeout calculation accounting for aperture time * updated CHANGELOG.md * removing extra whitespace --------- Co-authored-by: Justin Oca <justin.oca@nicom>
1 parent 72fce1e commit ac6f0b6

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ All notable changes to this project will be documented in this file.
4343
* ### `nidcpower` (NI-DCPower)
4444
* #### Added
4545
* #### Changed
46+
* Fix [#1664](https://github.com/ni/nimi-python/issues/1970): nidcpower_advanced_sequence.py has several issues preventing it from working out of the box on real hardware.
4647
* #### Removed
4748
* ### `nidigital` (NI-Digital Pattern Driver)
4849
* #### Added

src/nidcpower/examples/nidcpower_advanced_sequence.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
import sys
77

88

9-
def example(resource_name, options, voltage_max, current_max, points_per_output_function, delay_in_seconds):
10-
timeout = hightime.timedelta(seconds=(delay_in_seconds + 1.0))
11-
9+
def example(resource_name, options, voltage_max, current_max, points_per_output_function, source_delay):
1210
with nidcpower.Session(resource_name=resource_name, options=options) as session:
1311
# Configure the session.
1412
session.source_mode = nidcpower.SourceMode.SEQUENCE
1513
session.voltage_level_autorange = True
1614
session.current_limit_autorange = True
17-
session.source_delay = hightime.timedelta(seconds=delay_in_seconds)
15+
session.source_delay = hightime.timedelta(seconds=source_delay)
1816
properties_used = ['output_function', 'voltage_level', 'current_level']
1917
session.create_advanced_sequence(sequence_name='my_sequence', property_names=properties_used, set_as_active_sequence=True)
2018

@@ -30,11 +28,15 @@ def example(resource_name, options, voltage_max, current_max, points_per_output_
3028
session.output_function = nidcpower.OutputFunction.DC_CURRENT
3129
session.current_level = current_per_step * i
3230

31+
# Calculate the timeout.
32+
aperture_time = session.aperture_time
33+
total_points = points_per_output_function * 2
34+
timeout = hightime.timedelta(seconds=((source_delay + aperture_time) * total_points + 1.0))
35+
3336
with session.initiate():
34-
session.wait_for_event(nidcpower.Event.SEQUENCE_ENGINE_DONE)
3537
channel_indices = f'0-{session.channel_count - 1}'
3638
channels = session.get_channel_names(channel_indices)
37-
measurement_group = [session.channels[name].fetch_multiple(points_per_output_function * 2, timeout=timeout) for name in channels]
39+
measurement_group = [session.channels[name].fetch_multiple(total_points, timeout=timeout) for name in channels]
3840

3941
session.delete_advanced_sequence(sequence_name='my_sequence')
4042
line_format = '{:<15} {:<4} {:<10} {:<10} {:<6}'
@@ -50,7 +52,7 @@ def example(resource_name, options, voltage_max, current_max, points_per_output_
5052
def _main(argsv):
5153
parser = argparse.ArgumentParser(description='Output ramping voltage to voltage max, then ramping current to current max.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
5254
parser.add_argument('-n', '--resource-name', default='PXI1Slot2/0, PXI1Slot3/0-1', help='Resource names of NI SMUs.')
53-
parser.add_argument('-s', '--number-steps', default=256, help='Number of steps per output function')
55+
parser.add_argument('-s', '--number-steps', default=256, type=int, help='Number of steps per output function')
5456
parser.add_argument('-v', '--voltage-max', default=1.0, type=float, help='Maximum voltage (V)')
5557
parser.add_argument('-i', '--current-max', default=0.001, type=float, help='Maximum Current (I)')
5658
parser.add_argument('-d', '--delay', default=0.05, type=float, help='Source delay (s)')

0 commit comments

Comments
 (0)