Skip to content

Commit

Permalink
Add synchronization examples
Browse files Browse the repository at this point in the history
  • Loading branch information
WayneDroid committed May 27, 2024
1 parent 7c1d69f commit 59484bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/multi-functions-synchronization/ai_ao_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ def callback(task_handle, every_n_samples_event_type, number_of_samples, callbac
return 0

task_ai.ai_channels.add_ai_voltage_chan("Dev1/ai0")
task_ai.timing.cfg_samp_clk_timing(10000.0, sample_mode=AcquisitionType.CONTINUOUS)
task_ai.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.CONTINUOUS)
task_ai.register_every_n_samples_acquired_into_buffer_event(1000, callback)
task_ao.ao_channels.add_ao_voltage_chan("Dev1/ao0")
task_ao.timing.cfg_samp_clk_timing(5000.0, sample_mode=AcquisitionType.CONTINUOUS)
task_ao.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.CONTINUOUS)
task_ao.triggers.start_trigger.cfg_dig_edge_start_trig("/Dev1/ai/StartTrigger")

actual_sampling_rate = task_ao.timing.samp_clk_rate
Expand Down
8 changes: 5 additions & 3 deletions examples/multi-functions-synchronization/cont_ai_di_acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def main():
task_di = nidaqmx.Task()

def callback(task_handle, every_n_samples_event_type, number_of_samples, callback_data):
"""Callback function for reading singals."""
"""Callback function for reading signals."""
nonlocal total_ai_read
nonlocal total_di_read
ai_read = task_ai.read(number_of_samples_per_channel=1000)
Expand All @@ -29,10 +29,12 @@ def callback(task_handle, every_n_samples_event_type, number_of_samples, callbac
return 0

task_ai.ai_channels.add_ai_voltage_chan("Dev1/ai0")
task_ai.timing.cfg_samp_clk_timing(10000.0, sample_mode=AcquisitionType.CONTINUOUS)
task_ai.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.CONTINUOUS)
task_ai.register_every_n_samples_acquired_into_buffer_event(1000, callback)
task_di.di_channels.add_di_chan("Dev1/port0", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES)
task_di.timing.cfg_samp_clk_timing(10000.0, "/Dev1/ai/SampleClock", sample_mode=AcquisitionType.CONTINUOUS)
task_di.timing.cfg_samp_clk_timing(
1000.0, "/Dev1/ai/SampleClock", sample_mode=AcquisitionType.CONTINUOUS
)

try:
task_di.start()
Expand Down

0 comments on commit 59484bc

Please sign in to comment.