11-05-2015 08:15 AM - edited 11-05-2015 08:16 AM
Hi,
I am curious and basic question on the difference between tunnels and shift register.
Do you know the difference of memory or performance between them?
I had some strange experience in file reference.
Sometimes, tunnel showed lost of reference but shift register resolved this trouble.
In principle, I think they are the same if the connection is guaranteed. Is it right?
labmaster.
11-05-2015 08:41 AM
Where you would have had your issue is with a 0 iteration FOR loop. This most commonly happens with autoindexing and the array is empty.
Each tunnel is its own memory location. So if you do have the 0 iteration FOR loop, the default value of the data type will be the output. In the case of your references, this would cause you to lose your reference.
A shift register has the same memory location on the input and output of the loop. So if you initialize the shift register and you iterate 0 times with your FOR loop, what you initialize the shift register to is what will come out. This means you will retain your reference.
This is a very common issue.
11-05-2015 08:49 AM - edited 11-05-2015 08:49 AM
Thanks for the reply.
What do you mean "0 iteration for loop"? Is the attachment what you mean?
When do you use this kind of loop?
labmaster
11-05-2015 08:49 AM
No. They are not the same. With a shift register you can permanently store values at runtime because
it passes the value from one loop run to the next. of course you have to wire the input (left shift reg to
the right shift because else you pass the default value to the next loop run)
F.e. a functional global variable consists of a while loop(with true wired to the stop cutton) and a shift register which stores
a value.
With a tunnel you must decide if you want to pass the value from the last loop run outside or the complete array of values.
The input terminal passes the default value inside the loop if not wired or the wired value. the value will not be stored from one
loop run to the next.
11-05-2015 08:53 AM - edited 11-05-2015 08:53 AM
Labuser16383, I agree with your opinion.
However, I didn't indicate I mean when the value is not changed and just be transmit with the inital value in whole loop like some reference like in my queue example.
11-05-2015 08:54 AM
labmaster wrote: When do you use this kind of loop?
Rarely ever on purpose. Like I said, it usually happens due to autoindexing on an array that is empty, either due to an error or the user forgot to fill in the array.
11-05-2015 08:59 AM
FOR loop + reference + tunnel can be very dangerous ! See here.