How to save the data of different rates in a single VI?

Hello

I tried to acquire 2-channel measurement of voltage at 10 kHz and analyze data, finally to save the data to both 1 kHz and 1 Hz. What I did is this loop of producer/consumer use to do the work of recording at different rates. I have queued all the data in the main loop, and then removed the data and write it to the file in other loops. I added "wait = 1 ms' a consumer loop for recording data at 1 kHz (loop of fast logging) and added" wait = 1000ms' in another loop to get the slow 1 Hz (logging loop) data record.

My problem is that the data record works fine in the case of 1 Hz, but it does not work for the case of 1 kHz. Although the time-out period defined as 1ms, the interval between two samples in the loop of fast data recording is about 100ms.  Subsequently, 1ms, 10ms, 100ms, 150ms tried in this loop to see what intervals are in these cases. I found that the intervals are same as assigned in the timeout greater than 100 ms, but if the time-out is set to 1ms or 10ms, the intervals are again around 100ms.

My question is - why I can't reach data record 1 kHz using loop of consumers/producers, while the same way works for the case of 1 Hz?

Thank you very much

Hao

You are sampling at 10 kHz and you want to back up your data "as if you sampled at 1 kHz and 1 Hz", if I understand correctly.  I also understand that you use the design of producer/consumer model to help with this (a good idea).

I'm assuming that the producer 'product' a segment of data at a time, to say the value of a second of data or a 2 x 10000 I16 (assuming a 16-bit integer A/D) table you put into a queue and wait for the consumer.

If you have data at 10 kHz, how do you get representations to 1 kHz or 1 Hz?  There are (at least) two possibilities - average data over the interval of proper time, or (re) sample data.  The good thing is that you can handle the situation 1 kHz and 1 Hz, essentially at the same time and in the same processing loop.  I'll discuss the case 1 kHz - with the assumptions I made, the case of 1 Hz becomes almost trivial.  I'll discuss treatment also just one channel, as it is similarly almost trivial to go from 1 to N-channel.

If you have 1 second of data sampled at 10 kHz, and will "reduce" 1 second of data sampled at 1 kHz.  Note that you have 10 samples for each data point that you want in the end.  The "Averaging" method said "Replace all 10 points in the average of these 10 points", while "resampling" method said "replace 10 points with, say, the first point, ignoring the others.  An easy way to do this is to use the Reshape feature to transform an array of 10 x 1000 elements of your array of 10000 items 1-D 2D.  Now, you can use a loop FOR an average of 10 items or simply extract the first.  [This is where almost everyone, including me, a mistake - when you put a 10 x 1000 2D array in a loop, you get 10 iterations of 1000 items and we want 1000 iterations of 10 items.]  Oops, what to do?  [Simple - converts 2D array before sending in the loop FOR.]

So when you have processed your 10,000 points and got both 1000 samples "1 kHz" and 1 "1 Hz" sample, you write each of them in their respective folder and wait for the next item in the queue of the consumer.  Consumer focus on the queue loop, it will automatically 'block', waiting for the producer of the 'feed' some data.  Note that the producer generates data once per second, producing 10000 points for the consumer in the process, but the time to deal with these points and perform the required disk i/o should take only a few milliseconds (certainly not more than 100, even if writing to a floppy!), so you don't have much time to do other interesting things (such as display data).

Bob Schor

Tags: NI Software

