From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about shift registers in for loop

Hello,

 

I have a question about shiftregisters in For loop.

 

  1. I have an input cluster coming in to a FOR LOOP
  2. 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.
  3. 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

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 1 of 8
(3,174 Views)

@abikutn wrote:

Hello,

 

I have a question about shiftregisters in For loop.

 

  1. I have an input cluster coming in to a FOR LOOP
  2. 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.
  3. 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?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 2 of 8
(3,161 Views)

@abikutn wrote:

Hello,

 

I have a question about shiftregisters in For loop.

 

  1. I have an input cluster coming in to a FOR LOOP
  2. 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.
  3. 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

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


Message 3 of 8
(3,147 Views)

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.

 

 

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 4 of 8
(3,129 Views)

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 Smiley LOL) - 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

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


0 Kudos
Message 5 of 8
(3,124 Views)

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.

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 6 of 8
(3,117 Views)

@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.

 

 

 


"Should be" isn't "Is" -Jay
Message 7 of 8
(3,073 Views)

@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

 

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


0 Kudos
Message 8 of 8
(3,066 Views)