Adding delayed backplane trigger example#7
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new NI-DCPower community example demonstrating delayed backplane triggering between two SMUs, intended to show how one SMU can trigger another via a delayed Source Complete Event routed over the PXI backplane.
Changes:
- Introduces a new example script configuring two NI-DCPower sessions for delayed Source Complete Event triggering over the PXI backplane.
- Adds a CLI entrypoint and two pytest-style tests (simulation-based) for the new example.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| python nidcpower_delayed_backplane_triggering.py | ||
|
|
||
| ii. From terminal (with custom values): | ||
| python nidcpower_delayed_backplane_triggering.py -n1 "PXI1Slot1" -n2 "PXI1Slot3" -sd 50e-6 -vl1 1.0 -vl2 1.0 -of "DC_VOLTAGE" -mc 1 -et 6 |
| parser.add_argument("-of", "--output-function", default="DC_VOLTAGE", help="Output function (DC_VOLTAGE or DC_CURRENT)") | ||
| parser.add_argument("-mc", "--measurement-count", type=int, default=1, help="Number of measurements to fetch") | ||
| parser.add_argument("-t", "--event-timeout", type=float, default=6, help="Timeout in seconds for trigger event") | ||
| parser.add_argument("-op", "--options", default="", help="Driver option string") | ||
|
|
||
| args = parser.parse_args(argsv) | ||
|
|
||
| example( | ||
| smu1_resource_name= args.smu1_resource_name, | ||
| smu2_resource_name= args.smu2_resource_name, | ||
| source_delay= args.source_delay, | ||
| voltage_smu1= args.voltage_smu1, | ||
| voltage_smu2= args.voltage_smu2, | ||
| output_function= args.output_function, | ||
| measurement_count= args.measurement_count, | ||
| event_timeout= args.event_timeout, | ||
| options= args.options) |
| """ | ||
| Args: | ||
| smu1_resource_name (str): Resource name of the triggering SMU. | ||
| smu2_resource_name (str): Resource name of the triggered SMU. | ||
| source_delay (float): Delay in seconds before SMU1 generates the Source Complete Event. | ||
| voltage_smu1 (float): Voltage level for SMU1. | ||
| voltage_smu2 (float): Voltage level for SMU2. | ||
| output_function (str): Output function (DC_VOLTAGE or DC_CURRENT). | ||
| measurement_count (int): Number of measurements to fetch. | ||
| event_timeout (float): Timeout in seconds for waiting for trigger event. | ||
| options (str): Driver option string. Can be used to enable simulation. | ||
| Returns: | ||
| tuple: (smu1_measurement, smu2_measurement) | ||
| """ | ||
|
|
||
| def example(smu1_resource_name, smu2_resource_name, source_delay, voltage_smu1, voltage_smu2, output_function, measurement_count, event_timeout, options): | ||
|
|
||
|
|
| smu1_measurement = smu1.fetch_multiple(count=measurement_count)[0] | ||
| smu2_measurement = smu2.fetch_multiple(count=measurement_count)[0] | ||
|
|
||
| print("SMU1 Measurement:") | ||
| print(smu1_measurement) | ||
|
|
||
| print("\nSMU2 Measurement:") | ||
| print(smu2_measurement) | ||
|
|
||
| return smu1_measurement, smu2_measurement |
| @@ -0,0 +1,151 @@ | |||
| #!/usr/bin/env python3 | |||
There was a problem hiding this comment.
Recommendation: whitespace in the beginning can be removed.
| @@ -0,0 +1,151 @@ | |||
| #!/usr/bin/env python3 | |||
| """ | |||
| NI-DCPower SMU Delayed Backplane Triggering | |||
There was a problem hiding this comment.
Recommendation: should end with period as per flake.
| """ | ||
|
|
||
| import argparse # For parsing command-line arguments | ||
| import nidcpower # NI-DCPower instrument driver |
There was a problem hiding this comment.
Recommendation: try to re-arrange the order , put import sys before nidcpower, add one line spacing (between grouping) after grouping (argparse, sys) and then dcpower
| smu1.voltage_level = voltage_smu1 | ||
|
|
||
| smu1.measure_when = (nidcpower.MeasureWhen.AUTOMATICALLY_AFTER_SOURCE_COMPLETE) #setting measure when to automatically after source complete for SMU1 | ||
| smu1.source_trigger_type = nidcpower.TriggerType.NONE |
There was a problem hiding this comment.
Recommendation : comment on why Trigger is kept None for SMU1 , can be briefed for understanding.
| smu2.commit() | ||
|
|
||
| # Initiate | ||
| smu2.initiate() |
There was a problem hiding this comment.
Recommendation : Reason for Initiating the SMU2 prior to SMU1, can be mentioned for better understanding.
| voltage_smu1 (float): Voltage level for SMU1. | ||
| voltage_smu2 (float): Voltage level for SMU2. | ||
| output_function (str): Output function (DC_VOLTAGE or DC_CURRENT). | ||
| measurement_count (int): Number of measurements to fetch. |
There was a problem hiding this comment.
Action needed : Do not use 'measurement_count' as an argument, if through CLI it is passed , the Fetch measurement maybe inconsistent/fail, since only first element is fetched. Suggestion would be to use default as 1 , without considering it in argslist.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
|
||
| parser.add_argument("-n1", "--smu1-resource-name", default="PXI1Slot1", help="Triggering SMU resource name") | ||
| parser.add_argument("-n2", "--smu2-resource-name", default="PXI1Slot2", help="Triggered SMU resource name") | ||
| parser.add_argument("-d", "--source-delay", type=float, default=50e-6, help="Source Complete Event delay (seconds)") |
There was a problem hiding this comment.
change the abbreviation for 'source delay' to 'sd' as per list maintained.
| python nidcpower_delayed_backplane_triggering.py -n1 "PXI1Slot1" -n2 "PXI1Slot3" -sd 50e-6 -vl1 1.0 -vl2 1.0 -of "DC_VOLTAGE" -mc 1 -et 6 | ||
|
|
||
| iii. To simulate without hardware: | ||
| python nidcpower_delayed_backplane_triggering.py -op "Simulate=1, DriverSetup=Model:4139; BoardType:PXIe" |
There was a problem hiding this comment.
Since there are two modules involved, need some changes to include models that can be simulated together. Check on this.
| python nidcpower_delayed_backplane_triggering.py | ||
|
|
||
| ii. From terminal (with custom values): | ||
| python nidcpower_delayed_backplane_triggering.py -n1 "PXI1Slot1" -n2 "PXI1Slot3" -sd 50e-6 -vl1 1.0 -vl2 1.0 -of "DC_VOLTAGE" -mc 1 -et 6 |
There was a problem hiding this comment.
Check the abbreviation defined and used in CLI, they are different . Need a check.
| print("\nSMU2 Measurement:") | ||
| print(smu2_measurement) | ||
|
|
||
| return smu1_measurement, smu2_measurement |
There was a problem hiding this comment.
Recommendation : Check if there is a need to use return statement here, as measurement results are printed to console in 'example' function .
What does this Pull Request accomplish?
Adding backplane trigger example for SMU
Why should this Pull Request be merged?
User can use this example for triggering one SMU from another SMU
What testing has been done?