06-14-2013 11:06 AM
Hello,
I have a question about shiftregisters in For loop.
So how does the shift registers mentioned in step 2 get updated ?
is it for each iteration it passes the processed value to write into the out put cluster wire or after all the iteration is done it passes ?
Abhi
06-14-2013
11:23 AM
- last edited on
05-01-2025
01:30 PM
by
Content Cleaner
@abikutn wrote:
Hello,
I have a question about shiftregisters in For loop.
- I have an input cluster coming in to a FOR LOOP
- I use "Unbundle by name" to read some of the elements in the cluster and process it (for some calculations) and also pass the processed value using a shift register back into the FOR LOOP for using it the next iteration.
- I update my output cluster via the same cluster wire (assuming both are same dimensions) by using bundle by name and the shift registers values that is pasing through the for loop.
So how does the shift registers mentioned in step 2 get updated ?
is it for each iteration it passes the processed value to write into the out put cluster wire or after all the iteration is done it passes ?
Abhi
Does this link help?
06-14-2013 11:40 AM - edited 06-14-2013 11:43 AM
@abikutn wrote:
Hello,
I have a question about shiftregisters in For loop.
- I have an input cluster coming in to a FOR LOOP
- I use "Unbundle by name" to read some of the elements in the cluster and process it (for some calculations) and also pass the processed value using a shift register back into the FOR LOOP for using it the next iteration.
- I update my output cluster via the same cluster wire (assuming both are same dimensions) by using bundle by name and the shift registers values that is pasing through the for loop.
So how does the shift registers mentioned in step 2 get updated ?
is it for each iteration it passes the processed value to write into the out put cluster wire or after all the iteration is done it passes ?
Abhi
Shift registers pass data to outside of a loop (whether FOR or WHILE) after all iterations are done in that loop, however, value of wire that is connected between the shift register keeps updating within that loop. That's because when you have a FOR or WHILE loop, you're continuing to execute everything inside it until its last iteration - program execution does not go out of it until then. You can essentially think of a shift-register in your loop as its "internal component"). Once a loop execution is done, only then all outputs from that loop come outside of it (whether shift-registers or tunnels or whatever else).
-DP
06-14-2013 12:05 PM - edited 06-14-2013 12:07 PM
Thank you very much.
What is the difference in DATA FLOW between the first and second picture, if thats the case with shift register (it will only update after the execution if the LOOP) then what about the cluster wire inside the loop and outside the loop ? Will it update for every iteration or just after the FOR loop completes execution ??? How would it impact the speed of execution or would it even make a difference ?
CASE 1: I am updating my cluster values and also transferring the updated values to the next iteration "i" with the help of shift registers.
CASE 2: I am updating my cluster values OUTSIDE THE FOR LOOP (and displaying it on my indicator on front panel ) and also transferring the updated values to the next iteration "i" with the help of shift registers.
06-14-2013 12:10 PM - edited 06-14-2013 12:12 PM
Speed of execution might be negligible in either case (but I'd prefer case #2 as you're bundling all values after things are done in the loop, saves little bit of time - maybe in microseconds ) - but I'd have to see a little more on the left-hand side of those images to see how you have wired the shift registers.
By the way- since you have a storage location for your boolean items in that main cluster wire anyway, I would rather unbundle that boolean array and the boolean from main cluster, manipulate it (such as adding new element to the array) and then bundle it back - this way you would get rid of some of the unnecessary wiring/etc.
-DP
06-14-2013 12:17 PM - edited 06-14-2013 12:20 PM
Here are the files.
"By the way- since you have a storage location for your boolean items in that main cluster wire anyway, I would rather unbundle that boolean array and the boolean from main cluster, manipulate it (such as adding new element to the array) and then bundle it back - this way you would get rid of some of the unnecessary wiring/etc."
Dint Understand what you meant by this , you mean like the CASE 2 as I showed in above figure, I have done that if you see my program :
Programs:
DEV6 - case 1
DEV7 - case 2
PS: I am sure its not as good as how you explained me to make state machines. But I am still learning and trying, Will improve and make it neater as I progress.
Thanks.
06-14-2013 01:57 PM
@abikutn wrote:
Thank you very much.
What is the difference in DATA FLOW between the first and second picture,
OK, you are still not quite square on Loops and dataflow. I'll try to help out some.
Dataflow is dataflow any function or structure cannot execute at all until all of its inputs are available as soon as all of the data into a structure is available the structure may start but none of its outputs are available untill all of the code completes. So no, you can't "peek" at the current value on a shift register from outside the loop. The Output is not available until every iteration completes and only the last value written to the shift register can be passed out of the loop (Unless you add elements but lets keep it simple). Moreover no downstream code can execute at all until the loop completes all iterations.
06-14-2013 02:14 PM - edited 06-14-2013 02:16 PM
@abikutn wrote:
Here are the files.
"By the way- since you have a storage location for your boolean items in that main cluster wire anyway, I would rather unbundle that boolean array and the boolean from main cluster, manipulate it (such as adding new element to the array) and then bundle it back - this way you would get rid of some of the unnecessary wiring/etc."
Dint Understand what you meant by this , you mean like the CASE 2 as I showed in above figure, I have done that if you see my program :
Programs:
DEV6 - case 1
DEV7 - case 2
PS: I am sure its not as good as how you explained me to make state machines. But I am still learning and trying, Will improve and make it neater as I progress.
Thanks.
I haven't looked much into your latest vi - but one thing I found as a bad idea in your previous vi is that you had combined "Timeout" and "STOP button (Latch when released)" together in one event case. You might be experiencing problem because of that - but in either case you should consider keeping timeout as a separate event case. I believe Jeff answered your other question...
(and yes, what you had done in case 2 is what I was meaning - I couldn't see the whole diagram earlier so I didn't know that you were already doing that.)
-DP