LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop a WHILE loop inside event structure ?

Hi,

this seems very simple,  but impossible to do with LABVIEW !?

See attached VI "ON OFF E3648-E3649".

I want to command 2 power supplies ON (one button), then permanently read current throuhg readback, and switch OFF with another button.

But it doesn't work...

 

 

0 Kudos
Message 1 of 4
(4,985 Views)

Hello Lucas,

 

Nothing is impossible, its just that you need to have the right knowledge about using the tools you have. 

 

Regarding your implementation, the first thing i would advice is that never put a while loop inside an event structure. You are actually blocking the program flow by doing this. You can study about simple State Machines and use the state machine concepts for implementing the same logic. It will be as simple as you expect it to be and will be more effecient as well.

 

Check out these links:

http://www.ni.com/white-paper/7595/en/

http://www.ni.com/white-paper/3024/en/

 

Warm regards,

Nitz

 

0 Kudos
Message 2 of 4
(4,977 Views)

the problem is data flow.... unless it is a sub.vi that opens front panel and it is then you can shut it down.

 

since you have multiple controls you want to write and indicators you want to read...you can use an event driven producer/consumer design

 

  • event: 'power on' , your equipment is powered 'on,' writes to the approppriate drivers for initialization
  • goto 'read' statement
  • event: manipulate controls, writes to the approppriate drivers in the approppriate statement
  • goto 'read' statement
  • event: 'shutdown', run shutdown procedures by writing to the approppriate drivers and turn off equipment
0 Kudos
Message 3 of 4
(4,943 Views)

Your event is set to lock the front panel until it completes, meaning that interactions with the "MISE Off" button is not possible while the event executes and your code will lock up indefinitely because the event cannot complete. As a quick bandaid solution, uncheck that option in the event configuration.

 

Still, you have a very poor design and it should be improved. Use a proper state machine architecture.

 

  • Why do you have an empty timeout case doing nothing?
  • Why do you write the "MISE Off" value to a local variable of itself? That does not do anything useful or change anything.
0 Kudos
Message 4 of 4
(4,931 Views)