Reading and Writting to sharedd variable is so slow

I am using shred vairable to make a connection between 2 VI's. when writting to the variable at a VI, it take much time(5 seconds) in order to respon to the value chane in the second VI.
I am using LabVIEW 8.6
my operating system is WINDOWS VISTA, PREMUIM EDITION
my processor is Dual CORE 2.0
Solved!
Go to Solution.

Hello,
i am using binary shared variables. network-published. on the same computer. (PXI 8106 controller)
But I am more intersted in a project that I have attached in this message.
Description of the project: I have made double shared variable and ebnabled alarming (HI). I have also made 2 VI's in one i have changed tha value of the shared varaible and in the other I have made an event structure to respond to the alram (HI).
The problem is : the 2 VI's ran with out errors, but the second VI doesnt responded to the alarm when I have wrote the alarm value to the shared variable in the first VI.
Another Question regarding shared variables :
when I bind a shared variable to an Digital Input  channel, does the change of the input provokes a change in the value of the shared variable during the run time of the VI or it just takes tha last value before the VI run and any new change will not considered.
Another Questions regarding event-driven programing:
I would like to make an event to respond to a change in a digital Input channel. How I can do that.
best Regards!   
Attachments:
Untitled 1.vi ‏8 KB
Untitled Library 1.lvlib ‏4 KB
Untitled Library 1.lvlib ‏4 KB

