Joaquin_H Posted November 19, 2012 Report Share Posted November 19, 2012 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 Desplazamiento2.vi archivo.lvm.zip Quote Link to comment
jcarmody Posted November 19, 2012 Report Share Posted November 19, 2012 Your second mistake was in wiring the buffer size to the max queue size of the obtain queue node. The top loop is filling the queue with five elements and waiting for the bottom loop to respond, which it never does because of the way an Event structure works (see below). Your third mistake was in thinking that the event structure would respond to a change in the Buffer Full indicator. You could use a Value (Signaling) Property node to accomplish this: Your first mistake was your archetecture; take a look at the Producer-Consumer design pattern. Your VI will run if you change the two things I've mentioned, but it'll take forever to finish. If only I had finished my Algorithms course... You could do this, and your graph will fill instantly. Quote Link to comment
drjdpowell Posted November 19, 2012 Report Share Posted November 19, 2012 Your second mistake was in wiring the buffer size to the max queue size of the obtain queue node. The top loop is filling the queue with five elements and waiting for the bottom loop to respond, which it never does because of the way an Event structure works (see below). Actually, he needs that to throttle the producer loop to always provide “buffer” number of elements to the consumer loop. Instead, he has a bug in setting the number of iterations of the inner FOR loop (it should be “buffer”-1); removing that, the “buffer full” locals, and adding a Val(signal) property makes the code work. But this is all academic as... This is a very over-engineered way of doing what could be done with one simple loop with “Array Subset” in it. I recommend the OP start from scratch after resolving not to use any local variables, queues, or event structures. — James Quote Link to comment
Joaquin_H Posted November 19, 2012 Author Report Share Posted November 19, 2012 Thanks for your fast reply, I just change the Buffer Full indicator and now the event structure works properly. BUT if I remove the max queue size, the number of elements displayed would be in increment. drjdpowell, sorry, I don't understand where I'm wrong with the numbers of iterations. When I run the highlight execution the queue get the correct size of elements, 5 in this case, then the event structure flush the queue, and start again from element 1 to 6, 5 again but this time it doesn't trigger the event structure and the for loop keeps waiting. the main reason of doing this VI with queues, event structures, etc is because in the future this project can require real-time data from a mic or a NI card, or the possibility to add a scroll signal. So I think this form will be more scalable solution but if you know another way better to do it, please make me know it. thank you so much Quote Link to comment
drjdpowell Posted November 19, 2012 Report Share Posted November 19, 2012 When I run the highlight execution the queue get the correct size of elements, 5 in this case, then the event structure flush the queue, and start again from element 1 to 6, 5 again but this time it doesn't trigger the event structure and the for loop keeps waiting. That’s because the second time around your are setting N=6, so the FOR loop needs to execute six times, but the queue only holds 5, so it gets stuck waiting. 1 Quote Link to comment
Joaquin_H Posted November 19, 2012 Author Report Share Posted November 19, 2012 (edited) OK, I'm sorry about that stupid error. The only that I have to do is to remove the plus block in the outter for loop. Now it works fine. Thank you very much. Edited November 19, 2012 by Joaquin_H Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.