LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop while loop after time

Hi everyone!

In my application I have a while loop, where Labview is waiting for the message from server. If there is an error, the while loop starts from the beginning. I want application work in this way but when the listener is waiting more than 20 seconds or the errors appear in this 20 seconds every iteration, then I want to stop the while loop and the application runs on to the next frame.

Do you have maybe some ideas how to solve this problem ? I tried with elapsed time but I'm doing something wrong maybe, because it doesn't work.

I attach a part of my code.while.png

 


Thanks in advance!

0 Kudos
Message 1 of 6
(3,130 Views)

You are going to have to use a more advance architecture. Take a look at the state machine. There are examples that ship with LabVIEW. It is hard to help you with a picture. If you post your code yu may find some that can help you structure your code a little better.

 

 

Tim
GHSP
0 Kudos
Message 2 of 6
(3,116 Views)

One long flat sequence is not a proper program architecture!

(Not only that, but I am betting that Flat Sequence structure is superfluous anyway)

 

Learn how to program a State Machine.

 

Also don't post pictures of code, post actual code if you want someone to fix it.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 6
(3,104 Views)

@anna172 wrote:

I attach a part of my code.while.png

 


There is the "elapsed time" express VI, but as others have already said, your problems are deeper and you should really do a few more tutorials. much of your "visible" code makes no sense.

  1. Wired as given, there is no reason to have that bottom error wire in a shift register, because you never change it. Why do you maintain several parallel error traces. If this sequence frame is entered with an error condition, the loop will never stop because your "error" case has only default outputs (no error, FALSE). Is that part of the problem you are trying to solve?
  2. Typically, you would create a listener once for the duration of the program, not on demand.
  3. ...

Maybe if we could see the entire code, we could give more targeted advice.

0 Kudos
Message 4 of 6
(3,076 Views)

I forgot to write, that I'm a new user and it's my first "bigger" application in Labview. I was learning during writing this code and I know, that much could be better or entirely differently done, but unfortunately I can't do it better yet.
Thank you for your suggestions. You're right that this "bottom error wire" is redundant. I'll try to make some changes and then if the problem won't disappea, I will attach the entire code. I haven't done it earlier because without driver S7-1200, code doesn't work.

0 Kudos
Message 5 of 6
(3,023 Views)

@anna172 wrote:

I forgot to write, that I'm a new user and it's my first "bigger" application in Labview. I was learning during writing this code and I know, that much could be better or entirely differently done, but unfortunately I can't do it better yet. 


As I see it, you'll have to do better to get the results you're after.

 

You can try to advance your application using the (lack of) methology you're using now. It will in fact be much harder to get working. It will get increasingly harder as you keep adding to the code.

 

Trust us: get into more advanced programming techniques. It is the easy way.

 

If programming was easy, everybody would do it.

0 Kudos
Message 6 of 6
(2,998 Views)