LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Delay while using case structure

I apologize for not clarifying. Everything I have in that file I can use. Just cant add anything. So the number constants, while loop, case structure, stop terminal, greater than or equal to, True/false constant,  one text box, get date/time, date and time. They're all acceptable.

0 Kudos
Message 11 of 18
(322 Views)

I changed it to 2017. The stop terminal isnt supposed to be hooked to the false constraint. Suppose to have a separate button. Also I do know what a while loop does, just not for this. We were left in the dark about this part. I'm assuming he thought we didn't need to know.

0 Kudos
Message 12 of 18
(317 Views)
  • Please do not maximize the front panel and diagram window. That's super annoying! (You need to be able to see both windows AND the help window while programming!)
  • The output of the wait function is a relative U32 millisecond timer and can be any value from 0 to 4294967295. The actual value is only useful as a difference to a previous value.
  • Your 5000 diagram constant should be U32, not I32. Do you notice the red coercion dot? What do you know about numeric representations?
  • A case structure just containing two diagram constant that differ in value should be replaced by a "Select". Now all code is visible and nothing hidden in other cases.
  • If you have a 5 second wait, all you need to do is check if [i] is odd or even to decide which string to display. Do you know how to do that?
  • Why do you want to display the time and date? That seems very uninteresting for a simple code exercise.

 

See if you can get this working, then adapt it to your convoluted requirements.

 

altenbach_0-1709748470428.png

 

Somewhat cleaner would probably be the following. try to understand the logic!

 

 

altenbach_0-1709749504325.png

 

 

0 Kudos
Message 13 of 18
(310 Views)

I looked at your diagram.

 

Without seeing your explicit directions and not knowing whether or not this VI was provided to you or what let me summarize.

 

Originally you were provided the following constants (I am assuming):

1000

5

false

Text 1

Text 2

 

So now you have modified one of your constants to 5000. (Why? Did your instructions tell you to?)

 

Your functions are

Wait(ms)

Greater than or Equal to

Get Date/Time String

 

You have a control to stop your while loop, and indicators for Text, Date, Time.

 

Now, you indicate you are aware of what a while loop does, but you still are not using the iteration terminal. Your usage and understanding of the Wait(ms) function is also an issue. Reviewing the context help, or Help, you would see that the Wait(ms) output terminal millisecond timer value returns the value of the millisecond timer after the wait. So I am asking you, if you wire the input terminal to 5000, how many seconds will you be waiting, for 1 iteration of the loop to complete. Secondly, If you wait that long, do you have any guess what the OUTPUT of the function will produce (it won't be what you'd expect). How can that number ever be less than 5? Furthermore, when you use the output terminal, every function that is in the data flow sequence of that needs to wait. Hit the light bulb on your block diagram and click run. Watch the block diagram and see what is happening. That is the data flow. It will also show you what values are coming down the wires.

 

I really don't think that you have been left in the dark nor have lack of information being provided to you. The requirements are a bit unclear to US, the outside observer but if you are asked to use ONLY what was provided then this is what we must do. WE have to wire things to the appropriate locations to get the VI to run, we can't add additional things, modify constants, add nodes etc....We take what we are provided and solve the problem.

 

Your Get Date/Time String function has a boolean terminal on the input side of it doesn't it? Do you suppose this would be a good terminal to wire your false constant to? Do your requirements want you to change the value of the false constant to a true? We can't answer this for you without you telling us exactly what they wanted in terms of the date and time indicators.

 

So once again, ITERATION terminal. What does that do? How can that help you? Incase you never actually went to the links provided earlier, here is a picture of a while loop, utilizing the iteration terminal.

Kavanakt7_0-1709750712771.png

 

 

 

 

0 Kudos
Message 14 of 18
(299 Views)

@Kavanakt7 wrote:

here is a picture of a while loop, utilizing the iteration terminal.

Kavanakt7_0-1709750712771.png


That "iteration count" indicator outside the loop will only show an "interesting" value after the loop has stopped correctly via the stop button (or never if the VI was aborted) and is thus not very useful.

0 Kudos
Message 15 of 18
(293 Views)

Thank you all. For some reason, didn't think that the "i" in the while loop could be used. Now I see how I can use the greater than comparator and return true/false readings at certain times.

0 Kudos
Message 16 of 18
(288 Views)

@Kavanakt7 wrote:

 

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.

 

 

 


Yes, my previous comment remarked on the iteration terminal inside vs. outside the loop.  I was hoping we'd get to the conclusion eventually. Thanks altenbach for pointing that out!  

0 Kudos
Message 17 of 18
(276 Views)

@dmg1701 wrote:

Thank you all. For some reason, didn't think that the "i" in the while loop could be used. Now I see how I can use the greater than comparator and return true/false readings at certain times.


The iteration terminal together with a comparison is not useful, because the the output will change a maximum of once (or maybe even never!) unless you add a lot more code. I thought that the requirement is that is changes back and forth forever.

 

Have you looked at how I used it earlier (last picture here)?

 

altenbach_0-1709749504325.png

 

(... and please don't mark answers as solution if they don't answer the original question)

0 Kudos
Message 18 of 18
(262 Views)