Skip to content

Commit

Permalink
[NI-DCPower] Address timeout issues with nidcpower_advanced_sequence.…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
ni-juoca and Justin Oca authored Apr 24, 2024
1 parent 72fce1e commit ac6f0b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ All notable changes to this project will be documented in this file.
* ### `nidcpower` (NI-DCPower)
* #### Added
* #### Changed
* 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.
* #### Removed
* ### `nidigital` (NI-Digital Pattern Driver)
* #### Added
Expand Down
16 changes: 9 additions & 7 deletions src/nidcpower/examples/nidcpower_advanced_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
import sys


def example(resource_name, options, voltage_max, current_max, points_per_output_function, delay_in_seconds):
timeout = hightime.timedelta(seconds=(delay_in_seconds + 1.0))

def example(resource_name, options, voltage_max, current_max, points_per_output_function, source_delay):
with nidcpower.Session(resource_name=resource_name, options=options) as session:
# Configure the session.
session.source_mode = nidcpower.SourceMode.SEQUENCE
session.voltage_level_autorange = True
session.current_limit_autorange = True
session.source_delay = hightime.timedelta(seconds=delay_in_seconds)
session.source_delay = hightime.timedelta(seconds=source_delay)
properties_used = ['output_function', 'voltage_level', 'current_level']
session.create_advanced_sequence(sequence_name='my_sequence', property_names=properties_used, set_as_active_sequence=True)

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

# Calculate the timeout.
aperture_time = session.aperture_time
total_points = points_per_output_function * 2
timeout = hightime.timedelta(seconds=((source_delay + aperture_time) * total_points + 1.0))

with session.initiate():
session.wait_for_event(nidcpower.Event.SEQUENCE_ENGINE_DONE)
channel_indices = f'0-{session.channel_count - 1}'
channels = session.get_channel_names(channel_indices)
measurement_group = [session.channels[name].fetch_multiple(points_per_output_function * 2, timeout=timeout) for name in channels]
measurement_group = [session.channels[name].fetch_multiple(total_points, timeout=timeout) for name in channels]

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

0 comments on commit ac6f0b6

Please sign in to comment.