LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can you make a delay before a certain command executes?

So I have a function in a while loop, that repeats itself until I press the stop button, telling it to stop.  I have a general understanding for the wait (ms) function in labview and how it is used inside of a while loop.  My problem is I have a while loop, but I don't want it to begin as soon as I hit the "run" button.  I want the program to wait maybe 2 seconds before it begins gathering data.  How would it be possible to make a function wait 2seconds or so to initiate after I hit the run button?  If it helps I have attached the VI I am trying to write, with a delay before gathering the data.

0 Kudos
Message 1 of 9
(12,128 Views)

look at the time function called "time delay" and use the error lines to force data flow...

Message 2 of 9
(12,110 Views)

 

Owning Palette: Execution Control Express VIs and Structures

Requires: Base Package

Inserts a time delay into the calling VI.

Example

Dialog Box Options
Block Diagram Inputs
Block Diagram Outputs

Dialog Box Options

ParameterDescription
Time delay (seconds) Specifies how many seconds to delay running the calling VI. The default is 1.000.

Block Diagram Inputs

ParameterDescription
Delay Time (s) Specifies how many seconds to wait. The value you wire to this input overrides the value you set in the configuration dialog box.
error in Describes error conditions that occur before this node runs.

Block Diagram Outputs

ParameterDescription
error out Contains error information. This output provides standard error out functionality.

This Express VI operates similarly to the following VIs and functions:

Wait (ms)
Wait Until Next ms Multiple

Example

Refer to the Express Comparison VI in the labview\examples\express directory for an example of using the Time Delay VI.

 

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 3 of 9
(12,104 Views)

You have several loops, so let's assume that you want to delay the outer while loop. Dataflow dictates that a code element (e.g. a structure) cannot execute until all inputs have data. In this case, placing a wait before the loop and wiring the output of the wait to the structure will stall the structure until the wait has completed. (See picture). There is now a data dependency, even though the while loop does not really do anything with the value of the wait output.

 

 

 

Of course this is not really scalable, so a better idea would be to implement your code as a state machine, with one of the states being the wait state, which is called first.

Message 4 of 9
(12,099 Views)

@abikutn wrote:

 

Owning Palette: Execution Control Express VIs and Structures

Requires: Base Package

Inserts a time delay into the calling VI.

Example

Dialog Box Options
Block Diagram Inputs
Block Diagram Outputs

Dialog Box Options

ParameterDescription
Time delay (seconds) Specifies how many seconds to delay running the calling VI. The default is 1.000.

Block Diagram Inputs

ParameterDescription
Delay Time (s) Specifies how many seconds to wait. The value you wire to this input overrides the value you set in the configuration dialog box.
error in Describes error conditions that occur before this node runs.

Block Diagram Outputs

ParameterDescription
error out Contains error information. This output provides standard error out functionality.

This Express VI operates similarly to the following VIs and functions:

Wait (ms)
Wait Until Next ms Multiple

Example

Refer to the Express Comparison VI in the labview\examples\express directory for an example of using the Time Delay VI.

 


This is one confusing and malformatted post. I would recommend NOT to cut&paste random HTML content from websites. It never ends well.

Instead, write the name of the function and include a link to the help page. same information in 5% of the place. 😄

Message 5 of 9
(12,095 Views)

Awesome! This works for me. I still have another, similar question.  Does this only work for data functions that are sued to gather data?  So basically, I am trying to make a function that will write multiple types of information into a single .txt file which can be later opened in Excel.  I want it to write in the following order:

1. Write the name of the device being tested as input by the user

2. Write the time and date as retrieved from the computer's clock

3. Write in one column T (C) and in another column T (F)

4. Write the corresponding temperature in Celcius in one column and the temperature in Fahrenheit as measured by a temperature probe

5. Write in one column Voltage (V), a second column current (mA) and, in a third column power (mW).

6. Begin collecting, and writing voltage current and power data retrieved from another sensor in three seperate columns.

 

So now I know how to set a delay before the program collects and writes the temperature data as well as the voltage, current and power data retrieved from instrument inputs.  How can I delay functions such as writing the time and date, or other string data types?

 

0 Kudos
Message 6 of 9
(12,086 Views)

Simply make sure the functions occur in the right order. For file writing, using the error wire to enforce execution order is typically all you need.

Message 7 of 9
(12,079 Views)

So, for clarification, I will add pictures of how the data file is written from my program (CurrentTestfile.png), and how I would like it to be written (IdealTestData.png), as well as my code so far.  I have updated it a lot since the original post.

Ignore, for now the fact that I have 4 column labels (IterationVoltage (V)Current (mA)Power (mA)) and only two columns of data so far, as I have not yet set up the voltage and current sensors yet.  I just don't know how to get things in the order I want it in the .txt files that my program writes.

 

0 Kudos
Message 8 of 9
(12,076 Views)

Use flat sequence with the first frame of 2 seconds delay. write your main loop in the next sequence.

0 Kudos
Message 9 of 9
(10,339 Views)