My First XNode: Build Array From Mixed Datatypes

Many a times we need to show some data in table. The most common example can be the results of pass fail test.
Lets assume The Step data is as follows

  • Step Name
  • Actual Voltage
  • Expected Voltage
  • Tolerance +
  • Tolerance -
  • Result (Pass or fail)

for putting this data into array we need to build array of such values. However Build array does not allow building array of dissimilar data types and we need to convert every data in string format.
I thought I can create a Xnode to simplify the situation. It will help me to reduce development time and  at the same time it can make code much more readable.

Download Xnode Source Code Download Xnode Source Code
Posted in LabVIEW Experiments, LabVIEW Gyan | Tagged , , | 1 Comment

publisher subscriber or observer pattern for LabVIEW

Video for implementing publisher subscriber or observer pattern in LabVIEW

Posted in LabVIEW Experiments, LabVIEW Gyan | 2 Comments

Using conditional diagram disable for debug only code

Many a times we write some code in our application which is useful for development/debugging and we don’t want to deploy its functionality in executable.
previously it was quite cumbersome to keep track of all such snippets and remove them manually. with LabVIEW projects it has become quite simple.

Create a project for your application

Right click on project name and click on properties

On Properties page define symbol with name Debug and Value =  TRUE

Now put all your snippets inside conditional disable structure with condition Debug = TRUE

When you are all done and about to build exe open project properties and change value of debug symbol to FALSE

Posted in LabVIEW Gyan | Tagged , | 4 Comments

Recursive variable expression evaluation in LabVIEW

Recently i came up with a bit odd requirement of evaluating the expression of named values in LabVIEW

Requirements for expression evaluation were as follows

  1. Any number of named variables can be declared
  2. Expression may contain one or more  + or – operators
  3. Named values in expression can be constants or expressions
  4. Actual values of named variables will be declared in separate file
  5. Space will be used to delimit named values and operator

e.g. one of the valid expression can be Var1 + Var2 + var3

and file may contain
var1    25
var2    2
var3    var4 – var5
var4    22
var5    34

The problem appears to be very simple at first but I found its bit tricky. first of all, the depth of expression can go up to any level.
After some thought I figured out that use of recursion can solve the problem easily.
here is the code developed by me

Expression Evaluation code

Posted in LabVIEW Experiments | Tagged , , | Leave a comment

Automating Error Handling in LabVIEW, Its time to revisit

Error handler is one of the most important but often overlooked task of successful LabVIEW development. I also found that most of these tasks can be automated to a large extent.
Automatic trapping in State machine is a simplest form of automating task to check if errors has occurred while executing the current state. This ensures that you don’t accidentally forget to handle errors. If error has occurred then the state machine will go into error state.
While this is useful its not sufficient the most common tasks related to error handling are as follows

  1. Show dialog to notify user about error
  2. Log Error details to the file
  3. Abort application
  4. Take some corrective action
  5. Just ignore the error

Based on this required i developed a error handling library which automated these tasks and allowed dynamic configuration. The development is now almost 4 years old(i posted this library and got very good response on NI forum topic at that time. You can also download the library here ).

I think now its the time to recall my experience and apply some further features to make this library even more powerful. I am
One thing i have noticed is that my previous development was great for the handling errors but useless for trapping “mistakes”. It was focused entirely on run time system (or at least well tested stable LabVIEW code)
However we also need some aid to trap mistakes. My new development will be focusing on that. Some of the key concept i have jotted down are as follows

  1. Developer should be able to activate/deactivate the mistake trapping without modifying the source code or exe.
  2. User should be able to specify multiple levels of mistake trapping
  3. Each level can be activated/deactivate separately.
  4. User should be able to write external plug-ins who can get notification of errors/mistakes and automate further.

I would be glad if anybody can share their ideas to make this even more feature rich and more useful

Posted in LabVIEW Experiments, LabVIEW Thoughts | Tagged , , | 1 Comment

LabVIEW GUI inspired by Ubuntu Netbook remix

Recently i tried Ubuntu 10.04 Netbook remix. I was very much fascinated by its desktop GUI, and i decided i will do something similar in LabVIEW. Just couple of days back I designed it in LabVIEW.

To many people’s astonishment it uses only customized controls and no code writing was required for the GUI functionality.

For Left side menu I used a radio control each menu item is a customized button whereas background was created in flash and exported as semi transparent png. Then I used this png file for customizing the cluster of radio control.

Menu Content Area + Menu Item = Custom Menu

The pane on right side is also a set of radio controls placed in transparent tab.

Pane Content Area + Pane Button = Custom Pane

To Download the source code Click Here

Posted in LabVIEW Experiments | Tagged , , | 7 Comments

Dynapanels: Creating LabVIEW Controls at Run Time

Dynapanels is a technology which allows placing controls or indicators in a vi front panel. This technology does not use any VI Scripting and hence it is perfectly safe to use it in executable or commercial application.

  • Controls are created dynamically
  • Control can be binded to any variable published withing your program
  • No memory consumption if control is not created for any perticular variable.
  • Very useful for allowing end user to create their own report formats.
  • Macro recording can be added for storing control placements. or even raising actions in a perticular sequence.
  • Custom dynamic controls can be created in minutes by using template.
  • No VI Scripting is used.
  • Can be used to create toolbars (toolbars can be extended through plug ins as well)
  • Dynamic controls can handle any event of standard control
  • Can subscribe to more than one variable
  • Can preprocess data before display.
  • Uses Publisher Scubscriber Architecture

dynapanels LabVIEW Download Dynapanels Demo Exe LabVIEW 8.2
dynapanels LabVIEW Download Dynapanels Source Code LabVIEW 8.2

The demo code does not include all the features possible. Aim of this demo is to proove the concept to most basic level. We would like to know your ideas about what additional features we can add to it. Please feel free to provide us your feedback

Posted in LabVIEW Experiments | Tagged , , , | 6 Comments

If You Are A Smart LabVIEW Programmer No Ifs, No Buts

Last month during a discussion at client’s place we were discussing about the good system design and eventually one small thing came to my mind.
As one becomes more experienced LabVIEW programmer and designs better applications, number of case structures in his code dramatically reduces. This may appear baseless but this is what I have observed and verified after that.
As we become better system designers we start focusing on extendability and robustness. We start focusing on dynamic code and here is where Case structures start reducing.
Lets take an example. Say we want to design an application which controls a process by sending commands to a particular controller. The controller can have either serial or Ethernet link.
If a novice user is to program this application he might code some thing as follows

Nothing wrong in it actually. We are looking for the mode in which device is connected in and then select the appropriate case for communication.
However if we think in terms of extendability. This is not a very good code. If tomorrow we get USB or any other interface then we might need to modify our existing code and test everything again. So how about dynamic loading

This is much better because if new protocol support is required then we need to design just new interface. We don’t need to modify anything in our main code.
This is typically how most of the (unnecessary) case structures get eliminated.
Note: if you implement dynamic loading exactly as displayed in this snippet then the code will run much slower. There are well known trick to avoid performance hits. However i wanted to keep things as simple as they can be.

another big (rather biggest) source of case structure removal is adaptation of design patterns. Many fresh programmers don’t use any design patterns and their code is full of nested case structures (4 to 5 nested levels are quite common.) when they start using design patterns nested levels drop down dramatically.

Posted in LabVIEW Thoughts | 2 Comments