LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Block diagram editing slow

We've all been there, don't worry.  If you're interested in learning how to do it better, make sure to pay attention to everything Altenbach tells you, he's really experienced and like helping others.

Message 31 of 48
(1,602 Views)

Hello everyone,

 

               Find the attached vi,where in I have used 3 sets of sub vis. In each vi I will be getting new value for every 250ms( here I have attached a constant value). The sub vi should give me max value and average value. These should be stored in respective places of a table. These three sub vis use different parameter and hence  i have given different constants. 

                 

               Problem: Since i have given constant values i should have got 23.5 as max value and 23.5 as avg in (1,1) and (1,3) respectivly.   Similarly 44 in (1,4) and (1,6). But i'm getting wrong answers. what may be the cause?

Thanking you,
Sushmith
0 Kudos
Message 32 of 48
(1,597 Views)

You haven'tincluded the sub-vi but it's not needed to spot the problem.

 

You have three processes writing to the same table property node.  Each of these overwrites the last and the order of writing is essentially random.  You need to pass the wire for the table from one sub-VI to the other and have each one add only tha part they are responsible for.  Then, at the end, write to the terminal of the table, not the property node.

 

If you create three tables and wire each sub-vi up to its own table, you'll maybe get a picture of what's going wrong.  Given these three tables, an execution of your original program will gove ONE of these as a result, but not the combination of all three.

0 Kudos
Message 33 of 48
(1,590 Views)

Hello,

 

      I have attached the sub vi, can u please elaborate and tel me what exactly is wrong??

Thanking you,
Sushmith
0 Kudos
Message 34 of 48
(1,580 Views)

@sushmith_ks wrote:

Find the attached vi,where in I have used 3 sets of sub vis. In each vi I will be getting new value for every 250ms( here I have attached a constant value). The sub vi should give me max value and average value. These should be stored in respective places of a table. These three sub vis use different parameter and hence  i have given different constants. 

                 

               Problem: Since i have given constant values i should have got 23.5 as max value and 23.5 as avg in (1,1) and (1,3) respectivly.   Similarly 44 in (1,4) and (1,6). But i'm getting wrong answers. what may be the cause?


OK, as Shane already pointed out, this VI makes no sense as written.

 

Race conditions: Whatever subVI writes to the table last will win the race and the outcome is random. The results of the first two subVIs is irrecoverably lost. Most likely you know the final size of the table from the beginning, so initialize a 2D string array before the loop starts, and place it in a shift register then have each subVI modify the table. Use a FOR loop with three iterations, autoindexing over arrays of parameters. (Only one instance of the subVI is needed!), Then write to the table after the loop with the table coming out of the shift register. No value property nodes needed at all! (After looking at your subVI, there is a similar race condition in the subVI).

Improper loop use: since the number of iterations is knowen before the loop starts, yuo need a FOR loop, not a while loop. In fact since each iteration simply seems to overwrite the result of the earlier iteration, the outer loop does not seem to be needed at all.

0 Kudos
Message 35 of 48
(1,526 Views)

@sushmith_ks wrote:

 I have attached the sub vi, can u please elaborate and tel me what exactly is wrong??


Everything! Way too many local variables and value property nodes. Look at "action engines" to see how to store local data between calls. Similar to the main VI, there is a race condition that you operate on the same table values in parallel and whatever writes last wins.

0 Kudos
Message 36 of 48
(1,522 Views)

Hello Sir,

 

         Can you please modify the code and give me?? So that I will get some idea..

Thanking you,
Sushmith
0 Kudos
Message 37 of 48
(1,515 Views)

I started changing our code today but gave up because it's unclear what you're trying to achieve.....

0 Kudos
Message 38 of 48
(1,507 Views)
Spoiler
ITAR

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 39 of 48
(1,503 Views)

@sushmith_ks wrote:

Can you please modify the code and give me?? So that I will get some idea..


Your code make absolutely no sense, so it is beyond repair. Instead, tell us where the data comes from and how the table is initially formed and what it is supposed to do. How and when do the values stored in the front panel objects get reset?

 

Also, since this seems to be a different problem from the "diagram editing slow" topic of this original discussion, you should probably have started a new thread for this new question.

0 Kudos
Message 40 of 48
(1,477 Views)