Search code examples
eventslabview

Labview events - do a taks in parallel to a running loop


I'm trying to do something very simple:

  • OK button sums a+b and shows in c
  • Loop switch button control a infinity loop

enter image description here

Option 1 - Loop outside event enter image description here

Option 2 - Loop inside event enter image description here

I just want to be able to keep the loop running and the OK button working at the same time, how can achieve that simple task in Labview "way of life".

Results:

  • Op 1 - Outside event: One loop occurs after OK click, if loop is running, OK works only at first time
  • Op 2 - Inside event: Button OK does not work

Solution

  • Here is how you can do it with a Master/Slave configuration. All the user events are handled in the master, the counting is handled in the slave. The loop can be restarted and the stop works for both loops.

    The main code to run

    To Stop the code you use a different event, in the case the loop conditional is false you don't do anything in the slave loop. Not shown here, but the loop conditional also has it's own event structure to reset the counter if needed.

    The stopping condition

    This master/slave structure is extendable to as many loops as you want.