Can't write to instrument in while loop.

in  my case, I use 2 while loop for the progarm. one is to write the data to the instrument, another one is use local variable to change the data depend on time. the problem is the data which need write to the instrument does change. but another while loop doesn't write it to the instrument unless I push highlight excution in the diagram or choose save as in the file. could anybody help me to find the problem?

Hi Akuma,
the fact that it works when you highlight execution implies (perhaps) a race condition. The lightbulb serializes the execution of your VI, so that functions execute in succession although they don't depend on each other. When you then run the VI in realtime, some functions are executed at the same time, e.g. "VISA flush buffer" and "VISA write". It is important to define the order the VIs execute on your VISA interface for instance by wiring the error-cluster.
If this doesn't help, then post your VI (or a simplified version) or a screenshot of the diagram.
Greets, Dave
Greets, Dave

Similar Messages

  • Can't break out of a while loop

    Hi, I am doing a networking course, for which an assignment was to write an echo client and server. I did the assignment in Java and it works just fine. However, there is something I don't understand that is bugging me. I wanted a way to stop the server by either detecting when the client entered "quit" or when the user of the server entered "quit". This was not part of the assignment, but after trying many different things I really want to know (1) what I am doing wrong and (2) what the correct way to do things would be.
    I tried to put an "if" clause within the while loop so that if the client entered "quit" the server would detect that, close the socket connections, and break the while loop. But... it seems that I have done this wrong and I am not sure why.
    (Note - I am not a Java programer - just a beginner, and the course in question isn't a programming course. I did the program below by following some brief guidelines/tutorial. I don't even have any books on Java to consult right now - just ordered few from Amazon for any future projects.)
    The code:
    // EchoServer.java     - a simple server program. It listens on a predetermined port for an incoming connection.
    //                After a client connects they can input a line of text and
    //                the server will echo the exact same line back.
    import java.io.*;
    import java.net.*;
    public class EchoServer {
         protected static int DEFAULT_PORT = 3004;
         public static void main (String args[]) throws Exception {
              int portNumber;          
              try {
                   portNumber = Integer.parseInt(args[0]);
              } catch (Exception e) {
                   portNumber = DEFAULT_PORT;
              ServerSocket myServer = null;
                try{
                   myServer = new ServerSocket(portNumber);      
                   System.out.println("Echo Server started. Listening on port " + portNumber);
              } catch (IOException e) {
                   System.out.println("Could not listen on port: " + portNumber);
                   System.out.println(e);
              Socket clientSocket = null;                         
              try{          
                     clientSocket = myServer.accept();
              } catch (IOException e) {
                     System.out.println("Accept failed:  " + portNumber);
                   System.out.println(e);
              BufferedReader input = null;     
              PrintWriter output = null;
              try {               
                   input = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                   output = new PrintWriter(clientSocket.getOutputStream(), true);
              } catch (IOException e) {
                   System.out.println(e);
              String theLine;     
              while(true){
                   theLine = input.readLine();
                   output.println(theLine);     
                   output.flush();
                        if (theLine.equals("quit"))  {
                             input.close();
                             output.close();
                             clientSocket.close();
                             myServer.close();     
                             break;
                        }     // end if
              }     // end while     
         }     // end main
    }          // end EchoClient

    A few observations:
    - You might as well exit after you have caught your exceptions, since none of the conditions I see would allow your program to run properly afterwards. You can either do that by a System.exit(int) or a return;
    - Although this s an example program, you should take advantage of doing things right. Addining a try-finally would be good for tidying things up. First declare your variables before the main try, otherwise the finally won't be able to do its job. For example (this won't compile as is):
    Socket clientSocket = null;
    ServerSocket myServer = null;
    InputStream in = null;
    OutputStream out =null;
    try {
      String theLine = null;     
      while( (theLine = input.readLine()) != null ){
        output.println(theLine);     
        output.flush();
        if (theLine.equals("quit"))  {
           break;
      }     // end while
    } catch ( IOException ex ) {
      ex.printStackTrace();
    } finally {
      if ( in != null ) {
         in.close();
      if ( out != null ) {
         out.close();
      // add other conditions to close other closeable objects
    }The reasoning is that if an exception were ever to happen you would be sure that the clean up would be done. In your current example you may risk having an inputstream left open. Also note that BufferedReader.readLine() returns null when its arrived at the end of its content.

  • What is the maximum size of indexed array that can be created during execution of while loop?

    Hello,
    I am using a ring acquisition to take in images. If i write them as files in the loop, it slows down the acquisition unacceptably. Therefore i am converting image to array and storing the array until the acquisition is complete and then reading the array and converting back to image to save. The program sometimes runs out of memory (after a couple of minutes). Can anyone think of a way where i can store the array/images within the execution (without losing image information), without slowing it down and to avoid this memory problem?
    I have included the VI.
    Thanks in advance for any help or advice.
    kindest regards,
    FraserD
    Attachments:
    LL_Ring_in_IMAQ_8_bit_array_then_write_as_png.vi ‏94 KB

    When you build the array of pictures you do it using auto-indexing out of a while loop. That means that memory is aquired for a copy of the previous picture array and the array is rebuilt on every iteration, this is slow and requires a lot of extra memory.
    If you want to speed things up try initializing a shift register with a 3D array of a size that will be able to hold a certain number of pictures, then replace the "pages" as new pictures are aquired, replace operations do not require copying of the previous array and will thus be much much faster. The difference is exeptional when dealing with large arrays/amounts of data.
    Now, the shift register buffer could be built into a functional global, and you can add a push/pop logic to it so that you can have a p
    arrallell loop that works on writing the elements to disk. You could use a que for this, but I think even though you specify a size limit to the que it still aquires memory as new elements are added (correct me if I'm wrong people...:-)), so a functional global acting as a circular buffer og fixed size frame for a que should be better.
    MTO

  • Can't write cache file for while creating domain in soa 11.1.1.5 on HP-UX

    Hi,
    Installing SOA 11.1.1.5 on HP-UX and during domain creation/configuration I am getting the below errors
    **sys-package-mgr: can't write cache file for**
    and have lots of cache file errors for different packages
    Any idea what might be wrong and whats the cause of these errors and is it safe to ignore these errors if not what is the work arround. As I already looked at the below post but I don't find */var/tmp/wlstTemp* on my machine as suggested in the post below.
    SOA 11.1.1.5 install got can't write cache file
    So wondering if there's anything else I can do i.e. while creating or configuring a Domain pass some parameter to config.sh etc.
    Thanks

    Hi,
    I don't see python.cachedir in config.sh. Here is config.sh
    #!/bin/sh
    mypwd="`pwd`"
    # Determine the location of this script...
    # Note: this will not work if the script is sourced (. ./config.sh)
    SCRIPTNAME=$0
    case ${SCRIPTNAME} in
    /*)  SCRIPTPATH=`dirname "${SCRIPTNAME}"` ;;
      *)  SCRIPTPATH=`dirname "${mypwd}/${SCRIPTNAME}"` ;;
    esac
    # Set the ORACLE_HOME relative to this script...
    ORACLE_HOME=`cd "${SCRIPTPATH}/../.." ; pwd`
    export ORACLE_HOME
    # Set the MW_HOME relative to the ORACLE_HOME...
    MW_HOME=`cd "${ORACLE_HOME}/.." ; pwd`
    export MW_HOME
    # Set the home directories...
    . "${SCRIPTPATH}/setHomeDirs.sh"
    # Set the config jvm args...
    CONFIG_JVM_ARGS="${CONFIG_JVM_ARGS} -DCOMMON_COMPONENTS_HOME='${COMMON_COMPONENTS_HOME}'"
    export CONFIG_JVM_ARGS
    # Delegate to the main script...
    "${WL_HOME}/common/bin/config.sh" "$@"Thanks

  • Can we write 2 windows write_form inside loop endloop

    hi ,
    my requirement is i have header and its table details ..
    and i am maintaining header in 1 window and table in other .
    can i write those two write form in a loop endloop.
    if u have any example it help alot..
    thanks in advance.

    Hi,
    Between the LOOP and ENDLOOP you can call as many as WRITE_FROM inyour Driver program
    Regards
    Sudheer

  • How can I transfer data between two while loops in parallel

    Hello,
    I have two while loops in parallel and I want to transfer data from the first to the second loop. The problem isthat data are transfered only when the first loop ends. I tried with queue but it doesn't work. How can I do, preferentially without global variable ?
    Thanks.

    I join a very simplified VI's because the real works with PXI, RT, ...
    When you run the "secondVI.vi", no data comes in array from the "firstVI.vi".
    As I said in my first message, I tried with queue too but it doesn't work, because when the terminal go out from the while loop, while loop have to be ended to send data.
    Attachments:
    transfer_data.zip ‏20 KB

  • Can I make an awkwardly sized while loop

    So I ended up writing my code looking like this (see screenshot attached) and I want to add the upper right part into the while loop on the left.
    Is there a way to just make an awkwardly shaped while loop (which in this case would look like a lowercase R)?
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    Censored.PNG ‏28 KB

    No and if NI implemented as much they would probably have to file for a new patent since the old one mentions its shape (I think).
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Upload file writes too fast in while loop

    problem scenerio:
    My upload thread occasionally rushes through its while-write loop, writing data for a 3mb image in less than a second and then it waits for a longer time (10-30 seconds) for a response. The thread is writing directly to the OutputStream class using OReilly's implementation. I do not understand this delay. It appears to be buffering? I would like real time progress, which will be reflected in a progress bar. Is there something peculiar about this please:
    The corresponding console output is (for each image where the 1657 and 1907 times indicates problematic behavior):
    bufferSize: 8192, whileloopWriteTime: 40125, waitForResponseTime: 500
    bufferSize: 8192, whileloopWriteTime: 31937, waitForResponseTime: 625
    bufferSize: 8192, whileloopWriteTime: 1657, waitForResponseTime: 27843
    bufferSize: 8192, whileloopWriteTime: 1907, waitForResponseTime: 33734
    bufferSize: 8192, whileloopWriteTime: 48719, waitForResponseTime: 641
    bufferSize: 8192, whileloopWriteTime: 34578, waitForResponseTime: 688
    upload code (in an applet):
                   private int bufferSize = 8192;
                   private byte[] buffer = new byte[bufferSize];
                   private Socket socket;
                   private OutputStream os;
                   ..... etc
                   os = socket.getOutputStream();
                   ..... etc
                   // write the file bytes to the socket
                   int bytesReadIn=-1;
                   while ( ((bytesReadIn = fis.read(buffer)) != -1) )
                        write(buffer, 0, bytesReadIn);
                   write(strLFBoundaryLF);
                   if(socket != null) socket.shutdownOutput();
                   // read response section
                   String strResponse="";
                   String strInputLine="";
                   br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                   while( (strInputLine = br.readLine()) != null ){
                        strResponse=strInputLine.trim();
                        if(strResponse.indexOf("RES:") != -1) break; // contains bytes
                        if(socket==null || !socket.isConnected()){ intError=ERROR_SOCKET; break;}
                   if(socket != null) socket.shutdownInput();
    ....etc
         private void write (byte[] buf,int offset,int size) throws Exception {
                   os.write (buf,offset,size);
    ============================================================================
    jsp page receives the call from the applet:
              else if (part.isFile()) {
                   FilePart filePart = (FilePart)part;
                   String fileName = filePart.getFileName();
                   String filePath = filePart.getFilePath();
                   String strServerFilePath = fileInfoStorage.getServerFilePath(filePath);
                   File SaveFile = new File (strServerFilePath);
                   (SaveFile.getParentFile()).mkdirs();
                   if(fileName != null) {
                        FileOutputStream outStream = null;
                        try {
                        outStream = new FileOutputStream(SaveFile);
                        lgBytesTransferred += filePart.writeTo(outStream); // writes directly to the file
                        outStream.flush();
    ... etc
    =========================================================================
    package com.oreilly.servlet.multipart;
    FilePart class
    ... etc
    long write(OutputStream out)
    throws IOException
    if(contentType.equals("application/x-macbinary"))
    out = new MacBinaryDecoderOutputStream(out);
    size = 0L;
    byte buf[] = new byte[8192];
    int read;
    while((read = partInput.read(buf)) != -1)
    out.write(buf, 0, read);
    size += read;
    return size;
    public long writeTo(OutputStream out)
    throws IOException
    long size = 0L;
    if(fileName != null)
    size = write(out);
    return size;
    }

    Thank you for your responses.
    Accurately reporting the upload progress to the user is required, however a timely upload is also imporrtant.
    At present data appears to be sitting in a buffer for 10-20 seconds, while the progress bar indicates complete and before the next file upload is
    started.
    I am not using swing. I use an (non-gui) applet which handles communication between the server (jsp, servlet) and a dhtml, css interface.
    In the gui I a list of items awaiting upload is created. The gui paints a progress bar next to an item which is in progress (uploading).
    When an individual item's progress bar reaches 100% (confirmed to disk) the text 'complete' replaces the progress bar.and a the next item receives a progress bar. The gui also paints updates to a second global progress bar which indicates overall progress. The uploads are reliable, but for this issue.
    There's not much information except timing information in your post, and what would help us make educated guesses into what your program does are "etc."ed. Notably, does your applet maintain a single connection to your server for all image uploads?
    Presently the applet creates a new socket for each request. Another class manages and monitors the socket connection. The socket connection
    runs in its own thread. At the end of each file upload the socket and thread terminate. Once the upload behavior is stable I will attempt a more
    elaborate thread and socket management scheme.
    >
    Try acquiring more information with a network analyser such as Wireshark.
    I have wireshark. I will try and post results. However I placed a System.out.println in the
    O'Reilly class which receives the data and it appears to receive and write the file data (via OutputStream.write) in 1-2 seconds as
    reflected in the applet output.
    >
    This bizarre suggestion at least contains the germ of the issue. Your writes are just writing to the socket send buffer, not to the network. I would
    increase the socket send buffer size personally.
    I have not tested an increased socket send buffer size. This feels right. I will test this tomorrow and report back. Do you have a suggested socket send buffer size?
    Your suggestion that I am writing to the socket and not the network would certainly reflect the results I am witnessing.
    In the O'Reilly class data is being written from the incoming stream (8192 bytes per loop) to the file using the OutputStream write method. However because the data is writes are so fast it appears to be writing to a buffer and not the file.
    Yeah. Next question is is this really the O'Reilly code? that keeps testing the socket for null and isConnected() after it's already been in use and can't possibly be in any other state?
    This code which is testing the socket is not the O'Reilly code. The O'Reilly code is the FilePart class.

  • Can't install Garageband Instruments and Apple Loops 1.0 on OS Mavericks

    Today I decided to download (one more time) the Garageband Instruments update and I waited for like 5 hours+ and when it was almost finishing the download it appeared that I was already installed. So I went to Garageband to check out the new instruments and nothing was there, it was just like before the update and when I click on a new instrument to try it out, this message appears just like before download this:
    And when I go to the Mac App Store to download it again this is what I get:
    And after clicking the Update and/or the Update All button, it turns gray and says it is installed, it doesn't load or anything, I just click and then appears just like in the image below:
    My MacBook Pro is currently running the latest version of OS Mavericks and the latest Garageband ver. which is 6.0.5. I really need to use those new Instruments and can't figure out how to fix this... Thanks in advance to whoever helps me.
    Side note: I already tried restarting/turning it on and off and it didn't work

    I'm sorry but I can't find any button written 'Accept' on that page. On the Garageband app it is written Installed in gray just like on the Mac App Store. See the screenshot below if you could:
    Message was edited by: vperes

  • While loop doing AO/AI ... Performanc​e?

    Hi!
    I have been trying to get a VI to do concurrent Analog
    data in and out and both the input and output rates and
    waveforms can change while the VI is running. My problem
    is this:
    (a) If I try putting the read and write operations in
    separate while loops, one or the other loop will
    die in a buffer over/underrun.
    (b) If I put both into the same loop, then this works
    but I am limited in the choice of data-rate parameters
    because eventually one or the other DAQ VI will take
    too long.
    At this point I have only one loop and the buffers are big
    enough to hold 10 iteration. Every time one of the loops
    dies I reset it. Still this seems awkward. Is there a
    way of improving on the loop overhead and putting t
    he
    input and output in separate loops? Or any other way to
    improve performance?
    Rudolf

    Ok, I knew that ocurences did something useful but I am
    still a bit confused:
    * Can you set an occurrence for an output event. None
    of the examples I've seen say so but it looks like
    it should work
    * How do occurrences actually help with the "hanging"
    problem. Does the compiler see the occurrence in
    a loop and change the wait parameters?
    I looked at devzone but most of the stuff I found there,
    even the promising looking stuff was all about
    synchronizing and triggering, not about occurrences.
    Rudolf
    JB wrote:
    : Once in the read function, the program "hangs" until the number of
    : data points is in the buffer. The same applies to the write function.
    : This means that most of the time, your program is waiting.
    : To sol
    ve this problem, you must use DAQ occurrences (--> hardware
    : events).
    : For examples for using daq occurrences, type "daq occurrence" in the
    : search of the LabVIEW help or even better, at
    : http://zone.ni.com/devzone/devzoneweb.nsf
    : Hope this helps

  • Starting new while loop while old one still running

    Hi!
    I am attempting to write video images to AVI files. I want to give the user the option to decide when they want to begin to capture the images. I place the "start recording" button in one loop and the image acquisition and AVI Write subVIs in another loop. LabVIEW won't allow me to continue on with the image acquisition loop until I finish with the "start recording" loop. Any ideas how to fix this (to allow the image acquisition to start and continue having LabVIEW check for a button press on "start recording")?
    Attachments:
    Capture_and_Save_as_AVI.vi ‏177 KB

    Thanks. I suspected as much. In any event, I can't seem to find a good configuration of while loops and case structures which will produce the desired results. I want to start acquiring images and allow the user to choose to start recording at any time he desires. This issue is further complicated by the fact that the status of the "Start recording" must be checked at all times, but only initialized once, while the AVI Write Frame depends on that first initialization step but must be looped continuously aferwards in order to 'keep up' with the images being acquired. In the newly attached example, I placed the case structure inside the image acquisition while loop and the avi write frame inside a while loop inside of that case structure. unfortunately,
    labview decides to stay inside the avi write frame while loop after entering, instead of returning to the image acquisition while loop. i can't place the avi write frame inside the general image acquisition while loop because then labview will think i want to initialize the avi write frame right away and will return an error when avi write frame isn't provided with an avi refnum. Ideas?
    Attachments:
    Capture_and_Save_as_AVI.vi ‏174 KB

  • Noob Help with While Loop

    Sorry for the "Noob"-ness on this one. I am working on a program for class and I am having a problem with a while loop. So I opened a new document and began to code a while loop that is basic to test my while looping skill. Apparrently, I have none. Can anyone tell me why this While Loop will not work:
    public class test
         public static void main(String[] args)
         int LoanTerm = 0;
              while (LoanTerm < 3);
                   System.out.println (LoanTerm);
                   LoanTerm++;
    Thanks.
    FatherVic

    to explain, the ; means that the while loop body is empty, and you will just spin forever testing whether LoanTerm < 3, without doing anything else.

  • Timing with while loop

    Hello,
    How can I do a time with while loop?. I want to read a data in the While- Loop for 1 sec and then go to B .. I added a pic,
    Attachments:
    while- loop.GIF ‏6 KB

    nichts wrote:
    Hello,
    How can I do a time with while loop?. I want to read a data in the While- Loop for 1 sec and then go to B .. I added a pic,
    I would use as GerdW has mentioned,"elapsed time.vi" in a statement 1st case structure, after set time has elapsed> goto 2nd case structure. try not to use flat sequences....this can be done with case statements with transitional coding. I have noticed young LV programmers like to use flat sequences...I think it's a trap set up by LV developers? 

  • Help learning while/do while loops

    Hi everyone, glad to see there are resources out here like this where newbies with Java can get help and learn from the gurues!
    I am having a problem with constructing a while loop that is going to compute the sinx without using the Math.sin function....so given this
    sinx = x - (x^3/3!) + (x^5/5!) - (x^7/7!) + ......
    It seems I need to use the Math.pow function. So the sinx is alternating signs between each new set of parenthesis and the power and factorial are increasing by 2..starting with 3. I think this is were I am having my trouble.
    I was going to use a do-while loop for cosx which is
    cosx = x - (x^2/2!) + (x^4/4!) - (x^6/6!) + ......
    I think my problem is that I can't figure out how I would go about writing this. If I can get the sinx with the while loop, I can probably get the cos on a do-while statement since they are similar. I did get factorial(n) defined below.
    I have another main class which I am using to get the input of sin/cos x using computeSin and computeCos functions I am trying to build here.
    import javax.swing.*;
    public class NewMath
    public static double computeSin(double x)
    double result = x;
              // Going to use A WHILE LOOP
    return result;
         public static double computeCos(double x)
    double result = 1;
              // Going to use a DO-WHILE loop
    return result;
    private double factorial(int x) {
    if (x <= 1) return 1.0;
    else return x * factorial(x - 1);
    Any tibits of help would be nice. If I think I got it working before someone else posts, I'll post my results. Thanks.

    Any tibits of help would be nice. If I think I got
    it working before someone else posts, I'll post my
    results. Thanks.You already have your own tidbits, as you've observed the pattern of alternating adding/subtracting, as well as how the power and factorial factors relate. Any more "tidbits" here would just result in doing it for you, it seems. So get to it, and if you run into specific problems, you can ask.

  • How can I write waveform data from a while loop?

    Alright, I have a NI-5122 high speed digitizer that I need to acquire 10,000 waveforms. I am currently using the NI example code "niScope EX Multi Record Fetch More Than Available Memory.vi" to do this and then onto that later. I set the Number of Records to 10,000, min record length to 8192, and the min sample rate to 100M (S/s). On the Fetch vi,  I set it to get a 1D Dbl array and then send it to the while loop edge for auto indexing. What I want is to take each waveform and write it to a file next to the previous waveform not append it to the bottom of the previous one. I can do 100 and sometimes 1000 waveforms with my current setup and then use "write measurement to file.vi" to save the data, but at 10,000 it says that the memory is full. I have 256 MB on the NI-5122 and 4G of memory on my host computer. My reasoning is that if the NI-5122 can hold all that data then why can't my host computer. I have tried to fetch using 2D Dbl and transpose that matrix and send the data to "write measurement to file.vi" inside the loop and append the data that way, but when I do this the card does not acquire any data. Which seems like a software problem. I know this is probabaly worded poorly, so just post a response if further explanation is needed.
    Thank you.

    Hello,
    It sound like you might have received a LabVIEW: Memory is full message.  Are you also graphing this data as it is being acquired?  Are you building an array inside the loop?  At the 100 MS/s rate, you are using a lot of memory to acquire, graph, build and transpose array data, and then write to file.  If you are saving to file and do not necessary need to see the data, I would suggest taking the graphical indicator out of the code.  Please review some of the KnowledgeBases linked below about the LabVIEW: Memory is full.
    KB 36QD14V3: Why Do I Receive a "Memory is Full, VI Stopped at Loop Tunnel 0xXXXX" Error?
    KB 3ZNDGRS9: LabVIEW "Memory is Full" Error
    Samantha
    National Instruments
    Applications Engineer

Maybe you are looking for

  • My external Firewire drive keeps coming up as read only after reboot.

    Hello everyone, I have a perplexing problem that just cropped up yesterday. I have an iMac (9,1) running Mac OS X 10.6.7. I've had the machine about a month now. I have an external 500GB Firewire 800 drive that holds all my iTunes music files. This w

  • Safari Quit unexpectedly and wont open again

    hello there i download it something from the internet and after that safari wont work anymore on Macbook pro ios 10.10.1 safari 8 it says OK or REOPEN and both wont work its been like this for the past month i tried to fix it by reading online and i

  • Difference advanced & standard module of TRM

    Dear All, Todat I had the question if we were working on the advanced or the standard moudle of treasury and risk manager. I have no idea what the difference is? if any...? Can somebody please explain? kr, Stef

  • Newbie how to define variable of type element?

    JDEV 10.1.3.1 When I perform the following from BPEL designer in JDEV... variable new create variable Select element type Select a local file schema xsd Select element of choice Seems to define OK but fails to compile. Namespaces appear to include th

  • Returning User Password in Java code for custom reports

    Hi I'm doing a custom report and for the life of me I can't seem to find the password field in the database. :( Anyways I'm thinking maybe I can use java code to return the password and then using the decrypt password function. Could someone please s