Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Timer on/off loop action

Hi everyone,

 

I admit that I'm new to Labview. We have the board NI USB 6211 and with the attached code (a simplified one that allows us for testing) I can generate polar and bipolar square wave. I would like also to implement a continuous loop which allows me to generate the selected signal for like 5 minutes, then 10 minutes of break and again 5 min on, 10 min... The time on/off should be selected from the user, it's a variable parameter. Is possible to add a timer, which it will start as soon I start the loop? Which function should I use among time delay, time elapsed and wait or use an event structure? I'm a little bt confused from the many examples that are on the forum...

It would be really helpful your advices.

Thanks in advance.

 

0 Kudos
Message 1 of 4
(1,087 Views)

Here are 2 key principles when it comes to long waits:

1. Do your waiting in a way that's interruptible by the user.  It can be pretty annoying to click the Stop button and then have to wait several minutes for the program to actually stop.

2. Don't hog CPU while waiting, use a method that yields CPU.

 

For a new user, I'm inclined to suggest the approach I think will be simplest to get right, which is a combo of Elapsed Time and Time Delay.  Check Elapsed Time first.  Then proceed to a Case Structure where one case is for changing on/off when you reach the target time and the other case does a short CPU-yielding delay like maybe 0.1 sec.  (Note: if you really need to land on your target times precisely, you can use the outputs from Elapsed Time to figure out when you're getting close and adjust the last little bit of delay to be less than 0.1 sec so you can land on the target time more precisely.)

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 4
(1,069 Views)

Thanks for the answer. How am I supposed to connect these 2 function between "Elapsed time and Time delay? Because in Elapsed time, for now I set 2 seconds and delay time 5 seconds.

0 Kudos
Message 3 of 4
(1,040 Views)

Here's a working example that turns ON for 3 seconds and OFF for 6 a few times.  Study it to see if you follow the logic, explore the online help for functions you don't recognize or understand.  And be sure to click the link for the "Detailed help" too -- that's often where you'll find some of the most important, well, details.

 

 

-Kevin P

 

timed states LV2016.png

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Download All
0 Kudos
Message 4 of 4
(1,021 Views)