Jump to content

What is good practise?


Recommended Posts

Hi all,

I'm pretty new to LabVIEW. Can anyone point me to something which defines good practise?

Basically, when I'm making VI's, I come up with a way of achieving what I want, but I'm never sure if it is a good approach / if what I'm doing is good practise. For example recently I needed to keep track of how many times part of a case structure was executed. So I hid a numeric control and used that to store the value and used property nodes in the case structure to increment the count. I've got plenty of examples of things like this which seem really messy, should I be worried?!

Thanks

Link to comment

I know where you are coming from, I have been doing LabVIEW now for 6 or 7 months and I still look at code I have done and think, is that really the best way to do it ? and certainly there must be a better way to lay it out.

I actually thing LabVIEW is a hard language to learn in that respect, to make the transition from being able to write something that works and something that is efficient and a pleasure to look at, unless you are lucky enough to work with a existing pro who can guide your hand.

I am a lot better now than I was after just doing it for two months, but I still have a long way to go. I think it is a matter of practise make improvements.

I have picked up a lot from the LAVA forums and looking at examples and I would recommend two books that I have found very useful

0131458353_xs.jpg

The LabVIEW Style Bookby Peter A.President, Bloomy Controls, Inc. Blume - President, Bloomy Controls, Inc.Publisher: Prentice HallPub Date: February 27, 2007Print ISBN-10: 0-13-145835-3Print ISBN-13: 978-0-13-145835-2Pages: 400Slots: 2.0

http://safari.oreilly.com/0131458353

and

0131856723_xs.jpg

LabVIEW for Everyone: Graphical Programming Made Easy and Fun, Third Editionby Jeffrey Travis, Jim KringPublisher: Prentice HallPub Date: July 27, 2006Print ISBN-10: 0-13-185672-3Print ISBN-13: 978-0-13-185672-1Pages: 1032Slots: 2.0

Link to comment

A shift register sounds like what you want to use.

I'm guessing you have a while loop around the case structure. You place a shift register on the while loop, then wire an integer constant (typically -1 or 0) to initialize the register. Wire the shift register through the case statement, and increment (or decrement) the value of the shift register as needed. Be sure to connect every case, or the value of the shift register may not be what you expect...

Your feelings were correct, using hidden controls and property nodes for internal data is generally considered "bad form".

http://forums.lavag.org/index.php?act=attach&type=post&id=6450 (LabVIEW 7.1)

Link to comment

In the LabVIEW help go to Fundamentals -> Development Guidelines -> LabVIEW Style Checklist and Fundamentals -> Managing Performance and Memory -> Concepts to get some basic do's and dont's. Here you will find the following advice.

QUOTE(LabVIEW Help - VI Execution Speed)

Though you can use controls, control references, and Property Nodes to pass data between VIs, they were not designed for use as variables because they work through the user interface. Use local variables and the Value property, only when performing user interface actions or when stopping parallel loops.

One of the big selling points for LabVIEW is that it is easy (compared to other programming languages) for people with little experience to get a program to "work". Unfortunately that can lead to some pretty ugly code.

Link to comment

Hi,

Thanks for all the references :)

The shift register works. I've used them before, I just didn't realise that I could use it there - I have a lot of other things going on which clouded my thinking. Thanks.

Also, it is really quick and easy to get things to work... I want them to be computationally efficient / elegant too though, and I'm finding it hard to understand how to go about that...

Thanks again for the advice

Link to comment

QUOTE(PaulG. @ Jul 25 2007, 02:58 PM)

Paul thanks very much for that link, I have not stumbled across that guide and it look well work a read.

Danny

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.