ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event structure help, basic execution

Hello,

 

I am a new user of the event structure and have a very basic question. I am trying to write a program to control some GPIB power supplies that executes intial user settings (voltage, current limit, etc.) a single instance before stepping into an event structure.

 

Once inside the event structure, the timeout event will be infinite, and the program will only update when there is a change to any of the front panel controls. The problem with my current approach is that I am rewriting the same code twice. Once, before stepping into the event structure, and a second time when the user front panel controls change. Is there a way to incorporate the initial code to execute only a single time in the event structure shell? If so, how do I go about doing that? I don't want to put it in the timeout event because I would like to avoid having the program refresh itself unless a front panel control changes. But I do need that single intial execution. Any help is appreciated. Thanks!

0 Kudos
Message 1 of 4
(2,871 Views)

You can do one of the following teachinques:

 

  • First create an event for your main value changes and also assing the timeout to it. 
    • Place the timeout in a shift register initialized with zero and wire -a (=infinite) to the shift regsiter on the right. It will timeoutonce and then never again.
    • Use "Select" and wire =0 to the iteration terminal. Pick 0 for i=0 and -1 otherwise and wire the output to the timout terminal of the event structure.
  • Don't even use a timeout event, but use a value(sgnl) property write before the loop to trigger the main event with it. This way it will fire immediately after the event structure is ready for the first time. As a side effect, you can even bring the control to a defined state.

 

See how far you get.

Message 2 of 4
(2,869 Views)
 Place your whole initialisation step into a SubVI and call them before the event structure and even in the appropriate event case.
0 Kudos
Message 3 of 4
(2,867 Views)
the 0 timeout approach followed by a -1 change to stop future timeouts is a very clever solution. I hadn't thought about that. Thanks so much, that was exactly what I was looking for!
0 Kudos
Message 4 of 4
(2,852 Views)