Jump to content

Shared Variable FAQ


gap

Recommended Posts

Does example code exist for the LV8 real time module?

NI decided to change the real time code programing style by adding a shared variable.

What is it and how does it survive?

Examples of the new coding style would be helpful.

If they "really do exist"(just like talking M&M's which are tasty by the way) , where can the elusive code snipits reside.

Any help in linking or posting would great thanks in advance.

:book:

Link to comment

Here is a document that my local NI rep sent.

Author: Gerardo Garcia x32773

Last updated: 10/10/05

Note: this document is a work in progress. You can find a link to the latest version of this document here.

General Questions

1. What is a LabVIEW Shared Variable?The LabVIEW shared variable is a new feature in LabVIEW 8 for sharing data between VIs and networked computers. The API is similar to a local or global variable; however it has many additional features such as network buffering.

2. When should I recommend using shared variables to customers?

NI recommends using shared variables for most applications that need to share and monitor data across the network. As a general rule of thumb, we will recommend shared variables for most applications. Shared variables are not recommended in medium to fast streaming applications, such as vibration monitoring, etc. In these cases, low-level TCP or UDP functions will provide faster communication. See the performance section of the FAQ for more information.

3. How does the shared variable work?

The shared variable uses different methods to communicate depending on the shared variable configuration settings. When a shared variable node is placed on the block diagram, LabVIEW scripts the corresponding communication code in the background.

4. Can users see the code behind the shared variable?

No.5. What are the different types of shared variables?

There are three types of shared variables:

1. Single-process

2. Network-published

3. Time-triggered

The type of variable is designated through a setting in variable properties dialog.

6. What is a single-process shared variable and how does it work?Single-process shared variables behave much like global variables and will have similar performance. They are used to transfer data between VIs or loops on a single computing device. There are two advantages that single-process shared variables have over global variables:

  • Like 1
Link to comment
  • 2 weeks later...

Hi Fellows;

This seemed to me like a good send on a realtime target;

I have tried it, and the shared variables themselves do work on the RT,

but for now, binding a shared variable to a front panel control seemed

impossible.

NI does hint that it can be done; with the caveat and advice that since

one can not be sure that the front panel is loaded in memory, this will not

work.

Now, I tested it under windows and it works great and I can bind a front

panel control and shared variable; in fact I can simply drag the shared

variable onto the front panel and it works.

My aim is to create a "double throw" control (like a double switch) where

you can turn on or off the lights from two places... or change the numeric

value of a control from two places...

The purpose is to be able to control an instrument from a programmatic

text interface (script) or directly by clicking buttons on the user interface without

switching modes in such a way that the interfaces are always synchronized.

Currently I have this implemented using a rt buffer and front panel interface

I check on every loop to see if the buffer has something in i and and if yes,

update the control, else use the value in the control. this works great until you have

30 controls on the user interface and it becomes a drag on performance since

I am using the slowest RT...

Any suggestions or clarifications on how to bind front panel on RT ?

Walters

SpinX Technologies

post-633-1139837973.jpg?width=400

Link to comment

Howdy,

Since my name and extension appear in this thread, I felt obliged to reply :)

The FAQ in the post above was a working document and not meant to be shared externally, meaning there could be some mistakes in it. I would instead point you to an excellent application note on the NI Developer Zone called Using the LabVIEW Shared Variable. It answers most questions about the shared variable feature in LabVIEW.

As always, the NI support team is ready to help if there are any unanswered questions on the shared variable. Of course, if the shared variable is making your LV development life wonderful, I love hearing success stories, too.

Best regards,

Gerardo Garcia

National Instruments

LabVIEW Real-Time Product Manager

Link to comment

I do love the shared variable and have had much success replacing my homegrown UDP client server mechanism to get data between a Windows Host and a ETS desktop RT box. I do have a couple questions, though...

I can't get my shared variable clusters to slave to my strict type-defs. I point them to the type-def as I configure them, but, a change in the cluster requires me to redefine the shared variable by re-browsing for it. Kinda clumsy -- Am I doing this wrong?

Also, what UDP ports does the shared variable system use? While I'm at it, what ports does LV use for panel updates and all the rest of the under-the-hood traffic to the RT Box? I ask because I also have some UDP of my own going and I'm seeing re-connect speeds and other slow-downs that make me wonder if I'm stomping on some LV UDP traffic. Unlikely, given the number of ports, but worth asking about, I think.

Thanks,

Randy

Howdy,

Since my name and extension appear in this thread, I felt obliged to reply :)

The FAQ in the post above was a working document and not meant to be shared externally, meaning there could be some mistakes in it. I would instead point you to an excellent application note on the NI Developer Zone called Using the LabVIEW Shared Variable. It answers most questions about the shared variable feature in LabVIEW.

As always, the NI support team is ready to help if there are any unanswered questions on the shared variable. Of course, if the shared variable is making your LV development life wonderful, I love hearing success stories, too.

Best regards,

Gerardo Garcia

National Instruments

LabVIEW Real-Time Product Manager

Link to comment

One thing that I did not see pointed out earlier (maybe I just missed it) is that the SV acts like an individual Global with timestamp *and access control wrapper* which helps preclude some of the race conditions that we see with regular globals.

Another item is that (at least according to NI yesterday at our meeting) you must use Gigabit ethernet to get the Timed-Triggered version to work.

I really like the cleanup you can do to your code, especially some of the RT stuff using SVs.

Link to comment

Hi;

Thanks for your reply. Infact, I had perused the article in question and unfortunately it

doesn't clarify that particular question which is binding a shared variable to a front

panel of a realtime system.

I had no problem getting it to work on the desktop under windows xp.

According to Ni, you're suppose to be able to do it on the RT though they don't advice it as the

they claim the panel may not always be in memory.

I have tried it from the dev environment with the panel open; and therefore in memory ?

and it doesn't work. No error is given.

It simply act as two different variables.

Programmatically when I can change and read back the value of the shared variable but this changes don't reflect on the control front panel or vice versa; whereas on windows

This works great...

<i hope this details helps...

Walters

Howdy,

Since my name and extension appear in this thread, I felt obliged to reply :)

The FAQ in the post above was a working document and not meant to be shared externally, meaning there could be some mistakes in it. I would instead point you to an excellent application note on the NI Developer Zone called Using the LabVIEW Shared Variable. It answers most questions about the shared variable feature in LabVIEW.

As always, the NI support team is ready to help if there are any unanswered questions on the shared variable. Of course, if the shared variable is making your LV development life wonderful, I love hearing success stories, too.

Best regards,

Gerardo Garcia

National Instruments

LabVIEW Real-Time Product Manager

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.