11-25-2014 04:09 PM
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
11-26-2014 10:27 AM
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.
11-26-2014 10:33 AM
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
12-01-2014 04:57 PM
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?
12-01-2014 05:04 PM
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.
12-01-2014 05:24 PM - edited 12-01-2014 05:25 PM
@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,
12-02-2014 11:14 AM
Thanks John. I stumbled on the solution by trial and error, but your explanation makes sense.