Multiple use of a shared variable - buffers?

 Hi all,
I have an application on a RT target that measured data (around 60 variables stored in a big cluster) in a TCL, sends it via RT-FIFO
(a modified U8-Array buffer that contains the data converted into string and then flattened to U8-Array) to the NTCL which then
writes the data to a file and sends it via TCP/IP to the user interface on a PC.
This is slow. I know that strings should be avoided on RT and especially extensive formatting of variables into strings. I want to
switch over to shared variables now and write files on the PC only.
Problem: I need the data on the RT target as well for control purposes (PID regulation of a cooling system). Can I read the same shared
variable twice, once in the control sub-vi and once on the PC? How does that affect the buffeing of the shared varaible. Does each
"subscriber" gets its own read buffer?
Or should I use a global variable (this will again be a 60 element cluster) on the RT for communication between the read-data-vi, the
control-vi and the send-shared-variable-to-host PC-vi. As I've read, big global variables should be avoided as well on RT-systems.
Or can I use a queue instead of the global variable for the data-cluster? 
Cheers,
Olaf

Hey,
Transfering data from a TCL to a NPL (Normal Priority Loop) via RT FIFOs and then via TCP/IP to a Host System has a better performance then a shared variable.
So using shared variables instead of your actual architecture wont result in a better performance. I would suggest to optimize your code.
According to the shared variables behaviour: yes, you can read it at your Host and the RT System at the same time without loosing data when configured as RT FIFO.
Christian

