LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Indicator Refresh from Global Variable

Hi,
 
Here's an easy one from a newbie:
 
I am maintaining a global string variable that contains lines that report the status of my program.
 
Every time the global is updated I would like the contents to be written to a front panel string indicator. This means that the global is read from multiple points in the vi, but there is only one indicator icon that I can access.
 
What is the best way of ensuring that the indicator is updated every time the global is updated?
 
Thanks.
0 Kudos
Message 1 of 8
(4,333 Views)

Hi mem07,

      I'd be inclined to use the FP string as the storage device (instead of a global), and let other parts of the program read it when they need to.  The Value of the string is one of the string's Properties accessible via its reference.  The reference could be put in a global, and shared that way, but this is a great application for a little "Driver" for the FP control - see attached.  Initialize the driver once (passing it the FP string's reference) and after that just use the "driver" to manipulate the string.  To get an object's reference, right-click on the object and choose create reference - wire this to initialize! Smiley Happy

Cheers! 

Message Edited by tbd on 10-03-2007 03:36 AM

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 2 of 8
(4,327 Views)
I have used an Action Engine (see multiple threads on the forum for more information about AEs) containing a cluster. One element of the cluster is a boolean called Front Panel Update. The other element(s) of the cluster contain data to be displayed. Any place in the program where new data is written to the AE, the boolean is set to True. When the panel is updated, the boolean gets set back to False. Rather than an element of the cluster, the Update boolean could be an output of the AE directly. If data is stored in the AE which does not need to be displayed, leave the boolean false.

Lynn
0 Kudos
Message 3 of 8
(4,311 Views)
Hi mem07,

Some good answers have come up... Tbd is right - there is probably no reason to use a global.  The string indicator will work just fine in storing your value.  You mentioned that "there is only one indicator icon that I can access."  By that statement, I assume you mean that there's only one terminal that lets you access the value in your front panel indicator or control. 

A way around this that was mentioned by tbd is to use a reference and a property node.  Yes, you could right click the control or terminal and select create->reference, wire it to a property node (Application Control Palette), and select the "value" property.  Property nodes by reference are one of the slowest ways to update controls, though.  This is also a pretty advanced technique for someone new to LabVIEW (good learning experience, though).

A slightly faster method is to right click your terminal and create->property node, selecting the value property.  This property node is "implicit" because it doesn't use a reference.

The quick and dirty way to access the terminal's value is to create a local variable. Locals are frowned upon by the gurus almost as much as a global because they duplicate the value of the control in memory for each local - it'll get the job done, though, and they're refreshed faster than both property node types. To make a local variable, right click the control or terminal and select "Create->Local Variable".  If you know about globals, you probably already know about locals.

Whew - that was a lot to type.  The bottom line is that, every time you update the front panel control or indicator by any of these methods, it's functionally equivalant to using the terminal ("indicator icon.")  The trouble is when you have multiple parts of your code updating the indicator at the same time, leading to a race condition.  We'll leave that for another post.

I hope my rambling was helpful...

Jim


0 Kudos
Message 4 of 8
(4,306 Views)

Hi Jim,


A slightly faster method is to right click your terminal and create->property node, selecting the value property.  This property node is "implicit" because it doesn't use a reference.

Not sure if you've missed the point here... mem07 needs to maintain/update a string from other parts of the program, the VI I attached allows that but needs the string's reference.  You've described how to access the FP control-value - but only from the same diagram as the FP - by the property-node Value.

mem07 is probably finding all this very confusing!

Cheers.

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 5 of 8
(4,295 Views)

Hi, im trying to do a similar thing here, refresh an indicator from within a subVI.

 

The change is taking place two subVI levels down into the program and i want this to come out represented by a boolean change on the top level.

 

How might i go about this?

0 Kudos
Message 6 of 8
(3,957 Views)

There are several ways to do this, all complicated by the fact that you want to use a boolean.  Booleans can only be remotely manipulated if the mechanical action is compatible with remote manipulation.  So, first, you need to change the mechanical action of the boolean to either switch when pressed or switch when released.  Add code at the beginning of your program to initialize the boolean to the correct value (use a local variable or the boolean's terminal for this).  Make sure the initialization code runs before the rest of your program (you may need a sequence structure to ensure this). Now, right-click the boolean and create a reference - this will show up on the block diagram.  Pass this reference into the your subVI and use the Value property to change the value of the boolean.

 

Other options include:

 

  1. Use a user event to trigger a change of the boolean
  2. Use a state machine command to trigger a change of the boolean
  3. Use any other asynchronous event (e.g. occurrence, notifier, etc.) to unblock a loop and change the boolean
All of these are variants on a theme and require a producer/consumer style architecture to successfully implement.  If you are just starting out, use the reference.  Note that, as said before, references and the Value property are very slow and should only be used if nothing else will work.

 

0 Kudos
Message 7 of 8
(3,949 Views)

Thanks for the help! I will try to implement it a few different ways to see if i can get the hang of them all.

 

I am most certainly just starting out 🙂 absolute newbie diving into the deep end..

 

Thanks again!

 

0 Kudos
Message 8 of 8
(3,926 Views)