LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shift register for DAQmx Task Name, VISA resource name or error

Solved!
Go to solution

Dear users,

 

I have perhaps a stupid question: When do you use a shift register for a “DAQmx Task Name”, the “VISA resource name” or an error?

 

E.g. I am reading data from devices with the DAQmx Read/with the VISA Read Function.

When I took a look into the internet to see how I could improve my code I saw many examples like this:

http://digital.ni.com/public.nsf/allkb/CB86B3B174763C3E86256FFD007A2511

http://www.ni.com/white-paper/2835/en/ (there are many examples on this site).

You can see in these examples that no shift register was used for the “DAQmx Task Name”  or an error.

 

But you can also find examples like this:

http://www.ni.com/white-paper/3727/de/ (scroll down to the last image)

open on your computer "…\examples\Instrument IO\Serial\Continuous Serial Write and Read.vi"

or "…\examples\Instrument IO\VISA\USB\USB RAW - Bulk.vi".

In both examples a shift register was used for the error and/or the the “VISA resource name”.

 

I really do not understand why shift register were used in the last examples. But perhaps one of you can give me an explanation.

Perhaps you could also give me a recommendation: Shall I use in general shift registers or tunnels for the “DAQmx Task Name”, the “VISA resource name” and the error?

  

I would be very happy to get a reply!

0 Kudos
Message 1 of 9
(3,681 Views)

A task name is just that....a name.  It doesn't change once created but it does have to be passed to all of the DAQmx functions to know which task is being acted upon. 

 

The error is passed into a shift register so that it can be acted upon after the loop is complete.  if there was no shift register, the value of the error wire going into the while loop would be used for each iteration...causing the error to be lost.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 2 of 9
(3,673 Views)

Thank you for your quick reply and explanation.

Now I can understand well why it makes sense to use a shift register for the error.

But why is the shift register not used for the error in some the official NI (!) examples (see my links in my first post)?

 

I also would not use a shift register for a name, as you say: it is just a name and does not chance.

But why does NI use in the e.g. “Continuous Serial Write and Read.vi” a shift register for the name?

Somehow I do not see a reason for this. Can you or somebody else see one?

0 Kudos
Message 3 of 9
(3,666 Views)

It depends on whether or not they are doing any error control after the loop finishes.  They may only be passing the error thru for dataflow purposes. 

 

Can you show a block diagram of the Cont serial read write?  I don't see an example by that name.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 9
(3,662 Views)

Well, if you are stopping your loop on the error (as almost all of those loops are doing), then the shift register for the error cluster would be solely for the purpose of not losing a Warning.

 

Since we are talking aabout While loops, then tunnels are just fine for the task and references.  If we were dealing with FOR loops, then I say go shift registers for everything (references and errors).  Why?  Well, if you run the FOR loop 0 times (yes, it is possible), then you can loose your reference and/or error.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 9
(3,660 Views)

Dear aputman and crossrulz,

 

attached you can find the VIs which I mentioned in my first post.

 

Thank you also for your explanations. I understand now better why it makes sense to use the shift register for names (and other things) for FOR loops – but not for While loops (as in the attached VIs).

Anyway, I understand more now! Thank you for your help so far!

Download All
0 Kudos
Message 6 of 9
(3,655 Views)

Sorry, I can't open 2013 files.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 7 of 9
(3,649 Views)
Solution
Accepted by topic author partial

Personally, I prefer to just use the shift registers.  Shift Registers are actually the same memory location on both sides of the loop.  You can't guarantee that for the tunnels.  So for that reason, I prefer the shift registers.

 

Otherwise, it doesn't really matter for while loops.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 9
(3,644 Views)

Dear aputman,

 

I uploaded the file for LabVIEW 9.0 version (see attachment; I hope it worked).

 

Dear crossrulz,

 

Thanks for your reply! That is a good information and hint. I will follow your suggestion and will use shift registers more often now!

Download All
0 Kudos
Message 9 of 9
(3,599 Views)