LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delaying a value

Hi,
My vi calculates sequentially many matrix from input vectors (from front panel and files) and generates an output file. All components are in a while loop (many calculations every steps). If the input vector is from front panel, an indicator is send and written to output file.
My problem is : the indicator is written in output file with the previous calculation, i have a drift of 1 in the output file (the indicator seems "doubling" the calculation...).
How can i delay the value for 1 step of the while loop ???

thanx for helping

Matt
0 Kudos
Message 1 of 6
(2,938 Views)
Your question is not quite clear without seeing the code. If I am properly understanding your question you are wanting to write an output file when certain conditions are met, but only after completing a set of calculations. Is this correct? This sounds like a data flow problem. Make sure that your file write routine is the last thing in the loop. Also, I am assuming that you are not using local variables as this could result in a race condition which could lead to problems in this situation.

If all you're needing to do is pass some values from one iteration of the loop to the next then the shift register is designed for this. You will want to initialize the shift register, but without seeing the code I don't know exactly how you will want to initialize i
t.
0 Kudos
Message 2 of 6
(2,938 Views)
Thanks for your reply, and indeed i used shift register to create an array, then i use sub-vi "index array" to get the previous value of this indicator.
This solution works fine, but it uses memory and i think that's not an optimized solution...

Matt
0 Kudos
Message 3 of 6
(2,938 Views)
I still don't fully understand your program. Why are you creating an array and reading the last value? All you have to do is pass the value through from one iteration to the next. You read the value from the last iteration at the left shift register and write the value for the next iteration at the right shift register. No array and "minimal" memory use. Once again, without knowing more about what you're trying to do it is difficult to determine the best solution. Perhaps you could post a simplified version of the code that shows what you are trying to do.
0 Kudos
Message 4 of 6
(2,938 Views)
Hello All,

I followed this forum discussion and I really need to have Matt's code to resolve problem.
Can you please send it? Just to know what you exactly want to do. I need also to know your LabVIEW version.

Sanaa TAZI
Applications Engineer
National Instruments
0 Kudos
Message 5 of 6
(2,938 Views)
Ok, thanks for ur solution which works fine.
I can't post a simplified version of the code, because of the complexity of it, and i have no time to rewrite a simplified version.
thanks for your help.

Matt
0 Kudos
Message 6 of 6
(2,938 Views)