Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

PXI 6229 intermittent read problems

I am having an intermittent problem with reading analog and digital inputs a the same time.  I am not able to track down the problem since the code will run many times in a row ( I have tested it ten times in a row without fail).  If I try and run it at a different time it will fail usually by just never completing the task and hanging without any error message.  I am attaching the code (C# in MS Visual studio).  Any help will be appreciated.

 

Thanks

0 Kudos
Message 1 of 7
(4,510 Views)

You have your stream timeout set to -1, which is never timeout. Is there a reason for this? It could be waiting forever, which is why you would be seeing a hang without errors.

Daniel C.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 7
(4,486 Views)

I would probably get some kind of timeout error if I did not have the timeout set to -1 but it still does not explain why it will run many times in a row and then later on have a problem getting data.

 

Thanks,

Howard

0 Kudos
Message 3 of 7
(4,483 Views)

Hmm well that could be a problem. If you are expecting that error, it would be better to catch and handle the error than just having no timeout.

 

Does this program work every time if you remove the analog channel or the digital channel?

Daniel C.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 7
(4,439 Views)

The error I receive when not having the timeout set to -1 is that all data was not received.  I will run it without each of the digital or analog channels and see if it has a problem.  It seemed to be running consistently when I switched the order of reading the analog and digital channels.  Time will tell if that is a permanent fix.

Message 5 of 7
(4,436 Views)

@paofthree wrote:

It seemed to be running consistently when I switched the order of reading the analog and digital channels.


This makes sense--the digital task is relying on the sample clock from the analog input task, so you need to start the digital task first so that it is guaranteed to be started in time for the first sample.  If it takes longer for some (software-dependant) reason to start the digital task and the analog task has already generated its first clock edge, the digital task would come up one sample short.

 

BeginReadWaveform will start the associated task implicitly , or you could also explicitly call the task.start method for each task in the proper order (digital before analog in your case) before calling BeginReadWaveform.

 

 

Best Regards,

John Passiak
0 Kudos
Message 6 of 7
(4,432 Views)

Thanks John.  I stumbled on the solution by trial and error, but your explanation makes sense.

0 Kudos
Message 7 of 7
(4,419 Views)