LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While Loop and case structures in parallel

Solved!
Go to solution

I am measuring data from VISA Read in while loop..Loop is running on "stop if true"..

 

Process 1 for storing data in SQL...Boolean Operation "Latch when released"..

Process 2 about to fetch data DATA from SQL and PDF report...Boolean Operation "Latch when released"...

 

Process 1 & Process 2 works only if I replace "TRUE CONSTANT" instead of "STOP CONTROL"... 

0 Kudos
Message 11 of 20
(1,358 Views)
Solution
Accepted by topic author Tusharvp4

Hi Tusharvp,

 


@Tusharvp4 wrote:

I am measuring data from VISA Read in while loop..Loop is running on "stop if true"..

Process 1 & Process 2 works only if I replace "TRUE CONSTANT" instead of "STOP CONTROL"... 


As has been said several times before: do the basics courses to learn about THINK DATAFLOW!

THINK DATAFLOW: Process1 and Process2 can only execute when the loop has finished.

THINK DATAFLOW: The loop finishes on a TRUE condition.

When the loop containing your "VISA Read in while loop" never creates this TRUE condition then it will not stop iterating…

It's all in THINK DATAFLOW!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 12 of 20
(1,347 Views)

@GerdW wrote:

Hi Tusharvp,

 


@Tusharvp4 wrote:

I am measuring data from VISA Read in while loop..Loop is running on "stop if true"..

Process 1 & Process 2 works only if I replace "TRUE CONSTANT" instead of "STOP CONTROL"... 


As has been said several times before: do the basics courses to learn about THINK DATAFLOW!

THINK DATAFLOW: Process1 and Process2 can only execute when the loop has finished.

THINK DATAFLOW: The loop finishes on a TRUE condition.

When the loop containing your "VISA Read in while loop" never creates this TRUE condition then it will not stop iterating…

It's all in THINK DATAFLOW!


Hi, @Tusharvp4,

In case you didn't notice, "THINK DATAFLOW!" is a learning module available through NI.

  • (I think - I couldn't find it via Google just barely, but I'm pretty sure I did it recently...)

 

If it helps, here is a web page that explains LabVIEW dataflow.

And here is a (slightly) interactive tutorial that explains LabVIEW dataflow.

 

 

Keep in mind that the dataflow paradigm applies to LabVIEW's

  1. functions,
  2. subVIs, and
  3. structures.

And for each of these, in general,

  • If something has 0 wires going into it, it will tend to execute as quickly as possible
  • If something has 1+ wires going into it, it will not start executing until every input wire has received its data
  • If something has a wire going out of it, that wire will not send its data until that "something" has finished (in the case of a loop, the output wires will not have data until the loop is exited!)

So, seriously, look at LabVIEW tutorials and learn what dataflow programming is. As has been said, "THINK DATAFLOW!"

 

Good luck!

-joeorbob

 

Message 13 of 20
(1,300 Views)

Hi Tusharvp,

In your original code, the process inside the while loop is running continuously (until you hit Stop), but the processes outside the while loop (i.e. the 2 case structures) only run once. So even if you change the variable values later, the output won't be updated.

The simplest way is to add another while loop that includes the 2 case structures. These 2 while loops will run in parallel, and the local variables ensure that the values are updated in the case structures.

0 Kudos
Message 14 of 20
(1,286 Views)

Two while loops are working...There is being synchronous issue while loops run...Working on 2nd loop, 1st loop is being stopped work..

0 Kudos
Message 15 of 20
(1,234 Views)

We cannot help without seeing your vi and more explanations.

 


@Tusharvp4 wrote:

Two while loops are working...There is being synchronous issue while loops run...Working on 2nd loop, 1st loop is being stopped work..


Is that what you want or what you don't want? What is your definition of "working"?

 

0 Kudos
Message 16 of 20
(1,225 Views)

Here is my code...When I press log button it stores data in database...When I print button, first loop of running data is being stopped to work..

0 Kudos
Message 17 of 20
(1,219 Views)

Sorry, I don't have a gigantic 8k monitor, so there is no way for me to analyze or troubleshoot this. Who wrote this VI?

 

You have multiple terminals with the same (or similar) name, local variables with similar names everywhere. Absolute nightmare! You have two tiny subVIs, so why are their diagrams maximized to the screen? Do you know that index array is resizeable (lower loop)? etc. etc.

Your tiny inner loop makes no sense and uses 100% CPU until it is stopped, the case structure afterwards can never reach the false case, 

 

You really, really need to learn about code architecture, Only well organized code can be efficiently debugged.

 

You still have not explain what the problem is.

Message 18 of 20
(1,197 Views)
0 Kudos
Message 19 of 20
(1,171 Views)
Solution
Accepted by topic author Tusharvp4

@User002 wrote:

@GerdW wrote:

Hi Tusharvp,

 


@Tusharvp4 wrote:

I am measuring data from VISA Read in while loop..Loop is running on "stop if true"..

Process 1 & Process 2 works only if I replace "TRUE CONSTANT" instead of "STOP CONTROL"... 


As has been said several times before: do the basics courses to learn about THINK DATAFLOW!

THINK DATAFLOW: Process1 and Process2 can only execute when the loop has finished.

THINK DATAFLOW: The loop finishes on a TRUE condition.

When the loop containing your "VISA Read in while loop" never creates this TRUE condition then it will not stop iterating…

It's all in THINK DATAFLOW!


Hi, @Tusharvp4,

In case you didn't notice, "THINK DATAFLOW!" is a learning module available through NI.

  • (I think - I couldn't find it via Google just barely, but I'm pretty sure I did it recently...)

 

If it helps, here is a web page that explains LabVIEW dataflow.

And here is a (slightly) interactive tutorial that explains LabVIEW dataflow.

 

 

Keep in mind that the dataflow paradigm applies to LabVIEW's

  1. functions,
  2. subVIs, and
  3. structures.

And for each of these, in general,

  • If something has 0 wires going into it, it will tend to execute as quickly as possible
  • If something has 1+ wires going into it, it will not start executing until every input wire has received its data
  • If something has a wire going out of it, that wire will not send its data until that "something" has finished (in the case of a loop, the output wires will not have data until the loop is exited!)

So, seriously, look at LabVIEW tutorials and learn what dataflow programming is. As has been said, "THINK DATAFLOW!"

 

Good luck!

-joeorbob

 


I think this is a bit complicated and confusing.  It can all be distilled into this one sentence: "Remember that a node executes only when data is available at all of its input terminals and supplies data to the output terminals only when the node finishes execution," found here.  Apply this as explicitly and as literally as you can, and it will answer all your dataflow questions.  ("I don't know" may sound like a bad answer, but if you apply that sentence judiciously, "I don't know" may be the correct answer.)

 

This applies to structures as well.  Someone pointed out to me that structures are nodes, too, so it applies to them as well.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 20 of 20
(1,144 Views)