LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate a message and stop LabVIEW based on instrument failure or error message thrown

Hello,

 

I have attached a state machine that pauses the state and generates an error in state "Test 2".  What changes can I make to the program that will generate a message to be emailed to the user and then shut the program down?

 

In state "Test 2", for example, an error might be thrown by the instrument or the instrument that data is being taken from stops responding.

 

What architecture do I have to use or what method to employ in this case?

Download All
Message 1 of 11
(1,653 Views)

You have a good start with the state machine.  But you aren't doing much with it.  Initialize --> Test 1 -->  Test 2  -->  Exit.   It is a glorified stacked sequence structure.

 

State machines get their real power from decisions.  Create another state called Message.  Then have that called on an error in one of the other states.  So if Test 1 is error free, go Test 2.   Otherwise go to Message, which will then go to Exit.

 

Likewise Test 2 goes to Exit on no error, but Message then Exit if there is an error.

0 Kudos
Message 2 of 11
(1,641 Views)

Thanks for your response!

 

I understand your solution if the error gets thrown, thanks! However, how do I handle getting out of state 1 if instrument/device hangs?

0 Kudos
Message 3 of 11
(1,633 Views)

Hi hiNI,

 


@hiNI wrote:

how do I handle getting out of state 1 if instrument/device hangs?


Then you should run into a Timeout error…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(1,556 Views)

Hello,

 

Not in some cases.  I have devices hooked up that does not give any responses back if there is a problem with the software in the DUT.  Sometimes the device will just get stuck in the subvi and I will have to manually shutdown LabVIEW.

 

I do not know how to handle this problem.  Is it possible to get something like a secondary time out, outside of the state machine shown that can shutdown the program safely?  I have never used the produce/consumer template, but could this be a possible solution?

 

Thanks.

0 Kudos
Message 5 of 11
(1,549 Views)

Hi hiNI,

 


@hiNI wrote:

I have devices hooked up that does not give any responses back if there is a problem with the software in the DUT.  Sometimes the device will just get stuck in the subvi and I will have to manually shutdown LabVIEW.


You really should improve your whole setup to avoid such "getting stuck" problems…

 


@hiNI wrote:

Is it possible to get something like a secondary time out, outside of the state machine shown that can shutdown the program safely?  I have never used the produce/consumer template, but could this be a possible solution?


When only the subVI used for device communication gets stuck you can implement some kind of watchdog routine to detect those "getting stuck" errors. Using producer/consumer schemes with VIs running in parallel might help here…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(1,545 Views)

If the subVI can get stuck like that, then there is something wrong with the way the VI was written.  The subVI should be handling the situation where a timeout occurs and passes that error up to the main VI once it ends itself.

Message 7 of 11
(1,540 Views)

@RavensFan wrote:

If the subVI can get stuck like that, then there is something wrong with the way the VI was written.  The subVI should be handling the situation where a timeout occurs and passes that error up to the main VI once it ends itself.


Below is a kludge of an example, but I think it illustrates the OP's point. I set an extremely long timeout, set VISA Read to a serial port that has nothing to read. I close the port while the VISA Read function is waiting, I immediately get an error from the VISA Read function. However, instead of the program ending, it appears to run until the timeout time is reached even though the read function error-ed out before the timeout. Here the VISA Close appears to wait the rest of the timeout duration. Not sure what is going on, except if you have a long VISA timeout, you are stuck waiting for it.

 

See below:

 

Press the Stop button while the Read function is waiting.Press the Stop button while the Read function is waiting.

 

mcduff

 

Message 8 of 11
(1,529 Views)

@RavensFan wrote:

If the subVI can get stuck like that, then there is something wrong with the way the VI was written.  The subVI should be handling the situation where a timeout occurs and passes that error up to the main VI once it ends itself.


But O.P. don't get discouraged!  You are asking the right questions!

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.
Message 9 of 11
(1,506 Views)

I have now modified my program as per the suggestion to send the state machine to a "Message" state if an error occurs. 

Timeout.png

 

1. Is there a more efficient way to accomplish this as I have multiple cases in my state machine and I will have to add this new comparison state in each case?

 

2. I am still not sure how to handle the case of a device hang.  I am testing out a device that has prototype software and there are time that after I send a command the software in the device may cause a partial or total shutdown and I get no response from the device.  In this case, how can I efficiently handle the "hang" and allow LabVIEW to notify me and then safely shut down?  I am still not clear on how to accomplish this task.

 

Thanks for your time and inputs!

Download All
0 Kudos
Message 10 of 11
(1,402 Views)