LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is the shift register reference necessary in a producer/consumer architecture?

Solved!
Go to solution

Hi Guys,

I was just wondering if in the Producer/Consumer architectur is necessary the shift register wired to the reference of the Queue or of the Notifyer. Is it necessary?

I think it isn't, because it is enought a tunnel but, could anyone, who thinks that the shift register is necessary, explains me why  it is necessary?

In each samples I found the reference of the queue or of the notifyer is wired to a shift register, I've tryed to wire it to a tunnel and it works good so, what is it the best implementation?

 

Thank you in advance.

Ricky
Italian Developer engineer
www.www.selt-sistemi.com
0 Kudos
Message 1 of 6
(3,673 Views)

There is a habit of old timers using a shift register instead of a tunnel becuase of the "zero iteration For loop" where if the loop does not iterate the value coming out will be null.

 

Technically speaking your observation is correct.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 6
(3,668 Views)

You are right, it's not necessary at all. Just a matter of taste...

 

Felix

0 Kudos
Message 3 of 6
(3,666 Views)
Solution
Accepted by topic author g_Ricky

Thank you guys for your prompt replies....

Ricky
Italian Developer engineer
www.www.selt-sistemi.com
0 Kudos
Message 4 of 6
(3,658 Views)

I once took a Labview Intermediate class (long time ago) where the instructor explained why it was good practice to use a shift register.  Of course we all know that using a shift register for error in/out is desirable to carry any errors from one loop iteration to the next.  But since the reference will not change, why bother.

 

One explanation given was in case of a zero iteration loop, as Ben has already pointed out.  If the loop is skipped because of a 0 wired to N or because of an empty array wired to an indexed input, then the refernece will be NULL, and an attempt to close the reference after the loop will result in an error.

 

The other explanation was to just get in the habit of using shift registers.  Its a good habit, and you don't have to think about it.  "Hmmm... do I need a shift register on this wire or not?  Will it change?  If not then I don't need the shift register....."  Just do it as a habit and you won't ever miss a situation where you actually needed it but didn't put it.

 

I always put a shift register where a wire comes into a loop, goes into a function, and a copy comes out of the function to the other side of the loop.  There may be a few exceptions though, where you don't want the data propogated to the next iteration.  But by doing it by habit, I never miss putting it on error wires or other data in/out situations.  Bottom line is that you don't need it (as others have said), but it doesn't hurt to have it, and it builds good habits.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 6
(3,633 Views)

Hi Ben,

 

Someone recommended a producer/consumer architecture for my application, but, I have never studied this.  Is there a good tutorial or example you can recommend/provide so I can learn how to build this thing? 

 

Basically, I have a cDAQ 9174 and I am using one of the counters built in to this chassis to measure period of tick marks on an encoder wheel etc.   I have a nice vi that reads the period (frequency) of one encoder.  That part is pretty straightforward.

 

Now, I want to read TWO encoders simultaneously, and compare the values of the the two encoders, and execute subsequent commands based on the comparison of the 2 sets of simultaneously collected period values.  In other words, I have two spinning wheels with encoders, and I want to measure the period (frequency) of both wheels over 50 ms periods, and then compare the value of one wheel with the value of the other wheel, and do some calculations that are converted to motor speed commands.

 

Can you suggest anything that I can use to teach myself how to design the vi to do this? 

Thanks,

Dave

 

0 Kudos
Message 6 of 6
(3,512 Views)