-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add DO examples * fixed style errors * renamed files and reworked * removed comments * removed spinwait * call task start explicitly
- Loading branch information
1 parent
41b7aa5
commit ff11da3
Showing
5 changed files
with
74 additions
and
21 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,20 @@ | ||
"""Example for generating digital signals. | ||
This example demonstrates how to output a continuous digital | ||
pattern using the DAQ device's clock. | ||
""" | ||
|
||
import nidaqmx | ||
from nidaqmx.constants import AcquisitionType, LineGrouping | ||
|
||
with nidaqmx.Task() as task: | ||
data = [1, 2, 4, 8, 16, 32, 64, 128] | ||
|
||
task.do_channels.add_do_chan("Dev1/port0", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES) | ||
task.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.CONTINUOUS) | ||
task.write(data) | ||
task.start() | ||
|
||
input("Generating voltage continuously. Press Enter to stop.\n") | ||
|
||
task.stop() |
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,22 @@ | ||
"""Example for generating digital signals. | ||
This example demonstrates how to output a finite digital | ||
waveform using the DAQ device's internal clock. | ||
""" | ||
|
||
import nidaqmx | ||
from nidaqmx.constants import AcquisitionType, LineGrouping | ||
|
||
with nidaqmx.Task() as task: | ||
data: bool = [bool(i % 2) for i in range(1000)] | ||
|
||
task.do_channels.add_do_chan("Dev1/port0/line0", line_grouping=LineGrouping.CHAN_PER_LINE) | ||
task.timing.cfg_samp_clk_timing( | ||
1000.0, sample_mode=AcquisitionType.FINITE, samps_per_chan=len(data) | ||
) | ||
|
||
number_of_samples_written = task.write(data) | ||
task.start() | ||
print(f"Generating {number_of_samples_written} voltage samples.") | ||
task.wait_until_done() | ||
task.stop() |
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 generating digital signals. | ||
This example demonstrates how to write values to a digital | ||
output channel. | ||
""" | ||
|
||
import nidaqmx | ||
from nidaqmx.constants import LineGrouping | ||
|
||
with nidaqmx.Task() as task: | ||
data = [True, False, True, False] | ||
|
||
task.do_channels.add_do_chan("Dev1/port0/line0:3", line_grouping=LineGrouping.CHAN_PER_LINE) | ||
task.start() | ||
task.write(data) | ||
task.stop() |
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 generating digital signals. | ||
This example demonstrates how to write values to a digital | ||
output port. | ||
""" | ||
|
||
import nidaqmx | ||
from nidaqmx.constants import LineGrouping | ||
|
||
with nidaqmx.Task() as task: | ||
data = 0xFFFFFFFF | ||
|
||
task.do_channels.add_do_chan("Dev1/port0", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES) | ||
task.start() | ||
task.write(data) | ||
task.stop() |