06-27-2022 03:29 PM - edited 06-27-2022 03:53 PM
I am attempting to gate a counter channel that counts edges by using an input terminal. Essentially, I need it so that edges are only counted when that input terminal's signal is high.
I did this by setting up a counter input channel which takes an input connected physically to a counter output so I can count pulses from it. That part works on its own. However, when I tried to set up the gating it gave me the error that:
" DaqError: Specified property is not supported by the device or is not applicable to the task"
Status Code: -200452
This is the property in question which seems to provide this functionality:
I am working on a NI PCIe-6384 device on Windows 10. I suspect perhaps the solution is not to enable gating on that channel. Could this be a working approach with a minor error is there some other method?
Here is my code:
def gen_and_collect(self, testlow, testhigh, ctr=0): # Testlow & Testhigh are used for the counter generation to create custom pulse lengths. #Defining output counter output_counter = nidaqmx.Task() output_counter.co_channels.add_co_pulse_chan_time("Dev1/ctr"+str(ctr)) output_counter.timing.cfg_implicit_timing( samps_per_chan=len(low), sample_mode=AcquisitionType.FINITE ) # Defining counter for counting edges count_edge = nidaqmx.Task() ch = count_edge.ci_channels.add_ci_count_edges_chan( counter='Dev1/ctr1', edge=Edge.RISING ) # These two lines cause it to error (setting up the gating) ch.ci_count_edges_gate_enable = True ch.ci_count_edges_gate_term = 'Dev1/port1/line7' # Counter for generation setup sw = nidaqmx.stream_writers.CounterWriter(output_counter.out_stream) sw.write_many_sample_pulse_time(testhigh, testlow) # Running count_edge.start() output_counter.start() output_counter.wait_until_done(timeout=(sum(low)+sum(high)+initial_delay)*2) print(count_edge.read()) count_edge.stop() count_edge.close() output_counter.stop() output_counter.close()
Solved! Go to Solution.
06-27-2022 05:08 PM
I don't know any of the Python syntax, but in LabVIEW calls to DAQmx functions this is typically done by configuring a "Pause Trigger" for the task instead of setting up "gating."
I don't know why it has to be done this way -- the gating config functions sure *look* like they should be available to do the same job. But for whatever reason, DAQmx isn't allowing it. Anyway, configuring a Pause Trigger will give you the behavior you want -- counting proceeds while the pause trigger terminal is in one digital state, it pauses when in the other state.