07-18-2012 09:35 AM
Hi everyone. I have a while loop where I perform calculations at every iteration and display them on the front panel. Then, at a random loop iteration (here designated as i=9 for testing) it triggers an event where which performs new calculations on x number of iterations (iterations of the outer while loop) of the result of the outer calculations, while simultaneously performing and displaying the outer while loop calculations. That is the two math algorithms are in sync in iterations. After x iterations the program then returns to only calculating and displaying the while loop calculations using the updated value from the shift register, until another event is triggered (I did not show another event trigger in the sample code) I just cannot figure out a way to trigger an event and simultaneously do both calculations with the same loop iterations. Any suggestions?
Solved! Go to Solution.
07-18-2012 09:45 AM
So you want the code in the true case to execute on i=9 through i=9+10? The way you have it the code will only execute on i=9. You need to check if i is in the range you want using in range and coerce or some other code. But I think I don't understand your question.
07-18-2012 09:48 AM - edited 07-18-2012 09:50 AM
Something along these lines? You are confusing me a little by talking about events.
My numbers are not correct, but I'm sure you can figure it out.
07-18-2012 10:12 AM
Sorry for the confusion. Once triggered, inside the case structure I need to perform say 10 calculations in sync with the calculations running in the while loop, (triggering will be random, will only be true for one iteration then return false). Then after 10 calculations inside the case structure, turn to false, and continue to calculate and display the while loop. So say the case structure gets triggered at i=9, then from i=10 to i = 19, calculations are being performed and displayed both inside the while loop and inside the case strcture. Then at i = 20 return to just calculating and displaying the while loop calculations.
07-18-2012 10:21 AM - edited 07-18-2012 10:24 AM
I think I understand. How about this then. Basically, I have a counter being held in the shift register. Once the trigger is activated, the counter is reset. When performing the extra calculations, increment the counter. Once the counter reaches 10, you will no longer perform the extra calculation.
07-18-2012 05:21 PM
Thank you this is a good idea, I think it will work. My code is going to look something like the attached. My last question is what would be the best way to take in x consecutive data points into the case structure and perform calculations on all of them once they were received? Could I store each one in an array inside a flat sequence, then once the array is filled somehow transfer to another frame for processing?
07-19-2012 06:57 AM
I would wire the count directly into a case structure. You can have "0..9" (0 through 9) for one case where you build up the array, "10" for the second case where you perform your measurement, and "Default" which will just pass your previous calculation through. You will want a shift register for the array and another one to hold your previous measurement.
09-05-2012 08:38 PM
Hi, I am a little confused how this is going to work. If I wire the count to the case structure, the frame of the case will change at each iteration, so how can I store each data point in a shift register like this? I don't see how it can work, can someone clarify? Thank you.
09-07-2012 12:05 PM
The sample VI in crossrulz's previous post should provide the functionality that you are looking for. The while loop acts to iterate through the ten operations that you want to perform and the shift registers will allow it to save those values, as you understand. I believe that crossrulz is referring to shift registers on the while loop surrounding the case structure as shift registers cannot be used on a case structure, as you pointed out.