Global variable reference problem

Hai all,
Am facing a problem in assigning a control as a global one.
Actually i have assigned two OK buttons g1 and g2 as global ones. In 1.vi i have created control c1 (Switch when pressed) and in 2.vi i used g1. when i run both VI's, the g1 get updated with the change in values i gave in c1 in 1.vi (NO PROBLEMS).
But in 1.vi i created another control c2 (Latch when released) and in 2.vi i used g2. when i run both the vi's, the g2 didn't get updated with the change in values i gave in c2 in 2.vi
Anybody please suggest a immediate reply.
Regards,
Mathan

Hai,
Thanks for the timely help. Actually am using parallel port read and write loop.vi from the example finders in Labview 8.5 in my application.
In my project, USB device test using USBCV utlity, am in need of two controls (buttons). One will be a switch which give a high/low value when pressed/released. Other one will be a latch which will be used for remote wakeup of the device (a pulse). i have done this in labview.
But the test needs to be automated. That is when the USBCV utlity asks to connect/disconnect a device, automatically the switch control should be handled accordingly. when the utility asks for a remote wakeup, the latch control will get pressed automatically.
That is when i run my VI and the USBCV utility, when the utility prompts for certain action (connect/disconnect, remote wakeup), the VI should give appropriate inputs (from switch or latch) automatically without any user inputs.
Kindly give suggestions.

