LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI crashes

Solved!
Go to solution

I am creating a GUI in LabVIEW (Labview 2010)  since last month. But today suddenly occurred an error , Vi is crashing immediately after opening VI(It has worked yesterday). I am doing project having com port too. While doing work in each stages  i have saved back up also that too crashing now. But one thing noticed is that some time it will work. And VI perfectly working in 2011 version. Please help me to find solution. i am attaching the code for reference.

0 Kudos
Message 1 of 5
(392 Views)

Hi gishnu,

 


@gishnu wrote:

I am creating a GUI in LabVIEW (Labview 2010)  since last month. But today suddenly occurred an error , Vi is crashing immediately after opening VI(It has worked yesterday).


Simplest solution: pick the VI from your backup or SCC system.

You do backups regularly or use a SCC system, do you?

 


@gishnu wrote:

And VI perfectly working in 2011 version. Please help me to find solution. i am attaching the code for reference.


I can open the VI in LV2019.

Suggestions:

  • Cleanup the block diagram and reduce its size to one screen!
  • Remove all the Rube-Goldbergs!
  • Remove ALL THE DUPLICATED CODE! Use one (1) subVI instead!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(365 Views)
Solution
Accepted by topic author gishnu

Please learn LabVIEW (or hire someone with a year's experience with LabVIEW).  Here are some major flaws:

  • Do not use the Sequence structure (there are a very few exceptions, none of which apply to your code).
  • Try to keep your major wires (like the Error Line) running horizontal (almost no bends!) left-to-right.
  • Do not hide controls.  Do not place "unnecessary" controls (that you are not going to change) on the Front Panel -- replace them with Constants (see the VISA Configure Serial Port function).
  • You do not need a Front Panel control for (almost!) every option on VISA's Configure Serial Port.  Just wire in the desired Constants (or, if you are using the defaults, leave them unwired, and your Block Diagram uncluttered).
  • Do not use Formula nodes.  Use LabVIEW code.  If you need to make a little function to do something, write a little sub-VI and pass it inputs and create outputs, as needed.  Don't forget to use the default 4-2-2-4 Connector Pane (which you should use for at least 99% of all your sub-VIs) and put Error In and Error Out on the bottom corner connectors.  Inputs come in on the left, outputs go out on the right.  Incidentally, you seem to have Formula nodes that don't do anything ...
  • Ah -- you (sort of) found a legimate use for a Sequence -- wrapping it around a Wait function with Error In ad Error Out to "tie" the delay to a particular piece of code!  That's the rare place it makes sense for beginners.  Note that "modern" LabVIEW (say 2019 and later) have a "Stall" VIM that lets you put a Wait on any wire, and takes much less space (because the "space" is hidden in the VIM call).
  • Make your VI fit on a single screen (no larger than 1920 x 1080).  Your VI takes more than 6 screens!  Almost impossible to understand, debug, test, etc.  A very good way to "shrink code" is to look at a block of code and say "Can I make this into a sub-VI, with Error In, Error Out, a few (1 or 2, ideally) inputs and a few outputs?".  If the answer is Yes, you'll end up with a 32 x 32 "block" with inputs and outputs that takes much less space than the code you replaced (which was probably hundreds x hundreds).  The one "gotcha" is you need to make a simple Icon for your sub-VI to replace the "generic" Icon that NI uses for all of them.  The simplest thing to do is to is the following:
    1. Right-click the Icon (Front Panel, upper right) and choose "Edit Icon".
    2. Click "Layers". 
    3. Under "User Layers", click the VI Icon to select it and click the "X" to the right to delete it.
    4. Look at the Tools on the right.  Look at the two overlapping squares at the bottom.  You want the top one to be black, the bottom white (that's probably what they are).  If not, click one and choose the appropriate color.
    5. Now click the "Blue (filled) box" tool (third row, right side).  Place cursor on upper left of drawing area (checkerboard), click, drag down to lower right corner to make a white box with a black edge that fills the drawing area.
    6. .Click Icon Text (Tab to the left, where you previously clicked "Layers".  I recommend setting "Small Fonts", "Center", 10 (points, size of text), "Center text verically", and uncheck "Capitalize text".
    7. Create short (1-3 words) name for VI when placed on Block Diagram
  • Learn how to use VISA.  Generally, you send a command ("Do Something!") and VISA sends you a Reply ("OK", or "Here are the data you requested").  You (correctly, "accidentally", I'm sure) configured VISA correctly, namely to use a Termination Character of New Line, 0x0A), but you then used "Bytes at Port", which is usually wrong.  When you send the Command, you should have some idea of what VISA will be sending back to you, generally a packet of known (and finite) size, in characters, ending with the Termination Character that you specified.  So you simply do a VISA Read of "more characters than you know will be coming" (favorite values are 1000 characters, though I like 1024 characters).  You'll get a string of unknown length, but there is a String function that will tell you the length!

Whew.

 

Bob Schor

Message 3 of 5
(353 Views)

Step 1: Change your attitude such that you care about the quality of your work.

Step 2: Change your work ethic such that you are willing to expend effort to do quality work.

Step 3: Learn good coding practices.

Step 4: Use good coding practices.

Step 5: Throw that mess away and start over.

Message 4 of 5
(314 Views)

Thankyou for your valuable inputs, I will rework on my VI  with your suggestions. As a beginer to coding and LabVIEW, I think I have a long way to go.

0 Kudos
Message 5 of 5
(251 Views)