04-16-2012 10:26 AM
Hello,
if wrote a driver for NI-DAQmx and it worked well, until today.
By using counter inputs we are now running into troubles.
The following lines of code are part of my driver.
mLastError= DAQmxReadCounterScalarF64(GetTaskHandle(),
1.0, // timeout in seconds
value,
NULL);
if (mLastError == 0)
{
return true;
}
// Timeout expired -> no signal connected
if (mLastError == -200474) {
*value= 0.0;
return true;
}
return false;
Here the problem:
Developed with DAQpad-6016 it worked always. When I disconnected the input signal i got a timeout, by connecting again i got valid values.
Now, with USB-6211 after first timeout I am getting always a timeout.
Any idea ?
Best Regards
Heinrich
04-17-2012 06:23 AM
Hey Heinrich,
it seems that your Problem occurs because the loop you are using saves the error data. Try to set error status back to 0 once mLastError == -200474 has been detected.
Use line after "*value= 0.0;" to do so.
For alternative error-reasoning please state to which ports you have connected the counter. Are you using the default signal routing in your driver?
Best Regards
04-17-2012 07:01 AM
Hy,
mLastError is always set by calling the Getter function before.
I am creating tasks with MAX and are using them as they are.
It seems that USB 6211 does not reacquire data after a timeout.
DAQpad-6016 reacquires data after timeout.
My NI-DAQmx version is 9.4
Any idea ?
Best Regards
Heinrich
04-19-2012 01:58 AM
Hey Heinrich,
I found this article which might be helpful for you.
http://digital.ni.com/public.nsf/allkb/4E017925BDF2DC2D862572E6007C9594?OpenDocument
"For some DAQmx driver versions any input frequency below 100Hz yields this error, which is expected behavior by design."
What could be the reason is, that the DAQmx driver shows different behaviour for your new card (USB-6211)
In case this doesn't solve the problem please post some more code.
Best Regards
04-19-2012 02:58 AM
This is the problem, thanx.
I am not a VI specialist, which function in NI-DAQmx API can clear the error ?
I could call it before getting new data.
Best Regards
Heinrich
04-19-2012 04:43 AM
Hey Heinrich,
there is no functionality to clear the error. Just overwrite the error-code. In the LabView example I have sent you, error code 200474 is overwritten by a constant "0"
Best regards
04-19-2012 05:22 AM
// Timeout expired -> no signal connected
if (mLastError == -200474) {
*value= 0.0;
return true;
}
In my code -200474 is not really a error. I accept it and delivers 0 Hz back to the caller.
But when it happens I am getting always a -200474, unless what happens on the input.
My signals stays therefore at 0Hz.
Best Regards
Heinrich
04-19-2012 07:06 AM
As soon as mLastError == -200474 mLastError contains an Integer which you must overwrite in your if case. Just try:
*value= 0.0;
mlastError=0;
Good luck
04-19-2012 09:35 AM
mLastError = 0 will not bring a effect.
mLastError is the result of DAQmxReadCounterScalarF64();
The full code is similar to the following
bool MyClass::GetCurrentFrequency(double * value)
{
mLastError = DAQmxReadCounterScalarF64(GetTaskHandle(), 1.0 /* timeout in seconds */, value, NULL);
if (mLastError == 0) return true;
// Timeout expired -> no signal connected
if (mLastError == -200474)
{
*value= 0.0;
return true;
}
return false;
}
After getting the first -200474 i get always -200474.
Best Regards
Heinrich
04-19-2012 10:28 AM
Hey Heinrich,
until now I haven't fully understand why you catch errorcode ="0". What is the meaning of error "0" in your case? Default value for errorcode: "0" = no error
So usually setting errorcode to zero equals erasing it.