Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

pulse generation with python API

Hey, I'm using a USB 6212 device and am just trying to make a simple pulse generator using the python API, I've tried using the example here https://github.com/ni/nidaqmx-python/blob/master/nidaqmx_examples/ci_pulse_freq.py but this produces the error 

nidaqmx.errors.DaqError: The task is not buffered or has no channels.  If the task is not buffered, use the scalar version of this function. If the task has no channels, add one to the task.
Task Name: _unnamedTask<0>

 I also need to count pulses for a set amount of time and I can't find any resources on this. If anyone knows how to help me with these specific problems or where I can find good learning resources for this I would appreciate it.

0 Kudos
Message 1 of 2
(2,290 Views)

I actually managed to fix this issue and am now able to generate pulses using

 

with nidaqmx.Task() as task:
task.co_channels.add_co_pulse_chan_time("Dev2/ctr0", high_time = 1, low_time = 1)
pulse_count = 20
task.timing.cfg_implicit_timing(sample_mode=AcquisitionType.FINITE, samps_per_chan=pulse_count)

task.start()

task.wait_until_done(timeout = math.inf)

 

but now I need to count pulses for one second and cannot figure it out, so if anyone knows how to do this please let me know.

0 Kudos
Message 2 of 2
(2,231 Views)