Similar Messages

  • Modbus Ethernet read and write to a Eurotherm 6180XIO Modbus server using LV8.2 shared variables

    I am having EXTREME difficulty trying to establish communications with a Modbus device using LV8.2 shared variables.  The device is a Eurotherm 6180XIO Datalogger configured as a Modbus master.  The PC and a cFP-1804 are slaves.  All IP addresses are set correctly.  This approach using shared variables would seem simple, but I can't find any examples or proper guidance on how to get it working.  I am trying to avoid having to mess around with TCP/IP, OPC, or any other old-fashioned method.
    I have read many threads on related topics but none directly apply to this situation.  I have created a library containing a Modbus I/O server and shared variables bound to read and write holding registers.  I have followed all recommended tips for creating such variables but I can neither read or write data.  All data types are U16 due to Modbus protocol limitations.  I have also applied the LV x10 factor in the most significant digit in the register offset (6 digits instead of 5).
    I have a cFP-1804 on the same network which reads into the datalogger OK.  The registers I use are 31000 (for CH0 on module 0, 31002 for CH1, etc) and the data can be read as FLOAT32.  I have updated the firmwate on the 1804 to the latest level.  I cannot even get shared variables to read SGL values.  Using registers 301001 for CH0 and 301002 for CH1 I can only read U16 values, and not a 2-word SGL.
    Third party Modbus simulation software is able to write to and read from registers very easily, but not LabVIEW.
    Some questions are:
    - do I use a Modbus master or slave as an I/O server in the library as a target for binding the shared variables?
    - is there some other wierd translation in register offsets between LabVIEW and traditional Modbus?
    - is this actually possible using shared variables or am I wasting my time?

    Sending the whole 60-character string using a string or array would be the most efficient.  I have tried both methods, and these only cause the datalogger to flag a message log but no text is displayed.
    For a string variable, I have used the following binding "My Computer\Modbus Test.lvlib\ModbusServer6180\442305", where ModbusServer6180 is a Modbus I/O server configured with the logger IP address, and 42304 is the register offset at the start of the text block in the logger.  I need to write to 30 consecutive registers starting with this one.  I am not using buffering and have not enabled single writer.
    Can anyone confirm whether this method should work in 8.2?
    Does the string need a special termination character?

  • Is it necessary to use semaphores with shared variables

    is it ok to use semaphores with shared variables to prevent race conditions or is that built into the shared variable?
    - James
    Using LV 2012 on Windows 7 64 bit

    Semaphores are more of a method to protect a section of code from executing, and as tst as said they won't really help you.  There is nothing inherently harmful about having 2 sections of code trying to write to a shared variable at the same time.  Nothing like a crashed program, scrambled value, or an error message.  What will happen is that whatever happens 2nd is the value that sticks.  So a shared variable can still have the possiblility of race conditions just like local and global variables if you are dealing with multiple writers.  That is really an architecture problem.

  • Using TCP or shared variable for data transfer

    I am trying to send a large amount of numbers from a real-time module to a host computer.  These numbers have been arranged into a large array, such as an array with 10s of thousands of points.  The time critical portion of getting the information has already been done, so the data transfer back to the host VI is not time critical.  I know I will need to break the large array down into smaller arrays and then reform the large array after all the information has been sent.  I know how to use both TCP and shared variables with FIFO.  What I am unsure of is which one is better to use for this application.  I do not know what the maximum size arrays I can send through either.
    Also, from what I have gathered from using LabView is that the sender has to be listening for a connection before the client opens a connection, or else it will throw an error.  When I tried breaking it down into 50 points, if i did not wait long enough in the host VI or if I did not put a long enough wait function in the RT loop, and error would throw, so it would take a long time to transfer the data when it worked properly.
    Any help or suggestions is appreciated, thanks.

    Regarding the array size question, there is no real limit (other then the amount of memory in your system) to the size of data that you can transfer in a single block using either TCP or the Shared Variable. In your case you can easily transfer an array with 10's of thousands of data points in a single write operation. Both TCP and the Shared Variable will automatically handle breaking up the data for the maximum packet size on Ethernet and then reconstitute the array on the receiving end. In LabVIEW you will simply get back the array as a whole without needing to worrying about how the data is broken into smaller packets on the Ethernet.
    I tested the attached example which transfers 400kB per block (50000 Doubles) without any problems. You do need to have the Server (in this case RT) running first before the client (Windows) can connect.
    Message Edited by Christian L on 02-09-2007 11:34 AM
    Christian Loew, CLA
    Principal Systems Engineer, National Instruments
    Please tip your answer providers with kudos.
    Any attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system,
    or for use in hazardous environments. You assume all risks for use of the Code and use of the Code is subject
    to the Sample Code License Terms which can be found at: http://ni.com/samplecodelicense
    Attachments:
    TCP.JPG ‏44 KB

  • How to use the "Get Shared Variable List" VI on an RT target?

    Hello,
    I'd like to programatically iterate through all the shared variables in a library hosted on my CompactRIO. I dropped the "Get Shared Variable List" VI into my Real-Time VI, but when I tried deploying it, LabVIEW said
    Deploying PRC_GetVarList.viPRC_GetVarList.vi loaded with errors on the target and was closed.
    LabVIEW: Failed to load shared library dscProc.dll:ni_lvdsc_process_GetTagListEnd:C. Ensure that the library is present on the RT target. Use MAX to install NI software or FTP to transfer custom libraries to the RT target.
    LabVIEW: Failed to load shared library dscProc.dll:ni_lvdsc_process_GetTagListBegin:C. Ensure that the library is present on the RT target. Use MAX to install NI software or FTP to transfer custom libraries to the RT target.
    I looked at the MAX Software Wizard, but couldn't find any DSC-related modules. Where should I be looking?
    Thanks!
    Solved!
    Go to Solution.

    Hello,
    The DSC palette is not supported on Real-Time VIs and will lead to errors when deployed.  Unfortunately, to have a successful build you will need to modify your application and remove any of the VIs from the DSC palette on your RT Target.
    Regards,
    M. Whitaker
    ni.com/support

  • Error -195067903​5 When Using the LabVIEW Shared Variable

    While communication of PLC & labview 2014 SP1 via modbus ethernet I am getting continuously Error -1950679035 as per attachment.
    Also distribution manager system is not responding while expanding of shared variable library. And it is not showing list of variable.
    Please share some solution.
    Attachments:
    error.png ‏263 KB

    If the Distributed System Manager isn't running, then something is seriously wrong!  Has it ever worked?  Have you ever had a successful deployment of Shared Variables?  Have you recently installed a new version or updated LabVIEW?  These questions are designed to see if something "broke", or possibly never worked in the first place ...
    Bob Schor

  • Communicating Between Multiple LabVIEW Executables on different computer using Shared Variables

    hi,
    I need to develop some executables which will be launched on different computer of a LAN. Some DATA are common. I need to share the data using shared variables.
    I usually used LabVIEW so I 'm familiar with shared variables but in this case, the RT target is a part of my
    project.
    I do I need to procceed in my case?
    thanks

    Ok but it's not my configuration and I haven't found my answer in the tutorial.
    You speak of a case where there is a computer and a RT target under the same LabView project. As I said earlier, I often use labview RT and shared variable between computer and RT target. But I assume here it's different.
    My question is : how do you acces to the SVE from 3 computers (without any RT target)? 
    1. If I create 3 labview projects using the same Shared Variable, do I need to use the same .lvlib on each project?
    2. Is it possible? 
    3. How can I configure where the SVE should be? When I use a RT target, It only depends where I put my Lvlib. But here there is 3 projects. 
    James
    Attachments:
    Sans titre.JPG ‏9 KB

  • Using Shared Variables and Initialize Front Panel Binding (to PSP)

    Hi,
    I use LV DSC RT 8.2.1
    I have a Vacuum System That includes signals from - Pumps failure, Valves status, Vacuum gauge, start Pump ...
    Each signal is read by a FieldPoint. 
    All the relevant FieldPoint Channels are read by the Server (a computer in the Ethernet Network) and published to the network in the form of Shared Variables.
    I have a client VI that is reading the Shared Variables published by the Server using Front Panel Binding.
    Problem : 
    Some of the Bindings are in the mode 'Write &Read' and that causes some initialization problems.
    For example - Valve #1 is Open, and then a User start running the Client VI, (the Valve #1 Status mode is 'Write & Read")
                           if in the VI the status of Valve #1 is closed (before running it) then the Valve status is changing to Closed.
    I want the Client VI to first read the Physical status of the instrument and then to change the Value if the User changes it.
    But that's seems to be a problem when using Front Panel Binding... (is it?)
    I know I can Deploy a lvlib in the Client Side and Item Bind to the Shared Variables or Use DataSocket.
    (Is DataSocket is a Reliable method when connecting to Shared Variables? What are the disadvantages when using DataSocket?) 
    What is recommended by those of you that are experienced or by NI ?
    Sincerely Yours,
    Amitai Abramson.

    Amitai Abramson,
    Hello and thanks for using the NI Forums.
    I'm glad that you've read the Using the LabVIEW Shared Variable Tutorial on our website. Check out these other resources:
    Network Variable Technical Overview
    Troubleshooting Network-Published Shared Variables
    Why Do I See Unexpected Value Change Events for Shared Variables Using LabVIEW DSC?
    All You Need to Know About Shared Variables
    Creating a Value Change Event for Shared Variables
    Alternative Method for Using Shared Variables Between Systems in LabVIEW 8.x
    What Is The Difference Between Using Shared Variables And DataSocket VIs To Access OPC Tags?
    The issue that you are seeing by having "Write & Read" bound items on both the server and client side is essentially a race condition, you don't know which one is being read/written at what time. To resolve this issue I would take a look at some of the documents below.
    Using a Local, Global, or Shared Variable in Parallel Loops Can Cause Race Conditions
    Using Local and Global Variables Carefully
    Tutorial: Local Variable, Global Variable, and Race Conditions
    Locking a Shared Resource or Variable in LabVIEW Using Semaphores
    You mentioned not wanting to have two sets of shared variables (one on each side), but this is a great method to resovle this issue, that, or you can develope some sort of hand shaking to prevent these race conditions.
    I would suggest that in the future when using these forums you try to ask only one question per thread and make it more concise. It's hard to tackle multiple questions and such broad questions as "I want to know all the ways that I can connect to Shared Variables, and I want to know the advantages and disadvantages." I suggest this because we want you to get your questions answered and more concise questions will result in quicker and better answers. 
    Message Edited by Ben S on 10-01-2009 06:05 PM
    Ben Sisney
    FlexRIO V&V Engineer
    National Instruments

  • Target VI stops before being commanded using shared variable

    All,
    I decided to post this in general since it deals mostly with shared variables however I am working with a RT target so feel free to move it to another forum.
    I originally posted a problem I was having with the RT Module Getting Started example, regarding the 1950679023 error, and trouble shooting led me to create the simplest test project I could think of. (I know you all want a link to the VIs but my company does not allow me to access internet file sharing sites to upload data so bare with me.)
    NOTE: This is NOT an RT project. Just deployed on an RT target.
    In Project Explorer I have Host.vi under " My Computer " and Target.VI and 3 networked-published shared variables (call them A,B,C here for simplicity) with RT-FIFO checked, under my RT target.
    Host.vi is a single while loop with a 0.5sec time delay express VI. The loop contains (along w/ the time delay) 1 numeric control wired to SV A, 1 numeric indicator wired to SV B, and finally a Stop button wired to SV C plus the conditional term (stop if True). SV A is configured as write, SV B as read, and SV C as write.
    Target.vi is a single while loop with a 0.5sec time delay express VI. The loop contains (along w/ the time delay) a numeric add function wired to a constant double and SV A configured as read. Also, SV C is wired to the conditional term configured as read (stop if True). The VI adds the two numbers, one of which is controlled by the Host.vi using SV A, and sends the results to Host.vi using SV B until the Stop button is pressed on Host.vi and sent back to Target.vi using SV C.
    I successfully ran this project (which included my always present 1950679023 error). Then changing no code but merely redeploying/running it again right after or through out the course of many other project deployments I get incorrect data on Host.vi. Basically sometimes it would work, sometimes it wouldn't; having changed NO code. First discovery was that Target.vi would automatically stop after running ~ 1sec since deploying/running on the target and before I could disconnect and open/run Host.vi. I then deployed/ran Target.vi with a probe on the wire between SV C and the conditional term and highlight execution running. After an average of 3 runs through the loop the SV C would automatically send out a True signal even though I never open/run Host.vi. How can shared variable C, which is write controlled by Host.vi, automatically change it's state like that when I never even open/run Host.vi?
    Another interesting observation is, If I first open/run Host.vi and then deploy/run Target.vi, the program ALWAYS works. But those steps go against my limit understanding of running VIs with shared variables on a target, which I got from NI's RT Module Getting Started Guide? I am going to have a hard time developing anything useful with these shared variables if I can not get the LV RT Guide example and this simple VI working. Any help would be great.
    Thanks
    JD
    P.S. I've noticed this error message a few times during deploying/running either the Host.vi or Target.vi. The error is not consistent; sometimes I see sometimes I don;t.:
    error-2147220727 (Hex 0x80040309)
    The client process cannot communicate with the configuration server process. If this problem persists please note the steps you performed that led to this error and contact technical support.
    PXI-1045,PXI-8196 RT,PXI-4220 (slot 2),(2) PXI-6259 (slot 3 and 4),PXI-5152 (slot 5),PXI-2585 (slot 6),PXI-5404 (slot 7)
    LV 8.2.1, RT 8.2, DAQmx 8.5, MAX 4.2, VISA 4.1,
    Pharlap OS ver.12.0, PH_EXEC ver. 8.2

    Thanks for the responses, (sorry this is going to be long)
    - First question is how do you initialize a shared variable (SV)? I don't have the DSC module, which I know has an initial value parameter. The SV is configured as a read and doesn't have any inputs, so am I missing something on the way to initialize it? I know the boolean defaults to False, which is good for my application. Also, right clicking on the SV doesn't bring up any obvious solution? Help if I am lost. Also, all my code is inside the loop (both the RT.vi and Host.vi), nothing is outside the loop.
    - I think I learned something through some trial and error. I made this test VI project even simpler by just having an incremental counter using shift registers inside the RT.vi while loop. The results of that counter are sent out, by way of a network-published SV, to the Host.vi. This network-published SV is located under the target within the Project Explorer. I temporarily got rid of the boolean SV, which was used to stop both the RT.vi and Host.vi. It was that boolean SV that gave me all the problems.
    This new test VI works consistently (also as a stand alone application, which was a first for me). My thoughts are that the issues had something to do with not "completely" removing all previous run instances of the VI and associated SVs/library from the RTs memory. I think I was getting old buffer data or SV corruption when, on my first test VI, would re-run the RT.vi and have the boolean SV inexplicitly switch states from False to True, even though the write controlled instance on Host.vi wasn't even running. I now undeploy everything (and check the Variable Manager) to make sure I have a clean sheet when re-running the VI. Now that brings up a question, is undeploying the only, or proper, way to clear the RT's memory?
    Anywho, I reintroduced the boolean SV into this new edition of the test project (read instance on RT.vi and write instance on Host.vi, while "hosted?" under the target in the Project Explorer) and everything works (although I still get that 1950679023 error once in a while when running for the first time). Meaning, I deploy the RT.vi then disconnect, then run the Host.vi and get valid data, then I press stop and both VI's stop. I then clear out the RT memory (I think all of it?) using undeploy and then repeat. Doing this I get consistent, valid results. If this seems like a learning experience for me please let me know, I don't want something to "work" just by accident. 
    - To answer the second reply: 1) all the SVs where created under the target in the Project Explorer. Also, I have not unchecked auto-deploy or tried deploying manually, but will give it a try. That brings up a great point, most of NI's data on SVs is "technical specification" like and not very in depth for something so complex. I have not been able to find any "tips/tricks" or "best practices", like trying to deploy manually. Is it because SVs are still new?? Also, a frustrating thing is that NI's step by step tutorials treat SVs like they are simple and fool proof, but following their instructions to the T I get errors. They leave out all the little nuances of correctly working with SVs and so it creates a steeper learning curve.  Enough of my rant.
    Thanks again for the responses and any more help to come.
    JD
    PXI-1045,PXI-8196 RT,PXI-4220 (slot 2),(2) PXI-6259 (slot 3 and 4),PXI-5152 (slot 5),PXI-2585 (slot 6),PXI-5404 (slot 7)
    LV 8.2.1, RT 8.2, DAQmx 8.5, MAX 4.2, VISA 4.1,
    Pharlap OS ver.12.0, PH_EXEC ver. 8.2

  • How to use shared variables with native c programs

    Hello
    What is the way to use shared variables with native c programs?
    I have a c/c++ program that uses the NIDAQmx C-API to perform measurements. Now I want to communicate to a LabVIEW program via shared variables.
    Is there a C-API for shared variables as there is for the NIDAQmx functionality? Where can I find further documentation? The document "Using the LabVIEW Shared Variable" mentions that one "can read and write to shared variables in ANSI C", but there are no hints about how and where to look.
    Thanks in Advance

    Hi user42,
    with CVI 8.0, you cannot create or configure shared variables. However, you can read or write to an already configured LabVIEW 8.x shared variable from CVI using the DataSocket API.
    In order to do this you need to have and DataSocket 4.3 or higher installed.
    Here's a forum post about using the DataSocket functions a LabVIEW Shared Variables:
    http://forums.ni.com/ni/board/message?board.id=180&message.id=24569&requireLogin=False
    With CVI 8.1 and Measurement Studio 8.1 it's possible to use Shared Variables via the Network Varaiable Library (check out the end of the "Network-Published Shared Variable" section within the "Using the LabVIEW Shared Variable" documentation and the following link).
    Datasocket with LabWindows/CVI and LabVIEW Real-Time:
    http://digital.ni.com/public.nsf/allkb/CC4343488413A2F586256E6200099638?OpenDocument
    Daniel
    NIG

  • Using shared variables in windows 7 64 bit

    Hi !
    I am trying to use network published shared variables (with Labview 8.6.1) in windows 7 64 bit. I have three PCs on the network. All PC's are visible to each other. I am able to remotely log on to other PCs.
    But when i run my program, the shared variables are not able to read the value over the network. The same program was working with windows XP.
    I am not sure whether it is windows issue or labview issue.
    Please help ASAP.
    Mandar Joshi

    I am having the same problem with Shared Variables with LV8.6.1 and Win7 64 in a program that uses a shared variables to share in seperate loops. I was able to use a local variable instead, but would love to know if it possible to use shared variables with 8.6.1 and win7.

  • Shared variable engine OPC delay

    Hello All,
    I've got a bit of a problem with the delay time of updates between a non NI OPC server and a shared variable engine OPC client. I am using the redion OPC software OPCWorx with a database of around 120 tags to monitor and log data from a small pilot plant. The OPCWorx server has been configured with a 500ms update rate and the NI OPC client as the same. So here is my problem; logged updates occur no faster that 2.5s which is fine as we are exporting in 3 sec intervals (would still like to increase the performance of this to around 1 sec) but the main nuisance is the delay in changing control registers in the PLCs. The controls and indicators are directly bound to the shared variable items where by a change in a boolean control on the front panel to the indicated response can range from 5 to sometimes 15 seconds delay. If I bind the same control and indicator directly to the OPC item through the data socket the delay in response is almost unnoticeable at around 1 sec. I have increased the update/logging dead bands of the shared variables which seemed to help but only by a second or so.
    Im wondering what the limitations of using an OPC shared variable engine is and if this is expected or have I gone wrong somewhere. All the variables are configured as non buffered and to have single writers.
    A few changes have been suggested;
    - Upgrading the PC. The current hardware is AMD Phenom 2 3.21GHz processor, 4GB of ram running windows XP.
    - Using Modbus over ethernet instead of OPC.
    This is the first major use of the DSC module and using the shared variable engine as an OPC client so any information or insight to help with this would be much appreciated. 

    Hi Kallen,
    The Shared Variable Engine can become bogged down when there are more than 100 shared variables.  This may be what you are experiencing.  We can check buffering for the variables and disable it, and that should improve performance slightly.  As it is, using datasockets may be the best method for over 100 shared variables.  I apologize for the inconvenience.
    Here are some KnowledgeBase articles that can be of use with regards to this issue:
    How Does Buffering Work for Shared Variables?
    http://digital.ni.com/public.nsf/allkb/5A2EB0E0BC56219C8625730C00232C09?OpenDocument
    Why Is Accessing IO Variables Through The Shared Variable Interface So Slow?
    http://digital.ni.com/public.nsf/allkb/F18AEE4BE7C9496B86257614000C43DF?OpenDocument
    Matt S.
    Industrial Communications Product Support Engineer
    National Instruments

  • Slow update of shared variables on RT (cRIO) after building exe

    Hi,
    I've been struggling with this for the past few days.  I am having a problem with slow updating of shared variables on my RT project....but only after building the application into exe's.
    The application consists of an RT target (cRIO 9073) sampling inputs at a rate of 1sec.  I have a host PC running the front panel that updates with the new acquired values from the cRIO.  These values are communicated via shared variables.
    Once the cRIO samples the inputs, it writes the values to the shared variables, and then flags the data as 'ready to be read' using a boolean shared variable flag.  The hostPC polls this boolean shared variable and updates the indicators on the front panel accordingly.  
    Now, this worked fine during development, but as soon as I built the RT exe and host exe's, it stopped working properly and the shared variables ended up being updated very slowly, roughly 2-3sec update time.
    To give you some more background:
    I am running the Labview 2010 v10.0.
    I am deploying the shared variable library on the RT device (as the system must work even without the hostPC).  I have checked that its deploying using Distributed System Manager, as well as deploying it into the support directory on the cRIO and not the exe itself. 
    I have also disabled all firewalls and my antivirus, plus made sure that the IP's and subnets are correct and its DNS Server address is set to 0.0.0.0.
    There are 25 shared variables all in all, but over half of those are config values only used once or twice at startup.  Some are arrays, plus I dont have any buffering and none of them are configured as RT FIFO's either.
    The available memory on the cRIO is about 15MB minimum.
    What strikes me is that it works fine before building exe's and its not like the cRIO code is processor intensive, its idleing 95% of the time.

    Thats exactly what I'm saying, it takes 2-3seconds to update the values.
    I have tried taking out the polling on the PC side, and registered an event on the changing of that shared variable and that doesn't do anything to change the slow update time.  Even if I stop the PC, and just monitor the shared variables in DSM it updates slowly.
    I also tried utilising the "flush shared variables" vi to try to force the update....that does nothing.
    I wire all the error nodes religously. Still no luck.
    Its very strange, I'm not too sure whats happening here.  These things should be able to update in 10ms. 

  • Error codes for shared variables in Labview 8.5?

    I am trying to use Shared Variables in Labview 8.5 to enable real-time loops (similar to some of the examples in "Using the LabVIEW Shared Variable", published Aug 28, 2007).  I created it to hold the result of a 16-channel A/D converter (so a 16-element I16 array).  To avoid losing samples, I used buffering, with a buffer of 5.  To test this, I made a pair of VIs, one a producer that stuffs a 16-element I16 array into the shared variable "every so often" (controlled by a timed loop), and a consumer loop that reads the shared variable and does something with the data.
    If I think of the buffered shared variable as a Real Time FIFO (as the article suggests it is), I was curious how I would know (a) when the queue was empty, and (b) if the queue had overflowed.  Both are necessary if this is to be a practical means of exchanging data -- you want the producer and consumer to run more-or-less at the same rate, but only the producer is deterministic.  The consumer needs to be able to run "faster" if it falls behind (for example, because it is writing data to disk), but you don't want it to read data from the shared variable if there's nothing there.  [One can always read a shared variable, after all -- as the article states, it simply "holds" the last value written to it].
    Snooping around, I discovered that there are "error codes" associated with the shared variable.  In particular, a code of -2220 (FFFFF754) seems to signify an empty queue (or a shared variable that has not yet been written to), while a code of -1950678981 (8BBB003B) appears to be "buffer overflow".
    Is this documented anywhere?  Are there other "error codes" that would be helpful to know?  Is there some rationale to these seemingly-random numbers?  [It would help to develop code to utilize shared variables if there was a bit less "magic" and "mystery" involved].
    For what it is worth, with a buffer of size 40, I could generate 16 I16 values at 1 KHz (simulating sampling from a 16-channel A/D at 1 KHz) and pass it to a consumer node that (a) read from the shared variable until it was empty, then (b) "went to sleep" for 20 msec (simulating "doing something else non-deterministically"), and not miss any data (because I could then empty the Shared Variable RT-FIFO, which should have been half full, before it overflowed on me).  Not bad throughput -- I bet I could push it even higher.
    Bob Schor

    Hey Bob,
    The errors are documented in the LabVIEW help:
    Shared Variable Error Codes
    Real-Time Shared Variable Error Codes
    There are several error messages for buffer underflow/overflow depending on the settings of the network or RT FIFO buffers. In particular the -2220 and -2221 are useful for the producer/consumer use case. For example (as you probably know) the consumer can flush a variable using the error code (see the attached image).
    Gerardo
    Attachments:
    variable1.png ‏3 KB

  • Shared Variables for Real-TIme Robot Control

    I'm really stuck in my efforts to use LV real-time in my hardware control application. I have a 6-axis industrial robot arm that I must control programmatically from my PC. To do this I've developed a dynamic link library of functions for various robot control commands that I can call using Code Interface Nodes in LV (using 8.5). This has worked great, that is, until I tried to port parts of the application to a real-time controller. As it turns out, because the robot control dll is linked with and relies so heavily upon several Windows libraries, it is not compatible with use on a RT target, as verified by the the "DLL Checker" application I downloaded from the NI site. When the robot is not actually executing movements, I am constantly reading/writing analog and digital I/O from various sensors, etc.....
    This seemed to suggest that I should simply segregate my robot commands from the I/O activities, using my host PC for the former, and my deterministic RT loop on the target machine for the latter. I set up a Robot Controller Server (RCS) vi running on my host PC that is continuously looking for (in a timed loop) a flag (a boolean) to initiate a robot movement command. Because several parameters are used to specify the robot movement, I created a custom control cluster (which includes the boolean variable) that I then used to make a Network Shared Variable that can be updated by either the RT target or the host PC running the RCS. I chose NOT to use buffering, and FIFO is not available with shared variables based on custom controls.
    Here's sequence of events I'd like to accomplish:
    1) on my host PC I deploy the RCS, which continuously pools a boolean variable in the control cluster that would indicate the robot should move. The shared variable cluster is initialized in the RBS and the timed loop begins.
    2) I deploy the RT vi, which should set the boolean flag in the control cluster, then update the shared variable cluster.
    3) an instance of the control cluster node in the RCS should update, thereby initiating a sequence of events in a case structure. (this happens on some occassions, but very few)
    4) robot movement commands are executed, after which the boolean in the control cluster is set back to its original value.
    5) the RT vi (which is polling in a loop) should see this latest change in the boolean as a loop stop condition and continue with the RT vi execution.
    With the robot controller running in a timed loop, it occassionally "sees" and responds to a change of value in members of the shared variable cluster, but most times it does not. Furthermore, when the robot controller vi tries to trigger that the movement has completed by changing a boolean in the control cluster, the RT vi never sees it and does not respond.
    1) Bad or inappropriate use of network shared variables?
    2) a racing issue?
    3) slow network?
    4) should I buffer the control cluster?
    5) a limitation of a custom control?
    6) too many readers/writers?
    7) should I change some control cluster nodes to relative, rather than absolute?
    8) why can't I "compile" my RT vi into an executable?
    Any help would be greatly appreciated. Unfortunately, I'm writing this from home and cannot attach vi files or pictures, but would be happy to do so at work tomorrow. I'm counting on the collective genius in the universe of LV users and veterans to save my bacon.....
    David

    Hi David,
    I'm curious why you decided to build a CIN instead of developing the code in
    LabVIEW.  Is there some functionality that that LabVIEW couldn't
    provide?  Can you provide some more information about the LabVIEW
    Real-Time target you're using?  What type of IO are you using?
    It is impossible to get LabVIEW Real-Time performance on a desktop PC running
    an OS other than LabVIEW Real-Time.  Even running a timed loop in LabVIEW
    for Windows won't guarantee a jitter free application.  Also, no TCP based
    network communication can be deterministic.  This means Network Shared
    Variables are also not deterministic (they use a TCP for data transport) and I
    advise against using them as a means to send time critical control data between
    a Windows host and a LabVIEW Real-Time application.
    In general, I would architect most LabVIEW-based control applications as
    follows:
    - Write all control logic and IO operations in LabVIEW Real-Time.  The
    LabVIEW Real-Time application would accept set points and/or commands from the
    'host' (desktop PC).  The Real-Time controller should be capable of
    running independently or automatically shutting down safely if communication to
    the PC is lost.
    - Write a front-end user interface in LabVIEW that runs on the desktop
    PC.  Use Shared Variables with the RT-FIFO option enabled to send new set
    points and/or commands to the LabVIEW Real-Time target.
    Shared variable buffering and RT-FIFOs can be a little confusing.  Granted
    not all control applications are the same, but I generally recommend against
    using buffering in control applications and in LabVIEW Real-Time applications
    recommend using the RT-FIFO option.  Here's why:  Imagine you have a
    Real-Time application with two timed loops.  Time-loop 'A' calculates the
    time critical control parameters that get written to hardware output in
    timed-loop 'B'.  Loop 'A' writes the outputs to a RT-FIFO enabled variable
    with a RT-FIFO length of 50.  Loop 'B' reads the outputs from the shared
    variable, but for some reason, if loop 'B' gets behind then the shared variable
    RT-FIFO will now contain several extra elements.  Unless loop 'b' runs
    extra fast to empty the RT-FIFO, loop 'B' will now start outputting values that
    it should have output on previous cycles.  The actual desired behavior is
    that loop 'B' should output the most recent control settings, which means you
    should turn off buffering and set the RT-FIFO length to 1.
    There is also a clear distinction between buffering and the RT-FIFO
    option.  The RT-FIFO option is used to add a non-blocking layer between
    network communication and time-critical code in LabVIEW Real-Time
    applications.  It also provides a safe mechanism to share data between two
    loops running in a Real-Time application without introducing unnecessary
    jitter.  Network buffering is a feature that allows a client to receive
    data change updates from the server even if the client is reading the variable
    slower than the server is writing to it.  In the example I presented above
    you don't need to enable networking because the shared variable is used
    entirely within the Real-Time application.  However, it would be
    appropriate to send control set points from a Windows PC to the Real-Time
    application using network published shared variables with the RT-FIFO option
    enabled.  If it is critical that the Real-Time application executed all
    commands in the sequence they were sent then you could enable an appropriate
    buffer.  If the control application only needs the latest set point
    setting from the Windows host then you can safely disable network buffering
    (but you should still enable the RT-FIFO option with a length of 1 element.)
    Network buffering is especially good if the writer is 'bursty' and the reading
    rate is relatively constant. In the robot application I can imagine buffering
    would be useful if you wanted to send a sequence of timed movements to the
    Real-Time controller using a cluster of timestamp and set point.  In this
    case, you may write the sequence values to the variable very quickly, but the
    Real-Time controller would read the set points out as it proceeded through the movements.
    The following document presents a good overview of shared variable
    options:  http://zone.ni.com/devzone/cda/tut/p/id/4679
    -Nick
    LabVIEW R&D
    ~~

Maybe you are looking for

  • MacPro 1,1 10.6.8 won't boot after kernel panic

    I apologize for the long post, but figured I'd lay out the whole scenario. I had a kernel panic in Safari yesterday. Powered down. Powered on. Message appeared saying to power down, and restart again. Did that. Then the fun started. The restart was s

  • WithHolding Tax Deactivation Problem

    SAP Experts, During Migration i have deactivated EWT for the Company code, and uploaded all the open items, After Uploading the open items i have Activated the Same again, But now i am facing a problem that , With holding tax is not calculated for an

  • Navigate to technical objects programatically

    Hi Folks, We are developing an internal tool  for developers in our team. The tool will produce output of a technical objects list. It can be program,Function Module,Class methods, DB table,BADI,Exits(pre/post/OVR), Implicit enhancements etc Is there

  • Can someone help me with this error i keep geting?

    hello, ive been using photoshop for a while and then today i try to open it ad get this error: can anyone help me?

  • Lost my ITunes Library, can I synch it from my nano Ipod?

    Hi, I am not very tecchy, so have been struggling alot with this. Originally tried to COPY over my WHOLE Itunes Library (including my old ripped CDs) to a USB flash drive., for security.  Which has sort of backfired.  ThoughI followed the instruction