LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW NXG 5.0. How do Tag Nodes work?

I want to use a global variable in my application (many VIs) to hold on to some constants but it's not clear how Tag Nodes work - the help manual is not much help unfortunately, and I can't find any example apps.

 

Given what the manual does say, my expectation is that I can define a Tag in one place and use it throughout my application just like a global in a Text based language.  Great....but....

 

To create a Tag, I give the Create Node a value and it outputs a Tag Ref which I do what with??  If I have to pass it around my VIs through some call stack it doesn't seem very global.  Tags don't have names, only these references so it would seem that the only way to use them is to pass the reference around.  The manual also talks about Tag Proxies: "A tag proxy is a reference that is local to part of the application that mirrors the value of the actual tag to which it is linked in another location in the application" but doesn't explain how to create them or obtain them or link them to a Tag.

 

I've searched for example apps and through forums but I'm not any wiser.  Is anyone able to give me an explanation of how these Nodes actually work and their intended usage?  I don't want to get into 'race conditions' and 'the rights/wrongs of globals'.

 

Thanks

 

Andrew

0 Kudos
Message 1 of 10
(2,974 Views)

You can define it on the fly, or inside the project.  To retrieve it, use the Read Tag node.  They function just like globals in LV Classic, with the same pitfalls.

 

Okay, I can't resist:

Some say globals are "evil", but it's like calling a stick of dynamite "evil".  Use it carefully, and it's pretty powerful.  Use it carelessly and it could blow up in your face.  😉

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.
0 Kudos
Message 2 of 10
(2,968 Views)

I've not used LabVIEW classic so I have no idea how they work in that either 🙂 

 

I didn't explain myself very well.  I know how to create them, how to read them and how to write them - to the extent I know there are functions on the pallet to do so - but what I don't understand is the general way it works.

 

"A tag is single-point, latest value data that you can access from multiple documents within a project."

 

My expectation is to create a TAG in VI xyz (or somewhere) and thus it is available (somehow) to every other VI.  So in VI abc, how do I read it without the Tag reference?  If I have to pass the Tag ref from VI xyz to VI abc how then is that global?  How is it single point? And why wouldn't I just pass a value??

 

Clearly, I'm missing some context somewhere that isn't clear from the help manual.  

 

Thanks Bill

 

0 Kudos
Message 3 of 10
(2,954 Views)

@andrewDJ wrote:

I've not used LabVIEW classic so I have no idea how they work in that either 🙂 

 

I didn't explain myself very well.  I know how to create them, how to read them and how to write them - to the extent I know there are functions on the pallet to do so - but what I don't understand is the general way it works.

 

"A tag is single-point, latest value data that you can access from multiple documents within a project."

 

My expectation is to create a TAG in VI xyz (or somewhere) and thus it is available (somehow) to every other VI.  So in VI abc, how do I read it without the Tag reference?  If I have to pass the Tag ref from VI xyz to VI abc how then is that global?  How is it single point? And why wouldn't I just pass a value??

 

Clearly, I'm missing some context somewhere that isn't clear from the help manual.  

 

Thanks Bill

 


Sorry, I misunderstood what information you needed.

 

Assuming that you already created a tag, if you right-click on the tag/proxy ref in terminal of the Read Tag node, it lets you select the appropriate tag reference as a constant.  You don't need to bring a tag reference wire into your SubVI.

 

Is that the info you were looking for?  I'm sorry if I'm not being helpful.

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.
0 Kudos
Message 4 of 10
(2,939 Views)

Maybe a bit closer....

 

I created a new VI, dropped a 'Create Tag' node on it and wired a string constant to it:

 

andrewDJ_0-1595353718441.png

 

In another VI, I dropped a Read Tag node and I right-click on the input ref terminal and selected Constant. That created a constant with a drop-down list in it which is empty, so nothing to select.  I don't think I'm following what you are saying.

 

What you suggest makes it seem like Tags are 'design time' constructs: that is, I create a tag by setting up a VI and running it and it makes Tags; then as I build up other VIs, I can select the Tag I want.  If I want a new one, I have to change the original VI and run it to update the list (I can see that there is a file-based way of doing it as well.)  But how is its name/reference/id defined so I know what to select?

 

0 Kudos
Message 5 of 10
(2,929 Views)

I'm sorry, it's especially hard for me to answer your questions because I don't have NXG at work.  Actually, you should be able to create the tags inside your project's shared resource collection file.

 

For simple data types - e.g., string, integer, etc - you can simply create one from the available list of data types.  You can also create a tag from an existing control, such as a cluster.

 

You should then see the reference when you do the right-click thing.

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.
0 Kudos
Message 6 of 10
(2,906 Views)

Ok, I can give that a go in the morning. 

 

Does that mean that creating them on the fly with the Configure and Create Node is not much use - it would seem that I would have to rely on the Tag reference produced to use it?

 

Thanks Bill.

0 Kudos
Message 7 of 10
(2,899 Views)

@andrewDJ wrote:

Ok, I can give that a go in the morning. 

 

Does that mean that creating them on the fly with the Configure and Create Node is not much use - it would seem that I would have to rely on the Tag reference produced to use it?

 

Thanks Bill.


I haven't found a use for making them on the fly.  But then, I don't consider myself to be an NXG expert (although being knowledgeable in LV Classic makes it easier for me to understand).  I would be interested in hearing from people who found that feature helpful, though.

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.
0 Kudos
Message 8 of 10
(2,857 Views)

Ok, I think I've got it now.  I created a resource collection and added a tag and that then populates the DDL constant for a read node.  

 

Using them dynamically doesn't make any sense to me now, not least because there's no way of configuring them (i.e. giving them a name) - the name of the node seems to me to be wrong.  As you say, maybe someone else can point out their use.  The help could do with amending as well.

 

And some additional information for anyone who comes after:

  1. Reading the Tag still gives you a copy; if you change a value then you need to write it back.
  2. Value(s) set on a Tag persist beyond the running of your application.  If you don't want to carry them over - e.g. it's a look up list of generated values that have a single-run lifetime, you will need a means of resetting the Tag.

Do you have any idea what a 'proxy tag reference' is and how it is created?

 

Thanks for your input Bill, it helped me get there in the end.

0 Kudos
Message 9 of 10
(2,820 Views)

Sorry we meandered and made some side trips, but I'm glad you were able to figure it out.  🙂

 

And yes, the help is beyond terrible, especially when compared to the LV Classic CHM file.

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.
0 Kudos
Message 10 of 10
(2,806 Views)