LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How does one use the attributes of the Build Waveform function

Hi,

I have a questions that I was hoping someone may help me with. The function Build Waveform in Labview has a variant Attributes node when strectched. What is the correct format to write to this - eg set the X Axis name. I have seem the Set Attribute Function but I would like to the format of using the Attributes nodes in Build Waveform

 

Message 1 of 13
(6,415 Views)

Your question is not very clear to me.

 

All the information related to Set waveform attribute function is given here.

0 Kudos
Message 2 of 13
(6,410 Views)

Sorry for my lack of clarity.

I have attached a Back panel image that might help. The Build Waveform function has an attributes section but I do not know the format this is to be used in order to writes to it.

I was trying to set NI_ExpXDimension to t for time. It works when I use the Set Waveform Attribute function but what I would like to know is how to use the attributes section of the Build Waveform function.

 

How this is more clear

0 Kudos
Message 3 of 13
(6,405 Views)

I think you are talking about value datatype. value is the value of the attribute. This input is polymorphic, so you can wire any data to it.

 

Refer to the Create Waveform example VI in the C:\Program Files\National Instruments\labview <version>\examples\Waveform\Operations.llb for an example of using the Set Waveform Attribute function.

0 Kudos
Message 4 of 13
(6,399 Views)

Hi,

 

I understand how to use the Set Waveform Attribute function. My question is How to use the attributes section of the Build Waveform function. Or more so, What is the purpose of the Attributes section within the waveform cluster and is it possible for someone to provide an example of how it would be wired in order to set an attribute of the Waveform?

 

 

Message 5 of 13
(6,378 Views)

The Attributes can be used for whatever you want. The DAQmx VIs will set certain attributes (such as channel name), and the Express VIs that output waveforms will also set some attributes. But you can set additional attributes as you see fit, or as you need.

0 Kudos
Message 6 of 13
(6,367 Views)

I have the same question as the original poster, but the responses have not addressed the question directly. The OP seems to understand how to use the Set Waveform Attribute VI. Given his other posts, I will assume he also knows that the DAQmx VIs set attributes when a waveform is created. But what he is asking about specifically, as am I, is how to use the attributes terminal of the Build Waveform function. What should one wire to this terminal in order to set an attribute? There seem to be no documentation of this anywhere.

 

With the Set Waveform Attribute function, one wires the name of the attribute one wishes to set, as well as the value (wired on a separate terminal) of the attribute that is to be set. It is VERY apparent how to use this VI to set an attribute. What is not apparent is what to wire to the attributes terminal of the Build Waveform function. How does one wire something to that terminal in a way that tells LabVIEW both the name and value of the attribute?

 

For my case, I am building a waveform from the component y values, t0 and dt. I would also like to set the NI_UnitDescription and NI_ChannelName attributes at the same time using the same Build Waveform function. It seems inefficient from coding and performance perspectives to use the Build Waveform to set the y values, t0, and dt, and then separately set the NI_UnitDescription and NI_ChannelName attributes using the Set Waveform Attribute function (twice). I would like to do all these things in one step with the Build Waveform function.

0 Kudos
Message 7 of 13
(1,478 Views)

I'll preface this by saying I have basically zero familiarity with the waveform type and I haven't looked at the documentation.

 

From a little playing, it looks like the attributes element is simply a variant, as mentioned before, and it uses a useful property of variants: regardless of their value (which is probably empty in this case), you can set custom attributes on them. This is not as useful in recent versions, where the same functionality can be achieved using a map or a set, but it didn't exist elsewhere back then.

 

The answer to your question is that you can use a variant constant and then call the Set Variant Attribute or Set Waveform Attribute on it. This doesn't actually give you an answer, as it still requires exactly the same code, just placed before the build node.

 

A couple of things which can help you is that if your values are fixed, you can have some code to set them and then create an indicator from that variant and convert it to a constant. If you right click on the constant and select Show Data, you will see the attributes in the constant. That said, you should be able to do that with a waveform constant too.

 

The other thing is that if you want you can create a right click or Quick Drop plugin to allow you to edit the attributes on a variant, though this will still not help you if you want to modify it in code. You could also create an XNode to do this in code, but that is not a path I would recommend going down.

 

Ultimately, I doubt that this has any noticeable performance implications and if you don't like the way the code looks, the answer is often to create a subVI to hide the code you don't want to see.


___________________
Try to take over the world!
Message 8 of 13
(1,463 Views)

I can confirm that yes, the Attributes field of Build Waveform accepts the variant that holds all of the Waveform's attributes. And while you can get some of the same functionality from a Map, the variant attributes are useful as you can use a mixture of datatypes, and you can handle the attributes using either the Waveform attribute functions or the Variant attribute functions identically*:

 

Example_VI.png

 

Note that the following code segments are identical:

BertMcMahan_0-1690475281353.png

 

(Note that both "Read waveform attribute" and "Read variant attribute" will return ALL attributes if you don't wire the "name" input).

 

*There could be performance differences between the two versions but I've never checked. Generally these things are very fast, and I'd guess it just comes down to being prudent with memory copies. As far as just functionality, the two ways to access the attributes get you the same thing, just using different methods.

 

Message 9 of 13
(1,457 Views)

Also, when I have weakly typed things like this, I usually prefer having a dedicated component for building and reading them. For something like this, this could be a library with a typedef for your data, a VI for building which accepts and outputs the variant/waveform and the typedef and sets the attribute and a similar VI which gets the attribute.

 

That way, all the things like attribute name, type, representation of data, etc. can be managed by a single entity and you're less likely to have problems.

 

If you do this, you end up having to call all the set VIs in sequence anyway.


___________________
Try to take over the world!
Message 10 of 13
(1,449 Views)