Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

digital trigger DAQmx

Using PCI-6224, DAQmx

I'm trying to execute a few lines of C code immediately after a digital trigger (signal goes from high to low). Timing is critical.

One solution is to continuously read the input line as an anolog signal.

while (readData > 1.5 )
{ DAQmxReadAnalogF64(..,readData,...)
}
// insert code to execute here

This code reads one value at a time and checks to see if the digital signal has dropped below 1.5 V. Once it has, then the rest of the code is excuted.

This solution should work, but it may be too slow. I would like to use triggering, but have not found a way to do it. Triggering must be associated with a task -- ie, input/ouput to the board. In my case, I just want to run some code.

Any help would be greatly appreciated.
0 Kudos
Message 1 of 5
(3,677 Views)
Hello,

You could also set up an analog or digital task to aqcuire one point on a falling edge of your triger. This way, you could wait for the trigger without having to constantly poll the input lines. You would have to start the task then call a DAQmxWaitUntilTaskDone() function with the Time to Wait parameter set to -1. This would halt the execution of you code until the task completes.

I hope this helps,

Sean C.
Message 2 of 5
(3,660 Views)
That is, which method would have a shorter amount of time between the change in the digital signal and the execution of code?
0 Kudos
Message 3 of 5
(3,653 Views)
Hello,

With the polling method, the delay from a change in the digital signal and the execution of your code is dependant on how long after the change that the read is called. In a while loop, this is on the order of miliseconds.
The digital trigger delay is on the order of nanoseconds. If you set the task to acquire one point, this method would be faster. It also requires less CPU resources because you are not constantly polling the line.

I hope this helps,
Sean C.
0 Kudos
Message 4 of 5
(3,636 Views)
Hi Sean,

Thanks a lot for your help. It was very useful! It seems that everything is working fine..




@Sean C. wrote:
Hello,

With the polling method, the delay from a change in the digital signal and the execution of your code is dependant on how long after the change that the read is called. In a while loop, this is on the order of miliseconds.
The digital trigger delay is on the order of nanoseconds. If you set the task to acquire one point, this method would be faster. It also requires less CPU resources because you are not constantly polling the line.

I hope this helps,
Sean C.


0 Kudos
Message 5 of 5
(3,625 Views)