While loop with reading of text file - calendar of events in a given period

Hello world.

I created a program that if serial interface via a port to a syringe push in my lab. Currently, the program reads in a text file-flow rate values and sends them to the pump, one by one, through various commands. I need to ensure that whenever a new flow rate value is sent to the pump, it does in a specific/hard time for a while. I.e. every 0.1 seconds, changes in flow rate and must are active until the next period. I tried to use a timed loop and I think I've succeeded, but it hogs system resources, so I was wondering if there was a way to do it using the number of cycles or something of this nature. I just started using LabView, so I'm slowly getting the hang of it (easy when you watch my VI!)

See attached VI. I took orders from serial port and have instead orders display in an indicator. The nested and densely populated while loop contains the commands that need to be completed/last during the period (like 0.1 second).

Thank you for your time and help!

-Phebotalus

Hi, you should read some introductory material on LabVIEW to down the idea of the stream.

Basically, the data flow in the wires from left to right, and any node will not work until it has reached all of his contributions.

The thread of the error is the best way to run data streams.

***

In your VI I use data wires, their execution through structures, and forcing the structures to run in the sequence.  Using a structure of sequence you mentioned in your next post will force the two scripts to execute in the order of (the only one we discussed to be in race condition.)

Similarly, for brevity, I would wrap the EMO and she is business structure in a single sequence and force it to run last using stream.  In this way the user has the most possible time to decide to hit the EMO before she is called by the application.  As it is now, it most likely is interviewed at the beginning of the loop, so if it's the exchange value you won't see results until the next loop.

When running in execution of highlight you see the order of data flow, but that is not guaranteed to be the same for a normal performance, where the use of the data stream.

***

The counter tick account ms up to a very large number and then "says" reset and start counting again.  I know you want to START the loop as close to every 10 ms.  Yes, using data flow, take the number of cycles first, perform actions, then return the number of cycles.   The second time of the tick read that you are in a nested loop that does not stop until you get 10 or more difference on the number of cycles.

