PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

trying to use counter 0 out as clock for counter 1 with nidaqmx python

I'm trying to use the output of counter 0 as the clock for counter 1, in nidaqmx-python. see the attached code, also copied here (indentation in cut and paste is not working):

 

import time
import nidaqmx
import numpy as np
from nidaqmx.constants import AcquisitionType
from nidaqmx.stream_readers import CounterReader

num_samples = 2
with nidaqmx.Task() as clk_task, nidaqmx.Task() as ctr_task:
clk_task.co_channels.add_co_pulse_chan_freq("/PXI1Slot8/ctr0", freq=1000.0,
duty_cycle=0.5)
#clk_task.export_signals.ctr_out_event_output_term = "/PXI1Slot8/PFI5"
print("Ctr 0 output term is",clk_task.export_signals.ctr_out_event_output_term)
ctr_task.ci_channels.add_ci_count_edges_chan("/PXI1Slot8/ctr1")
# set up clock
clk_task.timing.cfg_implicit_timing(samps_per_chan=int(1000))
ctr_task.timing.cfg_samp_clk_timing(1000.0, source="/PXI1Slot8/Ctr0Out",
samps_per_chan=num_samples)
ctr_task.start()
data = np.zeros(num_samples) - 10
reader = CounterReader(ctr_task.in_stream)
clk_task.start()
while not clk_task.is_task_done():
time.sleep(0.1)
# samples_read = reader.read_many_sample_double(data,
# number_of_samples_per_channel=num_samples)
clk_task.stop()
ctr_task.stop()
print(samples_read)
 
I get the following error which I don't understand:
 
nidaqmx.errors.DaqError: The specified resource is reserved. The operation could not be completed as specified.

 

 

I even commented out the reading part, but does not make a difference. I tested the clock out and the counter reading separately and they both work, so I'm not sure why this is not working . 

0 Kudos
Message 1 of 1
(678 Views)