LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Execution Sequence

Solved!
Go to solution

Hi,

 

I'd like to have the user open 'ResearchIR.exe' prior to entering the experiment parameters and clicking on 'execute' to run the experiment. There must also be a STOP button to terminate the program at any time. My questions are:

 

1. Do I need to have the entire flat sequence inside a while loop as the user presses 'run'? the user then needs to click on 'open ResearchIR' prior to the sequence moving onto the next step

2. My case structure in the first part of the sequence doesn't accept the current case selectors. I'm basically trying to set it up so that if 'Open ResearchIR' button is TRUE, it moves onto the next step in the sequence, and if FALSE, it simply passes the false value to the AND gate

3. Once the above case is TRUE AND the 'start experiment' button has been pressed, the program executes. 

 

Please let me know if there is a better way to achieve this goal. Minimizing run-time certainly helps. 

 

High Level Interface

AnalogEE_0-1604352169714.png

 

Block Diagram

AnalogEE_1-1604352228929.png

 

0 Kudos
Message 1 of 4
(1,537 Views)

So, there's a bit of a misunderstanding of LabVIEW fundamentals in your code.

 

1) For starters, everything in the code needs to be placed into a While Loop unless you plan to make all decisions prior to pushing the "run" button.  For instance, your "stop" button will literally do nothing but always be whatever the value was when you pressed "run."  You have to understand, the "run" button is going to run whatever is on your block diagram once.  However, you'll then need to identify items that you only wish to run once... like your initialize items.  Your while loop is how items will loop more than once.  But no change to variables/controls outside of the while loop will affect what's happening within the while loop once the while loop gets started.  There are of course exceptions to this, but items I will not dive into after looking at your code.

 

2) If you look into state machines and event structures, what you're doing isn't necessary.  You can completely control when someone does something and what happens next after it.  Like have an initialize case where your .exe can be started and you can establish your connections to your DMMs.

 

3) I only say all this because your Case statements and all are very determined on values you input before you press your "run" button.  This is a common flaw for new labview users.  They think the block diagram is the loop. I  recommend finding a state machine template with an event structure.  Very much what you want for this.  More ideal might be a master/slave, but let's stay away from the more advance stuff for now.

 

Summarizing, your code will sorta work the way you want, but not really.

0 Kudos
Message 2 of 4
(1,524 Views)

I appreciate the feedback. The thing is that the user DOES need to input all desired parameters prior to beginning the experiment. They can't change it once the program has started unless the stop button is pressed. (This is the desired operation, not the current newbie code).

 

So basically the program has two different steps:

 

1) user opens ResearchIR and modifies that external program based on tutorials not relevant to this post

2) once the user has done that, they'll need to enter other parameters (e.g. duration, power supply voltage which will be added later) and then click on 'Start' for a one-time, continuous measurement until either the stop button has been pressed or the desired time limit has reached.

 

I will look into the state machines and event structures you suggested in the mean while. Do reply if this clarified what I'm looking to do.

 

Thank you

0 Kudos
Message 3 of 4
(1,519 Views)
Solution
Accepted by topic author AnalogEE

@AnalogEE wrote:

I appreciate the feedback. The thing is that the user DOES need to input all desired parameters prior to beginning the experiment. They can't change it once the program has started unless the stop button is pressed. (This is the desired operation, not the current newbie code).


 

See, that's still not true.  The "RUN" button is not the ultimate "GO AND DO THE TEST" button.  It's the "Run my code that is on this block diagram" button.  Your code can very easily sit there and wait and do nothing.  Which includes waiting for the user to input all desired parameters and waiting for the executable to do whatever it's got to do so that you can then do whatever it is you need to do.

 

My attached photo is an example of a state machine.  First, I want to make it clear that the 4 While Loops in the photo are all meant to represent 1.  I'm just lazy and didn't want to take a bunch of pictures.  What I'm doing is showing all the different cases/states within a Single While Loop.  You can press the 'run" button and then input your parameters whenever you want as long as you've done it correctly.

 

In your VI all your stuff is outside a While Loop.  Which means you can only input it before you press Run.  Your stop button will never do anything except be whatever it was before you pressed "run"

 

State Machine Example.PNG

0 Kudos
Message 4 of 4
(1,501 Views)