New domain and blog

New domain and blog
Please head over to my new domain to view my blog and current projects

Friday 22 November 2013

LabVIEW: Looking at constants differently

I have started listening to the LabVIEW podcast by VI Shots and am finding them really interesting. The last one I listened to was Five Tips to improve your LabVIEW Application with Fabiola De La Cueva. After listening to the podcast, I could relate to most of the tips and see where I was going wrong.

Then earlier this week I attended NI Days where I went to a presentation by LabVIEW Champion, Steve Watts and he spoke about the same subject. This triggered in my head that I should start to make an effort to create a set of rules for myself to stick to in all my applications.

So today I started by looking at constants differently.


This is from Fabiola’s presentation where she asks what is a constant?

As can be seen from the slide above, PI is a constant, the number of seconds in a minute is a constant but the number of flux capacitors in the DeLorean might change so is therefore not a constant. 

This means that using ‘constants’ in a program should be limited to ‘True Constants’ and ‘Variable Constants’ should either be wrapped in a vi or loaded from a configuration file.

Wrapping a constant in a vi and adding all your applications’ constants to the project makes them easy to manage and change if needed.
I have created a library which I will add to all my projects. This library will then be used as a template for the most common constants used in an application. I then make copies of each as needed, name them ‘xxx_constant.vi’ and use a comment in the application to indicate what the constant does.

I have tried to keep the icon colour the same as the default wire colour for each type making reading the application easier. You can get a copy of my library here if you want to have a look at it or use it.

The other method mentioned in the presentation is reading variable constants in from a configuration file. I have also tried this using an XML file which works well and is quick to implement. I will do another post with my vi’s I used some other time.

I hope this post has been able to help someone use better style. If I have done something wrong or not understood the concept properly, please leave a comment and let me know so that I can correct it and learn better style.

Greg