From 8d182b3d45bdc99dab116cc431f4bfe623f062c2 Mon Sep 17 00:00:00 2001 From: Khor Huai Sheng Date: Thu, 8 Jan 2026 16:10:41 +0800 Subject: [PATCH 1/4] Add Calculated Power Channel Python Example --- .../analog_in/calculated_power_acq_int_clk.py | 24 +++++++++++++ .../cont_calculated_power_acq_int_clk.py | 35 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 examples/analog_in/calculated_power_acq_int_clk.py create mode 100644 examples/analog_in/cont_calculated_power_acq_int_clk.py diff --git a/examples/analog_in/calculated_power_acq_int_clk.py b/examples/analog_in/calculated_power_acq_int_clk.py new file mode 100644 index 00000000..0ff9edf5 --- /dev/null +++ b/examples/analog_in/calculated_power_acq_int_clk.py @@ -0,0 +1,24 @@ +"""Example of analog input calculated power acquisition. + +This example demonstrates how to acquire a finite amount +of calculated power data using the DAQ device's internal clock. +""" + +import nidaqmx +from nidaqmx.constants import AcquisitionType, READ_ALL_AVAILABLE + +with nidaqmx.Task() as task: + task.ai_channels.add_ai_calculated_power_chan( + voltage_physical_channel="Dev1/ai0", + current_physical_channel="Dev1/ai1", + voltage_min_val=0.0, + voltage_max_val=5.0, + current_min_val=0.0, + current_max_val=0.02, + ext_shunt_resistor_val=249.0, + ) + + task.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.FINITE, samps_per_chan=50) + + data = task.read(READ_ALL_AVAILABLE) + print("Acquired data: [" + ", ".join(f"{value:f}" for value in data) + "]") \ No newline at end of file diff --git a/examples/analog_in/cont_calculated_power_acq_int_clk.py b/examples/analog_in/cont_calculated_power_acq_int_clk.py new file mode 100644 index 00000000..edd89507 --- /dev/null +++ b/examples/analog_in/cont_calculated_power_acq_int_clk.py @@ -0,0 +1,35 @@ +"""Example of analog input voltage acquisition. + +This example demonstrates how to acquire a continuous amount of +calculated power data using the DAQ device's internal clock. +""" + +import nidaqmx +from nidaqmx.constants import AcquisitionType + +with nidaqmx.Task() as task: + task.ai_channels.add_ai_calculated_power_chan( + voltage_physical_channel="Dev1/ai0", + current_physical_channel="Dev1/ai1", + voltage_min_val=0.0, + voltage_max_val=5.0, + current_min_val=0.0, + current_max_val=0.02, + ext_shunt_resistor_val=249.0, + ) + task.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.CONTINUOUS) + task.start() + print("Running task. Press Ctrl+C to stop.") + + try: + total_read = 0 + while True: + data = task.read(number_of_samples_per_channel=1000) + read = len(data) + total_read += read + print(f"Acquired data: {read} samples. Total {total_read}.", end="\r") + except KeyboardInterrupt: + pass + finally: + task.stop() + print(f"\nAcquired {total_read} total samples.") From ac66df337ad651f4e265c334a92753e2fb44cbfe Mon Sep 17 00:00:00 2001 From: Khor Huai Sheng Date: Thu, 8 Jan 2026 16:24:28 +0800 Subject: [PATCH 2/4] Fix formatting --- examples/analog_in/calculated_power_acq_int_clk.py | 4 ++-- examples/analog_in/cont_calculated_power_acq_int_clk.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/analog_in/calculated_power_acq_int_clk.py b/examples/analog_in/calculated_power_acq_int_clk.py index 0ff9edf5..634060bc 100644 --- a/examples/analog_in/calculated_power_acq_int_clk.py +++ b/examples/analog_in/calculated_power_acq_int_clk.py @@ -5,7 +5,7 @@ """ import nidaqmx -from nidaqmx.constants import AcquisitionType, READ_ALL_AVAILABLE +from nidaqmx.constants import READ_ALL_AVAILABLE, AcquisitionType with nidaqmx.Task() as task: task.ai_channels.add_ai_calculated_power_chan( @@ -21,4 +21,4 @@ task.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.FINITE, samps_per_chan=50) data = task.read(READ_ALL_AVAILABLE) - print("Acquired data: [" + ", ".join(f"{value:f}" for value in data) + "]") \ No newline at end of file + print("Acquired data: [" + ", ".join(f"{value:f}" for value in data) + "]") diff --git a/examples/analog_in/cont_calculated_power_acq_int_clk.py b/examples/analog_in/cont_calculated_power_acq_int_clk.py index edd89507..484fdb70 100644 --- a/examples/analog_in/cont_calculated_power_acq_int_clk.py +++ b/examples/analog_in/cont_calculated_power_acq_int_clk.py @@ -1,6 +1,6 @@ """Example of analog input voltage acquisition. -This example demonstrates how to acquire a continuous amount of +This example demonstrates how to acquire a continuous amount of calculated power data using the DAQ device's internal clock. """ From 6cd31574df82d05452371a5a1483782d184895c0 Mon Sep 17 00:00:00 2001 From: Khor Huai Sheng Date: Fri, 9 Jan 2026 18:20:42 +0800 Subject: [PATCH 3/4] Fix typo and add documentation for supported device --- examples/analog_in/calculated_power_acq_int_clk.py | 3 +++ examples/analog_in/cont_calculated_power_acq_int_clk.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/analog_in/calculated_power_acq_int_clk.py b/examples/analog_in/calculated_power_acq_int_clk.py index 634060bc..7b9a8249 100644 --- a/examples/analog_in/calculated_power_acq_int_clk.py +++ b/examples/analog_in/calculated_power_acq_int_clk.py @@ -2,6 +2,9 @@ This example demonstrates how to acquire a finite amount of calculated power data using the DAQ device's internal clock. + +Supported Devices: + - PXIe-4311 (DAQmx 26.3.0 or later) """ import nidaqmx diff --git a/examples/analog_in/cont_calculated_power_acq_int_clk.py b/examples/analog_in/cont_calculated_power_acq_int_clk.py index 484fdb70..3a544ba1 100644 --- a/examples/analog_in/cont_calculated_power_acq_int_clk.py +++ b/examples/analog_in/cont_calculated_power_acq_int_clk.py @@ -1,7 +1,10 @@ -"""Example of analog input voltage acquisition. +"""Example of analog input calculated power acquisition. This example demonstrates how to acquire a continuous amount of calculated power data using the DAQ device's internal clock. + +Supported Devices: + - PXIe-4311 (DAQmx 26.3.0 or later) """ import nidaqmx From f5087c1fc5012bca2fbea26442645314bdb2d6ed Mon Sep 17 00:00:00 2001 From: Brad Keryan Date: Fri, 9 Jan 2026 10:09:23 -0600 Subject: [PATCH 4/4] examples: Fix comment formatting --- examples/analog_in/calculated_power_acq_int_clk.py | 3 ++- examples/analog_in/cont_calculated_power_acq_int_clk.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/analog_in/calculated_power_acq_int_clk.py b/examples/analog_in/calculated_power_acq_int_clk.py index 7b9a8249..df0816ef 100644 --- a/examples/analog_in/calculated_power_acq_int_clk.py +++ b/examples/analog_in/calculated_power_acq_int_clk.py @@ -4,7 +4,8 @@ of calculated power data using the DAQ device's internal clock. Supported Devices: - - PXIe-4311 (DAQmx 26.3.0 or later) + +- PXIe-4311 (DAQmx 26.3.0 or later) """ import nidaqmx diff --git a/examples/analog_in/cont_calculated_power_acq_int_clk.py b/examples/analog_in/cont_calculated_power_acq_int_clk.py index 3a544ba1..132c87a2 100644 --- a/examples/analog_in/cont_calculated_power_acq_int_clk.py +++ b/examples/analog_in/cont_calculated_power_acq_int_clk.py @@ -4,7 +4,8 @@ calculated power data using the DAQ device's internal clock. Supported Devices: - - PXIe-4311 (DAQmx 26.3.0 or later) + +- PXIe-4311 (DAQmx 26.3.0 or later) """ import nidaqmx