Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Retriggerable task with fixed delay between retriggers

Solved!
Go to solution

Hi,

 

I have a basic problem but I'm struggling to solve it. I have a task which has a triggered pulse, and I want the task to be retriggerable but with a fixed delay time between retriggers (i.e. no delay at the start). I have a USB 6343 and use python NI DAQmx:

 

co_chan = trg_task.co_channels.add_co_pulse_chan_time(daq_device_name + chan_pulse,
units=nidaqmx.constants.TimeUnits.SECONDS,
high_time=high_time)

trg_task.triggers.start_trigger.cfg_dig_edge_start_trig(chan_trigger, nidaqmx.constants.Edge.FALLING)
trg_task.triggers.start_trigger.retriggerable = True

trg_task.start()

trg_task.wait_until_done(timeout=100)

 

This retriggers the pulse properly but I want to specify a delay in between the retriggers such that it won't happen again for X seconds. I don't want the delay to to be enforced when the task first starts, i.e. it can be triggered immediately. If anyone can point me in the direction of the solution it would be much appreciated.

 

Thanks,

Tristan

0 Kudos
Message 1 of 4
(1,371 Views)
Solution
Accepted by topic author tristan256

You can do this by chaining together TWO retriggerable pulse tasks.  The first will be a helper, the second will be the one you have now.

 

The key to this approach is that a retriggerable pulse (or pulse train) does not re-arm to be sensitive to new triggers until it has run to completion after the previous trigger.  So if you want to limit your trigger rate to be no more than once every, say, 2.0 seconds here's what you do.

 

Your helper task would be configured for the minimal possible low time, minimal initial delay and ~2.0 seconds high time.  It will be retriggered off whatever your external trigger signal is now.

 

Your main task will trigger off the output of the helper counter, which is delayed by a minimal amount from the external signal (can be < 1 microsec).  But the helper can't be triggered any more often than every 2 seconds, thus your main counter won't trigger and fire more often either.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
Message 2 of 4
(1,342 Views)

Thanks Kevin. I believe I have it working using the following code:

 

helper_task.co_channels.add_co_pulse_chan_time(daq_device_name + "/ctr3",
units=nidaqmx.constants.TimeUnits.SECONDS,
high_time=delay_time)

trigger_task.co_channels.add_co_pulse_chan_time(daq_device_name + chan_pulse,
units=nidaqmx.constants.TimeUnits.SECONDS,
high_time=high_time)


helper_task.triggers.start_trigger.cfg_dig_edge_start_trig(chan_trigger, nidaqmx.constants.Edge.FALLING)
trigger_task.triggers.start_trigger.cfg_dig_edge_start_trig("PFI15")

helper_task.triggers.start_trigger.retriggerable = True
trigger_task.triggers.start_trigger.retriggerable = True

trigger_task.start()
helper_task.start()

 

I hard code the helper counter in this snippet to highlight how it was done - /ctr3 & PFI15, since PFI15 is the out of counter 3. Is this the ideal way to do it? Seems like a slight waste of a counter and unfortunate it has to be specified in two different ways - ctr3 and PFI15.

 

Cheers,

Tristan

0 Kudos
Message 3 of 4
(1,300 Views)

I don't know the syntax under Python, but in LabVIEW there are DAQmx properties that would let me query the helper counter task for its output terminal rather than needing to hard-code it.  There are also internal signals with names like "/Dev1/Ctr3InternalOutput" that you could build programmatically when you know your device name and counter #.  (Offhand, I don't know if these are case-sensitive.  In the LabVIEW API, they're available as enumerated constants.)

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
0 Kudos
Message 4 of 4
(1,282 Views)