Jump to content

Writing to global from multiple loops


Recommended Posts

I am running a vi with muiltiple loops which generate different I/O's which i want to write to a master global array. Right now my current method is that I have a non-reenterant vi set up to write to the global and each loop uses this sub-vi to prevent over writing data from each other loop. This presents the problem of loops having to wait for other loops. My other option is several small global arrays which I can combine in a separate loop but this is much more anoying for organizing data. Is there any better method for each loop to write to the same array without having to wait for other loops?

Link to comment

The easiest and safest way is the way you're already doing it (assuming you're using an uninitialized shift register for your data store and not a standard global variable).

You can have an init case for initializing the array to its full size, a write case which accepts an index and a value and does a replace and a read case which can return the entire array as well as the index you wired in.

You can have 2 of these (one for DI and one for DO) and have the default action in each different (write for DO and read for DI). If you want analog, you can add more of these globals.

I'm not sure why you are concerned about the locking this creates. Unless your loops need to run extremely fast (usually faster than the speed with which you can get the actual I/O) the delay caused by locking this VI will be negligible.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.