LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error Handling

Solved!
Go to solution

Okay so my Main VI is a flat sequence code connecting to a bunch of motors using .NET references and then playing around with them.

The error handler I am trying to make should basically jump to the last flat sequence window (as shown) and close all my motor references and just finish the VI because the error encountered is of the motors not connecting and therefore will have to be manually restarted. 

Now Why don't I use the red Abort button is simply because whenever I do this it overwhelms my CPU and Labview crashes and I have to restart everything, thus the safest way to exit would be to follow the last sequence structure code. Now I tried to make a SubVI similar to my last sequence structure code with global variables (really stupid idea). So any w2ay I can achieve this? Change my sequence structure etc,. I'm running out of ideas now. 

 

I am also attaching my Main file but you may not be able to read the .NET references as that is from a separate 30 MB file. But should give an idea about data flow. 

error_snip.PNG

0 Kudos
Message 1 of 7
(1,943 Views)
Solution
Accepted by topic author bajajvishal11

Rewrite your code and remove the flat sequence structure. There is no way to jump over frames unless you start putting a case statement in everyone which would be HORRIBLE code. I would recommend you look into using a state machine. there are tons of examples out there.

 

As for the red abort button, you should NEVER use that to stop your VI, with the exception of the development environment and your code going completely off the rails. As you have observed, this is not a safe way to exit your program. It is like stopping your car by slamming into a wall. It will stop the car but the outcome is certainly not desired.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 7
(1,928 Views)

Okay I looked into State Machines and I think I can very easily convert my VI to one as it is already a sequential flat sequence, would basically have to just put each falt sequence block in a different case structure surrounded by a While loop. My only question now is that my error function is a SubVI How do I exit this SubVI and Jump to lets say my last Case Structure or "Stop case" from within the SubVI?? 

 

I apologize in advance if its a really stupid Question lol. 

 

0 Kudos
Message 3 of 7
(1,907 Views)

I think that if you right-click on the edge of your sequence structure, it gives you the option to convert it to a state machine!  YYMV, though, but I've seen it work quite well.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 7
(1,894 Views)

@billko wrote:

I think that if you right-click on the edge of your sequence structure, it gives you the option to convert it to a state machine!  YYMV, though, but I've seen it work quite well.


You must have a special plugin to do that.  The only built in options the Flat Sequence Structure lets you convert to is a Stacked Sequence Structure or a Timed Sequence Structure.  But a Stacked Sequence Structure can be replaced with a Case Structure, which gives you a basis for a State Machine.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 7
(1,862 Views)
Solution
Accepted by topic author bajajvishal11

@bajajvishal11 wrote:

... My only question now is that my error function is a SubVI How do I exit this SubVI and Jump to lets say my last Case Structure or "Stop case" from within the SubVI?? 


Your subVI should output the next state/case to run. Wire that into a shift register on the right side of the While Loop, and connect that string/enum from the corresponding shift register on the left side of the While Loop into the case selector of the case structure.

Doug
NI Sound and Vibration
Message 6 of 7
(1,815 Views)

@crossrulz wrote:

@billko wrote:

I think that if you right-click on the edge of your sequence structure, it gives you the option to convert it to a state machine!  YYMV, though, but I've seen it work quite well.


You must have a special plugin to do that.  The only built in options the Flat Sequence Structure lets you convert to is a Stacked Sequence Structure or a Timed Sequence Structure.  But a Stacked Sequence Structure can be replaced with a Case Structure, which gives you a basis for a State Machine.


No, I just have a bad memory.  Your recollection is the correct one.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 7
(1,776 Views)