LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array in LabVIEW 7.1 and LabVIEW 12

Solved!
Go to solution

 Hello Everyone,

 

I am not sure why this is happening. I have a program here where I have enumerator controls which has 0,1,2 and that leads to a boolean condition ( 0-F,F, 1-F,T,2-T,T which is displayed again in array 3. However the array 3 is the reverse of what we specify initially.

 

The program has 3 main buttons: NEXT,FINISH and STOP. 

The program does not stop till STOP is pressed.

Every time the NEXT is pressed, value of all the enumerator controls goes into the array and it keeps appending till I click FINISH. The # of times NEXT is pressed in kept is recorded

The FINSIH leads to a couple of operations:

1) It has a FOR loop which runs the number of times the NEXT is pressed.

2) Inside the FOR loop it changes each row of  48 elements array into a 2D array of 4X12, where position of the element is reversed . The original  array numbering is from left to right where every element is sequenctially added with left most element of port 0 as the 0th value of array and continues.  , but in the appended array , it changes to the numbering starting from right to left with the right most element compromising the Port 0 element 1.

3) This is fed to a boolean array leading to a boolean array of T/F.

 

Later I want to feed this T/ F values to my DAQ.

 

I am a little confused here, because this program runs perfectly fine inLabVIEW 12 however it does not iterate array properly in LabVIEW 7.1. Thus in LabVIEW 12 , I am able to get results as anticipated and there is a perfect match between "appended array" and the "array3". However in LabVIEW 7.1 , there is a mismatch between the "appended array" and "array 3". From what I could see, the Array 3 in 7.1 uses previous run's n data for array iteration 0. Then for array iteration 1 , it uses the the current runs's 0th data.  and then for array iteration 2 , it uses current runs'  1st data ... and thus it goes on till n-1, then it stops. 

 

Please suggest what would be the best way to solve this, and I dont see this in LabVIEW 12.

 

Thanks

G

Download All
0 Kudos
Message 1 of 5
(2,272 Views)

My guess is that you have a race condition by the way you are using the value property node.

 

In the "Finish" For Loop you are reading the value property of Appended Array in parallel with the writing of values to the terminal of Appended Array.  Which happens first?  Your data flow is broken and either could happen first depending on how the CPU is running.  Since the change from LV 7.1 to LV 12 is a major step, and there have been several compiler optimatizations between those versions, it is likely that a compiler optimization might have changed the order that operations are inclined to occur.

Message 2 of 5
(2,266 Views)

The loop in the "Finish" event contains an inherent race condition. You are writing to an indicator at the same time you are also reading its value property. It's probibly an accident that either version shows the expected data.

 

In a similar vein, you seem to be using value property nodes like local variables - very bad form... and an open invitation to further race conditions.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 5
(2,264 Views)
Solution
Accepted by topic author GV8

As has been said, your program just crawls with race conditions and general misconceptions about dataflow programming.

 

You are doing everything way too complicated! I can guarantee you that all this could be done correctly with less than 10% of your current code. For example your 48 picture rings could be placed inside a cluster container instead of a decoration. Now all you need is a single terminal followed by "cluster to array" instead of that gigantic spider web of code in the "next" event. Why is "number of occurances orange? That should be an integer! Why do you use a value property instead of wiring directly? WHy does the number of iterations depend on [i] of the outer while loop? That makes no logical sense. You have access to the main array from the shift regisiter, it does not even need a hidden indicator.Why involve the front panel for stuff that only the code needs? All that blue duplicate garbage code in the "finish" event could be consolidated into a single little FOR loop. 

 

See how far you get. The final code should probably fit on half a postcard once you do that. You don't need any of the value properties!

 

Once you shrink the code to 10%, you can make a 10x more complicated program with less effort that what you just did here!

Message 4 of 5
(2,251 Views)

Thanks a lot.

 

I changed all the property nodes to direct connections and changed the front panel to a cluster as suggested. I think this simplified the program a lot and made it much better.

 

Giving the direct connections one after the other solved the race condition.

 

Thanks a lot to everyone who pointed this out to me.

0 Kudos
Message 5 of 5
(2,225 Views)