Shared Variable Alias vs Programmatic Assignment, which is better?

Hello,
I am programming an application for a cRIO platform using the scan engine in LV2009SP1.  I'd like to use the cRIO as a standalone controller, and only connect a computer to it occasionally to download data.  I decided to do this using shared variables.  So far I've been successful at doing this in two ways, both involved creating nearly identical sets of shared variables on the cRIO and on the PC, which I think (correct me if I'm wrong) I understand is the way it should be done.  The differences are the following:
The first method was to create a parallel loop on the RT VI which would assign the values passed through the shared variables to the individual I/O channels.
The second method was to Enable Aliasing on each shared variable and bind it to the appropriate I/O channel.
After deploying the RT code to the cRIO for each case and running the UI on the PC, I noticed that both worked, however, the second method showed a short lag between command and feedback (~200ms or so).  The test I ran was to wire an analog output to an analog input, command the AO, and read back the value on the AI.  I can deal with the delay on the UI since it's only for reference - what I'm really interested in is the data that's logged on the cRIO controller.  My question is:  Is one of the two methods better or more appropriate than the other?  Is there something even better?
Thanks,
-NS

No Substitute wrote:
I decided to do this using shared variables.  So far I've been successful at doing this in two ways, both involved creating nearly identical sets of shared variables on the cRIO and on the PC, which I think (correct me if I'm wrong) I understand is the way it should be done.
Hi NS,
No correction necessary.  These are both valid ways of sharing data between your Real-Time controller and your PC.  Here's a forum that discusses some similar options to accomplish the same task (
Shared variable architecture for distributed crio system)
Regarding the latency issue with method 2, take a look at KnowledgeBase: Why Is Accessing IO Variables Through The Shared Variable Interface So Slow?
I hope this helps!
- Greg J
Why Is Accessing IO Variables Through The Shared Variable Interface So Slow?

