ntward Posted July 26, 2007 Report Share Posted July 26, 2007 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 Quote Link to comment
dannyt Posted July 26, 2007 Report Share Posted July 26, 2007 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 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 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 Quote Link to comment
LAVA 1.0 Content Posted July 26, 2007 Report Share Posted July 26, 2007 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) Quote Link to comment
PaulG. Posted July 26, 2007 Report Share Posted July 26, 2007 This should keep you busy for a while: http://zone.ni.com/reference/en-XX/help/371361A-01/TOC39.htm "Good form" is just the beginning. Quote Link to comment
dsachau Posted July 26, 2007 Report Share Posted July 26, 2007 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. Quote Link to comment
ntward Posted July 26, 2007 Author Report Share Posted July 26, 2007 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 Quote Link to comment
orko Posted July 26, 2007 Report Share Posted July 26, 2007 QUOTE(ntward @ Jul 25 2007, 07:42 AM) 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... I heartily recommend the Basics I&II and Intermediate I&II courses described http://sine.ni.com/nips/cds/view/p/lang/en/nid/10548' target="_blank">here. They are well worth the cost if you seriously want to learn the fundamentals and recommended programming styles of LabVIEW. Quote Link to comment
dannyt Posted July 27, 2007 Report Share Posted July 27, 2007 QUOTE(PaulG. @ Jul 25 2007, 02:58 PM) This should keep you busy for a while:http://zone.ni.com/reference/en-XX/help/371361A-01/TOC39.htm''>http://zone.ni.com/reference/en-XX/help/371361A-01/TOC39.htm' target="_blank">http://zone.ni.com/reference/en-XX/help/371361A-01/TOC39.htm "Good form" is just the beginning. Paul thanks very much for that link, I have not stumbled across that guide and it look well work a read. Danny Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.