LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sir i want to synchronize 3 vi's using occurence fn but i am not getting how to use occurences

i have no. of variables,in multiple vi's and if value of any bariable changes in any vi other vi need to do something.i know i can use occurences but i do not know how to implent them
0 Kudos
Message 1 of 5
(2,908 Views)
HI,

One way to accomlish this is to gloabal variables where you define all the variables which will affect all you relevent vi.

Change value from any of the vi will affect the global variable vaule which in turn will affect in the individual vi.

Hope this works. If you are looking something different, pl. give the feedback.

Best Regards,
Nirmal Sharma
India
0 Kudos
Message 2 of 5
(2,908 Views)
Hi Nirmal,

I have noticed that you have been trying to help out.

Let me offer some feedback, please.

Normal globals are OK if you have a value that is written by one entity ONLY. Multiple readers are are just fine. More than one writter can quickly lead to race conditions so they are habitually avoided by many experienced developers.

There is a common construct used in LV that is called by a number of different names i.e. LV2 global or Functional global.

Do a search on this site for many discusions toughting the benifits of a functional global.

I find that there are a number of benifits found in using these functional globals.

The first that comes to mind is that these constructs have a diagram so you can control exactly how they operate. (This is something that frustrated me when I was first starting out w/LV. What do you mean I can't get at the diagram?!)

Another benefit is that they take advantage of the nature of a "non-reentrant" VI in that only one entity can access a time thereby reducing the chances of race conditions. To do the same thing using normal globals, you have to build the global into an action engine or resort to using semaphores.

Next, they allow for the encapsulation of code. This is very helpful when you have situation where some shared data structures needs to be read, modified, and then written back. Doing this type of operation using normal globals is a disaster waiting to happen.

Next, LV2 globals can be served from one machine to another by using VI server techniques. Everything works the same as if the LV2 global was on the local machine.

Next, large blocks of data can be manipulated "in-place" (i.e. the operation is performed on the data in a single buffer instead of being copied, modified and then written back). ALL of the top entries in the LabVIEW Zone Dictionary Challenge used a variation on this construct.

So,
If the situation indicates that there is a single writter and multiple reads, globals are fine. Otherwise a LV2 global should be concidered.

Trying to help,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 5
(2,908 Views)
An occurrence is set up and must be fed into each VI or loop that has to wait for or set it. It sounds like what you are looking for is more in the line of a notifier.

I have included an example LV6.1, but it will work in LV7 as well. This example has 2 loops that use the occurrence. One watches a button and sets an occurrence when it sees the button pressed. The other loop waits for the occurrence and then sets a boolean. Notice that the occurrence is set up outside both loops and wired into both.

I included 2 loops that use notifiers. Since notifiers are named you can set them up in separate loops and VIs without any wiring connection beteen them. This makes notifiers a lot more powerful for synchronizing VIs and/or loops.

Have a look and see
if these meet your needs.

Rob
0 Kudos
Message 4 of 5
(2,908 Views)
I've found notifiers (or queues) easier to understand and use than occurrences. When one VI changes a value, have it also send a notification. The other VI's use Wait on Notifier which will wait until it receives the notification.

In fact, you may be able to do away with variables altogether and just use the notifiers themselves to hold your data.
0 Kudos
Message 5 of 5
(2,908 Views)