01-02-2020 02:34 AM
Hi members,
I want to ask how can I reset the i in the while loop to zero after i reach 15 in labview..
I want always to reset the i to zero after i reach 15.
your help will be highly appreciated
01-02-2020 02:48 AM
Hi Tasnim,
you cannot reset the "i" (iteration counter) in the while loop.
But you could apply simple math on the value delivered by i: when you want to count up to 15 and then start again with zero (like a sawtooth pattern) then a simple modulo operation (using Quotient&Remainder) will be the solution!
01-02-2020 03:41 AM
@Tasnim wrote:
I want to ask how can I reset the i in the while loop to zero after i reach 15 in labview..
I want always to reset the i to zero after i reach 15.
0-15 can be done with an AND. I AND 15 will result in 0-15. On an FPGA, that will be much more efficient than a Q&R, that potentially requires multiple iterations.
On an FPGA, you'll also run into the problem that the i will reach it's max value pretty soon. You'll get that on a PC as well, but it can take a while... On and FPGA running at 40 MHz, the 31 bits become a problem after 53 seconds. IIRC, on FPGA, the i will stop at it's maximum value, on a PC it will wrap to the min value. Not sure...
I'd consider for a shift register for any code except the most trivial. Increment the value when approprieate, and use Q&R or AND to get the effect. This will be more flexible in the long run, as the behavior is decoupled from the loop counter.
01-02-2020 03:44 AM
If your loop runs extremely quickly (typically on FPGA) you might instead consider a Shift Register and a select node with equals 15 comparison.
01-02-2020 07:42 AM
I will also throw in my vote for keeping your count in a shift register. As stated, only truly necessary if in an FPGA, but anything running a long time should use the shift register method instead of the iteration terminal.
01-03-2020 02:16 AM