Similar Messages

  • How many ways to read and write a local variable in a called VI?

    Ciao!
    I'm producing my first TestStand sequence. It is called "FirstAttempt" and it is made by a single step which calls a VI. One of the first dilemmas i encountered realizing this sequence is how to read and write a local variable (created going in Variables -> Locals ('FirstAttempt') -> <right click to insert local>) in the called VI.
    The first way (the only one i tried) is to create a control and an indicator on the VI front panel, connect them to their respective terminals in the connector pane and then specify (going in Step Settings -> Module) that these connectors (shown in the Parameter Name column) are linked to the local variable (selected in the Value column).
    The second way (not tried) consists in using TestStand API: create a Sequence Context reference on the VI front panel, link it to a property node in the block diagram, select the property "Locals" and extract from this the local variable name and value which, i think, can be readable and writable.
    So...
    Are the shown ways correct?
    Are there other ways?
    Knowing that a "local" variable can be considered "global" within the whole sequence, is there the possibility to simply create a reference to the local variable and use the reference in the called VI block diagram in order to save space in the connector pane (if using method 1) or in the block diagram (if using method 2)?
    Thanks!
    Message Edited by aRCo on 09-17-2009 05:09 AM

    Hi,
    Before TestStand 3 you would use the second way you quoted as its the only way.
    But now you would use the first way you quoted. You may still what to pass the SequenceContext if you were going to use the TestStand API. For TestStand 3.x and above you would use this way as the first chose. (Personnelly, I would not pass the SequenceContext into a VI if I know it was never going to be used in that VI.)
    Not sure I understand your final comment, maybe you are liking it to passing the reference of a control to a subVI so that the control can be updated from within the subVI.
    If this is the case and you had a situation where you had a step that was running in parallel with the rest of the steps in the sequence either as a separate thread or execution and were dependent on the contents of the  local variable changing from that parallel running step, then you would have to use the API SetVal method to change the local.
    Hope this is clear.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • 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?

  • Best Practice to Atomic Read and Write a Field In Database

    I am from Java Desktop Application background. May I know what is the best practice in J2EE, to atomic read and write a field in database. Currently, here is what I did
    // In Servlet.
    synchronized(private_static_final_object)
        int counter = read_counter_from_database();
        counter++;
        write_counter_back_to_database(counter);
    }However, I suspect the above method will work all the time.
    As my observation is that, if I have several web request at the same time, I am executing code within single instance of servlet, using different thread. The above method shall work, as different thread web request, are all referring to same "private_static_final_object"
    However, my guess is "single instance of servlet" is not guarantee. As after some time span, the previous instance of servlet may destroy, with another new instance of servlet being created.
    I also came across [http://code.google.com/appengine/docs/java/datastore/transactions.html|http://code.google.com/appengine/docs/java/datastore/transactions.html] in JDO. I am not sure whether they are going to solve the problem.
    // In Servlet.
    Transaction tx = pm.currentTransaction();
    tx.begin();
        int counter = read_counter_from_database();  // Line 1
        counter++;                                                  // Line 2
        write_counter_back_to_database(counter);    // Line 3
    tx.commit();Is the code guarantee only when Thread A finish execute Line 1 till Line 3 atomically, only Thread B can continue to execute Line 1 till Line 3 atomically?
    As I do not wish the following situation happen.
    (1) Thread A read counter from Database as 0
    (2) Thread A increment counter to 1
    (3) Thread B read counter from Database as 0
    (4) Thread A write counter as 1 to database
    (5) Thread B increment counter to 1
    (6) Thread B write counter as 1 to database
    What I wish is
    (1) Thread A read counter from Database as 0
    (2) Thread A increment counter to 1
    (4) Thread A write counter as 1 to database
    (3) Thread B read counter from Database as 1
    (5) Thread B increment counter to 2
    (6) Thread B write counter as 2 to database
    Thanks you.
    Edited by: yccheok on Oct 27, 2009 8:39 PM

    This is my understanding of the issue (you should research it further on you own to get a better understanding):
    I suggest you use local variables (ie, defined within a function), and keep away from static variables. Those local variables are thread safe. If you call functions within functions, its still thread safe. If you read or write to one record in a database using sql, its thread safe (you dont need a transaction). If you read/write to multiple tables and/or records, you probably need a transaction. Servlets are thread safe. You usually dont need the 'synchronized' word anywhere unless you have a function updating/reading a static variable and therefore want to ensure only one user is accessing the static varible at a time. Also do so if you are writing to some resource (such as a file, a variable in applicaton scope, session scope, or resource that everyone uses such as email server). You dont want more than one person at a time to write to it). Note the database is one of of those resources that is handled by transactions rather than the the synchronized keyword (the synchronized keyword is applied to your application only (not other applications that someone is running), whereas the transaction ensures all applications are locked out while you update those records in the database).
    By the way, if you have a static variable, you should have one and only one function (synchronized) that updates it that everyone uses. If you have more than one synchronized function, that updates it, its probably not thread safe.
    An example of a static variable you would use is a Datasource object (to obtain your database connections). You only need one connection pool in your application and you access it via the datasource variable.
    If you're unsure your code is thread safe, you can create two seperate threads that call the same block of functions repeatedly to ensure it works as expected.

  • Can't stop synchronized threads with I/O read and write

    I have two synchronized threads which doing read and write from and into a file.
    One thread called "reader" which does reading, encoding, etc from a source file and puts its output in a pre-defined variable. Another called "writer" which puts the reader's output into a file ( not the source file ). Both thread will notify each other when they've finished each of their part. It's similiar to CubyHole example of Java Tutorial example from Sun.
    But somehow it seems like the threads keep spawning and won't die. Even if the source file has been all read and the data has been fully written, calling interrupt(), return, etc has no effect. The threads will keep running untill System.exit() called.
    Is it because the threads were blocked for I/O operation and the only way to kill them is to close the I/O ?
    To be honest, it's not only stop the threads that I want to, I also want to somehow pause the threads manually in the middle of the process.
    Is it possible ?
    Cheers.!!!

    The example code for the problem using 4 classes called :
    - libReadWrite ( class holding methods for aplication operations )
    - reader ( thread class responsible for reading data )
    - writer ( thread class responsible for writing data )
    - myGUI ( user interface class )
    All of them written in different file.
    // libReadWrite
    pubic class libReadWrite {
    private boolean dataReady;
    private String theData;
    //read data
    public synchronized void read(String inputFile) {
    while (dataReady == true) {
    try {
    wait();
    } catch (InterruptedException ex) {}
    RandomAccessFile raf = new RandomAccessFile(inputFile, "r"); // I'm using raf here because there are a lot of seek operations
    theData = "whatever"; // final data after several unlist processes
    dataReady = true;
    notifyAll();
    public synchronized void write(String outputFile) {
    while (dataReady == false) {
    try {
    wait();
    } catch (InterruptedException ex) {}
    DataOutputStream output = new DataOutputStream(new FileOutputStream(outputFile, true));
    output.writeBytes(theData);
    dataReady = false;
    notifyAll();
    //Reader
    public class reader extends Thread {
    private libReadWrite myLib;
    private String inputFile;
    public reader (libReadWrite myLib, String inputFile) {
    this.myLib = myLib;
    this.inputFile = inputFile;
    public void run() {
    while (!isInterrupted()) {
    myLib.read(inputFile); <-- this code running within a loop
    return;
    public class writer extends Thread {
    private libReadWrite myLib;
    private String outputFile;
    public writer (libReadWrite myLib, String outputFile) {
    this.myLib = myLib;
    this.outputFile = outputFile;
    public void run() {
    while (!isInterrupted()) {
    myLib.write(outputFile); <-- this code running within a loop
    try {
    sleep(int)(Math.random() + 100);
    } catch (InterruptedException ex) {}
    return;
    //myGUI
    public class myGUI extends JFrame {
    private libReadWrite lib;
    private reader readerRunner;
    private writer writerRunner;
    //Those private variables initialized when the JFrame open (windowOpened)
    libReadWrite lib = new libReadWrite();
    reader readerRunner = new reader("inputfile.txt");
    writer writerRunner = new writer("outputfile.txt");
    //A lot of gui stuffs here but the thing is below. The code is executed from a button actionPerformed
    if (button.getText().equals("Run me")) {
    readerRunner.start();
    writerRunner.start();
    button.setText("Stop me");
    } else {
    readerRunner.interrupt();
    writerRunner.interrupt();
    }

  • Is there a way to use the FF vi's to read and write complex data types; specifically, clusters?

    I'm trying to interface with a Fieldbus device through LabVIEW.  I need to be able to read and write a variable that consists of a cluster of two unsigned int 32's.  The FF vi's provided with FF Communications Manager 3.2 do not support clusters.  I have tried to use a code interface node to write my own, but the CIN's I was using before to do this function do not give me a device list anymore (they were originally written on Communications Manager 2.3.5).  I have recompiled the .lsb, as well as trying to use the older versions of the header and library files.  Is there another workaround I can use?

    Hello Bryan,
    The BrowseDeviceList VI was released within NI-FBUS 3.2. For NI-FBUS Configurator 3.1, please unzip the attached file and copy the "addon" and "Ff" folders into "\vi.lib" directory. LabVIEW 7.1 or above version is required for using these addons.
    And for your information, there is a free upgrade (version 3.1.1) for NI-FBUS Configurator 3.1 users. Here is the link to the upgrade kit.
    http://digital.ni.com/softlib.nsf/websearch/00A1614EC291219586256F390020671B?opendocument&node=132070_US
    Hope it helps!
    Regards,
    --Josiane
    Attachments:
    locate_fflv_in_labview82.jpg ‏214 KB
    vi.lib.zip ‏391 KB
    locate_fflv_in_labview71.jpg ‏193 KB

  • Atomic reads and writes to memory

    In Solaris 10 running on x86 64bit processor are reads/writes of an int variable (written in C compiled with gcc) atomic operations? I have read on various forums that memory reads and writes of primitives are atomic but there are people who question this statement.
    I know there are atomic_ops provided by Solaris 10 for both user space and kernel but I am only interested in ensuring that an update to an int is atomic?

    ps10x# cat fred.c
    main() {
      int i;
      i=13;
      i=17;
    ps10x# gcc -S fred.c
    ps10x# cat fred.s
            .file   "fred.c"
            .text
    .globl main
            .type   main, @function
    main:
            leal    4(%esp), %ecx
            andl    $-16, %esp
            pushl   -4(%ecx)
            pushl   %ebp
            movl    %esp, %ebp
            pushl   %ecx
            subl    $20, %esp
            movl    $13, -8(%ebp)
            movl    $17, -8(%ebp)
            addl    $20, %esp
            popl    %ecx
            popl    %ebp
            leal    -4(%ecx), %esp
            ret
            .size   main, .-main
            .ident  "GCC: (GNU) 4.3.4"So it seems pretty clear that setting a variable is "movl $13, -8(%ebp)"
    and while I'm no expert on x86 assembler, I'm fairly sure a single movl instruction is atomic.
    However, the real issue is that the compiler might decide to stash a temporary copy of the variable in a register.
    And that could throw off the "atomic" nature of things.
    I believe that the volatile keyword is supposed to help prevent those kinds of issues.

  • Multithreaded problem in read and write thread

    This is a producer consumer problem in a multi-threaded environment.
    Assume that i have multiple consumer (Multiple read threads) and a
    single producer(write thread).
    I have a common data structure (say an int variable), being read and written into.
    The write to the data sturcture happens occasionally (say at every 2 secs) but read happens contineously.
    Since the read operation is contineous and done by multiple threads, making the read method synchronized will add
    overhead(i.e read operation by one thread should not block the other read threads). But when ever write happens by
    the write thread, that time the read operations should not be allowed.
    Any ideas how to achive this ??

    If all you're doing is reading an int, then just use regular Java synchronization. You'll actually get a performance hit if you're doing simple read operations, as stated in the ReadWriteLock documentation:
    Whether or not a read-write lock will improve performance over the use of a mutual exclusion lock depends on the frequency that the data is read compared to being modified, the duration of the read and write operations, and the contention for the data - that is, the number of threads that will try to read or write the data at the same time. For example, a collection that is initially populated with data and thereafter infrequently modified, while being frequently searched (such as a directory of some kind) is an ideal candidate for the use of a read-write lock. However, if updates become frequent then the data spends most of its time being exclusively locked and there is little, if any increase in concurrency. Further, if the read operations are too short the overhead of the read-write lock implementation (which is inherently more complex than a mutual exclusion lock) can dominate the execution cost, particularly as many read-write lock implementations still serialize all threads through a small section of code. Ultimately, only profiling and measurement will establish whether the use of a read-write lock is suitable for your application.

  • In iCal and Notifications on a notebook, is it possible to expand the notes window to make it easier to read and write notes?

    In iCal and Notifications on a notebook, is it possible to expand the notes window to make it easier to read and write notes? In the past, I have used Outlook calendar and tasks and I was able to expand the windows which allowed me to put a great amount of details into either the notes section in events and tasks. It would be great to be able to do this in iCal and Notifications as well. I am using a Macbook Pro with OS X 10.8. Thank you very much for assistance with this.

    HI,
    Try Spaces for a virtual desktop.
    http://www.ehow.com/how2189851use-spaces-mac-os-x.html
    Carolyn

  • I have an external hard drive, from Iomega. However, I cannot copy or save any file to it. On my PC it says that is possible to read and write in it, but in my Mac, it says I can only read. can somebody help me?

    I have an external hard drive, from Iomega. that I can open and see my files. However, I cannot copy or save any file to it. On my PC I have it says that is possible to read and write in it, but in my Mac, it says I can only read. can somebody help me?
    Also, Im a photographer, so I like to name a lot of files at the same time (used to do in on PC and it was very usefull.) cannot find out how to do it on my Mac. Really appretiate if some one can give me a solution! Thanx

    Your drive is formatted with the NTFS file system.  OS X can read but not write to the NTFS file system.  There are third party drivers available that claim to add the ability to OS X to write to an NTFS partition.  I have not tried them and don't know if they work.
    The only file system that OS X and Windows can both write to natively is the FAT32 file system.

  • Mac desktop. 10.6.8. Text edit. Not locked. Read and write. Still, documents are locking when they are moved from desktop to another folder on the server. Techies can't figure it out here. What am I not doing?

    Mac desktop. 10.6.8. Text edit. Not locked. Read and write, not read only. Documents are locking when they are moved from desktop to another folder or saved directly into that folder on the server. Not happening with anyone else but me and the boss's computer so has to be in the properties for my text edit software. Techies can't figure it out after trying for two weeks. Boss can do a cut and paste and put into a new document, but that's starting to become a problem.

    Mac desktop. 10.6.8. Text edit. Not locked. Read and write, not read only. Documents are locking when they are moved from desktop to another folder or saved directly into that folder on the server. Not happening with anyone else but me and the boss's computer so has to be in the properties for my text edit software. Techies can't figure it out after trying for two weeks. Boss can do a cut and paste and put into a new document, but that's starting to become a problem.

  • Read and write excel sheet data from uploded file in sharepoint site programmatically 2013

    hi team,
    I am working on sharepoint 2013.I want to read and write data in excel sheet (micrsoft excel) from stored file in shrepoint docoumnt library .please suggest me
    vijay

    Hi
    Vijay,
    check those links
    http://www.sharepointwithattitude.com/archives/61
    https://social.technet.microsoft.com/Forums/en-US/e760051b-a92f-473c-9ec9-0f0c36c99e40/read-and-write-excel-sheet-data-from-uploded-file-in-sharepoint-site-programmatically-2013?forum=sharepointdevelopment
    Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation. Please remember to mark the reply as answer if it helps.

  • Need help to read and write using UTF-16LE

    Hello,
    I am in need of yr help.
    In my application i am using UTF-16LE to export and import the data when i am doing immediate.
    And sometimes i need to do the import in an scheduled formate..i.e the export and imort will happend in the specified time.
    But in my application when i am doing scheduled import, they used the URL class to build the URL for that file and copy the data to one temp file to do the event later.
    The importing file is in UTF-16LE formate and i need to write the code for that encoding formate.
    The problem is when i am doing scheduled import i need to copy the data of the file into one temp place and they doing the import.
    When copying the data from one file to the temp i cant use the UTF-16LE encoding into the URL .And if i get the path from the URl and creating the reader and writer its giving the FileNotFound exception.
    Here is the excisting code,
    protected void copyFile(String rootURL, String fileName) {
    URL url = null;
    try {
    url = new URL(rootURL);
    } catch(java.net.MalformedURLException ex) {
    if(url != null) {
    BufferedWriter out = null;
    BufferedReader in = null;
    try {
    out = new BufferedWriter(new FileWriter(fileName));
    in = new BufferedReader(new InputStreamReader(url.openStream()));
    String line;
    do {
    line = in.readLine();
    if(line != null) {
    out.write(line, 0, line.length());
    out.newLine();
    } while(line != null);
    in.close();
    out.close();
    } catch(Exception ex) {
    Here String rootURL is the real file name from where i have to get the data and its UTF-16LE formate.And String fileName is the tem filename and it logical one.
    I think i tried to describe the problem.
    Plz anyone help me.
    Thanks in advance.

    Hello,
    thanks for yr reply...
    I did the as per yr words using StreamWriter but the problem is i need a temp file name to create writer to write into that.
    but its an logical one and its not in real so if i create Streamwriten in that its through FileNotFound exception.
    The only problem is the existing code build using URL and i can change all the lines and its very difficult because its vast amount of data.
    Is anyother way to solve this issue?
    Once again thanks..

  • How do I read and write at the same time using the NI-CAN channel API?

    Here's the situation.  I have one CAN bus, and I need to read and write channel data (using the channel API) at the same time both at an interval of 20 ms.  It's easy to do one or the other using the channel API, but you can't setup a channel task to do both.  It's either input or output, not both.  Is this even possible?

    Hi,
    yes , this is possible. But you have to create two tasks, one for input and one for output. see the attached example for LabVIEW.
    If you download and install NI-CAN 2.4 you will get this example and one for C and VB as well.
    DirkW
    Attachments:
    Single Sample Input Output same Port.vi ‏79 KB

  • How do I set an external HD permission to read AND write?

    I received an iMac for Christmas and need a little help.  I have a 2TB external HD that contains .shn and .flac files of GD concerts (and other music).  I managed to find Cog that will play them...but what I want to do is download them and move them upon completion to the external HD.  I can not do this because the HD is read only.  I can move stuff to a SD card because it is read and write.  I assume when I change the permission I will be able to move the folder of a show to the HD as well.  Surely this is simple...  Thank You and sorry for the dumb question!

    Your external hard drive is likely NTFS formatted for use with a PC.
    OSX can read but cannot write to NTFS formatted volumes. You can install software that allows writing to a NTFS drive, as Niel has suggested, or you can reformat your external drive using Disk Utility for use with your Mac.
    If you decide to reformat your drive for Mac use, copy your data off to another drive before you proceed.

Maybe you are looking for

  • Premiere Pro with Diamond VC500

    Can Premiere Pro capture video from device converter "Diamond VC500"?2

  • Tween a Group of Groups

    How can I tween a Group of Groups to scale? I use my Pshop groups in a similar fashion to how Flash uses Display Object Containers. I have one group containing the rest of my groups serving as a 'master group' so I can perform global transformations

  • Problem in IW73 transaction

    Hello' The serial numbers are not displayed in IW73 tranasction even though the serial numbers are associated with the material used in notification and service order. Thank you Regards Santosh

  • Determinations for a szenario without BPM

    Hi, if I would like to create a WebService -> XI -> DB szenario without BPM, how often I have to use the wizard (for agreements and determinations)? Normally with BPM, I needed three: 1) Webserivce BS to XI 2) XI to DB 3) XI to WebSerivice But withou

  • Add receipients of message as group in address book

    ok, this seems simple, but once again, Mac disagrees and makes it impossibly complicated. I typed in about 15 email addresses for a mass mailing I did in Mail recently, and I want to save these people as a group. I'll send emails to them all again in