Similar Questions

  • How to save the data in table 1 d to Excel in continuous

    Mr President.

    How to save the data in table 1 d to Excel at all times, so that all the data of the first scan must be placed first thought and all the data from the second analysis must be placed on the second Board and continue on the street...

    Sy@m...

    Hi Sy@m

    Here is a vi that might give you a few ideas to try:

  • How to read the data with different XML schemas within the unique connection?

    • I have Oracle database 11g
    • I access it via JDBC: Slim, version 11.2.0.3, same as xdb.
    • I have several tables, each has an XMLType column, all based on patterns.
    • There are three XML schemas different registered in the DB
    • Maybe I need to read the XML data in multiple tables.
    • If all the XMLTypes have the same XML schema, there is no problem,
    • If patterns are different, the second reading will throw BindXMLException.
    • If I reset the connection between the readings of the XMLType column with different schemas, it works.

    The question is: How can I configure the driver, or the connection to be able to read the data with different XML schemas without resetting the connection (which is expensive).

    Code to get data from XMLType is the implementation of case study:

     1   ResultSet resultSet = statement.executeQuery( sql ) ; 
    2   String result = null ;
    3    while(resultSet.next()) {
    4   SQLXML sqlxml = resultSet.getSQLXML(1) ;
    5   result = sqlxml.getString() ;
    6   sqlxml.free();
    7   }
    8   resultSet.close();
    9    return result ;

    It turns out, that I needed to serialize the XML on the server and read it as BLOB. Like this:

     1    final Statement statement = connection.createStatement() ;  2    final String sql = String.format("select xmlserialize(content xml_content_column as blob encoding 'UTF-8') from %s where key='%s'", table, key ) ;  3   ResultSet resultSet = statement.executeQuery( sql ) ;  4   String result = null ;  5    while(resultSet.next()) {  6   Blob blob = resultSet.getBlob( 1 );  7   InputStream inputStream = blob.getBinaryStream();  8   result = new Scanner( inputStream ).useDelimiter( "\\A" ).next();  9   inputStream.close(); 10   blob.free(); 11   } 12   resultSet.close(); 13   statement.close(); 14  15   System.out.println( result ); 16    return result ; 17
    

    Then it works. Still, can't get it work with XMLType in resultset. On the customer XML unwrapping explodes trying to pass to another XML schema. JDBC/XDB problem?

  • How to save the data in a form called?

    Hi all.

    I have two froms.like FORM A and FORM b.

    I have a button on the FORM B.

    When I click on this button, FORM B and FORM data should be store in the database...

    I wrote something like this in the form B

    when_button_pressed->

    commit_form;

    go_form ("c\user\babu\FORM A.fmx");

    commit;

    Here, my problem is when I click on save button only saved FORM B, FORM A not memorizing the data in the database.

    Please help me and tell me where the error...

    Post edited by: N.B.Babu

    I guess that the modules form a calls B with OPEN_FORM module (..., SESSION), IE. Module B works in the new session of database

    (by the way, the database connection is the same, because the connection to a database can go several database sessions).

    Your code cannot save the data in the two sessions of database:

    commit_form; -This saves the data only from module B (because A module work in diferent database session).

    go_form ("c\user\babu\FORM A.fmx");  -Now you in module A.

    commit; -This has no effect, you are now on the module to a.

    Kind regards

    Zlatko

  • How to save the data to the new file, when you press the button

    Hello.

    Run a program that reads data recorders seconds and displays a trace on the screen.

    What I want, is that when I press a button, the program will ask for a file name and begins to record data to the file, and continues to do this as long as the button is pressed.

    When I press the button again, the program asks the name of the file again, so I can select a new file to write.

    I've included a simplified version of my program that works by asking the file name at the beginning.

    How can I change the program it starts a new file every time that the key again.

    Kai,

    I changed the example that I gave you to LV8.0, but I have never used the option 'Save for the previous version' before, so I don't know if it will work.

    I have combined the start and stop of recording in a single button (just change the text to all what you need) and I used the 'value' property to pass the path between cases. The path can be formatted as you have in your version, don't forget to use the string conversion function filepath.

    Just in case where it doesn't work on your version of LV I've attached a screenshot of the block diagram.

    Hope this helps, let me know if you have more problems with this.

    Easy.

    Darren.

  • How to save the data just with qml?

    is it possible to save data in an application just with qml?

    for example, I want to record some settings that the user has set.

    or an array of integers.

    or is it still possible to use sqlite?

    willie44 wrote:

    I could be completely wrong, but QSettings should work for you.

    The sample application QSettings is the spaceship one.

    QSettings is no longer usable in C++

    but this seems to be the only way to do

  • How to save the pages that I open in a single window as a tab group?

    In Internet Explorer, I am able to "Add current tabs to Favorites" for all my pages are saved as a tab group. How do I do this in Firefox?

    Hello

    You can try to right click on a tab and a bookmark all tabs.

  • Save the data in a horizentall

    Hello

    Any that offered little help on how to save the data in a portrait. As a result of my attachment all my datas saved az a tables!

    And also, I'll be glad if you told me that I can add text in front of my data as an outamaticlly to explain?

    Any suggestions would be greatly appreciated! Thank you very much!

    Sincerely,

    First convert your string numbers using decimal channel number.  Once your numbers have the appearance of a string, you can format the text with them.  If finally, you can use concatenate strings to concatenate (add all channels) your number in the string with another text format:

    This code would create the following string:

    Then, you can save your all channels on a line using the same method as above.

  • How can I control the writing-data-to - spreadsheet.vi to save the data?

    Hi all

    I tried to draw a wave and save the data to excel. Now, I want to control the writing-data-to - spreadsheet.vi to save data when I want which means that the vi records nothing until I have send a command to it. How can I make this happen or do I need any other screws?

    Nicky

    Hello

    Maybe this wat you are trying to do... Let me know if it helps...

    Kind regards

    amine31

    (Kudos are always welcome)

  • all my data is all save on the local disk c, how to share the data with the other drive, local drive d.

    all my data records on the local disk c, how to share the data with the other drive, local drive d.

    Hi Jasonbichard,

    1. what type of drive is D? Is - this another partition on the same disk?

    2 Windows operating system you are using?

    You can change the location of the disk to save the data in the d: instead of C: and check if it helps.

    a. navigate to the location (username) C:\Users\.
    b. right click on the folder that you want to change the location, and then select Properties.
    c. click on the location tab and change the location to D: drive.

    d. click on apply and Ok.

  • How to use "Write to the spreadsheet" to save the data when I want?

    When I use write on worksheet to record data, I must determine whether to save data or not before running the program, is there a way I can run the program and then decide whether to save the data, which means I can have a 'save' botton After runing the program, when I shoot, I can record data, otherwise, it is not. Thank you.


  • How to read the data of BLOB and save to the file system

    Hi friends.

    I have called DEMO table there image stored as a BLOB. now my requirement is to know how to read the data of BLOB and saved in the file system. is there a procedure
    to read the blob object and stored in the file system. pls suggest me with an example.
    Thank you

    HI - don't know what version you have, but have a read through this:

    http://www.Oracle-base.com/articles/9i/ExportBlob9i.php

    Hoek link is to import the blobs in the db, it is export, to a file.

  • How to save the worksheet active instead of workbook

    The excel file has 3 different sheets.  I changed the data on the worksheet 3 but cannot save it in format MS DOS.  She saved the spreadsheet 1 instead.  How can I save the data on the worksheet 3? Here is the code example.  I am running windows XP SP3 latest and CVI 2010.

    #include "excelreport.h".

    int main (int argc, char * argv [])
    {
    HRESULT second;
    char szErrMsg [256];
    CAObjHandle HdlWorkbook;
    CAObjHandle HdlXLApp;
    CAObjHandle HdlWorksheet;
    double data [2] = {200,2354.25898};
    value of double type = 7777.9;

    If (InitCVIRTE (0, argv, 0) == 0)
    Returns - 1; / * memory * /.

    Open Excel and make it visible
    Second = ExcelRpt_ApplicationNew (VTRUE & HdlXLApp);
    If (second) goto ExcelRpt_Err;

    Open the Excel file
    Second = ExcelRpt_WorkbookOpen (HdlXLApp, "Template.xls", & HdlWorkbook);
    If (second) goto ExcelRpt_Err;

    Second = ExcelRpt_GetWorksheetFromName (HdlWorkbook, "Test_Cases", & HdlWorksheet);
    If (second) goto ExcelRpt_Err;

    put a breakpoint here
    Second = ExcelRpt_WriteData (HdlWorksheet, "D88", ExRConst_dataDouble, 1, 1, &value);)
    If (second) goto ExcelRpt_Err;

    put a breakpoint here
    value = value + 1111.1;
    Second = ExcelRpt_WriteData (HdlWorksheet, "D99 ', ExRConst_dataDouble, 1, 1, &value);" ")
    If (second) goto ExcelRpt_Err;

    Save the workbook
    Second = ExcelRpt_WorkbookSave (HdlWorkbook, "test3.txt", ExRConst_TextMSDOS);
    If (second) goto ExcelRpt_Err;

    close the workbook
    Second = ExcelRpt_WorkbookClose (HdlWorkbook, 0);
    If (second) goto ExcelRpt_Err;

    Quit the Application
    Second = ExcelRpt_ApplicationQuit (HdlXLApp);
    If (second) goto ExcelRpt_Err;

    order of memory space

    CA_DiscardObjHandle (HdlWorksheet);
    CA_DiscardObjHandle (HdlWorkbook);
    CA_DiscardObjHandle (HdlXLApp);

    ExcelRpt_Err:
    Memset (szErrMsg, 0, sizeof (szErrMsg));
    CA_GetAutomationErrorString (second, szErrMsg, sizeof (szErrMsg));
    MessagePopup ("Excel report error", szErrMsg);
    return 0;
    }

    Edit:

    You cannot save a single worksheet in Excel. At least not in Excel 2007 I.

    Just try to do it manually and see what that who gets you.

    If you mean, you want to save a file *.xls in *.txt format, you must do a SaveAs.

  • How to analyze the data of the cDAQ and Signal Express, especially after analysis?

    In the first series of tests of my instrument, it took longer than expected for the race.  Thus, the data was saved in 6 days.  The file is too large for export to Excel.  At the beginning of the project, I was as ignorant as I could go ahead and add analysis and the scaling of measures.  By the scaling, I mean my data of switching current dew points or whatever it is that I record.

    How to evolve the data to read the output data as expected 4mA = point of dew of-20 C or 0 PSIG?  Can I pre program this to be recognized for each event?

    For real analysis I am doing – I would first analyze the data I recorded and choose different points to send to Excel to graph and analyze.  Is this possible?

    Secondly, I would like to know how to scale and analyze my data in the project without having to do this later analysis in the future?

    I have a cDAQ-9172 with LabVIEW signal Express 3.0 that uses four modules - 9211 2 modules of thermocouple, my 4-20 1-9201 module +/-10V module and 1-9203.

    Thank you for any assistance.

    Hi Patricia,

    "' You can do this by adding a step Load/Save signals ' analog '.  I hope this helps!

  • Re: How to save the video file to a DVD-R for Equium A200

    I have the Equium A200. Someone can tell me how to save the video file to a DVD-R on my computer in order to use it later, or use it in windows movie maker and must not simply copy on another DVD-R right?

    My cursor also has disappered in the suite of windows media, that makes life quite difficult.

    Any ideas?

    Thank you.

    You mean, you want to copy the original DVD movie to HARD drive?
    Well, you can copy the contents of the entire DVD to the HARD drive. It means that you have to copy a lot of data.
    I would recommend shrinking the DVD movies using a tool called DVD shrink.
    It would decrease the data and would also copy the content to the HARD drive.

    But if you want to use these files later in windows movie maker, so you must convert these using a 3rd party tool.
    Google a bit and you should find many free applications that would help you to do this work.

    Good bye

Maybe you are looking for