-
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
bd555bd
commit 81e88d3
Showing
5 changed files
with
105 additions
and
20 deletions.
There are no files selected for viewing
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,21 @@ | ||
"""Example for continuously generating digital pulse train. | ||
This example demonstrates how to generate a continuous digital | ||
pulse train from a Counter Output Channel. The Frequency, Duty | ||
Cycle, and Idle State are all configurable. | ||
""" | ||
|
||
import nidaqmx | ||
from nidaqmx.constants import AcquisitionType, Level | ||
|
||
with nidaqmx.Task() as task: | ||
channel = task.co_channels.add_co_pulse_chan_freq( | ||
"Dev1/ctr1", idle_state=Level.LOW, initial_delay=0.0, freq=100.0, duty_cycle=0.5 | ||
) | ||
channel.co_pulse_term = "/Dev1/PFI13" | ||
task.timing.cfg_implicit_timing(sample_mode=AcquisitionType.CONTINUOUS) | ||
task.start() | ||
|
||
input("Generating pulse train. Press Enter to stop.\n") | ||
|
||
task.stop() |
33 changes: 33 additions & 0 deletions
33
examples/counter_out/cont_gen_dig_pulse_train_buff_ext_clk.py
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,33 @@ | ||
"""Example for continuously generating digital pulse train with external timing. | ||
This example demonstrates how to generate a continuous buffered | ||
sample clocked digital pulse train from a Counter Output | ||
Channel. The Frequency, Duty Cycle, and Idle State are all | ||
configurable. The default data generated is a pulse train with a | ||
fixed frequency but a duty cycle that varies based on the Duty | ||
Cycle Max/Min and the signal type. The duty cycle will update | ||
with each sample clock edge. | ||
""" | ||
|
||
import nidaqmx | ||
from nidaqmx.constants import AcquisitionType, Level | ||
from nidaqmx.types import CtrFreq | ||
|
||
with nidaqmx.Task() as task: | ||
duty_min = 0.5 | ||
duty_max = 0.8 | ||
duty_step = (duty_max - duty_min) / 1000 | ||
ctr_freq_data: CtrFreq = [CtrFreq(1000, (duty_min + duty_step * i)) for i in range(1000)] | ||
|
||
channel = task.co_channels.add_co_pulse_chan_freq( | ||
"Dev1/ctr1", idle_state=Level.LOW, initial_delay=0.0, freq=100.0, duty_cycle=0.5 | ||
) | ||
channel.co_pulse_term = "/Dev1/PFI13" | ||
task.timing.cfg_samp_clk_timing(1000.0, "/Dev1/PFI4", sample_mode=AcquisitionType.CONTINUOUS) | ||
task.out_stream.output_buf_size = 1000 | ||
task.write(ctr_freq_data) | ||
task.start() | ||
|
||
input("Generating pulse train. Press Enter to stop.\n") | ||
|
||
task.stop() |
32 changes: 32 additions & 0 deletions
32
examples/counter_out/cont_gen_dig_pulse_train_buff_implicit.py
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,32 @@ | ||
"""Example for continuously generating digital pulse train with implicit timing. | ||
This example demonstrates how to generate a continuous buffered | ||
implicit timed digital pulse train from a Counter Output | ||
Channel. The Frequency, Duty Cycle, and Idle State are all | ||
configurable. The default data generated is a pulse train with a | ||
fixed frequency but a duty cycle that varies based on the Duty | ||
Cycle Max/Min and the signal type. The duty cycle will update | ||
with each sample generated. | ||
""" | ||
|
||
import nidaqmx | ||
from nidaqmx.constants import AcquisitionType, Level | ||
from nidaqmx.types import CtrFreq | ||
|
||
with nidaqmx.Task() as task: | ||
duty_min = 0.5 | ||
duty_max = 0.8 | ||
duty_step = (duty_max - duty_min) / 1000 | ||
ctr_freq_data: CtrFreq = [CtrFreq(1000, (duty_min + duty_step * i)) for i in range(1000)] | ||
|
||
channel = task.co_channels.add_co_pulse_chan_freq( | ||
"Dev1/ctr1", idle_state=Level.LOW, initial_delay=0.0, freq=100.0, duty_cycle=0.5 | ||
) | ||
channel.co_pulse_term = "/Dev1/PFI13" | ||
task.timing.cfg_implicit_timing(sample_mode=AcquisitionType.CONTINUOUS) | ||
task.write(ctr_freq_data) | ||
task.start() | ||
|
||
input("Generating pulse train. Press Enter to stop.\n") | ||
|
||
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,19 @@ | ||
"""Example for generating digital pulse. | ||
This example demonstrates how to generate a single digital pulse | ||
from a Counter Output Channel. The Initial Delay, High Time, Low | ||
Time, and Idle State are all configurable. | ||
""" | ||
|
||
import nidaqmx | ||
from nidaqmx.constants import Level | ||
|
||
with nidaqmx.Task() as task: | ||
channel = task.co_channels.add_co_pulse_chan_time( | ||
"Dev1/ctr1", idle_state=Level.LOW, initial_delay=0.0, low_time=0.01, high_time=0.01 | ||
) | ||
channel.co_pulse_term = "/Dev1/PFI13" | ||
|
||
task.start() | ||
task.wait_until_done(timeout=10) | ||
task.stop() |