From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a built-in way to stop a task if it does not receive a digital start trigger within a specified amount of time?

Yo,

 

I was wondering if there is a way to set a timeout for a task's digital start trigger that is built into the NI API? I would like to cancel or stop a task if it does not receive a digital start trigger within 15s of the task being started. My task's digital start trigger configuration code is shown below.

_task.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("/" + _deviceLocator.DeviceName + "/PFI1", DigitalEdgeStartTriggerEdge.Rising);
0 Kudos
Message 1 of 3
(2,299 Views)

Hi b!tmaster,

 

You are going to want to set your timeout values:

 

Using the DAQmx Task Timeout Property in Visual Studio

This should set the amount of time you wait to acquire the samples before timing out. This should also cause the same timeout if you do not receive the specified trigger in the time you set.

0 Kudos
Message 2 of 3
(2,260 Views)

Hey sherlockhom,

 

I have added the following line of code to my configuration, but no DaqException is ever thrown.

_task.Stream.Timeout = 15000;

Upon further investigation, if one looks at the description of the Timeout property on the DaqStream Class Zone NI page they will find the following piece of information...

"A write is considered complete when all of the written samples have been transferred to the task buffer. Writes do not wait until the written samples have been generated by the device."

This description suggests that this Timeout property cannot be used for what I am trying to achieve. And explains why a DaqException is not thrown for me.

0 Kudos
Message 3 of 3
(2,258 Views)