LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array of clusters does not updates properly

Hello...

I builded a VI to split a series of 10000 values in many segments, each one overlapped by 50 %. The product of all the values of each segment is calculated and by means of visual inspection and Led selection (green means that the segment will be used, red means that the segment will not be used), I can select which segment will be used for the final sum. For example: if I have 20 segments, but only segments 4, 8, 15 are green, only the products of the segments 4, 8 and 15 will be summed to generate the final result. The final result should be refreshed if the Lenght of the Segment is changed or if any Led is switched to green or red, but the update does not occur properly. Sometimes all the segments are showed properly but if I change one Led or the Lenght of Segment control, the given result is wrong. When the Lenght of Segments control is changed, all the Leds need to be adjusted to green state.

I don't know where is the problem in my code, but I think that is something related to the cluster constant that is wired to the first Unbundle by name, since that this constant was created from the cluster before it was inserted into array, and not from the array. If I create the constant from the array, the code returns an error.

To avoid race conditions I used flat sequence.

Thanks in advance for attention and help.

Dan07


Message Edited by dan07 on 07-26-2008 08:31 AM
0 Kudos
Message 1 of 15
(3,300 Views)
I spotted one problemous area:

Where you have an uninitialized shift register, so for every event the value of the last iteration is used.

What's the meaning of this piece of code?
I think you devide the length of the array by half the length of the segment?

Ton


Message Edited by TonP on 07-26-2008 05:34 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Download All
0 Kudos
Message 2 of 15
(3,286 Views)
Hi dan,

race conditions only occur when you use local variables - no need for a sequence structure here...

The problem is most probably the uninitialized SR of the small while loop inside main event... See attachment for comments!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 15
(3,285 Views)
Also notice that you overwrite the boolean value of all the leds if you change the length of the segment, or change the value of any boolean.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 15
(3,282 Views)


GerdW wrote:
race conditions only occur when you use local variables - no need for a sequence structure here...

He was probably trying to avoid a race condition because of using one Local.  It could be avoided by making the Array an indicator and wiring directly.
 
R
 
Message 5 of 15
(3,268 Views)
Tonp wrote:

What's the meaning of this piece of code?


In the example that I sent, there was a For Loop to generate 10000 random numbers, but in the real situation, instead of random number generation, a ascii file is loaded and the file does not have always the same number of values (i.e. sometimes the file has 9547 values, sometimes 12348,...). Taking into consideration the lenght of the segment, this while loop simulates how many segments (overlapped by 50 %) need to be generated to show all the file. Because of this I take the size of the array and let the while loop runs until it found a value greater than the number of values in the array, in the sequence, the while loop stops and send to the for loop the N.

I.e: if the lenght of the segment is 20, the segments will be:

First segment: from value 0 until 20
Second segment: from value 10 until 30
Third segment: from value 20 until 40
.....

I think you devide the length of the array by half the length of the segment?

The Lenght of the array is not divided by half the lenght of segment. Due the 50 % overlap, the array is not logically divided by the lenght of segments, some values are show in two different segments graphs, because the segments are 50 % overlapped.

In the file that I sent the labels in the slide control does not match with the real values that the slide send (i.e: in the label 20 the value sent was 64, in the label 40 the real value was 128...). This happened because I take the slide from another VI of mine, sorry.... But this issue does not modify the final result, because this VI is only a example of my problem. Attached is a fixed version.

Thanks for attention

Dan07
0 Kudos
Message 6 of 15
(3,262 Views)
TonP and GerdW

You are right about the shift register. In the example sent by GerdW, when a 0 constant is wired to the shift register, the code runs properly when I change the lenght of segment value in the slide control. GerdW, you are right about the sign operator.

But I don't know why the leds can't be changed. When I click on the LED it state does not change. A Wait function in my code could solve this issue?

The main idea of the code is:

- Load a ascii file with n values
- Specify the lenght of segment and split the file in segments overlapped by 50 %
- Make a visual inspection and select the segments with green led, that will be used in the final calculation
- The segments with red will not be used

If I change the lenght of segments, all the leds need to be setted to green and in the sequence I can perform a new visual inspection and change the state of the Leds that I want.

Thanks for help

Dan07
0 Kudos
Message 7 of 15
(3,261 Views)
JoeLabview

The array is used as a control because I need to change the state of the Leds (green of red) to specify which segments will (green) and will not (red) be used to the final calculation. Because of this I used the local variable and lets the Array like a control and not like a indicator. I think that if I change the array to a indicator, I will not be able to change the state of Leds.

Thanks for attention

Dan07
0 Kudos
Message 8 of 15
(3,258 Views)
GerdW

In your VI, I can't change the state of the Led because the array is setted to indicator instead of control. Do you know a way to change the state of the led using the array as a indicator to avoid the use of local variable?

Your idea to avoid the use the feedback was very good.

Thanks for attention

Dan07
0 Kudos
Message 9 of 15
(3,249 Views)
Instead of green and red, I am using in my example Led ON (segment will be used), Led off (segment will not be used)

Sorry...
0 Kudos
Message 10 of 15
(3,246 Views)