Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

continuous DAQ with time delay

Previously, Crossrulz helped me to build a VI which can run automatically and continuously. It works very well.

 

Now a question comes to me on how to add certain time gap between each data acquiring. For example, acquire the data for 10 seconds, then rest for 20 seconds, and then the VI will automatically restart to acquire the data for 10 seconds, then rest for 20 seconds. This process will repeat over and over again, until stopped manually.

 

Attached isf the VI file.

 

Do you have any suggestions based on previous VI?

 

Thanks in advance!

 

loop test.png

0 Kudos
Message 1 of 7
(3,964 Views)

You can do it, but not with the DAQ assistant. I would switch to using actual DAQmx calls. Look at the DAQmx examples in find examples...-> Hardware Input and Output.  You can use a loop with a wait function and a Stop Task.vi., Then start the task again repeatedly.

 

That should do the trick.

TimC
National Instruments
Applications Engineer
0 Kudos
Message 2 of 7
(3,930 Views)

I don't see why you couldn't do this with the DAQ Assistant (although personally I don't really like using it either).  The code you posted doesn't seem to do what you are asking however, since the inner loop will immediately begin executing again after each time it has completed.  

 

What you're asking about is a textbook use-case for a simple state machine.  I'd suggest reading up on it (see here) and see if you can incorporate this into your code to implement what you need.

 

 

Best Regards,

John Passiak
0 Kudos
Message 3 of 7
(3,921 Views)

Hi TimC,

 

Thanks for your suggestion. I know DAQmx will work very well. Actually, most of my existing VIs were built with DAQ assistants. I would stay with them as that can save me some time. 

 

But anyway, thanks for your suggestion.

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

Hi John,

 

Thanks for your hint, and I read through the instruction of state machine. Now two questions just come up to me.

 

1. to incorporate the state machine into my code, do you mean using the state machine as a timer to time for 20 seconds?

 

2. us the output of the Elapsed Time as the input of the state machine? us the output of the " wait " to replace the output of the Elapsed Time.

 

Thanks again for your help!

0 Kudos
Message 5 of 7
(3,877 Views)

One of the states in your state machine would incorporate the 20 second delay.  

 

You will want the code to remain responsive though in case the user wants to exit, so using "wait" for 20 seconds is probably not desirable.  You could instead continue to use the Elapsed Time VI and run the state machine loop at some rate, polling whether or not the time has elapsed while also polling for a user stop button push.

 

OR... if you wanted to get a little fancier you could eliminate polling by using an event structure.

 

 

 

Best Regards,

John Passiak
0 Kudos
Message 6 of 7
(3,859 Views)

Another approach would be to run the data acquisition continuously and simply discard the data during the 20 second rest periods. This eliminates turning the DAQ on and off at specific times.  You should probably still consider use of a state machine to control what you do with the data and the timing. A Producer/Consumer architecture is well suited to this method as it completely separates the data acquisition from the data processing/display/saving tasks.

 

Lynn

Message 7 of 7
(3,848 Views)