LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop will not iterate in case structure

Good morning,

 

With the attached VI I am trying to continuously collect and plot data from an RS32 connection. The first case structure checks to see if the user entered the appropriate data. The first while loop clears the serial port, collects data, plots the raw data and plots the "cleaned data". However once the second case structure finishes and the data point is plotted to "Clean Signal" the VI aborts. I need the first while loop to continue pulling data and plotting to each chart without having the VI restart each time. Any help will be greatly appreciated. 

 

Thanks

 

-Grover

0 Kudos
Message 1 of 12
(3,490 Views)

OK, you have a few fundamental problems with that code but, nothing we can't help with.

 

  1. Open and close VISA sessions outside of loops.  Read inside the loop.  What is the device on the other end?
  2. The case structure seams to demand that the user inputs were correct before pressing the run arrow (Or the abort button gets pressed immediately) Tell me a story.....What will the user be trained to do after opening this vi.
  3. How did you want that outer loop to act? Continue on "Error" or "Stop" makes little sense to me.

"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 12
(3,469 Views)

Your VI looks like it is "inside out".  Usually a while loop is the outermost structure, not a case structure.

 

You shouldn't reconfigure your serial port on every iteration of the while loop.  Do it once before the loop starts.

 

Your outermost while loop (inside the case structure) is set to continue if you hit the stop button OR you have an error.  If neither of those things happen, your loop will stop.

 

Perhaps you want to set the loop termination to be Stop when True instead of Continue when True?

 

(Note.  You can debug these kinds of things yourself if you run with Highlight Execution turned on.)

0 Kudos
Message 3 of 12
(3,469 Views)

1.  You need to change the stop condition of the while loop.  It is currently set up to be Continue if True.  Change it to Stop if True (is should look like a stop sign).

2.  You don't need the little loop to check for the number of bytes at the port.  Just tell the VISA Read to read the 15 bytes.

3.  I'm not sure why you have another loop inside.  Are you having problems with data sync?

4.  You don't need to call the Stop VI function in the FALSE case.

5.  You really should not be using the Run Continuously (I'm guessing you are using it based on your description).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 12
(3,462 Views)

Bill, That's darned funny.  I completely agreeSmiley Very Happy

[EDIT] Tim you are lateSmiley LOL


"Should be" isn't "Is" -Jay
Message 5 of 12
(3,461 Views)

EDIT: Better answers above 😄

 

Regards

Mondoni
0 Kudos
Message 6 of 12
(3,458 Views)

Jeff·Þ·Bohrer wrote: Tim you are lateSmiley LOL

Yeah.  Work got in the way.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 12
(3,447 Views)

Thank you for everyone's input and patience, as I am new to LabVIEW. I have updated my VI and it is performing the way I would like. I have attached the new version, would anyone mind looking over it to make sure I am still not violating major programming conventions?

 

Thanks again. 

0 Kudos
Message 8 of 12
(3,426 Views)

Again, you don't need to call the Stop LabVIEW function.  Just wire a TRUE out of the you False case to stop the loop.

 

You really should close your VISA session after the while loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 12
(3,418 Views)

I assume you mean after the inner while loop? This will not affect the reading of data in further iterations? And just for my own edification, why the need to close it?

0 Kudos
Message 10 of 12
(3,414 Views)