Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-DAQ Change of detection using ansi C

I am writing some code to be use with a NI 6528 board and I am using the ansi C driver. I was wondering if I can set up multiple input events. For example, I have 2 channels that I need to detect for both rising and falling edges, but there is another channel on the same port that I need to detect only rising edges. Can I separate these two events and have it call 2 separate functions? Following the examples for events, I first create a task (DAQmxCreateTask), add a group of channels to that task (DAQmxCreateDIChan), set the detection for that one set of channels (DAQmxCfgChangeDetectionTiming), then I attach an interrupt function to this task (DAQmxRegisterSignalEvent). Can I create two separate tasks, configure them with different channels and detections, and attach different ISR functions? I couldn't find any example of having multiple tasks and events. Am I only to have one task, do all the configurations, and only have one ISR function? Thanks for the help.
0 Kudos
Message 1 of 4
(3,849 Views)
Hi Josh,

A resource conflict error will occur if multiple tasks are configured since the circuitry is in use for the existing task. However, you should be able to accomplish your task by specifying only the channels that you want to include as the parameters for risingEdgeChan[] and fallingEdgeChan[]

From the DAQmx C Reference:

risingEdgeChan = The names of the digital lines or ports on which to detect rising edges. You can specify a list or range of channels.
fallingEdgeChan = The names of the digital lines or ports on which to detect falling edges. You can specify a list or range of channels.

Hope this helps,
Lesley
0 Kudos
Message 2 of 4
(3,837 Views)
Thank you for your repsonse. I am still slightly confused about these tasks. You are saying I can only configure and run only a single task? This means I can only register one ISR or can I register two different ISRs, but only one task can be active? At no point I can have two tasks running at one time? If, for example, I have an ISR that reads on rising edges, if I ever do any output, I must first close the input task before I apply the output?
0 Kudos
Message 3 of 4
(3,829 Views)
Hi Josh,

You can only run one digital task. In your application, one ISR will be sent when a rising edge is detected on any of the three channels, or when a falling edge is detected on the 2 channels which you care to monitor for a falling edge. You're able to make use of the unused digital lines and ports for other input and output operations while a task is configured for change detection. However, you cannot configure two change detection tasks happening at the same time.

Thanks,
Lesley
0 Kudos
Message 4 of 4
(3,815 Views)