From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

counter timeout 6211

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

 

0 Kudos
Message 1 of 12
(6,685 Views)

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

 

 

0 Kudos
Message 2 of 12
(6,674 Views)

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

 

0 Kudos
Message 3 of 12
(6,672 Views)

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

0 Kudos
Message 4 of 12
(6,661 Views)

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

0 Kudos
Message 5 of 12
(6,657 Views)

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

 

0 Kudos
Message 6 of 12
(6,654 Views)

// 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

 

 

0 Kudos
Message 7 of 12
(6,652 Views)

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

 

0 Kudos
Message 8 of 12
(6,650 Views)

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

0 Kudos
Message 9 of 12
(6,646 Views)

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.

 

 

0 Kudos
Message 10 of 12
(6,643 Views)