Write time stamp and Voltage to text file

I am a novice 2011 LabVIEW user and am trying to build a program that will write TIME in one column and VOLTAGE in another to a text file for later interpretation with MATLAB. I started to add elements to an existing code, which I downloaded from the examples forum, because it works well for my purposes of sending a finite square signal. The code that I started modifying is attached to this thread. If somebody wants to take the time to provide me with an example of how I can do this with my existing code, it would be greatly appreciated. I learn better from example.
Regards,
Sean. 
Attachments:
Voltage - Generate and Write.vi ‏99 KB

This is a pretty simple set of code that every 5 seconds writes to a csv file that is stored in the location shown in the code. In order to apply something similar to your code simply run the data that you wish to store into the concatenate strings in the form of a string and it should be fine. 
Although after looking over your code a second time you should probably take a look at the convert "Array to Spreadsheet string" function, all you would have to feed it is an array of times and measurements at the completion of your program and feed it into a file and it should do everything for you.
Attachments:
Write to File.vi ‏20 KB

Similar Messages

  • Time stamp to name a TDMS file

    Hi:
    I am using data from excel files to create a time stamp, after that,my VI creates TDMS files with this data in files with 5000 samples, also I am using time stamp to named the TDMS files, but my problem is that my first file takes the name 180000.000, How can I modify this? because I need my file´s name will be the first data from excel.
    I attached my VI and two excel files, the idea is that the first file will be 84327.500 and the second will be 84740.950
    Attachments:
    test1.xlsx ‏150 KB
    test2.xlsx ‏151 KB
    testfile.vi ‏56 KB

    First, let me congratulate you on taking your first steps to learning LabVIEW. If you have not already done it, I highly recommend you go through the online tutorials. You have an actual project to work on, so application of what you learn will be fairly immediate.
    For your actual program issue, you need to read the data from the Excel file and convert it to a timestamp before you set your filename. The order of operation of your program is to set the TDMS file name while simulataneously reading from the Excel file. After you have already created the TDMS file, you convert the data to a timestamp and write this to your timestamp front panel control. Note that the first point you write to the TDMS file may or may not be what you think it is. It could easily be the same 180000.000 value you are using to name the TDMS file. You have what is known as a race condition. The order of operation between the read and write of the timestamp control is not known and can be variable. It is one of the reasons that you should NEVER use local variables to pass data around. Use wires. In LabVIEW, wires are the data and take the place of variables in a text base language. Front panel controls should be used only for user interace reasons. In your loop, you should wire the timestamp from its current conversion (wired into the timestamp on the front panel) directly to the TDMS write (currently wired from a local variable of timestamp).
    A couple of other things. You do not need to convert your data arrays to matrices to index them. This can be done directly with Index Array from the array palette. This single primitive will replace the Array Subset, convert to matrix, and index matrix primitives.
    You do not need to go through a string conversion to produce a timestamp. The Date/Time to Seconds primitive in the timing palette will do it directly. You will need to populate the cluster input.
    When you posted your code, you did not include your subVIs. In the future, include all your VIs, either separately or in a ZIP file.
    Finally, to solve your intial problem, use Index Array to pull the first row of data from the Excel file, then convert this to a timestamp using Date/Time to Seconds. Use this to create your TDMS file.
    You may have noticed, if you do all this, you do not need your timestamp front panel control, other than as a simple monitor.
    Good luck! Welcome to LabVIEW.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • How to add header and fooder in text file

    Hi,
    i have created simple application for generate report from database into text file.
    But i need to add header and fooder in text file. I dont know is there any API for adding these.
    Can anyone help me to create header and fooder in text file.
    the below text are needs to be print in the header
    name of the table :
    Recorder type :
    file creation time:
    the below text are needs to be print in the footer
    Recorder Number:
    Record Type;
    the actual code is
                           pst = con.prepareStatement("select REQUEST, DOMAIN_NAME, TRUNC(DATE_OF_CONFIGURATION) AS dateofConfig  FROM employee where id=300");
                               rs = pst.executeQuery();
                            while (rs.next()) {
                                 request = rs.getString("REQUEST");
                                    domain_name = rs.getString("DOMAIN_NAME");
                                    dateofconfig = rs.getString("dateofConfig");
                                    System.out.println(request + " " + domain_name + " " + dateofconfig);
                                   data.add(request + " " + domain_name + " " + dateofconfig);
                            System.out.println("before calling method");
                            writeToFile(data, "c:/Employee.txt");
                            System.out.println("file created successfull");
                            rs.close();
                            pst.close();
           private static void writeToFile(List list, String path) {
                    BufferedWriter out = null;
                    try {
                            File file = new File(path);
                            out = new BufferedWriter(new FileWriter(file, true));
                            for (Object obj : list) {
                                String s=  obj.toString(); 
                                 out.write(s);
                                    out.newLine();
                            out.close();
                    } catch (IOException e) {
    }Thanks
    Jasmin
    Edited by: user13836688 on Mar 21, 2011 4:06 AM
    Edited by: user13836688 on Mar 21, 2011 4:07 AM
    Edited by: user13836688 on Mar 21, 2011 4:08 AM

    user13836688 wrote:
    i have created simple application for generate report from database into text file.First off, when posting code, use &#91;code]...&#91;/code]. or '' tags, not '<code>'.
    But i need to add header and fooder in text file. I dont know is there any API for adding these.
    Can anyone help me to create header and fooder in text file.Well you plainly have the code to write the file contents; and furthermore your report seems to be contained in a List called 'data'. Why not just add the header and footer lines to it? I'd also suggest making 'data' a LinkedList. That way you can add the header afterwards with no performance hit, just in case the information it contains isn't available at the start of your report loop.
    Winston                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to list the contents of an OSX directory, and output to text file?

    hello there any hints with any known program that does following
    I have recorded my music directory to DVD and now i would like to make an .txt file what the dvd contains...cos its way of hand to write all 100xx files by hand...
    How to list the contents of an OSX directory, and output to text file?
    any prog that does that? any hints?
    best regards

    This script makes a hierarchical file listing all files in a folder and subfolder:
    Click here to launch Script Editor.
    choose folder with prompt "Choose a folder to process..." returning theFolder
    set theName to name of (info for theFolder)
    set thepath to quoted form of POSIX path of theFolder
    set currentIndex to theFolder as string
    do shell script "ls -R " & thepath returning theDir
    set theDirList to every paragraph of theDir
    set newList to {"Contents of folder \"" & theName & "\"" & return & thepath & return & return}
    set theFilePrefix to ""
    repeat with i from 1 to count of theDirList
    set theLine to item i of theDirList
    set my text item delimiters to "/"
    set theMarker to count of text items of thepath
    set theCount to count of text items of theLine
    set currentFolder to text item -1 of theLine
    set theFolderPrefix to ""
    if theCount is greater than theMarker then
    set theNestIndex to theCount - theMarker
    set theTally to -1
    set theFilePrefix to ""
    set theSuffix to ""
    repeat theNestIndex times
    set theFolderPrefix to theFolderPrefix & tab
    set theFilePrefix to theFilePrefix & tab
    if theTally is -1 then
    set theSuffix to text item theTally of theLine & theSuffix
    else
    set theSuffix to text item theTally of theLine & ":" & theSuffix
    end if
    set currentIndex to "" & theFolder & theSuffix
    set theTally to theTally - 1
    end repeat
    end if
    set my text item delimiters to ""
    if theLine is not "" then
    if word 1 of theLine is "Volumes" then
    set end of newList to theFolderPrefix & "Folder: > " & currentFolder & return
    else
    try
    if not folder of (info for alias (currentIndex & theLine & ":")) then
    set end of newList to theFilePrefix & tab & tab & tab & "> " & theLine & return
    end if
    end try
    end if
    end if
    end repeat
    open for access file ((path to desktop as string) & "Contents of folder- " & theName & ".txt") ¬
    with write permission returning theFile
    write (newList as string) to theFile
    close access theFile

  • Can you use an external hard drive (G-Tech 1 TB) as both a time machine and for storing extra files?

    I just got a new external hard drive and will be getting my macbook pro next week. I was wondering if the external hard drive could be used as both a time machine and to have extra files on it? And if so how would you do that?

    Time Machine requires a drive that is formatted in Mac OS Extended (Journaled), so you will need to check to make sure that this requirement is met.
    A drive that the manufacturer says will work with both Mac and Windows will not work with Time Machine.

  • ALE, IDOC - need to send IDOC and create a text file

    Hi,
    i need to send idoc to some other system and create a text file in that.
    I want sent data to Channel Cluster.
    what are the settings required for that in transactions
    BD54
    SCC4
    SM59 - which connection is required
    WE21 - which type of port
    WE20 - which partner
    BD64
    Is there any other function modules required.
    which function module is suitable like MASTER_IDOC_DISTRIBUTE.

    Hi,
    SM59 - Use TCP/IP Connection with connection type 'T'
    WE20 - Partner Name can be logical system name, if it is a vendor/customer you can configure it under the respective names.
    Thanks
    Krithika

  • Extract date/time stamp and modifier name from memo field

    I need to extract all date/time stamps and modifier name strings from the Work Log memo field - or conversely, filter out all of the comments after the date/time modifier strings.    I have the string extract but it only extracts the first one.  I need to loop until all are found - how can I do this?  The memo field will look something like this:
    3/5/2009 3:32:05 PM John Doe
    Comments - string can be any length
    3/4/2009 12:35:43 PM John Doe
    Comments - string can be any length
    3/4/2009 12:28:17 PM Jane Dough
    Comments - string can be any length and include date format 2009-06-04 14:20 CST.
    3/4/2009 12:27:47 PM Mary HadaliddleLam
    Comments - string can be any length
    3/4/2009 12:26:55 PM Lamseedivy
    Comments - string can be any length
    3/4/2009 12:15:22 PM Mareseedoes
    Comments - string can be any length.

    Here is a formula that will strip all 'comment' and blank lines and puts the datetime stamp and user names into an array.  You have to manipulate the elements of the array to further separate the datetime stamp and user name if required.
    // Declare two indices
    numbervar i := 1;
    numbervar j := 1;
    // Split each row of the memo field into an array
    // if chr(10) does not work then try with chrw(13) or chr(13)
    stringvar array x := split({Sheet1_.Comments},chr(10));
    // Declare a holding array
    stringvar array y;
    // Declare the size of the new array to be equal to the elements in array 1
    redim y[ubound(x)];
    // Copy only if the first word of each element of array 1 is neither "comments" nor a blank line
    for i := 1 to ubound(x) do
    if split(x<i>) = 'comments' or x<i> = '' then
    else
    (y[j] := x<i>;
    j := j + 1;
    // Compress the new array to eliminate the last blank element
    redim preserve y[j-1];
    // Joining the elements of the new array and the number of elements for display
    join(y,chrw(13)) & chrw(13) & ubound(y);
    With your example, this formula will return:
    3/5/2009 3:32:05 PM John Doe
    3/4/2009 12:35:43 PM John Doe
    3/4/2009 12:28:17 PM Jane Dough
    3/4/2009 12:27:47 PM Mary HadaliddleLam
    3/4/2009 12:26:55 PM Lamseedivy
    3/4/2009 12:15:22 PM Mareseedoes
    6.00
    Make sure the "can grow" option is checked to display the results and also check for case sensitivity of "comments".
    Edited by: Sanjay Kodidine on Jun 30, 2009 10:13 AM

  • GetSelectedFields()  for time stamp and user stamp using java api

    using Java API's
    getSelectedFields() returns NULL  value if values presented also, for Time stamp and User stamp
    properties in Flat tables , is there any other alternative way to get the SelectedFields values ?
    Edited by: Vijaya Sekhar Reddy Alla on Mar 19, 2008 3:16 PM

    Well, I can't say I solved the problem, because I got another one afterwards.
    As usually I created a GetFieldListCommand, set its needed attributes and executed it. Then I read all the field properties out:
    FieldProperties[] fieldProp = getFieldListCommand.getFields();
    Afterwards it is possible to do what you want. Using a for-loop.
    for (FieldProperties fp : fieldProperties) {
        UserStampFieldProperties usfp = (UserStampFieldProperties) fp; // <= Cast error
        FieldId[] fieldIDs = usfp.getSelectedFields();
    And this is what I get now:
    Exception in thread "main" java.lang.ClassCastException: com.sap.mdm.schema.fields.FixedWidthTextFieldProperties cannot be cast to com.sap.mdm.schema.fields.UserStampFieldProperties
    Why this happens, I don't know. But it should somehow be solveable.

  • I used "Get Waveform Components" to separate waveform data. I need to get the time stamp and write it on file as an header.

    I am not able to solve the problem because I can't find an I/O vi that writes on file time stamp data. An error occurs, because of connecting different data types. How can I convert time stamp data so that I can use it as input in a write on file vi? Please, help me!

    The problem with the selection seems to be that you are using two different indexing tunnels on the for loop. One of them loops over every value of the first incoming waveform, the other one over all waveforms in the incoming array. The value you wire to the N terminal will be ignored, the number of loop executions will be the minimum of your indexes. Anyway, the loop doesn't seem to do what you wanted:
    - If you want to store the complete waveform: loop over all waveforms, check for the maximum of each of them and write it just like you do now.
    - If you want to store only the values of each waveform that actually exceeded the threshold: You can either use 2 nested for loops to iterate over each value of each waveform. Use shift registers t
    o create new arrays of timestamps / values for the values you want to store. You need to either convert the waveform to x-y-pairs (VI on analog waveform palette) or calculate your own timestamps. You might as well want to check out the "Search waveform" VI. Configure it so that value+-tolerance covers the band between your expected minimum value and your threshold value. The VI will give you the indices and timestamps of all fits.

  • Writing time and voltage to a file

    I am using labview 7 Express with Windows XP. I have a PCI-MIO-16XE-10 DAQ card. I want my program to update 5 times a second. It is doing this with a while loop. However, I only want to write the date to a file once every 10 seconds. I want to write the time, and two voltage values to the file. Now it writes the voltages to a file every time it updates, and only the voltages,not the time. I am using the write to spreadsheet file.vi. I was unable to attach the labview file to this question, hope I can still get some help. Thanks.

    If you're using the Write to Spreadsheet File VI, then you're closing the file after each write -- then it should be easy.
    To time when the time should be written, you can either count the number of times your loop has run, divide that by 50 using the Quotient and Remainder VI (5 times a second times 10 seconds), and take the Remainder and any time it is 0, write the time...
    Or you can check the current time every loop, and when the difference from when the last time the time was written is greater than 10 seconds, write the time again...
    Anyway, get the current time string, concatenate a tab after it, and wire that to the Write Characters to File VI, using the same filename that your Write to Spreadsheet VI is using. This will put the current
    time into your spreadsheet file and add a tab, so that your spreadsheet file is still in the right format. (The "spreadsheet" file is just a tab-delimited text file, where the text is your data.)
    Mark

  • Write voltage to text file

    I am reading voltages from a few instruments that are currently being displayed in numeric indicators.  How would I write the voltages read from each channel to separate text or spreadsheet files?

    Hello Aye,
    to save to a spreadsheet file just bundle all info into a 1D array (if you read a point voltage), of into a 2D array (if you read several voltages over time).
    if you want to make nice report on every channel, here a solution to save on a text file. every voltage reed gets an index and its value. the finished string goes to a "save to txt file"
    Message Edited by Gabi1 on 05-06-2007 02:11 PM
    Message Edited by Gabi1 on 05-06-2007 02:12 PM
    ... And here's where I keep assorted lengths of wires...
    Attachments:
    save to spreadsheat and to text.PNG ‏7 KB

  • Write x y position and voltage to same file

    Hi,
    I've been writing a program to perform a 2D scan with stepper motors.  There are actually 3 in the program but only 2 perform the scan.  I have used a subvi to take 10 voltage measurements at each position in the scan.  What I'd like to do is record the X and Y position for each set of 10 voltage measurements.  I'm fairly sure I can record the position with the 'GetPosition' function for the motors, but am a little lost on how to get them to write to the same file, and whether or not those positions would correspond to the voltages taken there.  I have included my vi and the subvi used for reference.  If anyone has any suggestions on this problem I'd greatly appreciate it.
    Cheers
    RJ
    Attachments:
    xyz scan 015.vi ‏116 KB
    Keithley 2000 Read Multiple.vi ‏44 KB

    rjwilliams wrote:
    ... I'm fairly sure I can record the position with the 'GetPosition' function for the motors, but am a little lost
    on how to get them to write to the same file, and whether or not those positions would correspond to the
    voltages taken there.
    Well, this is a bit too diffuse. You seem to be writing to a file, but the code is nearly incomprehesible from a dataflow point of view.
    If you are not sure if the file contais the correct values, just run the program, proble the wires, and look at the file later. You should be
    able to tell if the are correct or not. Why should they be different? What values do you expect? What values do you get?
    I agree with Ray that you NEED to cleaup the code in order to troubleshoot. Your code is just a bewildering jumble of code fragments,
    trapped deep inside stacks of while loops and event structures, all tied together with confusing logic.  All you need is a simple state
    machine with one while loop containing one event structure.
    Message Edited by altenbach on 07-07-2008 07:48 AM
    LabVIEW Champion . Do more with less code and in less time .

  • How to write time stamp to a file

    Hi,
    I'm using LabVIEW 8.2 and for my simulations purpose I've to store my data with time stamp (seconds having 6 digit precision ) in a text file.
    I'm using get time vi to get the time of the host computer on a  6 point precision (which I've attached also). My problem is I'm unable to convert this time stamp into string which can be written to text file directly. I would prefer to avoid the "unbundle cluster" which gives me individual elements (like seconds,date,time,year,day of the year, etc) and them convert each of them into a string.
    Looking to hear from any one of you soon,
    Regards
    Attachments:
    get time.vi ‏14 KB

    Hi Roiht
    You will never achieve 6 digits precision with the "get date/ time i seconds function" Perhaps 1 if you are lucky. But you can convert the time to string using the "format data/time string" function. You find it in the same palette as the other time functions.
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • FINDING, TIME STAMPING, AND SAVING SELECTED PORTIONS OF WAV FILE

    Hello Everyone,
    LV 6.1
    What I'm trying to do is build an app that
    captures, timestamps and saves peaks only in a *.wav file from the sound card.
    Specifically, dog barking.  My dream would be that I have a constant input
    from a mike into the sound card which LV will real time analyze. When a threshold is triggered
    (a dog bark) the app will save the bark only with a time stamp.  My case against
    my neighbors would be better exemplified is I were able to present them with a
    time-of-day graph with tic marks at each bark and a cd they could listen to of
    the barks only.
    Explorations so far:
      The sound VI's don't have time stamp outputs
      I have searched the knowledge base and found a few apps but came to a dead end with my knowledge
      I have experimented with various waveform analysis vi's but can't find the combo that gives me what I'm looking for
    I can handle the post processing of graphs / spreadsheets but the waveform analysis for capturing the bark is eluding me. If someone could just get me started I could run with it but so far I ain't smart enough.
    Thank You...........

    Hi rscully,
    I think a great starting place is the "Sound Input to File.vi" example found in the Example Finder. Since the output is waveform data, you should be able to extract the timing information from the waveform data. Try using the "Get Waveform Components" function. If that doesn't work for you, you may also want to just grab the time stamp from the system clock with the "Get Date/Time String" function.
    To record the bark, you can perform signal processing to match the bark frequency. The first thing that comes to mind, is to record a bark, analyze the power spectrum to find the peak power at a specific frequency range. Then in your program, you can find the power spectrum for that specific frequency range, and if the peak within that range exceeds a threshold, record the bark and time-stamp. This method should be simple if you have the NI Spectral Measurements Toolkit. See this tutorial.
    Once you have verified that a bark has occurred, you may want to record the previous bark sound data and the post bark sound data. This will ensure that the entire bark is captured in a sound file. I have edited the "Sound Input to File.vi" example to demonstrate this. Please see the attached picture. I hope this helps!
    Mike Lyons
    National Instruments
    http://www.ni.com/devzone
    Attachments:
    record_bark.jpg ‏105 KB

  • Forwarding text mssg so it includes date /time stamp and number sent to

    My blackberry would forward or email a text message so that it included the address sent to, and was date and time stamped.
    I see how to forward in the iphone 4 ( Verizon) but it only send sends the message with no other data.
    How can I get it to include the data ?

    dbbrass wrote:
    Improved messaging and notifications is one of the big things of which many iPhone users are hoping gets added in the next major iOS update (iOS 5).  Keep your fingers crossed.
    If enough people put an enhancement request it may happen a whole lot sooner. 

Maybe you are looking for

  • Currency translation - not picking up currencies from master data

    Hi, We have a currency translation defined for a key figure. We've defined a variable for users to select target currency. 0currency is set to pick up from master data, but the input help on the variable is only showing currencies from infoprovider.

  • Getting error While run adop phase=prepare allnodes=yes action=db

    Hi , While running adop phase=prepare allnode=yes action=db. I am running this command on master node and it got completed ,while on slave not node it ended with error. Below is the status of adop adop -status Current Patching Session ID: 13 Node Nam

  • Copy and Paste not working properly in MLion

    A week or so ago I purchased and installed the upgrade to Mountain Lion OS X. Whenever I try to copy large number of files from one folder to onother in my desktop, the copy and paste process does not. Copy/Paste of a few files works, different from 

  • Problem in insert image function

    Hi there...I'm brand, spanking new to Dreamweaver CS3, and I just started working through tutorials to try to learn the software. I'm having a little issue with something that is problem very easily fixable to the gurus here. When I tell Dreamweaver

  • Import package error in SAP BPC 4.1

    Hi, Can anyone please assist. I tried running the import package several times on bpc ver 4.1 without aby success. I even tripple checked Users and Security and it validated successfully but the package still crashes in the middle of processing. The