Similar Messages

  • Labview on Shared Variable

    Hi,
    In our application we want share the some IO's in Tablet PC(remote PC) and HOST PC.
    We are using real time controller in our application.
    For this purpose we have create shared variables in *.lvproj. While we craeting shared variables we can not assign DATA type as a cluster of different elements to the shared variables.
    Due to this we created *.ctl file of that cluster and then tried to assign the same cluster to the particular shared variable.
    There are nuamber of shared variables in this application with different cluster of elements.The problem is that the same *.ctl file assign to two different shared varialbles which we not required. Because we have created different *.ctl files for two different shared variables.
    Is our apporach is right?
    Can we use *.ctl file as a data type as cluster of different elements for shared variable?
    Please suggest ....
    Thanks in advance

    I believe your approach is correct.
    Share Variables use the data type. So if you have a number of controls with the same type of cluster, e.g. Cluster1 is String & Numeric, Cluster2 is String and Numeric, then when you assign the Shared Variable to Cluster2 it will be identified as Cluster1.
    This is a reported bug in shared variables.
    One workaround would be to change the data type e.g. Numeric in Cluster1 may be INT16 while Numeric in Cluster2 may be INT32.
    Then the Shared Var's will identify them as different data types.
    DOK

  • Why should you explicitly open and close shared variable connections?

    I'm looking into switching over from the old Datasocket API to the new Shared Variable API for programmatic access to shared variables, and I noticed that LV doesn't seem to have any problems executing Shared Variable Reads & Writes without first opening the connection explicitly. That is, I can just drop in a shared varaible Read VI, wire a constant to the refnum input, and it will work. I'm wondering, then, what benefits are offered by explicitly opening the conenction ahead of time...?
    I guess I could see some cases where you want to open all necessary connections in an initialization state of a top-level state machine, particularly if you want to use the "Open & Verify Connection"---so you could jump straight to an error case if any connections fail. But other than that, why else might one want to explicitly open the connections.
    And, along those lines, are there any problems with implicitly opening the connections? One reason why I am hesitant to open them explicitly is because for one of our applications, we need to be able to dynamically switch from one variable to another at runtime. It would be nice to just switch the variable refnum (wired to the input of the Read function), without having to manually close out the old connection and open a new one. A quick prototype of this seems to work. But am I shooting myself in the foot by doing so?
    Thanks in advance.

    I'd expect there's a very small number of people at NI that would know the answer to the detail you're asking for.  But, let's try to extrapolate from this rather old post to see if we can understand what they're forming their impression on.
    The shared variable has to have some sort of reference going on in the background.  It looks like they're calling this a connection.  It's how LabVIEW knows where to find this variable on the network.  We can also see this reference certainly exists if we're opening/closing the reference in the explicit method.  You see the connection as just a string referencing the variable by URL.  This "reference" has to be stored somewhere.  No matter how we're looking at this, we're aware there's a reference of some sort stored. 
    Now, we'd want to look at what would cause this reference to go away.  If you open/close explicitly, it's easy to see it goes away at the close.  If it's implicit, when would it make sense to close it out?  The VI can't be expected to guess where it's done being referenced and close it out.  This puts us into a situation where the soonest it could close is when the VI ends.  From my experience, references tend to be wiped when you close out LabVIEW.  It's this kind of idea that makes the FGV possible.  I wouldn't be surprised by Morgan's claim here.
    If we look at scalability, you're talking about two different topics.  You're talking about adding an extra open, close, read, etc rather than just a few wires.  That certainly would look a mess.  In terms of the dynamic swap that was being discussed, we wouldn't be adding all of those.  The concern would be if enough connections were opened it'd start to behave similar to a memory leak.  This could be something that works with a smaller number of variables.  If you continue to scale, it becomes problematic.  This is why they suggest it's not scalable. 
    To your questions:
    Does LV allocate some kind of session in memory using that string as a lookup?
    It would HAVE to allocate some memory to hold that string.  Otherwise, it'd be pointless to even have the reference. 
    Does it reuse that session if other parts of the application reference the same variable, or does it create a unique session for each referencing call to "Read Variable.vi"?
    I would expect this to be "it depends."  With the implicit method, I would expect it to open a new reference in each point it isn't wired.  This is similar to int x,y = 5;  x and y share the same value but are their own unique memory location.  If you wire the reference to the other points, it should use the same reference.  This would make more sense to me than the program seeking out any other potential usage of the variable in the application to see if there's already a reference open.  I could be wrong, though.
    And what resources does this "connection" actually represent?
    At best, this is just the string.  At worst, it's the string and the TCP socket.  I'd lean towards the first.  Opening and closing sockets should be relatively easy in most applications.  But, it also wouldn't surprise me if it holds the socket.
    I'm sure others have a better understanding than I do.  But, that's what I'd expect for anything you've asked.

  • Using shared variable not in the project.

    hi all
    I have a project with the 2 RT targets and the development PC which were i currently deploy all my shared variables, But I need to finally deploy these shared variable in a different stand alone windows based machine. To do this I created separate application which does nothing but deploys the shared variables in this PC. but when i tried to bind to this variables (frount panel binding) from my RT targets it woudnt work, the led does not glow, it is always transperent. but when I tried to connect to these variables from my development PC it works fine. I double checked the firewall problem, that is not the case here. Can anyone tell me what am i doing wrong?
    Thanx
    Arun

    Hi Prashanth
    Thanks for the reply. I did realize that the front panle connection would not be supported in RT, now i have the shared variables on my RT machine which has te source as the windows machine. If the windows machine is my development machine the shared variables connect fine, but if its a different PC the shared variables connect for few seconds and with the error info "shared variable value 0" then the connection gets disconnected.
    Also i read a note in the shared variables help, it said to subscribe and publish on a network shared variable all the shared variable which connects to this variable should be active. does this mean that if there are 2 RT targets that subscribe data and one of them is not switched on the shared variable does not work.?
    Thanks again for your support.
    Regards
    Arun

  • Difference between Shared Variable Refnum and Control

    Dabbing my toes in Shared Variables for another project.  Glad to see A LOT more support from NI in terms of Shared Variables (especially now that built executables can be set to automatically deploy shared variable libraries...thats a big help).
    In the Shared Variable block diagram palette (under Data Communication) there are a number of VIs that can be used to progmatically access and consume shared variables.  Awesome.  One thing that I have noticed is there is a difference between a "Shared Variable Control" (from the I/O front panel palette) and the "Shared Variable Refnum In" that you obtain from right-clicking one of the VIs from the Shared Variable palette and selected "Create Control".
    My first thought was that these two were one and the same, but they are not.  Visually they look different:
    Also, the reference input to the VIs in the Shared Variable palette only take the "shared variable refnum" control as input.  The control from the "I/O" palette does not work.
    This wouldn't be much of a problem, but I prefer the look of the Silver Shared Variable Control much more to the control I get from the "Create->Control".  Also, the variable browser in the Shared Variable Control is A LOT nicer than the control refnum gives me.
    Here is the Shared Variable refnum variable browser:
    Here is the much nicer looking browser that pops up from the Shared Variable Control:
    So I guess my questions are:
    Why are there two reference data types that seemingly perform the same function but are incompatible with one another in LabVIEW?
    How can I use the Shared Variable Control with the Shared Variable palette VIs?
    Thanks for your input.

    Hello Nickerbocker,
    You actually want to use the Shared Variable Control in the context of Alarms, I/O Servers and other categories inside the DSC Module. Like you already saw, to use the basic functionality of a Shared Variable, such as programmatically reading / writing to it, you need to use a refnum.
    Regards,
    Daniel REDS
    RF Systems Engineer
    Help us grow.
    If a post solves your question, mark it as The Solution.
    If a post helps, give Kudos to it.

  • Does OPC UA Shared Variable Server support Alarm&Event and historical access?

    OPC UA Shared Variable Server is a sample code and resides at https://decibel.ni.com/content/docs/DOC-25602
    It seems to support DSC <-> OPC-UA tag synchronization.
    But does it support alarm&event and historical access?
    I tried to open it with LabVIEW 2012, but lots of VIs were missing in the code, and I am not familiar with DSC and OPC-UA.

    Hi iCat,
    From your post on the example itself, a colleague of mine responded with: "This uses the OPC UA server included in DSC 2011 SP1 which does not include direct support for Alarms and Events. However you could use this idea to synchronize to shared variables on a Windows host which could have those abilities enabled."
    So it looks like it doesn't directly do this.
    Matt S.
    Industrial Communications Product Support Engineer
    National Instruments

  • LVE / OPC / Shared Variable / LV 8.0 & 8.2

    I try to communicate with an OPC Client having problems...
    There are two ways to do that:
    First way:
    Simply create a shared variable in my project file which I can use per drag & drop after deploying it. The shared variable uses the Labview Variable Engine (LVE) and the NI-PS-Protocol. If I have read it correctly, these shared variables can also be OPC items. And yes, it works but limited.
    Second way:
    Each control / indicator has a data binding tab under properties. There I can select data socket and pass manually the OPC protocoll reference (e.g. opc://localhost/National Instruments.Variable Engine/\\.\test\SGL Array) which is not very comfortable but it works unlimited.
    Is problem is that the second way works fine for Labview 8.0 and 8.2 but the first way works in a curios manner on Labview 8.0.
    That means:  In labview 8.0 I can use the shared variables as OPC items without problems but only for non-array data types. Each array type (SGL,DBL, Waveform,...) does not work. We used the shared variables as simple OPC items a long time and now intented to add an array realizing that it does not work. Than someone told us to install DSC Modul wich adds the OPC functionallity to LabView, seeming to solve the problem.
    The remaining fact is that LabView 8.2 has no need for the addionally OPC functionally of the DSC Modul. Way 1 and 2 works without problems in 8.2.
    Ok, we have an unlimited license of using LabView in all versions and with all toolkits. But we want to use LabView 8.0, because our vis are programmed there and we do not to intend and vesion upgrade.
    If there is no solution here, we can use way to, but I am really interested, why shared variable arrays are not supporting OPC compatibility while non-array data types do.
    THX for an answer, best regards from Berlin

    Please refer to that thread http://forums.ni.com/ni/board/message?board.id=170&message.id=76313&view=by_date_ascending&page=1 for further information.

  • How to add a new Shared Variable programmatically to an existing and deployed library?

    Hi there!
    I am trying to accomplish this on both LabVIEW 8.6 and LabVIEW 2010 and seems like it's not any different in this situation.
    My case: A project has a library with 4 Shared Variables (SVs). The library and the variables are deployed (visible in Distributed System Manager 8.6/2010). I want to add 2 more variables into this library. It is possible to do this manually from Project Explorer window's options menu. But while running an application it has to be done programmatically. Can I provide the library reference to the one currently existing without creating a new one?
    "Create Or Add Library To Project" function in the Datalogging and Supervisory Control (DSC) toolkit does not help in this case. That function, as the name suggests, just tries to create a new library in the project.
    Two possible methods:
    The function "Add Shared Variable To Library" (DSC>EngineControl>Libraries & Processes) needs a library reference, which could be provided via "CreateOrAddLibraryToProject" function, but this function tries to create a new library, and if I provide the path of the existing library it throws an exception that the library already exists in the project (yes, as I wrote above, I need to add new variables to an existing and deployed library).
    OR
    The function "Create Shared Variable" (DSC>EngineControl>Variables & I/O Servers) will add Shared Variable in a process, and not physically in a library file, and the problem (limitation) with this approach is that it doesn't allow to add complex data type Shared Variables (for example in LabVIEW 8.6 it has only 4 datatype options in input parameter, and even in LV2010 it does not have "Image" datatype that I need).
    The scond method is my preferred method as it allows to work on Online Shared Variables and doesn't create them physically in libraries (and this is good as the variables' scope remains only till the Variable Engine is running). But it doesn't support advanced data types, and the first method is powerful in terms that it supports to virtually any datatype, it just seems tricky to get that reference to the library.
    Any tips?
    Thanks ahead!
    Vaibhav

       <<<<>>>>   
    As the above two images show, while a library does not exist, it is easy to use the "CreateOrAddLibraryToProject.vi" which will add a new library to the project (if it doesn't exist on file system, a new library will be created) and that way, using the reference (the green wire going out from the function and the Case Structure, can be used to add Shared Variables to the library. The problem was what to do when a library already exists in the project, how to add more variables to it. I was looking for a way to get a library reference, and somehow I could not see it inside a Project's property (VI Server functions). Hence I posted the question. And upon continuing my search, I found it on the Application's property list.
    I hope it was useful for someone else as well. And thanks for the replies. Please share a better idea if you have.
    Vaibhav

  • CRIO and ni 9234 modules not working or communicating through fpga with accelerometers, fpga connected to real time application which is also connected to shared variables linked to modbus slave

    Hi,
    I have a compact rio which has a 4 way chassis attached to that chassis is three ni9234 modules they are linked using fpga to a real time application then using shared variables in the low speed loop that are linked to a modbus slave to communicate with dcs, the ni 9234's have accelerometers connected to them with iepe ac coupled option on the c modules, my problem is the real time application seems to be running okay even when power loss occurs it restarts with no problem and the fpga writes to the portable hard drive bin files fine but without a accelerometer connected I get low noise readings as soon as I connect a accelerometer to any one of the 10 outputs it just goes to a fixed number (0.03125) as soon as disconnect it again it reverts back to reading noise, I have run a scan on the modules and only get a spike when I connect or disconnect the accelerometer, I have tested the voltage at the pins of the module and I get 22 volts dc which makes it more likely that the hardware is not the problem but a software is maybe causing this to hang-up, I attach project and files for your perusal. I also carried out a new project which in scan mode directly linked the module input to shared variable and the same scenerio again. Help would be much appretiated. 
    Many thanks
    Jason
    Solved!
    Go to Solution.
    Attachments:
    logger 2plusmodbus2.zip ‏679 KB

    Whren using waveform acquisition with the 9234s we recommend the following FPGA and RT template.
    http://sine.ni.com/nips/cds/view/p/lang/en/nid/209114
    it can be extended as a data logger with:
    http://zone.ni.com/devzone/cda/epd/p/id/6388
    or using shared variables combined with scan engine
    http://zone.ni.com/devzone/cda/tut/p/id/9851
    The FPGA in all of these, as well as the RT framework have been used successfully by 1000s of users.  I would recommend giving these a try. 
    Preston Johnson
    Principal Sales Engineer
    Condition Monitoring Systems
    Vibration Analyst III - www.vibinst.org, www.mobiusinstitute.com
    National Instruments
    [email protected]
    www.ni.com/mcm
    www.ni.com/soundandvibration
    www.ni.com/biganalogdata
    512-683-5444

  • Error programmatically deploying shared variable lvlib from an installed app

    I'm using shared variables in my app.  According to what I've read, I need to deploy the lib programmatically using the app invoke node deploy library.  I do this and it works fine for the app exe on my machine.  But then I created an installer and tried it on a "virgin" machine and I get a "error 1 at invoke node" saying "an input parameter is invalid."  I added an indicator that shows the lib file path I'm using and it's fine.  I had left the target IP addr unwired but I also tried 127.0.0.1 just in case.  Any ideas what's going wrong here?

    Hi:
    If including the SVE installer didn't resolve the issue then it looks like there are some other possibilities that are discussed in the following forum threads.  Not sure if you've seen these yet, but hopefully they will help.
    http://forums.ni.com/ni/board/message?board.id=170&message.id=240865
    http://forums.ni.com/ni/board/message?board.id=170&message.id=230033
    http://forums.ni.com/ni/board/message?board.id=170&message.id=249345
    Message Edited by A Person on 03-23-2009 02:40 PM
    Message Edited by A Person on 03-23-2009 02:40 PM
    Alex Person
    NI-RIO Product Support Engineer
    National Instruments

  • Programmat​ically redirect shared variables

    I can programmatically change the data binding for a shared variable from (from on RT target to another) using method 1 as described here:
    http://digital.ni.com/public.nsf/allkb/2E8BAD0EA21​8A7558625712E0003F044
    However the change is only associated locally with the current VI, if I restart the VI or access the shared variable from a different VI it returns to the initial data binding as defined in the variable library.  I have to change the binding each time a start a VI.
    Is there a way to programmatically change the data binding in such a way that the change is persistent and shared between vi's?

    Hi PESobol,
    when you want to store changes you actually need to store them!
    You can access shared variables programmatically using functions like "Open Variable connection". So you could load a text file with descriptions of your shared variables and connect to such a variable based on information of the text file. For me that seems like a better way of configuration than having to change and save VIs all the time…
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Data Logging a programmatically created shared variable of cluster or array datatype into citadel DB

    Hi,
    Is there a way to log a programmatically created shared variable of cluster or array datatype into citadel DB?
    I have attempted to programmatically create a shared variable of type 'double' and was able to successfully log the same into Citadel DB. In the attachment, Please refer to the attached project SV_TC.lvproj and specifically to SV_W.vi for the code that i have used (W.png file shows the dB in MAX and shared variable in NI Distributed System Manager)
    However when i tried the same approach to create a shared variable 'array of double', i noticed that traces are not getting created and hence data logging isn't happening into the Citadel DB. I was however able to write and read the shared variable array without issues. The same is true with cluster datatype also. Please refer to SN_NW.vi for the code that i have used - only difference from SV_W.vi is that i have tried to create a shared variable of type 'array of double'
    One observation is that if i create an 'array of double' or cluster in a shared variable library using the project explorer and deploy, i could see that these being logged into Citadel DB.
    Hence i want to understand what could be done to achieve the same programmatically? Could you please advice?
    Regards,
    Sridhar
    Attachments:
    SV_TC.zip ‏3925 KB

    Why is the transaction happening over remote?
    Because we need the information to be on our database immediately when they submit it.
    I don't know anything about streams or replication.....
    The web database is run by the company that hosts our web site. We use PL/SQL to show the pages and output the html. It fetches the data the customer is requesting from our database, but I'm struggling to get the best way to insert into our database from there.

  • Which computer sets the time stamp of a shared variable?

    Which computer sets the time stamp of a shared variable? The computer that hosts the variable or the computer writing the variable?
    (This is important when the system clocks differ.)
    Greetings,
    shb
    Solved!
    Go to Solution.

    Good Question - I have only one use case which is similiar...
    I have a cRIO which hosts a NSV library which is bound to a mirror library on the PC.  The PC library
    is set to log to a Citadel DB.  When my cRIO RT software writes values to the NSV the timestamp is created
    at the instant the write occurs using the RT system clock (which incidentally is sync'd to GPS time).  This timestamp is preverved all
    the way up to the PC and the Citadel DB.

  • Programmatically deploying WSN node shared variables

    I'm working on a WSN network composed by one WSN9791 gateway, eight WSN3202 programmable remote nodes and one PC with LabView.2013. The nodes are programmed to get some voltage readings and store them in shared variables. My main application is running on a PC, it basically reads the global variables values and performs other processing.
    Before running the main application I give the command "Deploy All" by right-clicking on the gateway name. I can do the same by right-clicking on each node and selecting "Deploy".
    Some weeks ago, due to a thunderstorm, the power to the entire system was lost and, after automatic restart, my application was no longer able to contact the shared variables and I had to manually repeat the "Deploy" sequence.
    My question is: "is there any way to programmatically deploy/undeploy shared variables"?
    Note that in my application I access the nodes shared variables by opening a connection to the variable and then reading its value (see attachment 1) instead of using explicit connections to variables (see attachment 2).

    Hi,
    this is done on your block diagram using an Invoke Node. Go to your functions palette on your block diagram and go to Programming>>Application>>Invoke Node. Then left-click the Method of the Invoke Node and go to Library and select the desired command. It is important to note that you cannot deploy single variables at a time, you can only deploy variable libraries at a time. 
    I also think that the following article will help you understand better the process of using shared variables in LabVIEW. I referenced it while I was researching your questions. 
    Using the LabVIEW Shared Variable: http://www.ni.com/white-paper/4679/en

  • Re: shared variable: create programmatically then read/write

    I programatically create and destroy Shared Variables using these subVIs (see enclose llb file for Add Variable Connection.vi and Delete Variable Connection.vi).  But it seems to take a long time to run each subVI.  This might be tolerable for a single Shared Variable, but it gets rather lengthy if several need to be created or destroyed.  The user specifies how many depending on how they are using the application.  Is there a more efficient way of doing this?
    Also, after a Share Variable is "created," it can take a while before it is usable for reading and writing in another part of the application.  Is there a way to determine a Share Variable is ready prior to using Search Variable Container and Open Variable Connection functions to find and use it?

    Ummm, nothing attached. Also mention, when you do post, what version so that people won't waste time downloading when they don't have the appropriate version installed.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

Maybe you are looking for

  • New Mac Pro 2.8 and Problems with Aperture

    Hi, I just bought a new Mac Pro 2.8 with the standard 2GB of RAM. My main application is Aperture. Since I loaded it and pointed to my library, the system runs *very* slow when I am in Aperture. I get a lot of spinning wheels for everything I do ...

  • ACNS design/setup

    Hello everyone, I've just started learning ACNS and I'm a bit confused about some of the setup/design options. I'm just reviewing the documentation and do not have the kit yet so I can't try things out the moment. This is what I have found out so far

  • How to create multiple idocs based on complex condition

    HI Users, my scenario is jms(xml file) to idoc. for each file have multiple records for each record i need to create multiple idocs. source structure: <lineitem> <student sid="cid">456</student> <hreference> <reference rtype="number">123</reference>

  • UD complete without valuation

    Hi All, I am having a unique problem with one of the Inspection lot created with 04 type using MFBF UD status shows UD   ICCO SPCO , but the Inspection lot valuation in the usage decision tab is blank Stock posting is not completed When i try to use

  • Passing variable of 'DynamicParameter' to a SAPGUI Iview using ApplicationP

    Hi all, We are calling a R/3 Transaction QM03 within an IView in the Portal which works fine. Now, we also want to call this QM03 Iview from a URL in the PCUI screens. Since the PCUI framework passes all required info through the 'DynamicParameter',