Similar Messages

  • Table Reference Global Variable

    Hi,
    Inorder to update a table in One VI from another VI, i need a Global Variable Reference of that Particular Table. How  shall i create it.
    Anybody please comment on this.
    regards,
    mfp.

    You can use LV2G,
    an example is attached, you may work on same lines.
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.
    Attachments:
    Another VI.vi ‏16 KB
    LV2G.vi ‏11 KB
    Table owning VI.vi ‏13 KB

  • Is there a way to check which VI and it's subVI are using which item in a global variable.vi

    While i writing the program, the program is growing and i also use global variable for it, but sometime some variables is delete from the VI (due to modify of the VI)
    But usually I don't update the Global Variable.vi, there are is some indicator or control in the Global Variable.vi is not being select as a item in main VI.
    So how can i differentiate between the still using control/indicator(selected item in main VI) and extra control/indicator(not selected item in main VI)

    From your global definitions .vi, select one of the global variables, then right click. Select 'Find Global References'. This will give you a list of .vis using that global variable. You can also get the same info by right clicking a global variable reference on one of your .vis and selecting 'Find', then 'Global References'.
    Hope I understood your question!
    Matt

  • How do I store VI References in global variables and access them later

    From what I know, Labview automatically deletes VI references when they go out of use. Is there a way for me to override this so that I can access a set of preloaded references in a separate VI? Essentially I would like to open the VI's dynamically into the memory, store the references in global variables and access them at a later time. The VI's I'm referencing won't be known until runtime. I know its not the safest way to do it, but it would be the most productive on my end.
    Thank you
    Clay Upton

    I'm not sure what you mean by "a later time", but a VI reference will remain valid as long as the VI is in memory. If you don't unload the VIs, the references will remain valid.
    If you do need to unload the VIs, for whatever reason, I would suggest the following:
    Create a functional global as your interface for obtaining the references.
    Feed the paths to the VIs into the VI when initializing it (since you don't know which VIs in advance).
    When calling the VI to obtain the references, have the VI check them first (using the Not a Number... primitive). If it sees that they're invalid, it can open a new reference and return that.
    You should note that when a VI is removed from memory, the data space is used is released, so if those VIs are expected to hold data (using shift registers, etc.) this will be a problem.
    The description I've given will only be usable in certain instances (and it has its intricacies), but you didn't really give any details about what you're actually trying to accomplish.
    Try to take over the world!

  • Dynamic call of a vi with a reference stored in a global variable

    Hello,
    I am trying to program a VI which calls DAQmx functions in some cases, in other cases DAQmx may not even be installed. To prevent a broken arrow on machines where DAQmx is not installed, I want to use a sub-VI containing the DAQmx function calls which is called dynamically by a main VI. For speed I want to prevent continuous opening and closing the VI reference, so I want to store the reference to the sub VI in a global variable. In this variable I also want to store the Analog Input Task. I want to use an initialization VI to write the VI reference of the sub VI and to configure and start the Analog Input Task and write the Task ID to that Global, too. In that way I was hoping to be able to improve the performance of the dynamic calls and the Task calls. BUT - when I write the refererence and task to the Global and read it out from another VI, the reference is not valid anymore and the Analog Input task is also not valid, even if both the initialization VI and the Global are still open (but not running). Does somebody have an idea how to solve that? It is a bit difficult to describe, so here is what I want to do in a shorter description :
    - run a initialization VI which
      defines a reference to a sub VI which will be called dynamically later on
      and a AI task ID definining a DAQmx physical channel configuration to use for subsequent read cycles
      and writes both (VI reference and AI task) to a global variable
    - run another VI which
      reads the VI reference of the VI to call dynamically from that global
      runs the corresponding VI dynamically
      the dynamically called VI performs an AI task corresponding to the DAQmx task ID read from that global (it reads an analog value for instance from the  
      physical channel configured by that AI task) 
    Why all that? To prevent creating and destroying the VI reference for each call of the sub VI for speed. And to use the configured DAQmx channel for subsequent read tasks only if the subVI is called dynamically - if it is not, then the application will not see the DAQmx calls and therefore no broken arrow will occur if no DAQmx is installed on the machine.
    Can somebody help me with this? Why can't I store and read out the reference to the sub VI to/from a global, and why is the AI task not valid when read out from the dynamically called sub VI? I am somewhat lost with all that...
    Thanks in advance,
    Gabs

    Uh - I am almost getting crazy with that
    Kevin, that solution is the right one for programming an application. In that case everything will work fine. But during testing, it is more convenient to call all VIs from their front panels one after another. That's how I'm doing it for everything that needs to be exchanged between such VIs: store them either in a global or in a functional global variable. In that way the user can "play around" with the VIs without wiring them together in a main VI. Therefore, after some thinking I liked Davids idea with that daemon VI (I solved that by adding a boolean in the initialization VI to choose if that daemon is necessary - during testing phase - or not - when using the VIs in a main application). BUT:
    David: It does not work!!! I have exactly done what you proposed and this daemon VI is really running, having a True/False frame with a constant of False wired to the selector and holding both the functional global and the dynamically to call VI in the True frame. In that way, after initialization is finished, both VIs are still running but idle. Anyway, when I read back the value of the reference or the DAQmx task, it is invalid again!
    That really costs just too much time. Does anybody have any idea what to do now? David, I was hoping that your suggestion would solve the problem, because it would be logical that it would - why then is LabVIEW destroying the reference and task anyway even if that daemon VI containing the functional global is still running???
    Regards,
    Gabs

  • Control references vs. global variables

    I guess my question centers on the appropriate application of control references.
    I am writing a complex program that has a state machine at the top level, and, for one frame of the state machine, a while loop containing a couple subVIs, each of which contains many subVIs. The lower-level subVIs are affected by buttons on the top-level VI. Information from the lower-level VIs must be shown on the top-level front panel within the loop. My question is: what is the best way to do this?
    (I have a previous version of the program that I wrote that keeps just about everything on the top level so that I can update the front panel, but this is not at all modular.
    In addition, I considered breaking things up into more than on
    e front panel, but this doesn't seem to be a good option for this section of this program.)
    Last week I read about control references, and decided that this could be the way to deal with this issue. I have not worked with them before, so I want to know: Are control references an appropriate solution for this issue? Is it good programming practice to use them, especially to update data on charts and graphs? How do they compare programming-wise and efficiency-wise to global variables?
    Global variables are another solution, I think, but I would have way too many variables to update. I think the advantage with global variables is that one could just insert a global variable in a subVI and not have to wire it up through the different subVI levels, which one would have to do (I think) with control references.
    Can you offer any advice?
    Thanks!

    Paul,
    The actual implementation of the solution is up to you. This is indeed a complex question.
    I would offer the following advice:
    On globals:
    Try to avoid them. I try to restrict the use of globals to unidirectional. If you have ever dealt with a race condition, you will know why. Mistakes are often made with globals, and they are quite apt to become the biggest source of bugs in a program, especially in one as large and/or complex as your appears to be. If you must use globals, try using a shift register, or LabVIEW 2 style global instead. Basically, you use an unitialized shift register with two (or more) cases: Read and Write. This prevents race conditions, but only if the VI is non reentrant. However, implementation is still difficult.
    Control References:
    I also have read and heard about control references. I have had much use for them, for controlling the appearance of controls and indicators (and decoratiopns too, I guess...). However, I would caution you on using them to pass data around. This violates dataflow in a big way, as you are passing around pointers, instead of data. I believe this is difficult to implement, and even more difficult to keep straight. I personally recommend using them only for attributes of FP components, not for passing data.
    So, what do I believe is the most elegant solution? I think a data server is your best bet. This is close to a LabVIEW 2 style global, but a little more active. Simply write all of your data into a subVI in any manner, a queue, a FIFO, LIFO, etc. Then, retrieve the data as desired. Buffering, queuing, etc are all handled by the data storage and retrieval subVI. It becomes sort of a small active database. The two sides (storage and retrieval) are independent of each other, and the code is all handled in the function. A basic version is a LIFO, Last In First Out, wherein the data is overwritten constantly. The data is then read by the reading VI, the front panel VI in your case, at any time, and the data is always the latest. You can add complexity as you need, such as making it a FIFO. This is done by simply writing the data to an array, then reading back the oldest value (by reversing the array and reading index 0.)
    I believe this is an elegant solution to your problem. It does maintain dataflow, except that time is taken out of the equation, depending on how you look at it. It simplifies your program because you only need to do three things. Write the data handler, then drop in the function into the VI that writes, and the one that reads. It is also flexible in handling the data.
    Good luck, and let us all know how you do.

  • Problem with .DLL and global variables

    Hi,
    I need some helps to figure out my problem.
    I wrote a .dll file to open and run a GUI. When I run it at the first time, it is ok. When I call it again, there is an error "Pointer to free memory passed to library. It will be ok if I completely exit the program that calls the .dll before re-call it. I think there is some problems with global variables when I call another thread. How can I free global variables between threads. Is there any solution for this problem?
    Thanks

    Vinh Pham:
    Are you doing anything intentionally that frees your globals?
    CVI ships with an example program that demonstrates calling a DLL to create a user interface: guidll.cws.
    I made two simple modifications to guidll.cws.
    1. In guidll.c, I made hpanel global by moving its declaration from RunDLLUI() to right below the #include statements.
    2. In useguidll.c, I duplicated the lines calling RunDLLUI () and MessagePopup() to call the DLL gui twice.
    I built the project and ran it.  I had no problems with free'ed globals.
    Take a look at the guidll example.
    Can you either post your code or a modification to guidll that demonstrates the problem you're having?

  • Problems in syncronyzing two threads into Test Stand using a Global Variable (TestStand 4.1.1)

    I have one thread that is doing TCPIP Aquisition into a Global variable defined in Teststand. And I have another thread that it supose to read it. All are in the same sequence and execution. The problem is that the aquisition thread got a lot of bytes, while the processing thread is reading always only a few. Do you know what the problem could be?
    I will attach also some pictures just to be maybe more clear...
    Attachments:
    Implementation_pictures.zip ‏368 KB

    I wasn't looking at your Sequence, I was looking at Receive_HDL_Block.JPG. What is that VI doing (the one with number 3 on the icon and Size_in_bytes as an input) ?
    Where in teststand are you doing any checking?
    I don't really understand your sequence.
    You have a sequence (running in a new thread) (why), following by another called Receiver Handler (also running in a new thread) then two more sequences which seem to do some with transmitting something (also running as new threads). You are only waiting on one of these threads (the Receiver Handler). There does seem to be any loops in TestStand, you dont seem to be bothered about the other threads that you have running. What happens when this test sequence finally does stop, what is stopping the Threads that you have running.
    Your pictures dont really seem to fit in with your Test Sequence, such as where does Test_005.vi fit into everything
    The whole thing is a bit of a nightmare.
    Maybe your best bet would be to scrap the lot and start again. Only this time have a better understanding of what you what to achieve, what would be best to put into Teststand and what to put into labview. Whether you really need all those new threads running.
    Sorry to be so blunt.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • How do you reference a created global variable in a report text field?

    I have created a parameter using the Globaldim statement in a script file. when I reference this parameter in any other script file during the current DIAdem session the value is passed without any issue.  Call the variable parmxyz where I assign it a value of 25.3 
    The help section under Globaldim mentions that global variables can be referenced in all panels, scripts, and dialogue boxes.  When I try to insert a text box on a report page using the @@parmxyz@@ it returns NOVALUE where I expect to see 25.3 (for example).
    When I substitute @@CurrDate@@ I do get the date, so I know the text box is valid.  What am I doing wrong?
    Steve    M 

    Hello Steve!
    It should work the way you did it. But their are some circumstances wich might prevent it:
    You have reseted the global script engine. All variables will be lost.
    You have a Sub with the same name in a command extension script. There is no warning ;-)
    One Test you can make is to put in '@@TypeName(paramxy)@@' as the expression to see the variable type. You can also try a realy unique variable name. The last option is to use ItemInfoGet to get detailed infos about your variable.
    Matthias
    Matthias Alleweldt
    Project Engineer / Projektingenieur
    Twigeater?  

  • Replacing 20 fixstatements by Global Variable - Problem 255 bytes length

    Hello,
    we have an issue in businessrules with setting the fix statement on 1 dimension:
    we currently use Fix (@RELATIVE("CBU_ALL",0) ) - on level 0 are approx. 3000 members - on medium level are 20 CBUs Seat and 20 CBUs Door
    we have approx. 20-30 similar businessrules - which either calculate on seat or door CBUs
    the requirement is to either calculate with a rule the 20 CBUs for Seats or the 20 CBUs for Doors
    as we currently do not fix properly on either Seat or Door CBUs, we calculate approx. 1500 empty members (empty, if fix in another dimension done correctly) - tests showed, that this doubles the time which would be needed.
    I know we could easily set 20 fixes in each business rule:
    @RELATIVE("CBU_BMW_Seat",0)
    ....20 more....
    @RELATIVE("CBU_Ford_Seat",0)
    (the fix above would then exclude the 1500 members, which are below:
    @RELATIVE("CBU_BMW_Doors",0)
    ....20 more....
    @RELATIVE("CBU_Ford_Doors",0)
    unfortunately, the number of CBUs/Customers is frequently renamed or some are added, so I can not afford to built these 20 fixstatements into 20 different businessrules and maintain them all the time.
    I thought of using UDAs or Attribute Values -
    but it seems not to be possible in a fixstatment to combine a relative or Children fixstatement with UDAs, which are set on the upper member ?
    I assume it works, if I classify all 3000 level 0 members with UDA or attribute SEATS or DOORS - but that's inefficient
    @RELATIVE("CBU_BMW_Seat",0) AND @UDA(CBU,"SEATS")
    @CHILDREN("CBU_BMW_Seat") AND @UDA(CBU,"SEATS")
    @Descendants("CBU_BMW_Seat") AND @UDA(CBU,"SEATS")
    @UDA(CBU,"SEATS")
    generally, it seems not to be allowed to combine Children or descendant fixes with any other relations or conditions ?
    @CHILDREN(@Match(CBU," Seat") ) (attempt to search for all children of all CBUs with Seat in its name)
    So the idea is to define 2 global variables:
    1 for Seats and 1 for Doors:
    [SEAT] includes then then: @children("CBU_BMW_Seat") ... 20 more @children("CBU_Ford_Seat")
    advantage would be, we can maintain the list of CBUs in 1 place
    my problem is: length of global variable is limited to 255 bytes - I need 800 to 900 digits to define the 20 CBUs
    having 8 global variables instead of 40 CBUs referenced in Fixstatements is not really an advantage
    even if I would rename the CBUs to just S1,S2,S3,S4 D1,D2,D3 (S for Seat, D for Door) (and use aliases in Planning and Reporting with full name to have the right meaning for the users), it does not fit into 1 variable: @children("S1"), @Children("S2"), ..... is simply too long (still 400 digits)
    also other attempts to make the statement shorter, failed:
    @children(@list("CBU_BMW_Seat","CBU_Ford_Seat",.....)) is not allowed
    is there any other idea of using global variables, makros, sequences ?
    is there a workaround to extend global variable limit ? we have release 9.3.1 - is this solved in future releases ?
    are there any other commands, which I can combine in clever way in fixstatements with
    @relative
    @children
    @descendants
    with things like @match @list ?
    (Generation and Level are no approrate criteria for Separating Seat and Doors, as the hierarchy is the same)
    please understand, that as we use this application for 5 years with a lot of historic data and it's a planning application with a lot of webforms and financial reports, and all the CBU members are stored members with calculated totals and access rights and setup data on upper members,
    I can not simply re-group the whole cbu structure and separate Seats and Doors just for calculation performance
    CBU dimension details is like this:
    Generation:
    1 CBU_ALL
    2 CBU_BMW
    3 CBU_BMW_Seat
    4 Product A
    4 Product B
    ..... hundreds more
    3 CBU_BMW_Door
    4 Product C
    4 Product D
    .... hundreds more
    2 CBU_Ford
    3 CBU_Ford_Seat
    4 Product E
    4 Product F
    .... hundreds more
    3 CBU_Ford_Doors
    4 Product G
    4 Product H
    .... hundreds more
    20 more CBUs with below 20 CBUs Seat and 20 CBUs Door

    How hard would it be to insert 2 children under CBU_All? Name them CBU_Seats and CBU_Doors, then group all the Seats and Doors under them.
    Then your calc could be @Relative(CBU_Doors, 0).
    I know it's not always easy or feasible to effect change to a hierarchy, but I just had the thought.
    Robert

  • How can I obtain a reference to a global variable?

    I wish to change the contents of the columns in a global multicolumn listbox. As far as I can see, the only way to access the columns in a multicolumn listbox is to create a reference to it and access the ItemNames property. But how can I create a reference to a to a global variable?

    You can open a reference to a global as if it is a normal VI and then get a reference to a control on that VI. I have included a little VI here with a test global variable to get the item names from an MCL in that global. I needed the MCL in the main program just to force the reference to a strict MCL reference. You could turn this into a sub VI that just returns the item names of a named MCL if that works better (then the MCL that's only used for reference would not be on your main front panel).
    This VI searches through all the names of the controls on the referenced VI until it finds the one that's asked for.
    Have fun with it.
    Rob
    Attachments:
    Get_Ref_to_MCL_in_Global.zip ‏158 KB

  • What is the difference between using a global variable,passing a valuee and using a reference?

    I have created a project that consists of several VIs.  Only the main VI has a front panel and the others perform functions.  The function VIs are dependent on controls on the main VI's front panel.  I have several ways of passing the value of the controls.  One is to use a global variable and just place it on the dependent VIs.  Another option is to strictly connect the terminal from the control to a VI connector block and pass the value directly.  My last option is to create a reference of the control and reference it inside the dependent VIs, but this would also require connections to be made to the VI block.
    What are the advantages/disadvantages of these options?
    -Stephen

    5thGen wrote:
    I have created a project that consists of several VIs.  Only the main VI has a front panel and the others perform functions.  The function VIs are dependent on controls on the main VI's front panel.  I have several ways of passing the value of the controls. 
    1) One is to use a global variable and just place it on the dependent VIs.
    2) Another option is to strictly connect the terminal from the control to a VI connector block and pass the value directly. 
    3) My last option is to create a reference of the control and reference it inside the dependent VIs, but this would also require connections to be made to the VI block.
    What are the advantages/disadvantages of these options?
    -Stephen
    1) Globals are evil and introduce race conditions.
    2) The sub-VI only get the value when it was called and updates that occur while the sub-VI is runing are not sensed by the sub-VI
    3) This uses property node "value" or "value signaling" both of which run the user interface thread which is single-threaded and you incur a thread swap hit to performance. You also have a potential for race conditions.
    The are various methods for sharing dat to/from sub-VI which include Queues and Action Engines.
    I hope that hleps,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Problem with view object for global variables

    Hi,
    I'm using jdeveloper 11.1.2.3.0
    We are using view object with transient attributes for global variables.
    we defined the view as explained here:
    http://docs.oracle.com/cd/E14571_01/web.1111/b31974/bcstatemgmt.htm#ADFFD19610
    also we defined one of the attributes as primary key.
    When we start to test our application with disable connection pooling we got some problems.
    sometimes the row in the global view object is deleted.
    (for example after using executeEmptyRowSet on other view object).
    it looks strange, we couldn't fוnd why does it happen.
    Any idea?

    As Timo said, it is very hard to help without source.
    Are you sure that you do the next step:
    After the call to super.prepareSession(), add code to create a new row in the transient view object and insert it into the view object.

  • Problems with global variable!!

    Hi!
    I am using some cluster (global variable), and certain fields in the cluster don't be updated.I can't understand where is the problem, because some fields are updated correctly and others no!!
    Any idea?
    Thanks in advanced!!
    Graci

    A functional global acts as a global variable in that it allows LV applications to access the data from different parts of the vi or from different vis for as long a LV is running. The vi is set to not be reentrant so that race conditions are avoided. Since functional globals are subvis that you write you also have the ability to store many global variables which are dependent upon only one input by performing the calculations within the functional global vi. You can certainly achieve this by using semaphores, but with functional globals this synchronization is built in.
    In the functional global vi you have a while loop which is set to stop after 1 iteration. This while loop has a shift register which holds the global data. There is a cas
    e structure to determine whether to read or write the functional global variable. In the write case the data from the input is written to the shift register on the right side. In the read case the data from the left shift register is written to the output and also passed on through to the right shift register. A good example can be found at the following link.
    http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3DB4956A4E034080020E74861&p_node=174821&p_submitted=N&p_rank=&p_answer=&p_source=External

  • Global variable problem

    hi all
    if i use this SELECT 'C' || mycodes.NEXTVAL INTO :ins2.code FROM DUAL; on pre-insert trigger so the global variable is not working for this field :ins2.code..
    but if i use on key-commit then working but i want to use on pre-insert
    here is my key-commit trigger codes
    begin
    SELECT 'C' || mycodes.NEXTVAL INTO :ins2.code FROM DUAL;
    if
    :ins2.name is not null
    then
    :global.name := :ins2.name;
    :global.code := :ins2.code;
    commit_form;
    end if;
    end;
    plz help me out thanks in advance
    sarah
    Edited by: SarahSarahSarah on Sep 7, 2009 6:41 AM

    Hi Sarah!
    The pre-insert trigger fires just when you call the commit_form build-in.
    So :ins2.code and :ins2.name are still null when you try to assign the values to the globals.
    Put the code inside the pre-insert trigger direct after the sequence-select.
    if
      :ins2.name is not null
    then
      :global.name := :ins2.name;
      :global.code := :ins2.code;
    end if;
    end;and the key-commit trigger:
    if
      :ins2.name is not null
    then
    commit_form;
    end if;
    end;or assign the values to the globals after the call to the commit_form build-in:
    if
      :ins2.name is not null
    then
      commit_form;
      :global.name := :ins2.name;
      :global.code := :ins2.code;
    end if;
    end;Regards
    Edited by: Magoo on 07.09.2009 13:47

