LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Good programming with Labview.

Dear,
First, I'm a beginner in programming with Labview.
Please see my attachment.
1. I used local variables to save a temporary value in the WHILE loop.
2. Too complicate to interprete the wires.

Are there any other cute ideas not to use above?
Or tell me if you can see some bads with my code.

Additionally, I would like to know how fast labview execute the loop compared to windows programming.

Thanks in advance.

Sungjun.
0 Kudos
Message 1 of 3
(2,719 Views)
How about

1. Use State-machine to replace the sequence structure?
2. Use Format Into String instead of Concatenate Strings.

Regards
ianf
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 Kudos
Message 2 of 3
(2,719 Views)
Here are a couple of suggestions.
1. Never ignore the Error Out outputs where they're available. Especially when you're doing any kind of I/O or communication with external devices or instruments: you should always know if there is an error. It may be as simple as an instrument being turned off. I often chain Error Out to Error In throughout the VI so the first error gets reported and I don't try to do anything else. You could also use one of the error handling functions in ..\vi.lib\Utility\error.llb like General Error Handler.vi to display the error. You should also add Error In and Error Out to your VI. They're available on the Array & Cluster control palette.
2. Make more use of dataflow to control the execution of your program. Review the LabView Help topic "Dataflow: The Concept Behind LabVIEW". You can eliminate many of the sequence frames and sequence locals in your VI if you use more dataflow.
3. Sequence structures are a programmers choice. They're a natural for code-based programmers to understand. But they have some severe limitations. I very rarely use them. You'll find a lot of comments here from experienced users telling you to never use them. One of their main limitations is that they are inflexible: every frame gets executed in a predetermined order no matter what happened previously. For simple programs, that may not sound like a big deal, but as the complexity of your applications grow, that can be a severe limitation. They are often replaced with a state machine, which is typically implimented as a case inside a while loop. You can find lots of references here for state machines.
4. Create sub-VIs for some of your more complex functions (like writing a record to a file). Having sub-VIs makes your program easier to read, debug, maintain, and re-use. Click here for some additional comments on sub-VIs.
Message 3 of 3
(2,719 Views)