NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Member
SuSto
Posts: 7
0 Kudos

How to make GPIB devices to go to zero upon stop?

I need to have my GPIB devices simultaneously (and preferably gradually) be set to zero when the program is stopped. How can I accomplish this? Also, what does clearing the devices do?

Proven Zealot
GerdW
Posts: 9,808
0 Kudos

Re: How to make GPIB devices to go to zero upon stop?

Hi SuSto,

 

I would say: the answer to both questions is given in the manuals of your GPIB devices...

Best regards,
GerdW


CLAD, using 2009SP1 + LV2011SP1 (sometimes even LV2014) on WinXP+Win7+cRIO
Kudos are welcome :smileywink:
Knight of NI
altenbach
Posts: 27,374
0 Kudos

Re: How to make GPIB devices to go to zero upon stop?

[ Edited ]

You need to programmatically capture and discard all events that try to close the VI and initiate your shutdown code instead. (you can also simply disable these mechansims) Of course the regular ways on the front panel (e.g. a stop button) should also do the same thing.

 

Look for the filtering events "Application close?" and "panel close?".

 

(For the (hopefully rare) cases where the application crashes or is killed by the task manager, you might still have a problem. What is your OS).


LabVIEW Champion . Do more with less code and in less time .

Member
SuSto
Posts: 7
0 Kudos

Re: How to make GPIB devices to go to zero upon stop?

I'm using a flat sequence with three frames: initialization, run test, and shut down. I want a stop button to just skip the "run test" frame and go straight to shut down. I was going to put the contents of the second frame in a case structure triggered by a stop button, so the stopped case just goes through to the third frame without running the test, or stopping mid-run.

 

Would this work, and if so where do I need to put the stop button to accomplish this?

Knight of NI
johnsold
Posts: 10,099

Re: How to make GPIB devices to go to zero upon stop?

That would work if the stop button is pressed before the run test frame starts executing. Once it has started, you would be inside the run case and the stop button would have no effect.

 

A much better way is to convert your program to a state machine. The initialization would be one state.  Shut down is another state. Run test probably consists of multiple states.  With such a state machine pushing the stop button will make the next state "shutdown" regardless of the present state when the button is pushed.

 

It is also much easier to modifiy a state machine if anything ever needs to be changes about your tests.

 

Lynn

Member
SuSto
Posts: 7
0 Kudos

Re: How to make GPIB devices to go to zero upon stop?

I'll be honest, I'm pretty new to LV, so I'm not confident in my ability to make those kinds of changes. Would it be possible to use an Application Exit? Event structure with my shutdown procedure inside? If so, would I need a while loop around my flat sequence frames?

Knight of NI
johnsold
Posts: 10,099
0 Kudos

Re: How to make GPIB devices to go to zero upon stop?

It is actually rather easy to start the conversion to a state machine. (Be sure to make a back up copy of your program first!)  Pop up on the edge of the sequence frame and select Replace >> With Case Structure.  Wrap a while loop around the case structure.  Create a typedefed enumerated control for the state selector. Then fix the errors which occurred due to the replacement.

 

Look at the examples and Design Patterns which come with LV.

 

You should plan on having a stop button on the front panel.  Application Exit has its place, but get the basic architecture right first.

 

Lynn