LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Functions Sub-Palette with constants of different data types

Solved!
Go to solution

Dear fellow Labview enthusiasts,

My question is to put it simply: Can I add predefined numeric constants into my Functions Palette?

What do I mean by that, lets say you use quite often the number 27 with data type u32 as a constant in your programming. To do this you have to drop a numeric constant then type in the number 27 then right-click and changing the data type to what you want. Can I create a custom sub-palette in my Functions Pallete where I have "commonly used constants"? I know I can add VI`s to my Functions pallet, so I guess I can make a subvi that spits out the number 27 as a u32 and whack that into my sub-palette, but that looks ugly and not visually appealing. A subvi is a massive square with an icon I have to draw.

Soo... yeah... is there a way to add custom constants into my palette? Any ideas? The same way I have Pi as a DBL constant in my Maths palette by default (or under "Numeric", I don't remember but you get the point).

0 Kudos
Message 1 of 13
(282 Views)

Vi icons can be small. See the attached example. Hint: select and cut the whole icon, then make a small box.

pincpanter_0-1632306265734.png

Making a vi for one constant seems overkilling. It's possible that the compiler optimizer converts it to the actual constant, I'm not sure. In any case, you can enforce this behaviour making the vi inline.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 2 of 13
(276 Views)
Solution
Accepted by topic author datatechNDT

If you create a VI containing the constant and place it in the palette there is an right-click option 'Place VI Contents' in the palette editor. This will place the constant on the BD instead of the VI, if you choose the item in the palette.

 

UliB

Message 3 of 13
(247 Views)

Make a "Place VI Contents" VI as was previously suggested. VIPM is by far the easiest way to get functions into the palettes IMO. You can do it without VIPM but it has a nice interface that makes things easy.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

Message 4 of 13
(240 Views)

We already have the right answers.

 

I am backing the same idea, create VI for each constant, add these VIs to the palette, configure the palette to place VI contents instead of SubVI.

 

Secret - this is how some of LabVIEW's palettes work too!

-Santhosh
Semiconductor Validation & Production Test
Soliton Technologies
NI CLD, CTD
LabVIEW + TestStand + TestStand Semiconductor Module (2013 - 2020)
NI STS for Mixed signal and RF
0 Kudos
Message 5 of 13
(217 Views)

genius! I didn't know you can configure it so it places the vi contents rather than just a vi.

0 Kudos
Message 6 of 13
(204 Views)

thanks for the suggestion. I will make it into a package.

0 Kudos
Message 7 of 13
(203 Views)

@datatechNDT wrote:

What do I mean by that, lets say you use quite often the number 27 with data type u32 as a constant in your programming.


A thought on 'use quite often the number 27 as a constant'.

'Pi' is a constant, '60 seconds per minute' is a constant.

'27 commands for my instrument' might be constant right now, but can change in the future.

And if someday 27 changes to 28 you have to find every instance of the constant and change it.

 

Have a look at

https://forums.ni.com/t5/Past-NIWeek-Sessions/NIWeek-2013-How-to-Polish-Your-Software-and-Developmen...

(presentation and comments) for advantages of having a constant in a VI (as suggested by pincpanter).

 

UliB

0 Kudos
Message 8 of 13
(186 Views)

Please do consider recommendations of pincpanter and UliB, depending on what this "constant" means to you, it could either be set in stone or a named constant whose value you would like to update in the future.

-Santhosh
Semiconductor Validation & Production Test
Soliton Technologies
NI CLD, CTD
LabVIEW + TestStand + TestStand Semiconductor Module (2013 - 2020)
NI STS for Mixed signal and RF
0 Kudos
Message 9 of 13
(180 Views)

The main use case behind my constants is when I manipulate binary files. Most of the time you chop and typecast into different data types and I just wanted to have a quick drop-down for data types and certain values that I use when manipulating those binary files. Because so far the way I typecast is you drop the typecast function then you drop numeric constant- right click - change data type... any way. Thank you for the help guys. I made my palette and configured it to drop VI content.. game changing 😄 

0 Kudos
Message 10 of 13
(125 Views)