LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why is the shift register needed?

Hi,
 
This example is from the LabView Intermediate class.  I am referring to the shift register that holds the queue reference in the produce loop of this example.  Why is this needed?  Why couldn't this simply be a pass through tunnel instead?  There's no reason to believe the queue reference would be modified inside of the loop.  I have othe code that I have written and simply having a tunnel seems to work fine.
 
Thanks,
 
Jason
PS  I have attached the main_TLC.vi file - see the "Record - Value Change" event in the producer loop.
 
0 Kudos
Message 1 of 4
(2,311 Views)

Actually, I would sat that the use of shift-registers in ths situation is problems waiting to happen. However this code has a lot of other problems.

To begin with the code takes a single queue reference and sends it two places. This is asking for trouble. What happens if the lower loop finishes and releases the reference while the top loop is still using it?

Next there's a place in the code where an error cluster passes through a FOR loop using tunnels. This is very bad because a FOR loops can execute zero times. In this situation, the result is that you will never see any errors that happened before the loop. Consider what happens if tlc_Cue_Module.vi generates an error. The output (which is specifying the loop count) will most likely be zero. No iterations, no data passed through--your code isn't working and you don't know why. Or worse, you might not even know there was an error and you think its working but it really isn't.

Finally, if an error occurs during initialization (before the split in the queue reference) the lower loop will never quit because there is no way to tell it to quit because you can't generate the event. But even if you could, an error keeps the lower loop from even looking for events. The proper way to manage errors in a event-driven process is to always provide an event that gets triggered if an error occurs. That way the code will always have some place to go.

I realize that this was probibly an exercise from the class, but whatever you do don't write real applications this way.

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 4
(2,285 Views)
I looked at all of the queue files in the examples folder and none of them have a shift register on the top output of the queue function. The bottom output has a shift register to keep the error loop updated after each queue function. Probably just a programmers habit when working with a while loop.
0 Kudos
Message 3 of 4
(2,282 Views)
I don't think there is a problem with shift register used for a refnum. It is however not really necessary for while loops and a pain because you have to wire it through every single case and event frame. Forgetting to wire it in an event frame wouldn't break the VI as event frames allow by default unwired output tunnels but give you strange results when run.

The main problem I see is that the lower loop does NOT terminate when an error is present in the error cluster and the upper loop doesn't even check the error cluster at all but just keeps looping an error over and over not really being able to do anything else than waiting for the user to press the stop button.

Rolf Kalbermatter

Message Edited by rolfk on 07-07-2005 02:52 AM

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 4
(2,264 Views)