And, on the off chance that you must achieve "return" on the tick counter comes stops the nested loop then move.  (if the second measurement is less than the first, then the tick counter handed.  If you miss this situation while you'd have to wait a long time for the condition of the difference > 10 in the reunion, basically locked in the loop.

***

You could put the EMO sequence, we have seen, in line with data streams.  Before or after the second control of ticks will not make much difference in terms of 10ms.  I would put it after checking the tick, again give the user more time to hit the EMO if necessary.

***

I put in a queue for the stream error and removed the other stuff.

LV2010

Check out some of the LabVIEW intro docs, they are online, they discuss these issues and much more.

Tags: NI Software

Similar Questions

  • Not able to read the text file several times - Bug?

    I open the Refnum to a text file by starting my software and I'll keep the file open until the software works. I read a text file when an event occurs. The problem that I'm facing here is when I read that the file 1st time Lily can't read the text of the file but when I read it to get even empty string only. Could someone help me understand why this happens.

    A race condition?  What's with the two readings at the same time?  Keep the opened file is not a problem, but remember that there is a file pointer.  If you read empty strings, it's probably because you're at the end of the file.  Use Set leader VI to set Position is for the beginning of the file.

  • How to read a text file with line breaks

    Hello

    I'm reading a text file in a textFrame.  We read in, but does not include line breaks is just a big long line of text.  I use the following code to read the file.  I tried to insert a \n character after each readln() but that has not helped.  I also tried to create a variable that the readln() was crammed in before setting the textFrame.contents variable, but which does not work either. I'm puzzled. Any help would be appreciated, thanks.

    While (! notesDoc.eof) {}

    noteTextRef.contents += notesDoc.readln ();
    }

    Doug

    Just use fileObect.read () instead of fileObect.readln () / / read online also try to use instead of \n \r

  • How to exit while loop with delay schedule?

    I have a pretty heavy program that iteratively takes a series of measures from a number of channels using a variety OR-Switch and OR-DMM screws that I assembled as a result of various examples and several help pages. Each channel is sampled once during each iteration with data to be saved in a text file for later analysis, after it is imported into Excel. I added to the screen 'real time' indicators and charts to see what looks like running data.

    Each iteration is performed using a While loop with a delay timer, even if a previous version, I used a timed loop. Measures for the series of channels are collected with a loop For inside the While loop. The loop For includes screws which:

    1 cut the channel and wait as debounce.

    2 Initializes the DMM and passes the configuration information.

    3. wait for a while to make sure that the DMM is set.

    4. measure.

    5. close the DMM.

    6 disconnect all the switches.

    The terms of the election of the channels is ends in 15-20 seconds and I am currently collecting data every two minutes, so he spends "wait" time "collection". Each iteration of the loop For initializes and closes the DMM to avoid the hot switch.

    Other components of the program are configuration setting controls, etc. (in front of the While loop), a "current measurement" indicator and a writing-text inside the loop file operation For, several indicators of the iteration (inside the While loop, but outside the loop For) and a bunch of operations related to the grouping and table that provide graphics of groups of time vs measures.

    I don't know there are more elegant ways to perform many functions that I do and I'm not posting the VI here because I want to concentrate on what I know, it's a big problem with my program (for now!) - I can't figure out how to get out of the While loop. I tried the combinations of Boolean control, its conditions of latch and Stop / continuous if true to nothing does not.

    I want a 'Stop' button that ends the While loop, at the next opportunity, but it is not working properly, I think, because the stop button does not play with good timing, because the program runs either the loop For or the time delay at the beginning of the While loop. 'Next opportunity' can mean 'Immediately', 'at the end of the next iteration of the loop,"or"at the end of the next delay schedule." I think that if I get one of these scenarios to work, I can get an any of them to work!

    Help, please!


  • A form of Oracle, I want to read a text file.

    A form of Oracle, I want to read a text file. In shape on a press of button I have:

    declare
    in_file Text_IO. Type_de_fichier;
    linebuf VARCHAR2 (1800);
    filename VARCHAR2 (30);
    BEGIN
    filename: = GET_FILE_NAME ('U:\ora_devl\pps\work\a.txt', File_Filter = > ' text (*.txt) | * .txt |');
    in_file: = Text_IO. Fopen (filename, "r");
    LOOP
    Text_IO. Get_Line (in_file, linebuf);
    -: text_item5: =: text_item5 | linebuf | Chr (10);
    Text_IO. New_Line;
    END LOOP;
    EXCEPTION
    WHEN no_data_found THEN
    Text_IO. Put_line ("Closing the file...");
    Text_IO. Fclose (in_file);
    END;

    He gets an ORA-302000. I suspect that the problem starts with the GET_FILE_NAME because when I comment, but treats it continuously without end.

    Forms [32 bit] Version 11.1.1.3.0 (Production)
    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    What can you tell me? Thank you

    GET_FILE_NAME will try to open a 'Open file' dialog box on the server, which obviously cannot happen. If you want to use this type of behavior, you must use the function CLIENT_GET_FILE_NAME and WebUtil. Example:

         filename := CLIENT_GET_FILE_NAME('C:\', File_Filter=> 'Text Files (*.txt)|*.txt|All Files (*.*)|*.*|', dialog_type=> OPEN_FILE);
    

    See the Help Builder Online for more details. You can also view the demo which is available here:

    http://www.Oracle.com/technetwork/developer-tools/forms/downloads/index.html

    More information here:

    http://www.Oracle.com/technetwork/developer-tools/forms/webutil-090641.html

    In addition, it seems that you try to use a mapped drive ('U'). Although this can be made to work, it is not recommended and in some cases is not supported. If you need access to remote files, you must use another mechanism to put the file on the local computer before handling.

  • Read a text file

    I have hopefully a quick question.

    Why doesn't the reading of text file in this example?

    Thank you

    When you write to a text file, LabVIEW keep a pointer with the reference so that you have the file open. So after you write 'test' in the file, your new pointer is now at location 4. When you read on, it reads pointer 4 and on.

    Use the function set the file Position in the palette advanced to read the 0 position.

  • How can I read only text files in a directory.

    I wrote a program to play the files in a directory, but I want to let him read the text files from the directory.

    import java. IO;

    public class {data}

    Public Shared Sub main (String [] args) throws IOException {}

    String target_dir = "C:\\files";

    File dir = new File (target_dir);

    File files [] = dir.listFiles ();

    for (file textfiles: files) {}

    If (textfiles.isFile ()) {}

    InputStream BufferedReader = null;

    try {}

    inputStream = new BufferedReader (new FileReader (textfiles));

    String line;

    While ((line = inputStream.readLine ())! = null) {}

    System.out.println (Line);

    }

    } {Finally

    If (inputStream! = null) {}

    inputStream.close ();

    }

    }

    }

    }

    }

    }

    You mentioned you want to only read text files.

    If you are referring to a specific set of extensions, you can filter on this basis.

    ex: you want to only read .txt files, you can add an if condition as below:

              if(textfiles.getName().endsWith(".txt")) {
                  // Add your code here
              }
    

    See you soon

    AJ

  • testimonial widget that reads the text file

    Is there someone who makes a testimonial widget that can read a text file? I am considering this is a block for customer testimonials that can read a file of say 50 different clients we wil cut and paste from various places, so that there is always a fresh review illustrated.

    Themes of Muse has some text widgets: one as a ticker-tape driveand displays a (small) number of citations. But none will allow you to modify a file of text outside the Muse of let's say 50 paragraphs and read on the page, one by one, in order.

    There are a lot of scripts to do exactly what you want, like this: alternating Message text box . JavaScriptSource, and many others, just Google: "alternating rotation script of text message". But are you able to manage scripts and HTML codes in Muse ? Maybe some useful script Wizard can cook a place for you or modify an existing one, provide you a text template file and help hair and be implemented in Muse page.

    Don't let them not to edit your output !

    Ask them to help you with a method to ensure within the Muse:

    1. adds a style and script in the header of page (see Page Properties)

    2 Insert the HTML code on the page (under the object menu)

    3 attach the text file on the site (hyperlink, link to the file)

    So, you can change the text file and download all changes with Muse.

    Hope this helps?

  • USB for my iPhone, so it can read a text file

    Hi, I would like to be able to connect a standard USB to my iPhone, so it can read a text file from USB, any suggestions on cable/apps? Thank you, Tony

    Hello. In fact, you can use any USB adapter to connect your iPhone to the computer and transfer text files. Apple recommends the adapter like this http://www.apple.com/shop/product/MD820AM/A/lightning-to-micro-usb-adapter

  • Read a text file in a cod

    I'm sure this must be quite easily, but can someone please tell me how I can read a text file, I want to display as a resource?

    There are methods available for playback of image files, but I have never attempts to read a text file...

    Thank you

    The same as any other file. The most important thing is to get an input stream. After that, you can for example read as bytes and create a string of. It really depends on the content.

    InputStream input is Class.forName("yourClass").getResourceAsStream ("resource_file_name");.

    Then something like:

    data from Byte [] = new ubyte [4096]; or the actual size of the stream
    int len = 0;
    Len = input.read (data);
    If (len == 0)
    {
    System.out.println ("empty folder");
    return;
    }
                   
    Dim str As String = new String (data, 0, len);

    Of course, it's just sort of pseudocode.

    Rab

  • Control and Simulation in a loop / while loop with TCP/IP reading / writing of synchronization

    Hello, I have a problem with reading TCP/IP and written in two loops. The problem is NOT to get the two loops to read and write to and from the other. This has been accomplished. My problem is when I run control and the loop simulation on my laptop and the while on a RTOS remote on the controller on-Board of LabVIEW in a remote PXI chassis, the while loop the remote system running on four 4 times faster than the loop control and simulation on my laptop. In other words, for each iteration of the loop control and simulation on my laptop, there are 4 four iterations of the while loop on the remote system. I need to know how to get a degree of kinship (1:1) with these iterations of the loop. When I run a longer simulation in real time, say 10 seconds, the control and Simulation loop begins to slow, i.e. the simulation time slows down until it is no longer in real time and the "Late Finish"? Parameter is set to true and the LED lights and continues to stay lit. At this point, the system destabilizes due to what I believe is being well sampling rate too discreet and I have to end the simulation. How can I get a ratio of one to one between the loops and also to avoid slowing the loops causing destabilization?

    To give an overview of my application, I implement a control system in a network, seen in "image2.png". This is achieved using my laptop as a subsystem 1. Reference signals are generated from the laptop and the error signal is produced. Control measures taken and the control signals are sent via TCP/IP to the remote system. Position feedback is returned, and the process repeats. My system has Core I7 Procs w / 3 GB of RAM, up to 1 GB/s speed via ethernet and LabVIEW 2011 installed with all necessary modules and networking tools. The attached VI Custom_Wireless_Controller works on my laptop. The remote system I'm working on that has the 7830 NI R Series with FPGA card. OTN runs on the PXI chassis with an enbedded controller that has networking capabilities of up to 100 MB/s via ethernet. I use the FPGA for the acquisition of data and apply control signals to my plant. The plant is the PCE twist connected to the FPGA through the cable of the ECP - RIO of NOR. Subsystem 2 is this side of the CNE. The FPGA collects position, he sends to the controller via the network, receives signals from the network drive and writes signals to the plant power amplifier that operates the plant. This process is repeated and the VI and is titled Custom_Wireless_Plant.

    I appreciate the help really and look forward for her and for any question!

    Well, the first step is to understand what you have set up right now. Your control and Simulation loop on the side of the controller is configured as 'Runga Kutta 4' and you have a loop timed on the other side. In addition, you have the primitives of TCP/IP on the control and the Simulation diagram and means he will perform (a message) on the size of each minor step, which in your case is 4.

    So, you have two options:

    1. replace the Solver side controller Runga Kutta 1 (this must synchronize loops)

    2. hold RK 4, but create a Subvi around two primitives of TCP/IP and configure from the VI to run than the major (continuous) step-size. If you do it right, you should see a 'C' on the upper right part of the VI you have created.

    Please let me know if what I said is not clear...

  • 2 parallel while loops with functional overall to share data

    Hello

    I'm having a problem with the sharing of functional with globals data between two parallel while loops:

    1. One of the loop (bottom) generates a random number periodically and write the total functional sample.
    2. Another loop (above) has a structure of event and when it expires, he would read the functional global and intrigue, a chart data point.

    The problem is sometimes the functional overall seems to be 'locked' and the output becomes zero constant. It also seems that whenever I first open the VI, it works fine. But for the second time running, he begins to have the problem.

    You must initialize your VI stop FGV FRONT of your lower loop begins.  Even if you use a global variable that is functional, you have a race condition.  FGV is read in the lower loop until it had a chance to be initialized with a value of false in the upper loop.  Functional global variables do not forget their data between executions of the VI.  So it is always set on stop the last time that you ran the VI.  This works your VI the first time it's because VI does not have in memory, so when it loads, it loads with the default value False in the shift register.

  • Can LabVIEW read a text file on Internet?

    I'm using LabVIEW 8.5 and I would read a text unformatted line stored on a web site file (example: www.text.com/test.txt).

    I found that I can not do so using the standard text file reading Subvi. is there a better way?

    Thank you for your help.

    Don't forget form the full url (for example starting with ftp or http).

    You may also need to add the string [text] at the end of the URL. See help.

    Here is an excerpt:

  • Not able to read a text file or binary

    I am reading in a file text or binary, as shown in the Blackberry "how - adds an application of plain text or binary files"

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/How_To _...

    I use Eclipse 3.4.2 I implemented a project of Blackberry with the following structure:

    Test1 (project name)

    -src (folder)

    |   + com.name.xxx

    |   + com.name.yyy

    |            Test1.Java

    + NET_RIM_BLACKBERRY

    |

    -test

    I'm reading in the test file is at the level of the main project folder.  For example, the Test1.jdp file is located in the folder of the main project and the test file (text file or binary).  I am trying to access the file using the line of code below:

    Class classs = Class.forName(this.getClass().getName());
    
    InputStream is = classs.getResourceAsStream("/test");
    

    The getResourceAsStream indicates that the file will be in the same location as the location of the Test1.jdp file if the bar oblique is in front of the name of the file, or that it will look in the source for the main class file.  When I have the slash I get error

    CAFETERIA: could not find the test file

    I tried several different attempt to get to the CAFETERIA to find the file, but I'm running out of ideas and I would appreciate someone else's ideas on what to try.

    Thank you

    Thank you klyubin and stef

    I found a solution that works for me with Eclipse plug-ins, JDE.

    First, the example of Blackberry in the how-to (see original thread number) with test as file is named simply 'test '.  This does not work for me at all in Eclipse.  I gave up to place the file in the folder of the project Eclipse (main folder) and placed in the src folder, which of course gives a compile error because is not a Java file, and of course when using file name in my java code I changed the code correctly as in the first line that follows :

    
    // this will look in the source folder of the class // that myClass refers tois = myClass.getResourceAsStream("test.txt");
    
    // this is supposed to refer to a file called 'test' // in the source folder of the class that myClass refers to // but apparently for Eclipse it must have a .txt extension// as in the above exampleis = myClass.getResourceAsStream("test");
    
    // this is supposed to refer to a file called 'test' // in the main project folder but not apparenlty for Eclipseis = myClass.getResourceAsStream("/test");
    
    // this is supposed to refer to a file called 'test.txt' // in the main project folder but not apparenlty for Eclipseis = myClass.getResourceAsStream("/test.txt");             } 
    

    Note: I was also getting the error message when I place the file named "test" in the src below directory.  I managed to get rid of this error message by configuring the path building (similar to deleting the file of the JDP file including klyubin suggested above for Blackberry JDE ordinary rather than the plugin Eclipse) to remove the file 'test' for compiling so I would not get the compile error.

    However, this was not my main problem - if you name the file test.txt and place it in the src directory you do not get this error I believe.

    Errors during construction

    Errors running builder "Blackberry resources Builder" on the project...

    Could not compile files

    java.io.FileNotFoundException: C:\path to the file I had added in the directory\.rrh of the source (or some truncation of the file name .rrh - for example te.rrh)

    Finally, I have checked the jar (as klyubin suggested) file that is created when I place the file 'test' or 'test.txt' in my Eclipse project main folder.  The jar file did not contain the name file and so when I run in the Simulator, the file is not found.  Even when I put the file in the jar (main directory) myself the Simulator still could not find the file.   When I placed the test.txt file in my directory src the jar resulting file contains the file named and the Simulator can find the file ok.

    So, it seems to me that for the plug-in Eclipse JDE contextual explanation of the method getResourceAsStream does not apply as described at this time.

    getResourceAsStream

    public InputStream getResourceAsStream(String name)
    

    Looking for a resource with a given name. This method returns null if no resource with this name is found. The rules looking for resources associated with a given class are specific profile. RIM implementation notes: this method searches the resource from the directory in which the current JDP project file is located. By default, it is assumed that this JDP file resides in the parent directory of the package of the current project space. Thus, the package space tree (for example, com/rim/PackageName) is added to name so that the search begins from this space package, that is, in the source directory of the current project. However, if the current JDP project file does not lie in its presumed location, the behavior above prevent the resource located. In this case, the user must add a slash (/) in the name of the resource before calling getResourceAsStream. This treats the name as an absolute path, which is compared to a tree whose root is the location of the JDP file. Parameters: name - name of the desired resource Returns: a java.io.InputStream object. Since: JDK1.1

    If Alain klyubin (or someone else) can enlighten us more on why the file should be named *.txt to find the file in the source directory, which can be useful to me and others in the future.  My real goal is to read in an image file named *.jpeg.  We'll see how it goes.

    And thank you klyubin for the suggested code change which I had also found in another thread...

    // this was more than what was necessary//Class myClass = Class.forName(this.getClass().getName());
    
    // this is simpler  Class myClass = this.getClass();
    

    And so many other Eclipse users who try to follow the Blackberry How To - add a text or a binary file in an application, do not forget to consult the file name in your code java as in the examples that I gave above.

  • Reading a text file

    I did a code that reads values in the text file. Now I want to produce a chart that can watch the number of items in the files (x axis) and the values in the text file (y-axis).


Maybe you are looking for

  • Music and playlists in iTunes

    I just added a CD in iTunes "Add folder to library" which went well. The tracks are now show under "Recently added" but I have problems adding these tracks in my playlists. The pearls of wisdom? Thank you

  • Virus problem on Satellite M30x-174?

    Tonight when I got home from work my laptop startet to behave very strange. Last night it worked fine. But now as soon as it loaded windows it says "failed to load for laptop policy" and it is almost impossible to launch a program (an anti-virus prog

  • How to contact with SQL using LabVIEW 7.1... ?

    Hello... I want to create a system that deals with the database and stores the database to the server through SQL... Can someone guide me please how to contact SQL using LabVIEW 7.1... ? Thanks for any help on your part...

  • Google talk plugin Setup error 1603

    Original title: I haveagoogletalkplugin error 1603.I can notload google talk plugin neverhadproblem beforeand cantfix he... Help Google talkplugin can not be charged more on my google phone error 1603 whenever I try toload the plugin to talk... I kno

  • ASA ips feature

    I want to ask you what the works of IPS on ASAs functionality. There all the signatures, or it is limited? Perfect me if Iam wrong if I say that I needed module AIM for ips work on the asa. If Iam right, so why AIM has only 1 ethernet interface. This