05-29-2018 03:19 PM
Hi,
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.
05-29-2018 03:24 PM - edited 05-29-2018 03:24 PM
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.
05-29-2018 03:36 PM
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.
05-29-2018 05:00 PM
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.
05-30-2018 12:40 AM
This code was probably written before introduction of conditional loop tunnels in LabVIEW. Using these tunnels would do the code much more efficient.
05-30-2018 10:08 AM
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
05-30-2018 10:40 AM
Bob's (a) is the #1, #2 and #3 priority!
So, what's this VI's name?
/Y
05-30-2018 10:52 AM
Thank you. This is useful.
05-30-2018 10:53 AM
Hi,
VI's name is Phase Shifter Output Sel.vi
05-30-2018 10:55 AM
Hi,
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.