07-21-2020 11:05 AM
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
07-21-2020 11:31 AM - edited 07-21-2020 11:34 AM
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. 😉
07-21-2020 11:43 AM
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
07-21-2020 12:40 PM - edited 07-21-2020 12:43 PM
@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.
07-21-2020 12:59 PM
Maybe a bit closer....
I created a new VI, dropped a 'Create Tag' node on it and wired a string constant to it:
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?
07-21-2020 03:07 PM
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.
07-21-2020 04:02 PM
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.
07-21-2020 09:15 PM
@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.
07-22-2020 07:45 AM - edited 07-22-2020 08:38 AM
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:
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.
07-22-2020 11:10 AM
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.