Maybe you are looking for

  • Every page I open is tiny, every time I open it, How can I make tham ALL bigger all the time

    I installed FF4, and now the all the web pages I visit must be zoomed in, each and every time I visit them. I reinstalled FF3.16, and now I've got the same problem with it. Man this really sucks, as before I could actually use this browser fairly eas

  • Smart form-table header-box

    Moved to correct forum by moderator Hello All, in my smartform iam displaying the data by looping a table. i ahve put a header inside loop. and for each new sales order , ia m going explicitly to new page, and when more number of items are there, tha

  • How to load an XML file to oracle9i server?

    I want to use XSU DBMS_XMLsave package to load an XML file to a relational table using PL/SQL from a distant server. Now, I don't know how to load that XML file to the distant server. Somebody help me?

  • How do I prevent AVG Secure Search from reinstalling itself. (I've uninstalled it twice so far).

    I accidentally downloaded the AVG Secure Search toolbar. I uninstalled it, but it reinstalled itself. I looked online for solutions to this problem, and multiple people have encountered it. However, none of them had a solution. How do I prevent this

  • B2B communication using PI

    Hi all, I want to know what exactly is the meaning of B2B communication and A2A communication.How are both of them different? How exactly does the concept of "Party" help to establish B2B communication. Many Thanks, Neha