LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to timeout DAQ when disconnected

Solved!
Go to solution

Hello Everyone,

Attached a subVI that is used in a larger VI to control temperature acquisition from a cDAQ 9174. The VI itself works. However, due to some hardware fault (most likely a bad USB 2.0 A cable) the  cDAQ disconnects freezing/crashing the whole application. Now, of course we are going to substitute the faulty hardware, however I was wondering if there is a way to pause a loop like the one attached to this post when the DAQ channel is not detected and have the VI start again once the channel is connected again.  

 

Thank you,

Michele

0 Kudos
Message 1 of 8
(4,480 Views)

Try to reduce the timeout in DAQmx Read. It will give an error if the data is not acquired within that timeout period.


CLD Using LabVIEW since 2013
0 Kudos
Message 2 of 8
(4,467 Views)

Thanks kartiknattar, however I wonder if there is a way to bypass displaying the error and stop the program. I'll try to explain better. I would like the application to keep on running and waiting for the user to reconnect the DAQ rather than stop and restart. I am not sure that is possible that is why I am asking it here in the forum.

0 Kudos
Message 3 of 8
(4,462 Views)

I beleive LabVIEW creates new session everytime DAQ is initialized but you can still try the below method to bypass the error.

Just insert the error number which you get when the device is disconnectedbypass.PNG

Let me know if it helps you.

 


CLD Using LabVIEW since 2013
0 Kudos
Message 4 of 8
(4,455 Views)
Solution
Accepted by topic author Mik3ySky

You would need to reconfigure your simple example, don't know if what you posted is an example or your real program. I have implemented what you want in some of my programs with the following modifications:

  1. I use a State Machine
  2. I use continuous acquire in DAQmx
  3. If I a get an error my State machine stops the tasks, clears the task, and sends a message to the user.
  4. I do not try to reconnect to the DAQ automatically.

You need to decide what you want to do when an error occurs, ie, stop the program, try to restart the task, etc. Best method in my opinion is to make a state machine.

 

cheers,

mcduff

0 Kudos
Message 5 of 8
(4,441 Views)

Hi McDuff, 

thanks for your reply. Could you post your VI so I could test it? I would like to check how you implemented point 3.

Best Regards,
Michele

0 Kudos
Message 6 of 8
(4,425 Views)

Unfortunately due to company policy I cannot post it. But I can describe in more detail what I did along with some pictures.

 

  1. Look at the example DAQmx Continuous Acquisition with Events.

I use an Event Structure that tells me when N number of points is ready from the device, in my case I choose N such that the time is 100ms. (For example if my sampling rate is 1kSa/s, then N is 100 samples) Before starting the acquisition I change the timeout on my Event structure from -1(infinite) to something like 500ms. If I go to the time out state then I know my DAQ did not read in 100ms and something went wrong. I then start a sequence of events to clear the error, clear the task etc, send a message and wait for the user to respond.

mcduff

N points eventN points event

 

timeout errortimeout error

 

Ignore the comment, never changed itIgnore the comment, never changed it

 

 

 

 

0 Kudos
Message 7 of 8
(4,413 Views)

I made a state machine and I obtain the goal of giving the user the choice of waiting for the DAQ to be reconnected before making a new measurement or stop the loop.

 

Thanks McDuff

0 Kudos
Message 8 of 8
(4,408 Views)