LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For loop stops unexpectedly

Hi,

 

I'm trying to show a waveform from a file using the waveform graph, but I modified my diagram to be able to show it from the index of the array that I want. In this case I have a buffer size and I display the signal from 0 to buffer size, then from 1 to buffer size +1, and so on.

 

But I can't understand why the code stops at certain point without reaching the total size of the signal.

 

You have here my VI and the file with the waveform, maybe you need to change the path on the diagram to be able to open the file. Also I use the waveform as an array internally beacuse I will need to do some work with it later.

 

If you can help me with that I will be very thankful Smiley Happy

Download All
0 Kudos
Message 1 of 4
(2,428 Views)

You are using a value change event for an Indicator and that is not going to be triggered and your 2nd loop is not going to execute. You can trigger user event or using dynamic event registration and for Indicator it won't trigger these two type of event. You can remove the Event structure in the 2nd loop and use simply a case structure.

 

Your for loop didn't stop but waits. The reason is you are using a Enqueue without timeout (means -1, infinite) and the buffer size is 5 so once the buffer is filled the Enqueue Functions waits for the buffer to be cleared thats why it appears to be stopped working.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 4
(2,421 Views)

Thank you P@Anand,

 

I just replace the buffer full indicator with a value signaling to be able to trigger the event structure. The queue was flushed the first time, but, when the second iteration goes from 1 to 6, I get once again 5 elements but the event structure doesn't flush que queue.

 

I don't understand why the first iteration works fine but the second doesn't. 

 

Thanks again

 

 

0 Kudos
Message 3 of 4
(2,404 Views)

OK we have a small misunderstanding here.  you seem to be trying to implement a Producer Consumer (Data) design pattern.  There is a good shipping example of this pattern. the consumer loop would be effectively timed by the enqueue data and the event structure is not helping the consumer loop much at all (In fact it may be obfuscating the real issue)  the consumer loop also has no means to terminate (Infinite loop) this needs to be corrected. 

 

The worst sin I see is that you probably want a notifier with an array of dbls as the data type instead of the queue of scalar dbls.  Think about it for a few moments and see if a simplification of your code would occur to you by changing to that approach. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 4
(2,396 Views)