LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Different cases inside a loop.

Solved!
Go to solution

Hi.

I have 4 cases inside a loop.
In one of the cases, I want to run 3 events 10 seconds each,  according to the elapsed time from the moment I entered the case:

event 1- 10 seconds, event 2- 10 seconds, event 3- 10 second (in total 30 seconds), and all this inside the loop. How can this be done?

 

Thanks

0 Kudos
Message 1 of 6
(1,981 Views)

It sounds like you're describing different States of a test ... so check out the State Machine architecture.

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 6
(1,967 Views)

@rivlin wrote:

I have 4 cases inside a loop.
In one of the cases, I want to run 3 events 10 seconds each,  according to the elapsed time from the moment I entered the case:

event 1- 10 seconds, event 2- 10 seconds, event 3- 10 second (in total 30 seconds), and all this inside the loop. How can this be done?


 

Your description is way too vague! Is your "loop" a WHILE loop or a FOR loop? Do you have four case structures or one case structure with four cases? I doubt "you" are entering any cases, you are probably sitting on a chair. The term "event" has a special meaning in LabVIEW, so please clarify what you mean by it. How long does it take to execute the code in each state? Does it stay in each case for 10 seconds or keep entering the same case for 10 seconds?

 

Typically we can give much more precise help if you would attach a real VI containing at least a code skeleton with all the major components.

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

Hi KNIGHT OF NI

 

Apologies for the lack of clarity
I was under time pressure so it came out that way...
I tried to summarize the problem:
I create a while loop (attached), and a stacked sequence. There is a led outside I want to update.

It can be seen that the attempt to do so is misleading, because in fact the program is "stuck" because of the time delay.

In addition, all the other indicators (not seen in this short program) stop updating.

Is there a possibility to keep everything around work and not to be affected by the time delay?

Thanks

Yonatan

Download All
0 Kudos
Message 4 of 6
(1,883 Views)

Hi rivlin,

 


@rivlin wrote:

I create a while loop (attached), and a stacked sequence. There is a led outside I want to update.

It can be seen that the attempt to do so is misleading, 


Nobody told you to use a stacked sequence. (In fact usually we advise against them, and they are even hidden from functions palette nowadays.)

 

You were told to implement a state machine. Why don't you do so?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(1,880 Views)
Solution
Accepted by topic author rivlin

Here is a super simple timer in a state machine to give you an idea how it's done.  You could add an event structure to change states on the fly or expand it to multiple states that do different things based on the time elapsed or user input.  Note that the 1 mSec Wait VI in the main loop gives good user interaction and allows other code to run but also gives some time for the CPU to run other processes.

 

Also look at the state machine available as a startup template and check online for lots of examples.  It's an important pattern for LabVIEW and probably the most used so understand it well if you plan to advance your abilities.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 6 of 6
(1,865 Views)