A Few Tips on VI Design in LabVIEW
LabVIEW VIs are very similar to functions or subroutines in C programming language. It can be called inside of other VIs, once it was created. Here are a few tips on the design of VIs:
1. You should assign the inputs on the left terminals of the connector and the outputs to the right side, because all LabVIEW built-in functions follow this convention. And this aids the readability of the code.
2. It’s a good idea to have a few extra connectors in VI in case additional inputs and outputs are needed in the future.
3. About the icons of VIs. Try to create icons that are descriptive so that someone looking at the code for the first time can determine its function easily. Using text in the icons often helps.
Decode Serial Port File Transfer Protocols from Scratch with LabVIEW and Serial Monitor
Sometimes we need to write our own software to transfer files to serial port connected device, like DNC, which provides manuals and working software but no source code or the author of the software does not exist or does not support the software anymore. So, it’s a must to decode the serial transfer protocol to build our own software which is based on this protocol.
Here, I’ll show how to decode the serial transfer protocol from scratch with the help of LabVIEW and Serial Monitor step by step.
Step 1, we need to install a serial monitor software. Here we use HHD Software Serial Monitor. This software provides a monitoring device driver, which lies upon the serial device driver of the Windows NT, Windows 2000 and Windows XP operating systems. It collects all information including data read and written, control codes received and sent to the underlying hardware by the user mode client. After the installation of the serial monitor software, we first run this monitor software and start a monitoring session and set it up to log all the activity of the serial port like the figure below. Read the rest of this entry »
A Note about the Current VI’s Path Constant in LabVIEW
The current VI’s path constant in LabVIEW is often used to make the path of files which are in the same or relative folder of the VI application in our developments. If we use this constant in the development environment, everything is fine, and it works. But, if we build the VI into an executable, it will not find out the associated files because the path made is not correct.
Why this happens?
Because the path of a VI changes when we build it into an executable.
For example. If the VI is called myapp.vi, and it exists in the C:\MyApp directory. And assume that we have built an executable named myapp.exe, which also exists in the C:\MyApp directory. This is what the Current VI’s Path function will return:
In the LabVIEW development environment: C:\MyApp\myapp.vi
Running the executable (myapp.exe):C:\MyApp\myapp.exe\myapp.vi
So, when we have an executable, we actually need to strip the path twice to get to the correct directory.
A Better Way to Program Controls of the Same Kind in LabWindows/CVI
Usually, there are only one or two controls of the same kind in a normal VI(Virtual Instruments, computer based measurements and automation systems) application. And, we can write the callback functions of these controls one by one in LabWindows/CVI. But, if there are more than four in number of the same kind of control, it’ll be a hard work to write the callback functions one by one for them.
If the controls have similar functions, it’s a better idea to make them use the same callback function. It save a lot of time and make the program short and simple. Every control on the UI(User Interface) has a unique reference ID, we could build an array of reference IDs to store the ID information of every control on UI. And, in the callback function, the parameter “control” can be used to identify which control is functioning. And a loop in the callback function can be used to find out the right execution code and run it.
Code can be like this:
Read the rest of this entry »
Three Principles to Follow when Design LabVIEW Applications
When using LabVIEW to develop huge and complex applications, we would encounter many problems not only the same as we use text based programming languages but also some problems which are unique for LabVIEW. LabVIEW is a graphic based programming language, it free us from the worry of syntax error and memory problems, but on the other hand, in my option, it also have some disadvantages like not very good at large project management like other text-based programming languages. Since the version 8.0, LabVIEW has added some features to make itself a better programming tool at project managements. I think it will be better and better.
To make LabVIEW a good tool in huge and complex applications development, we should follow three principles: scalable, readable, and maintainable.
Scalable: The VI designed should be easily to be modified, and it allow us to add functionality to it. We should use good design practices to create VI which is scalable, think about the design early in the design process to make sure it is scalable for future modification rather than a fixed non-scalable VI for current application only. When designing any application, we should consider the purpose of the application and how to manage changes when the scale of the application goes beyond the original specification.
Readable: When working with LabVIEW, we should make the diagram code structured, easy to read and easy to understand. And the easy to read and understands leads to easy to maintain.
Maintainable: When we develop VIs, we should make it easy to add new features without completely redesigning the VIs. We should use forethought to design and create VIs to make sure they are more maintainable.
Create a Tri-State LED Indicator in LabVIEW
Under some conditions, the traditional boolean LED indicator is not enough to indicate the test result. For example, before the test finish, the status of current UUT(Unit Under Test) is unknown, which value should be displayed, the green TRUE with the meaning of success or red FALSE with the meaning of fail? Both are unacceptable, it’s better to use black color to indicate an unknown status.
But the default LED indicator in LabVIEW has only two state: FALSE and TRUE, it’s not possible to use it to display three status. So, some programming is needed to create this tri-state LED.
Here is what I have done to make this happen:
The front panel, one enum control and one LED indicator:

The property of the enum control: Read the rest of this entry »