-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db57411
commit ebcc616
Showing
5 changed files
with
74 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Example for reading digital signal. | ||
This example demonstrates how to acquire a continuous digital | ||
waveform using the DAQ device's internal clock. | ||
""" | ||
|
||
import nidaqmx | ||
from nidaqmx.constants import AcquisitionType, LineGrouping, READ_ALL_AVAILABLE | ||
|
||
|
||
with nidaqmx.Task() as task: | ||
task.di_channels.add_di_chan("Dev1/port0/line0:3", line_grouping=LineGrouping.CHAN_PER_LINE) | ||
task.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.CONTINUOUS) | ||
task.start() | ||
print("Acquiring samples continuously. Press Ctrl+C to stop.") | ||
|
||
try: | ||
total_read = 0 | ||
while True: | ||
data = task.read(READ_ALL_AVAILABLE) | ||
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.") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Example for reading digital signal. | ||
This example demonstrates how to read values from one or more | ||
digital input channels. | ||
""" | ||
|
||
import nidaqmx | ||
from nidaqmx.constants import LineGrouping | ||
|
||
|
||
with nidaqmx.Task() as task: | ||
task.di_channels.add_di_chan("Dev1/port0/line0:3", line_grouping=LineGrouping.CHAN_PER_LINE) | ||
|
||
data = task.read() | ||
print(f"Acquired data: {data}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Example for reading digital signal. | ||
This example demonstrates how to read values from a digital | ||
input port. | ||
""" | ||
|
||
import nidaqmx | ||
from nidaqmx.constants import LineGrouping | ||
|
||
|
||
with nidaqmx.Task() as task: | ||
task.di_channels.add_di_chan("Dev1/port0", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES) | ||
|
||
data = task.read() | ||
print(f"Acquired data: {data}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""Example for reading digital signal. | ||
This example demonstrates how to input a finite digital pattern | ||
using the DAQ device's internal clock. | ||
""" | ||
|
||
import nidaqmx | ||
from nidaqmx.constants import AcquisitionType, LineGrouping, READ_ALL_AVAILABLE | ||
|
||
|
||
with nidaqmx.Task() as task: | ||
task.di_channels.add_di_chan("Dev1/port0", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES) | ||
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) + "]") |