Showing results for 
Search instead for 
Did you mean: 

Decoding a Labview Code



I am new to Labview and have been tasked with modifying a code written by someone who is no longer with my company. I need some assistance with trying to decipher the following Labview code; can someone help me understand what processes are occuring during the TRUE and FALSE cycles of the loops below?


Thank you very much.


0 Kudos
Message 1 of 20

Hi BHelang,


There are a couple of good debug tools for the task. On the block diagram, click the lightbulb for "highlight execution". This will allow you to see what is going on at a slower pace. If this is a SubVI, right click >> subVI node setup >> suspend when called. This will pause execution and open up this VI whenever it is called. Make sure to uncheck "suspend when called" when you are finished debugging.

CLA // LabVIEW 2016 // BALUG // Unofficial Forum Rules and Guidelines
0 Kudos
Message 2 of 20

You would do well to visit the main forum page.  There are lots of links to training and tutorials.  Most of them are free and readily accessible; some require an active SSP.  It is easier than most languages to produce bad code using bad practices.  Use this forum as a teaching tool, also.  It is here that you can validate what you've learned elsewhere.  Don't just ask for solutions - you'll rarely be handed code - be ready to put your thinking cap on, because it will ultimately be YOU who will arrive at a solution with our guidance.  Go ahead, ask questions.  We don't bite too hard.

(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 3 of 20

It looks like it finds the center of a "true" section at the end of a 1D Boolean data array.


It reverses the 1D array, then looks from the end (now the beginning) until it encounters the first T.  It then accumulates the indices of all of the subsequent T points until it encounters a F, at which point it stops the FOR loop.  The accumulated indices for the T portion of the pulse are averaged, giving you the index of the center of the pulse.   Note that the MEAN function will output a double and indices are integers by definition so the "center" of the pulse will likely not line up with an actual data point.


Any true pulses other than the very last one in the data are ignored because the FOR loop stops before processing them.


FWIW, the code is not very fault-tolerant.  Any noise on the Boolean line (a spurious F in the middle of the T pulse, for instance) will dramatically affect the results.



Message 4 of 20

This code was probably written before introduction of conditional loop tunnels in LabVIEW. Using these tunnels would do the code much more efficient.

_____________________________________ - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 5 of 20

Is this a sub-VI, or did you "pluck it out" of a larger VI?  If it is a sub-VI, then you should look in the Description Property of the sub-VI where the developer who wrote the code describes its inputs, outputs, and (briefly) what it does.  Oh, the Description is blank?  Well, this is a Big Mistake that you should not make for any VI that you create and save -- be thoughtful of those who follow you (including yourself, in three months time) and (a) create a meaningful name for your VI, (b) create a brief description for your VI, and (c) create a (simple, say a box with 2-3 short words of text) LabVIEW Icon for your VI.


Bob Schor

0 Kudos
Message 6 of 20

Bob's (a) is the #1, #2 and #3 priority!

So, what's this VI's name?


G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
0 Kudos
Message 7 of 20

Thank you. This is useful.


0 Kudos
Message 8 of 20



VI's name is Phase Shifter Output

0 Kudos
Message 9 of 20



I did pick it out of a much larger, more complicated VI. I thought I would start from the bottom and work my way up the VI chain.


Thank you.

0 Kudos
Message 10 of 20