Software timing - Functional Global?

I was reading NI Intermediate manual to prepare for the CLD exam, and noticed that they used Functional global variable in combination with timed loop for the software timing. Also, the error handling was implemented using functional global.
However, I was reading in one post( not this forum) that the functional global is obsolete, can anyone shed any light on this issue, why would the functional global be obsolete: and if it is, what are acceptable design for software timing.
Thank you.

Cory K wrote:
I dont see why a global would be obsolete.
There are some instances when using a global variable is the best option, especially in cases when a resource will be used on several different computers.
A functional global variable isn't the same thing as a global variable. A functional global variable is what was used before global variables were introduced in LabVIEW 3. It is the heart of an Action Engine.
As for their obsolesence... Hah! That's all I have to say on that.
As to the original post:  I'm a tad suspicious. What kind of software timing and error handling is being done with a functional global variable? Can you post the code?

Similar Messages

  • Using functional global variables to transfer data between touch screen device and other targets

    Hi,
    We are currently developing a control system that will operate on a cRIO with a touch screen interface. During development we have been using functional global variables (FGVs) to handle most of the settings/data etc, however we have just realised that we may have an issue updating the data on the touch screen, and vice versa.
    Previously we have implemented similar programs using shared variables, however we were wondering if there is anyway to implement FGVs in a similar manner, whether it'd be a combination of FGVs and shared variables.
    Regards,
    Mike
    Software version: Labview 8.2.1

    See this thread on LAVA about sharing FGV's across projects. THis should be extendable to cross paltforms (I believe).
    You also may want to concider an upgrade to LV 8.5.1. We have found a number of performance related issues with LV 8.2.1 and RT.
    If you decide not to upgrade, just remeber what I wrote (above) when you have reason to question the performance.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Using triggers with software timing

    Hello
    I'm using the PCI-6259  M
    series multifunction DQ board on a linux box (SLES 10.2) and am using
    the ansi_c api and the driver is NI KAL 1.4.  My application requires
    10 analog inputs, 8 digital inputs 8 digital outputs and all 4 analog
    outputs to interface with a piece of HW in real-time.  Currently I am
    doing straight software timing meaning I am not using the
    DAQmxCfgSampTiming call but am doing "on demand" sampling at a external hw
    controlled 1 ms interval using the NI read/write api calls.  I use 4
    NIDaq tasks (analog input/output,digital input/output).   I was
    attempting to add a analog input trigger to my system to mark a specifi
    event.  Here's what I want to do and after reading the NI documentation
    I'm not sure I can accomplish this with the NI ansi_c API
    I
    want to keep the software timing mentioned above in place which is making simple DAQmxRead/Write calls at that above specified 1 ms interval.  I want to ADD to my analog input task a trigger event for APFI1 and assign to it
    a callback function when the trigger condition occurs.  From the examples that
    comes with the driver (Acq-IntClk-AnlgStart) it looks like the event callbacks are tied to the TASK NOT the trigger.   I don't see how I tie the event callbacks in the API to a specific trigger not the whole task.  I need to be able to access my other anlog inputs "on demand" but want my trigger to fire a callback when the trigger condition occurs.  Also if this is possible what is the latency between the hw event and the execution of the callback?
    Kevin

    This is a cross-post. See my reply here:
    triggers using nidaq-mx
    http://forums.ni.com/ni/board/message?board.id=250​&view=by_date_ascending&message.id=54949#M54949
    Joe Friedchicken
    NI VirtualBench Application Software
    Get with your fellow hardware users :: [ NI's VirtualBench User Group ]
    Get with your fellow OS users :: [ NI's Linux User Group ] [ NI's OS X User Group ]
    Get with your fellow developers :: [ NI's DAQmx Base User Group ] [ NI's DDK User Group ]
    Senior Software Engineer :: Multifunction Instruments Applications Group
    Software Engineer :: Measurements RLP Group (until Mar 2014)
    Applications Engineer :: High Speed Product Group (until Sep 2008)

  • What's wrong with a "regular" global in this case? AND WIl ActiveX objects stored in functional globals remain valid (when used in an executable)?

    I've written a plugin layer for a LV executable.  When this layer makes a call to the plugins' initialization functions, I want each plugin library to be able to initialize and maintain its own global memory (where things like VISA resource names or ActiveX objects are stored).  However, I've found that I can't manage to keep my global VIs "alive."  I'm inclined to switch to functional globals, but I suspect that this will be a problem for things like ActiveX objects (that in this particular case reference a CAN interface).  I believe that the functional global will indeed store the object from run to run, it's just that I'm somehow disinclined to think that the object will remain valid.  I think you'll have to re-initialize it.  Can anyone speak for or against this hunch?  (If you can't tell, I'm trying to avoid building a whole little test executable just to debug this problem.)
    I suppose the more profound question is "Why don't the globals stay in memory?"  I'm attaching an image of what the application layer that calls the plugins' intializations looks like.  Next I'm attaching an example of an actual initialization routine.  You'll notice that I've even gone so far as to explicitly open the ref to the global VI that I want to keep in memory.  Then I just leave it there dangling - but it still gets dropped!  In my mind I shouldn't even have to do this, since the dynamically-called subVI "MC_CMO Init.vi" actually initializes the globals and runs with AutoDisposeRef = False. 
    Lastly, this is my first-ever attempt at writting plugin software.  So if you look at my code and have any criticisms/pointers, I'll greatly appreciate them.
    Thanks in advance,
    Nick
    "You keep using that word. I do not think it means what you think it means." - Inigo Montoya
    Attachments:
    AppLayer.JPG ‏60 KB
    InitPlugin.JPG ‏103 KB

    I am not sure if I follow you completely on your work-around.
    Everything I have to say on this topic is based on obesrvations and threads I have read on Info-LabVIEW. Therefore it is subject to corecttion by those who know better.
    LV is smart enough to know when "something" that had been opened, can be closed. It is not perfect.
    If for instance you open a VISA refnum and pass the refnum  to a LV2 AS A REFNUM the refnum in the LV2 stay alive as long as the VI's are running.
    If you start another VI that uses the LV2 to fetch the refnum, it should get a valid ref as long as it starts before the first goes idle.
    You then be able to work with refnum usign the VI launched second as long as stays active.
    I often create action engine that can be invoked where required throughout an application. If the action engines get a ref in one state (like init) and use it another, I will generally write a "tester" that calls the action engine action to test the engine. In this case, my "tester" stays live and it keeps the ref's fresh.
    I suspect if you tried to trick LV you could. If you type cast the ref nums to I32 and stored those in a LV2, I could see how LV could loose track of the resource sharing, but that is something I would avoid.
    So I encourage you to do some experimenting with keeping track of who's running when to see if your work-around will work.
    If you think you understand it better than I explained it, please post.
    Trying to help,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • I STILL cannot acccess ITUNES or SOFTWARE UPDATE functions

    I have not been able to assess Itunes for many months - or the online software update function either. I noticed an Internet Explorer logo pops up every time I launch either function (software update or Itunes music store), then it shows the bar download at 1/3rd, where it stays until I get the timed-out message.
    I went to update Explorer (in case that was the problem) and Microsoft says it stopped supporting Mac in 2005!
    Is that the problem? Is Mac still using a Microsoft browser to access their updates and store, when Microsoft doesn't even support Mac anymore? I suspect so, or else why does the Explorer logo always show up?
    I expect Apple is losing a lot of Itunes sales because of this. It appears I am not the only one having this ongoing problem.
    Will upgrading my OS help, or will I get the same Explorer logo?
    G5 Mac OS X (10.3.9)
    G5   Mac OS X (10.3.9)  

    Apple does not use Internet Explorer for Software Update and never has. If IE is launching when you try to run Software Update, there's clearly something amiss with your system. It's not likely an iTunes error since the Mac OS X Software Update doesn't work either, so I'd suggest you repost your question in the Mac OS X 10.3 area. You'll be more likely to get useful suggestions there. The easiest fix may be to do an Archive and Install reinstallation of Mac OS X 10.3, but someone else may know of a quicker fix.
    And yes, as you've discovered, Microsoft dropped support for the Mac version of IE two years ago, and Apple hasn't included IE with Macs for quite a while now.
    Regards.

  • Article: Functional Globals in LabVIEW 8.5 - No Loop, No Joke

    Hello Everyone,
    I've written another article on my blog:
    Functional Globals in LabVIEW 8.5 - No Loop, No Joke
    I hope you find it interesting
    Thanks,
    -Jim
    Message Edited by Jim Kring on 09-07-2007 08:24 AM

    Thank you for your attention!
    I've opened the fixed vi and all seems to be ok, but in few mouse click all messed up again causing strange floating wire and a LV crash.
    If you are brave please try the following procedure (save and close all of your work..!):
    Open your fixed vi.
    CTRL-E to display the block diagram.
    Rigth click on the upper (DBL) feedback node and change it to "Globally Initialize".
    Right click again on the same feedback node and select "Move Initializer One Loop Out".
    Select the feedback node, the "+", the "+1" and the other (blue, INT32) feedback node.
    Then perform the "Horizontal Centers" alignement.
    (in my case) voila! Move one of the 2 feedback node and see what happen....
    Now try to close and save the vi.
    I run LV on a NI PXIe-8106 so I think that this kind of hw is fully compatible with NI software... :-)
    I suspect that in this case the problem is not at a graphic level but reflect a corruption of internal data LV data.
    Attachments:
    Broken wire.jpg ‏54 KB
    Error3.jpg ‏60 KB

  • Will more function globals or sub vis slow down realtime DAQ or display

    I need to do high sampling rate DAQ with varient data process and display.
    Shall I intend to put all the code into one vi to accelarate the speed,  or can I use more function global or sub vis to make the structure looks more reasonable.
    Just worry how the compiler handle the data transfer when call function global or sub vis.
    Will it creat new data copy and slow down the speed. Thanks.

    The other 2 loops in charge of the data processing and display will keep checking the version of the 2 function global. 
    For high performance, you want to avoid this sort of thing. Basically, you're polling the functional global to see if it has new data. Polling will eat the CPU unless you include WAIT periods, but doing that slows your responsiveness.
    Consider using custom events.
    For the sake of discussion, let's say you need to process data in the TIME domain (1) and the FREQUENCY domain (2).
    You create two events: NEW TIME DATA and NEW FREQ DATA, each carrying an array of DBL (the time-domain data from the DAQ).
    The DAQ routine, when it gets a new data block fires both these events, feeding it the new data. 
    Your TIME DOMAIN loop (1) has registered for one event.  When that event is triggered, the code accepts the data, and does whatever it needs to do (filters the time domain, graphs it, writes to file, averages, whatever).
    Another loop (2) has registered for the OTHER event.  When THAT event is triggered, the code accepts the data, performs FFT on it, and  does whatever it needs to do (filters the frequency domain, graphs it, writes to file, averages, whatever).
    Or you could do the same thing with queues.
    When the use changes conditions, you change which event you listen to, or which queue you consume from. 
    The idea is that you want to avoid polling.  Let the system tell YOU when data is available. Don't be asking the system if it's available. 
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • How can I activate a functional global without displaying a LabVIEW VI ??

    Hello. I'm using Teststand and have been got stuck on a problem now.
    Whenever I communicate to a LabVIEW VI which is activated as a functional global,  I purposely displayed the LabVIEW VI on front pannel to make sure the data communication.
    However once I released the check mark 'Show VI front pannel when called' , the data transmission including receiving vanished. As a matter of fact, always the numeric data resturns ' 0 '.
    So the data communication must be transacted with a shift resgister function at each step in Teststand, so it always provides a command to the functional global VI for an e-num  item selector.
    Therefore it looks the shift register function doesn't work at the point anymore in the functional global VI.
    Otherwise as long as I suspend the VI as a display, checking on the box 'Show VI front pannel when called' , I exactly can make sure the data communication , receiving the command and returning the data.
    Have you heard that kind of unusal problem before?
    Do you think it happened due to data communication or just simply Teststand applicational error?
    If it has some useful information, I try to fix them. 
    Thank you.
    Noriyuki

    hirose wrote:
    Hello. I'm using Teststand and have been got stuck on a problem now.
    Whenever I communicate to a LabVIEW VI which is activated as a functional global,  I purposely displayed the LabVIEW VI on front pannel to make sure the data communication.
    However once I released the check mark 'Show VI front pannel when called' , the data transmission including receiving vanished. As a matter of fact, always the numeric data resturns ' 0 '.
    So the data communication must be transacted with a shift resgister function at each step in Teststand, so it always provides a command to the functional global VI for an e-num  item selector.
    Therefore it looks the shift register function doesn't work at the point anymore in the functional global VI.
    Otherwise as long as I suspend the VI as a display, checking on the box 'Show VI front pannel when called' , I exactly can make sure the data communication , receiving the command and returning the data.
    Have you heard that kind of unusal problem before?
    Do you think it happened due to data communication or just simply Teststand applicational error?
    If it has some useful information, I try to fix them. 
    Thank you.
    Noriyuki
    I'm not sure about the current versions of TestStand but in previous versions you had the possibility to preload certain test steps or initializer VIs. TestStand made sure to keep them in memory for the entire duration of the particular test sequence. You create such an initializer VI and call your init method in there and mark that step as preload. On loading the sequence or initializing it your step gets called and stays in memory for the entire duration. I would be surprised if TestStand doesn't support this anymore.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Do I need to use a semaphore when reading/writing a functional global from reentrant VIs?

    I have a program that spawns multiple reentrant VIs running simultaneously.  These VIs write their status to a functional global.  The VI that monitors them periodically polls this global to check out how they're doing and takes action based on their collective status.  (BTW, I'll mention that this monitoring VI is NOT the parent that spawned the reentrants, just in case this might affect memory management as it pertains to my question.)
    Anyway, 90% of the time, stuff goes off without a hitch.  However, once in a while the whole thing hangs.  I'm wondering if there's any chance that I've overlooked something and that some kind of collision is occurring at the global.  If that's the case, then should I be setting a semaphore for the global read/writes?
    And, if this is a problem, then there is something deep about functional globals that I don't yet understand.  My notion of them is that they should negate the need for a semaphore, since there is only one global instance, which cannot be simultaneously called by the various reentrants.  Indeed, this is arguably THE WHOLE POINT about functional globals, is it not?  Or am I missing something?
    Thanks,
    Nick 
    "You keep using that word. I do not think it means what you think it means." - Inigo Montoya

    Thanks Uwe,
    This is a good hunch.  However, functional globals typically run at "subroutine" priority.  With this priority, it is not possible to select a specific execution system; it is always "same as caller."
    I will try your suggestion by switching to "time-critical" priority.  However, I do not know if this could lead to a different set of issues (non-determinism?).  It will probably take a little while to hear back from my guys on whether this makes a difference or not, because the error is sporadic, and sometimes doesn't come along for quite a while.
    While probing all of this, I looked at the execution settings for my reentrant VI.  It has standard settings: "normal" priority, running in the "same as caller" execution system.  My impression has always been that LV creates the clones with unique names.  This allows the clones to be in the same execution system with no problem, and the fact that the execution dialog allows me to choose "same as caller" for a reentrant VI supports this assertion.  This is logical, since there could potentially be many more clones than available execution systems.  "Preallocate clone for each instance" is selected, which is what I want, I think, though I don't know if it matters in my application.
    In summary, I am trying out your suggestion, but with skepticism.  Any other suggestions from anyone out there?  Any misunderstandings on my part that need clarification?
    Thanks,
    Nick 
    "You keep using that word. I do not think it means what you think it means." - Inigo Montoya

  • Functional Global Variable in the CLAD sample Exam

    Hello,
    A question in the CLAD sample exam #2 keeps puzzling me. It's question number 32 about FGVs:
    32. Which is not an important part of creating a Functional Global Variable?
    a. Using Shift Registers to store information
    b. Changing the VI’s execution settings to Reentrant
    c. Setting the VI to inline into calling VIs
    d. Setting the While Loop to stop after one iteration
    The answer given is the following
    32.Correct Answer: B
    Topic: Functional Global Variables
    Justification: It is not necessary to inline functional global variables into their calling VIs. In fact, inlining requires that the subVI be reentrant, which is forbidden for functional global variables.
    Clearly, for an FGV to work properly, the VI must NOT be reentrant. So I would have selected answer B, but the justification seems to clearly point to answer C as well, doesn't it? Is it a typo, a subtlety in the wording? I am stuck on this one!
    Solved!
    Go to Solution.

    Well, inlining requires reentrant.  Therefore, the best answer should technically be C.  This looks like one of those rejected/retired questions since it isn't quite right and/or left up to too much interpretation.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to use functional global with a large amount of variables?

    Hi all,
    I'm currently developping a LV program which control and acquired data from a device. Up to now I used global variables ( very conveniente to use for experimental parameters). But now my program is become to be too large and I have too much "global" variables to continue to use a global.vi.
    I'm wondering if functional global can help me. If someone has an exemple of how use functional global with a large amount of variables...
    thanks

    I agree with Ben.
    Using queues is better than a number of Globals or Action Engines (Functional Globals).  If you need to pass data to a sub-vi, you can simply wire the queue out to a queue control of a sub-vi, or a reference.  See attached example of passing data to a sub-vi using a queue.  The example is an extremely simple, undocumented tid-bit of code that sends the loop count to the consumer VI.
    Run the main program called QueueProducer.vi.
    R
    Attachments:
    QueueProducer.vi ‏18 KB
    QueueConsumer.vi ‏14 KB

  • Multiple copies of functional global using vi references

    I have several producers aquiring data into a functional global (one functional global per producer). These functional globals are identical except for the name. Would it work to have only one functional global VI and obtain a separate reference for each producer? The matching consumer would also use the proper reference to consume the data.
    The functional global contains an array of the data which must be parsed by the consumer. It is possible that the array of data may not contain a complete set of data on a single "store" operation by the producer. The consumer, of course is written to check for a complete data record before completing processing on the record.
    Solved!
    Go to Solution.

    Les__Bartel wrote:
    tst wrote:
    Regardless of whether there is a better way, the answer to the question is yes. The FGV needs to be reentrant and the reference you open needs to be reentrant too and then you can use the CBR node to run the specific copy of the FGV.
    I thought a reentrant vi would not maintain the state of the uninitialized shift register from one call to the next.
    A reentrant VI will maintain the state of its uninitialized shift registers.  However, you need to be really careful how you do this.  First of all, you need to make sure it is set to Preallocate Clones.  What will happen in this situation is that each different place you call that subVI will each be a different clone.  This means that each call will have its own data.  The problem with this is that you can't share the data across multiple instances and therefore multiple loops.  If you don't believe me, go play with the Mean Point By Point VI.
    So what happens if you set it to shared clones?  A big freakin' mess.  You will have no control over which clone will be called where and there will be some major data corruption.
    This is why FGVs are almost always non-reentrant.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Functional global set as reentrant vi in CLD sample?

    In the CLD atm sample question attached. It set its functional global as a reentrant vi...
    Now let me get this right , a non reentrant vi, no matter how many times it's called, stores its data into one location. So a functional global should be a nonreentrant vi so the functional global can SET the same data in the same place, and GET the same data in the same place.
    Whereas a nonreentrant vi creates clones everytime it is called, and each clone stores a different set of data in a different place. So a functional global should not be a reentrant vi because it cannot retrieve the same copy of data; there are many different data sets stored in different places, the functional global would not know which data set to retrieve.
    But how come this CLD sample set its functional global as reentrant vi and it works???
    Attachments:
    ATM Simulator LV86.zip ‏116 KB

    richjoh wrote:
    In your VI code "Shared clone is selected"
    Below are past from the LV manual --
    "Memory Usage - Only allocates clone VIs for the maximum number of simultaneous calls to the reentrant VI. Decreases memory usage..."
    "Execution Speed - Creates clone VIs on demand. Slightly decreases execution speed and speed may vary per call.."
    ...and Preallocate is versa of above.
    Yes the only reason to use Reentrant in any LV example is to keep separate copies in memory. This author uses the reentrant VI to track 3 different transaction in his example (looks like an banking ATM, I have not run it as yet). The author reentrant is for "deposit", "withdrawal" and "pin entry". Ctrl+F, the VI is used in 4 instances, one of them is to Get current action, the other 3 are Set.
    IMHO, the example is overblown. Wonder how long it took the author to create it?
    The reason it works is all access is sequential.
    Overblown, yes. Reminds of the kid trying to show-off by climbing over the fence to pose next to the lion's cage. It will bite them eventually.
    Keep It Simple Sir has clearly bee violated.
    I will watch for someone who can explain WHY that was a good decision unless they felt there would 500 of these ATM GUIs running in parallel.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Functional Global Variable on Hold

    Hello everyone,
    I understood, by reading threads on the forum, that a call to a Functional Global Variable will block its execution if the FGV is already being accessed by another VI, correct? Is there any other way it would block, apart from the stated?
    The motive of the question is that I have one FGV (non-reentrant) that is read by 8 subVIs concurrently (they are, actualy, the same vi, but configured to reentrant) and whose access time varies, strangely, based on the number of subvis running.
    When less than 5 VIs are trying to access the FGV, the execution is blocked (I assumed it, because when the FGV is disabled and replaced by a constant there is no problem with the execution) and the access lasts at least 50 ms; if this number is between 5 and 8, the execution is done much faster. My first guess was that the FGV hasn't been initialized until the fifth subVi is called, but I don't know how to check that.
    I can figure that there is something wrong with the FGV, but can't put my finger on it. Any ideas?
    Thank you in advance for any help.
    Solved!
    Go to Solution.

    Thank you for your response, Ben
    I'll try to explaing the problem better with the images that follow.
    I have 8 concurrent instances of the "bitDefiner.vi" - shown below - in the program.
    It reads from the AE (a simple read-write one) and it's the only one to call it besides the writer (that generates the appropriate signal), gets the rising edge of a waveform and determines how long it takes until the falling edge, giving a category to this time later on. If it doesn't determine the period between rising and falling edge before the timeout runs out, it aborts the execution of the while loop. This VI execution is setup like this:
    That being said, let's go to the problem.
    Assuming there is nothing using the AE but one instance of the bitDefiner, it won't get the rising edge, due to the fact the signal is not being generated, resulting in a timeout. The return value on the diff indicator should be next to the one defined to timeout(image below)
    However, when the subvi concludes its execution, the diff indicator shows 54ms intead of 15ms; so I concluded that the AE is taking to long to process the call. Besides that, I'm quite positive that there is only one thread accessing the AE.
    After this result, I ran the other instances of the bitDefiner and after the 5th one got activated, the diff went to the expected 15 ms (I'm still thinking how to show that on picture).
    I tried highlighting the execution, but it didn't show me anything unsual. The call chain just present that the caller is the bitdefiner VI as expected.
    Any thoughts on that?

  • Functional global variable question

    Hello,
    I fully understand how a functional global variable (FGV) works and its purpose but I have one last question.
    How do I guarantee (or how is it guaranteed) that my sub-VI (the FGV one) is not re-entrant, in other words, how am I sure that when an instance of the FGV is running it does not loose the processor to others?  Is this an option that I can choose in a sub-VI or is it related to the while loop or case strucure that compose a FGV?
    Joao

    Hi Joao,
    For a little more background on configuring reentrancy and the options you have available if you do want to make a subVI reentrant:
    LabVIEW Help: Reentrancy: Allowing Simultaneous Calls to the Same SubVI
    http://zone.ni.com/reference/en-XX/help/371361K-01/lvconcepts/reentrancy/
    As Lynn said, all new SubVIs will be non-reentrant by default.
    Regards,
    Tom L.

Maybe you are looking for