LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Delay while using case structure

New to LabVIEW.  Trying to achieve the simple task of Display one text, wait 5 seconds then display another. Using a case structure, Wait(ms) timer, Greater than comparison symbol and True/False constant.onlinehelp.png

0 Kudos
Message 1 of 18
(749 Views)

All you need for a delay is a Wait (ms) function set to the number of milliseconds that you want to wait AND a "wire" whose data flow you want to slow down.  Before VIMs were introduced (I can't tell what version of LabVIEW you have, but I'm betting it is newer than 5-6 years old, so this should work for you).

 

Open the Timing Palette.  Do you see a "Stall Dataflow.vim" function?  Find a wire whose data you would like to delay (for example, the wire carrying Text to a String indicator).  Make the Wire run into the VIM, and connect the Output from the VIM into the display.  Now add how many milliseconds you want to wait to the top left input to the VIM.  This will make the input to the Indicator "wait" that many milliseconds before it displays it!  The magic of DataFlow.

 

[In the Old Days, I would put a Wait (ms) near the Error Line, and place a Frame Structure around both, then make the Error Line run through the Frame Structure.  I even made this into a sub-VI so it didn't look so ugly.  If you double-click the VIM and peek inside, you'll see that's just what the Stall VIM does, but it can "sit" on any wire, including the Error Line.  Much neater].

 

Bob Schor 

0 Kudos
Message 2 of 18
(691 Views)

@dmg1701 wrote:

New to LabVIEW.  Trying to achieve the simple task of Display one text, wait 5 seconds then display another. Using a case structure, Wait(ms) timer, Greater than comparison symbol and True/False constant.


These are very odd requirements, so this is probably homework and a truncated code image does not really help. Where does "another text" come from? What's in the other cases of the case structure? How many different texts are there and what should happen when you run out? What other primitives and structures are you allowed to use????

 

Show us what you tried (attach your VI, not a picture!), explain exactly what you think is not right with your attempt, and we might be able to point you in the right direction.

 

Often just explaining the problem in detail will help you solve it yourself. Do you have a rubber duck?

0 Kudos
Message 3 of 18
(670 Views)

I would do this as its easier but I had to do it within certain constraints. Needed with the ones listed

0 Kudos
Message 4 of 18
(662 Views)

Yes its homework. Been trying myself for a few hours. Its probably really easy but I'm brand new to LabVIEW. Its suppose to be on Text 1. Then after 5 seconds swap to text 2. I cant add anything else but only what's provided in that file. Got text 2 to swap after 5 seconds but doesn't show text 1 originally. Also display the Time and date. Which I completed.

0 Kudos
Message 5 of 18
(660 Views)

Without outright giving you the answer. It is important to understand the elements provided in the code.

 

The while loop has an iteration terminal (which starts at 0). A stop terminal (which stops when a true is provided, it can also be changed to a continue while true by right clicking it and selecting this option).  The while loop will execute everything that is inside it and repeat until stopped.

 

The wait(ms).vi waits the amount of time you wire to it. The unit of time that is being wired to is in millisecond.

 

The greater than or equal to element performs this type of comparison between the top terminal and bottom terminal. 

 

The case structure, in its simplest form executes whatever is inside of it for the condition that is satisfied by its conditional terminal. 

 

You have 3 constants provided to you, 2 integers and a Boolean. 

 

You should utilize the help and context help as you are learning LabVIEW. It defines all these elements in more detail. The structure elements have more capabilities than what I have provided. 

 

Now a tip to hopefully get you moving in the right direction. The false constant wired to your case structure should not be wired there. There's another element provided that would give you better conditions to satisfy a TRUE and FALSE scenario.

 

Out of curiosity, have you any prior programming experience? Is this course an introduction to LabVIEW or an engineering class utilizing LabVIEW?

Message 6 of 18
(625 Views)

No programming experience really at all. I understand them some, just having trouble where to put at this point. If I use everything. The comparator would always be true and never return false. Which is confusing me. You have to use everything in it provided, i thought it would automatically run false then 5 seconds go to true. 

0 Kudos
Message 7 of 18
(613 Views)

@dmg1701 wrote:

i thought it would automatically run false then 5 seconds go to true. 


That is exactly what you need to solve with those puzzle pieces. 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 18
(584 Views)

No worries. Well eventually the number of iterations your while loop has executed should be greater than or equal to 5.

 

On iterations [0,1,2,3,4] the comparison terminal will return false if you compare

iterations >= 5.

 

If you are waiting 1 second on every iteration of the while loop, then that means when you get to the iteration 5 (5 seconds later), the comparison will be true. It will stay this way until you stop and restart the program.

 

I do not have LV 2022 so I can not view the VI you shared. Your screen shot does not show the stop terminal of the while loop. I am assuming the professor wants you to wire the false constant to the stop terminal which will require you to hit the abort button on your VI to stop the execution. 

 

I do not know the context of your class, but with no programming experience some of these concepts are likely foreign to you. This link Build and Configure a While Loop in LabVIEW (The examples utilize tunnels to update the iteration count outside of the while loop, you don't want that feature, you need to know your current iteration which can be found from inside the while loop)could be useful. Here is another useful link LabVIEW For Loops and While Loops Explained.

 

Let me know if you are still not able to get your VI to function as expected. I can be of more help if you export your LV to 2017.

File >> Save for Previous Version , select LabVIEW Version 17.0 from the drop down and click save.

 

 

 

0 Kudos
Message 9 of 18
(577 Views)

@dmg1701 wrote:

 Using a case structure, Wait(ms) timer, Greater than comparison symbol and True/False constant.


To be clear, the current code already fails this requirement, because it has other elements (e.g. a while loop, numeric constants, string constants, etc.) and I assume you are allowed to add wires, for example (also not mentioned as allowed!). Also the wait is not a "timer", just a delay.

 

As a first step, we need to know the exact requirements. What else are we allowed or not allowed to use? What should be the loop rate? How are we supposed to stop the program?

0 Kudos
Message 10 of 18
(565 Views)