{"id":23473,"date":"2018-07-12T08:00:12","date_gmt":"2018-07-12T15:00:12","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=23473"},"modified":"2021-06-09T14:15:48","modified_gmt":"2021-06-09T21:15:48","slug":"4-rookie-labview-mistakes-and-how-to-prevent-them","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/4-rookie-labview-mistakes-and-how-to-prevent-them\/","title":{"rendered":"4 Rookie LabVIEW Mistakes and How to Prevent Them"},"content":{"rendered":"<p>Since I started using LabVIEW, I have made a lot of mistakes. I sometimes wince when I look at my early code. While most of the code works, it is often an unreadable mess. Since then, I have learned a lot of good techniques to improve the organization of my code.This article reviews the four mistakes that I personally made the most while I was starting with LabVIEW. For a more extensive list of common mistakes made in LabVIEW, please follow this <a href=\"http:\/\/www.prweb.com\/releases\/top_6\/labview_mistakes\/prweb10555235.htm\">link<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-19478 aligncenter\" style=\"font-size: 14px; font-family: 'Open Sans', Arial, sans-serif;\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/nrjsxmfm912163998723206173-2-600x338.jpg\" alt=\"\" width=\"600\" height=\"338\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/nrjsxmfm912163998723206173-2-600x338.jpg 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/nrjsxmfm912163998723206173-2-768x432.jpg 768w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/nrjsxmfm912163998723206173-2-1024x576.jpg 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/nrjsxmfm912163998723206173-2-800x450.jpg 800w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/nrjsxmfm912163998723206173-2-1200x675-cropped.jpg 1200w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/nrjsxmfm912163998723206173-2.jpg 1242w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<h3>1. No Error Handling<\/h3>\n<p>If an error occurs, the code comes to a screeching halt and gives a cryptic error, leaving the operator scratching a confused head. LabVIEW can fly a plane or lead a rover across Mars, but not if you\u2019re using Automatic Error Handling. The error cluster is easy to use! We can gracefully exit, fix, or prevent erroring applications from being a problem.\u00a0The following VI snippet shows an example of an error handler structure.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-23542 aligncenter\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2018\/01\/6249iBEB2A65630FF740F.png\" alt=\"\" width=\"505\" height=\"234\" \/><\/p>\n<h3>2. Overusing Flat Sequence Structures<\/h3>\n<p>This is a mistake I personally made a lot when I first started using <a href=\"https:\/\/digilent.com\/shop\/labview-home-bundle\/\">LabVIEW<\/a>. It was because I did\u00a0not fully understand the concepts behind \u201cdataflow\u201d execution, which is fundamental to LabVIEW programming. One indication of this is that users often overuse the flat sequence structure on their block diagrams. Users often rely on flat sequence structures to force the serial execution of code on the block diagram, instead of using the flow of data with wires between nodes. If you want to learn more about data flow in LabVIEW so you can better understand when you should and shouldn&#8217;t use flat sequence structures, check out this <a href=\"http:\/\/www.ni.com\/newsletter\/51735\/en\/\">link<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-19475 aligncenter\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/omqscgta3425732529143391934-600x160.png\" alt=\"\" width=\"600\" height=\"160\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/omqscgta3425732529143391934-600x160.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/omqscgta3425732529143391934-768x204.png 768w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/omqscgta3425732529143391934-1024x272.png 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/omqscgta3425732529143391934-800x213.png 800w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/omqscgta3425732529143391934.png 1425w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<h3>3. Misusing Local Variables<\/h3>\n<p>Another common mistake in <a href=\"https:\/\/digilent.com\/shop\/labview-home-bundle\/\">LabVIEW<\/a> programs is an overuse of local variables. Local variables are a piece of shared memory used to pass data between different sections of a computer program. Commonly used in text-based languages, variables can be very empowering, but can also lead to problems when a race condition is encountered.<\/p>\n<p><span style=\"font-size: 14px;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-19481 aligncenter\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/original-600x593.png\" alt=\"\" width=\"600\" height=\"593\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/original-600x593.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/03\/original.png 645w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/>Unlike other programming languages where passing data through variables is essential, LabVIEW provides the <\/span>dataflow<span style=\"font-size: 14px;\"> method of moving data from one part of a program to another. The parallelism inherent to LabVIEW makes overusing variables problematic because shared memory is often accessed by different code locations at the same time. If this happens, one read\/write operation wins the \u201crace\u201d and the other loses. The losing data operation is forgotten, so overusing variables in LabVIEW can ultimately lead to lost data.<\/span><\/p>\n<h3>4. Disregarding the Need for Documentation<\/h3>\n<p>Trying to discern what a program that is written by someone else does can be helped greatly by good code documentation. Unfortunately, documentation is normally left until the end of the development cycle, after the functionality is complete. This leaves little time to document code properly, and trying to understand poorly documented code can be a nightmare. Instead, time should be carved out during development to start the documentation process. I have found that making personal notes on my code as I go helps a lot too. You would be surprised how much you can forget after a few days of not looking at your code.<\/p>\n<p><a href=\"http:\/\/www.ni.com\/newsletter\/51735\/en\/#\"><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/www.ni.com\/cms\/images\/devzone\/pub\/sozwpodk8077875224802494052.png\" alt=\"\" \/><\/a><\/p>\n<p>Thank you for reading my blog post, and for more information about common mistakes\u00a0in LabVIEW, follow this\u00a0<a href=\"https:\/\/zone.ni.com\/reference\/en-XX\/help\/371361J-01\/glang\/property_node\/\">link<\/a>. If you are interested in trying out LabVIEW for yourself, you can purchase a copy of\u00a0<a href=\"https:\/\/digilent.com\/shop\/labview-home-bundle\/\">LabVIEW 2014 Home Edition<\/a>\u00a0which includes everything you will need to run\u00a0<a href=\"https:\/\/www.labviewmakerhub.com\/doku.php?id=learn:tutorials:libraries:linx:3-0:beaglebone-black-setup\">LINX 3.0<\/a>.\u00a0Please comment below with any questions or comments you may have.<\/p>\n<p>&nbsp;<\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-23473 jlk' data-task='like' data-post_id='23473' data-nonce='ee750c7abc' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-23473 lc'>+4<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-23473 jlk' data-task='unlike' data-post_id='23473' data-nonce='ee750c7abc' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-23473 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-23473 status align-left'><\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>Raise your LabVIEW skill level with these helpful tips!<\/p>\n","protected":false},"author":42,"featured_media":23542,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4323,1563],"tags":[],"ppma_author":[4493],"class_list":["post-23473","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","category-guide"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2018\/01\/6249iBEB2A65630FF740F.png","authors":[{"term_id":4493,"user_id":42,"is_guest":0,"slug":"astanton","display_name":"Austin Stanton","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/056fddaefc60a1f99c226ea5757a8c41?s=96&d=mm&r=g","author_category":"","user_url":"","last_name":"Stanton","last_name_2":"","first_name":"Austin","first_name_2":"","job_title":"","description":""}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/23473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=23473"}],"version-history":[{"count":0,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/23473\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/23542"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=23473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=23473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=23473"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=23473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}