Discussion:
PCI-6527 reading input/output after callback problem using NIDAQmx 8.0
(too old to reply)
Jesse O
2006-09-07 18:10:10 UTC
Permalink
Hello Vladimir,

To clarify a little more, when using change detection/notification in DAQmx you
configure change detection for the task with the DAQmx timing VI. 
When you use the timing VI, you set the condition for when new data is available.  In the
case of change notification you have available data everytime there is a change
in one of the lines you are looking at. 

This means that if you perform a DAQmx read it will wait for a change to occur
before returning.  If no change occurs within the amount of time specified
by the timeout parameter of the read function, it will return invalid data along with an error status code.  I believe this is
what is happening to you.  This is why performing a single software timed
read before you start your change notification task allows you to read valid
data.

Secondly, you are limited to a single change detection event.  For example, if you try to create a change detection task for
Dev1/port0/line0, and another change detection task for Dev1/port0/line1 you
should receive error -50103 which states that "The specific resource is
reserved.  The operation could not be completed as specified."

Finally, I have tried the change detection example I mentioned to you in both Visual C++ 6 and .NET 2003.  I have had no problems running these examples.  I have tried all combinations of running and closing the examples with no problems. Could be more specific into exactly what you did to get the program to crash.

Regards,

Jesse O.
Applications Engineering
National Instruments
Jesse O
2006-09-11 16:10:10 UTC
Permalink
Hello Vladimir,

If I understand your first question correctly, you want to have two tasks for
the same digital line.  One task that performs change detection and the
other task that just performs software timed digital input?  If so, this
is not possible.  If you try to setup a task to do this, you will get
error -200587 which states that the "Requested operation could not be
performed, because the specified digital lines are either reserved or the
device is not present in NI-DAQmx. It is possible that these lines are reserved
by another task..."

Instead, you could have one software timed task read the input once before you
start your change detection task.  Then you have the digital line state in
your application.  You would be notified of any future changes.  If
you store this updated value in a variable you always know the last data
available on the digital lines.

It looks like you want to perform some operations for specific line
changes.  To do this, you could read in the current value, compare it to
the old value (stored in a variable) and decide from there what code to
execute.  Similar to how the example
works.

Finally, you mentioned that you are not getting any data back from the change
detection read until a timeout occurs.  In running the code (on another
board), I found that I required multiple changes to occur before I was able to
read data.  I think this might be causing
your problems.  I modified the code so that after only a single change
data is available in your application.  To do this, you can change the
data transfer mechanism.  I have copied the section of code from the
example program, plus the modification I made below:

    DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
    DAQmxErrChk
(DAQmxCreateDIChan(taskHandle,"Dev2/port0/line0:7","",DAQmx_Val_ChanPerLine));
    DAQmxErrChk
(DAQmxCfgChangeDetectionTiming(taskHandle,"Dev2/port0/line0:7","Dev2/port0/line0:7",DAQmx_Val_ContSamps,1));
    DAQmxErrChk
(DAQmxRegisterSignalEvent(taskHandle,DAQmx_Val_ChangeDetectionEvent,0,ChangeDetectionCallback,NULL));
    DAQmxErrChk
(DAQmxGetTaskNumChans(taskHandle,&numLines));
    DAQmxErrChk (DAQmxSetDIDataXferMech(taskHandle,
"Dev2/port0/line0:7", DAQmx_Val_Interrupts ))


Regards,

Jesse O.
Applications Engineering
National Instruments
Jesse O
2006-10-20 17:10:15 UTC
Permalink
Hello again,

Can you please provide more detail about the problem you were seeing.  The
previous examples we were talking about involved digital input and change
detection.  You mention that there is a problem with the digital output
example.  Which example are you referring to, and can you explain a little
more about the problem you are seeing?

Regards,

Jesse O.
Applications Engineering
National Instruments

Loading...