Record a continuous flow of data in a txt file?

Hello world! I'm relatively new to the ICB and I was wondering if I could get help on something. I'm trying to modify a sample file that reads permanently a tension from a daq card. I would like to save this data in a text file, but I am relatively new to the C programming language (I'm a java person) and cannot distinguish the location data. Once I know where the data is, I think that I can write the data using a sort of loop and the fprintf function. Any help would be greatly appreciated. This is the code for the method StartCallBack of the "Cont Acq - Int Clk" file that I use:

int CVICALLBACK StartCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
Int32 error = 0;
Chan Char [256];
uInt32 sampsPerChan;
float64 min, max, rate;
The int journal;
char errBuff [2048] = {'\0'};

If (event == EVENT_COMMIT) {}
GetCtrlVal (panel, PANEL_CHANNEL, chan);
GetCtrlVal (Panel, PANEL_MINVAL, &min);)
GetCtrlVal (Panel, PANEL_MAXVAL, &max);)
GetCtrlVal (Panel, PANEL_RATE, &rate);)
GetCtrlVal (panel, PANEL_SAMPSPERCHAN, & sampsPerChan);
SetCtrlAttribute (panel, PANEL_STRIPCHART, ATTR_XAXIS_GAIN, 1.0/rate);
Journal = (int) log10 (rate);
SetCtrlAttribute (panel, PANEL_STRIPCHART, ATTR_XPRECISION, log);
SetCtrlAttribute (panel, PANEL_STRIPCHART, ATTR_POINTS_PER_SCREEN, sampsPerChan);

/*********************************************/
DAQmx Configure Code
/*********************************************/
SetWaitCursor (1);
DAQmxErrChk (DAQmxCreateTask("",&gTaskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(gTaskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,));
DAQmxErrChk (DAQmxCfgSampClkTiming (gTaskHandle",", rate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, sampsPerChan));
DAQmxErrChk (DAQmxGetTaskAttribute (gTaskHandle, DAQmx_Task_NumChans, & gNumChannels));

If ((gData =(float64*) malloc (sampsPerChan * gNumChannels * sizeof (float64))) == NULL) {}
MessagePopup ("error", "not enough memory");
GoTo error;
}

DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(gTaskHandle,DAQmx_Val_Acquired_Into_Buffer,sampsPerChan,0,EveryNCallback,));
DAQmxErrChk (DAQmxRegisterDoneEvent(gTaskHandle,0,DoneCallback,));

/*********************************************/
Starting code DAQmx
/*********************************************/
DAQmxErrChk (DAQmxStartTask (gTaskHandle));

SetCtrlAttribute (panel, PANEL_STRIPCHART, ATTR_NUM_TRACES, gNumChannels);
SetCtrlAttribute(panel,PANEL_START,ATTR_DIMMED,1);
}

Error:
SetWaitCursor (0);
If {(DAQmxFailed (error))
DAQmxGetExtendedErrorInfo (errBuff, 2048);
If (gTaskHandle! = 0) {}
/*********************************************/
Stop DAQmx code
/*********************************************/
DAQmxStopTask (gTaskHandle);
DAQmxClearTask (gTaskHandle);
gTaskHandle = 0;
If (gData) {}
Free (gData);
gData = NULL;
}
SetCtrlAttribute(panel,PANEL_START,ATTR_DIMMED,0);
}
MessagePopup ("DAQmx Error", errBuff);
}
return 0;
}

Hello supercharizard,

It comes to the appropriate line in the code that you posted that can lead you to "where the data is.

DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(gTaskHandle,DAQmx_Val_Acquired_Into_Buffer,sampsPerChan,0,EveryNCallback,NULL));

DAQmxRegisterEveryNSamplesEvent function establishes a callback as a routine function that will be called when at least a predefined amount of data is acquired. The part highlighted in the line is the reminder issued on this event, that you can study and modify the data adding streaming.

This knowledge base entry gives a brief explanation of the events available. There are many other resources on DAQmx works as well in Help and online on this site that you should carefully study to better understand data acquisition.

Regarding the release, there are several ways to do: here are two examples that produce a binary file (more fast, but you will need to write code to read data back) or add it to an ASCII file aligned in columns (slower but readable with a text editor, which is no code needed to read the data back). Another alternative is to make use of TDM stream on the disk library: this last resource is notably more complicated then I suggest you approach after some more practice on the fundamentals.

Tags: NI Software

Similar Questions

  • Inserting data in a txt file

    Hello world
    I created a form in 6i where I can open a .txt file to show me all the data in this file, so after the display of data in my form, I press a button and I insert data in my database, but if I add new data to this .txt file when I press record it says that certain values are already inserted and they cannot be repeated , because the id is not null, so what I want to ask you is how can I modify the same program to make me insert values that are not already inserted. Only new data.
    This is my code:
    Get_file_contents PROCEDURE IS
    Salida Varchar2 (1000);
    Compañía Varchar2 (5);
    Number of alert: = 0;
    OUT_FILE Text_IO. Type_de_fichier;
    -in_file Text_IO. Type_de_fichier;
    -linebuf Varchar2 (1000);

    Function Abre_Archivo
    Return boolean is

    BEGIN
    OUT_FILE: = Text_IO. Fopen(:file_name,'r');
    Return (true);
    exception
    While others then
    Return (false);
    END;

    BEGIN
    go_block ('MY_BLOCK');
    clear_block (no_validate);
    premier_enregistrement;
    If Abre_Archivo then
    OUT_FILE: = Text_IO. Fopen(:file_name,'r');
    End if;
    -Validation;

    LOOP
    Text_IO. Get_Line (OUT_FILE, Salida);
    : MY_BLOCK. SCHOOL_ID: = substr (Salida, 1, instr(Salida,',',1,1)-1);
    : MY_BLOCK. CLASS_ID: is substr (Salida, instr(Salida,',',1,1) + 1, (instr(Salida,',',1,2)-instr(Salida,',',1,1))-1);.
    : MY_BLOCK. Class_name: = substr (Salida, instr(Salida,',',1,2) + 1);
    : MY_BLOCK. STATUS: = 'A ';

    next_record;
    Synchronize;
    END LOOP;

    Text_IO. Fclose (OUT_FILE);
    premier_enregistrement;
    Exception when No_Data_Found then
    delete_record;
    Text_IO. Fclose (OUT_FILE);
    premier_enregistrement;
    END;

    OK, the constraint is the id of class only. So adjust the WHERE condition so that it only checks the class id.

  • How to ignore the details of footer when loading data from a .txt file

    Hello experts,

    I import data from a txt file in my database. I jumped my header using SKIP information, but how can I ignore my footer details.
    Thank you

    Answer on your other thread:

    Txt for a required format file processing

  • How constantly write data in a txt file

    Hello
    first of all, sorry for the bad English, but I have a problem to write data continuously to the txt file... I have a chart 2D with values based 2 sliders (sliders values) and some functions I want to interpolate the value by using the bilinear method... and after that the value of the sliders, interpolated value and the value of the closest points, I want to write to a file txt... for every 2-3 seconds perhaps, it would be ideal to be formatted as ::
    x y f f1 f2 f3 f4
    ..   ..  .. . .. .   ..   ...  . ..
    ... ...  ..    ...   ...   ...   ...

    but... first of all I have a problem with writing data, because every time he deletes old data and simply write a new and it is not horizontal... I am very very new to this (it's obvious) and any help will be very grateful 
    Thank you

    Diane beat me to it, I made a few changes to your code, so I'll post it anyway.

    As proposed, please go through the tutorials.

    I added an entry to the worksheet at the end node just to show it can be done at the end so. Table of building on a while loop is not very efficient memory, but it's just to show you what can be done. If you plan to go this route, initialize an array and use the subset to the table replace.

    All the best.

  • write data to a txt file

    Hello.

    I use visa and serial Protocol in my vi n want to save the data from MCU in labview to txt file format which, in the data record in each row not each tab.

    I want to just save not given time. Meanwhile, I plot the data in the chart.

    I search in the forum and consider the posts but can't find a solution.


  • Problem with registration of data in the txt file

    Hello

    I have 2009 Labview, Labview real-time 2009 and cRIO 3.3.0. I also NEITHER cRIO-9024 more cRIO-9112 chassis and modules.

    I would like to save the data measured modules in the txt files, but I want to do in a period of time to time desire. For example, I want to save data of measurements of 60 seconds and repeat every one hour. I of the project (in the file attachment vi) and normally it works fine but I noticed that the recording of the data is not correct. I mean it seams to save what was in the memory before. That's the problem with Windows XP I have check with another computer with Vista and it seems to be ok. It seems that on XP the buffer (refnum?)  is not clear and it retains the previous values.

    Can someone explain to me why it happened and how I can obey Windows XP? Or maybe there are techniques to clear the memory buffer/refnum for rescue?

    Thanks for any help.

    Kind regards

    Kamil


  • How to save data in a txt file.

    Does anyone know why the txt file is empty with no content?

    FILE * f = fopen ("/ shared/documents/save.dat", "w");
    {if(f==null)}
    fprintf (stderr, "Failed to create output. txt\n");
    _exit(2) (1);
    }
    fprintf (f, "Hello World");

    File is created, but the file txt empt without 'Hello World '.

    Ha ha solved.

    fclose (f);

  • IDCS6 MACOSX JS: data merge multiple txt files one after the other

    Hello everyone.

    I have a situation where I have to data merge multiple text files to a single file indesign real "base". Databases formats are the same, the point of difference is a code in the second field of the database that refers to a postal box (not a zip/postal code, a code of 'distribution center' that has possibilities of 56 or greater). I would prefer data merge a file and then somehow split the PDF via Acrobat, but the length of postal areas resulting is incompatible and something that cannot be done if the document "split" feature in acrobat.

    The database starts as one massive file but using a one line code, can be divided into postal areas in separate text files.

    My last question: is it possible data merge several files at the same time (for example one after the other) and to give them their names based on the names of the input text file?

    OLE Kvern had a script to merge the data to a file without the user interface. I changed the last line slightly so that it generates a PDF file based on [high quality]:

    if(app.documents.length != 0){
            var myDocument = app.activeDocument;
            app.dataMergeOptions.removeBlankLines = true;
            //Select a source file.
            var myDataFile = File.openDialog("Select a data file")
            var exported = "file location(redacted for the sake of this post)"
            if(myDataFile != ""){
                    myDocument.dataMergeProperties.selectDataSource(myDataFile,);
                    myDocument.dataMergeProperties.exportFile(exported,"[High Quality Print]",);
            }
    
    }
    

    I guess that the answer has to do with the variable "myDataFile" and rather than just being open a dialog box, it could be somehow by selecting a table of text files, but it is where I am out of my depth.

    Ideas or thoughts which may not involve trying to do both the many mergers, but can somehow revolve around a great fusion of PDF?

    Thank you very much

    Colin

    Since writing my last response, I realized there was a better answer. It is a scenario of Peter Kahrel and a modified version of a script by Olav Kvern. Details can be found here: batch of merge data | Adobe Community

    I have since made other mods to the script is easier to understand:

    if(app.documents.length != 0){
    // make sure to use the document that is open
            var myDoc = app.activeDocument;
    // get the name of the document that is open for future naming purposes
            var myName = myDoc.name
    // get the location of the folder that contains both the indesign files and the text files
            var myLocation = "FULL PATH LOCATION OF FOLDER CONTAINING TEXT FILE AND DESTINATION FOR FINAL PDFS"
    // define the names of the data files to use based upon the names of the indesign files
            var myImport = myLocation + myName + ".txt"
    // define the names of the data merged PDFs to be created
            var myExport = myLocation + myName + ".pdf"
    // the actual engine for the merge, including DM instructions such as remove blank lines, object fitting etc.
            var myDataFile = myImport
            app.dataMergeOptions.removeBlankLines = true;
            if(myDataFile != ""){
                    myDoc.dataMergeProperties.selectDataSource(myDataFile,);
                    myDoc.dataMergeProperties.exportFile(myExport, "[PDF/X-1a:2001]", );
            }
    
    }
    

    If this script will automatically merge a file which is open as LONG as the data file is the same name as the indesign file with .txt at the end for example

    Woodward.indd (indesign file)

    Woodward.indd.txt (used for merging text file)

    This script does still not the original memory and who was using an indesign document, to browse for many text files and merging of PDF based on text files.

    HOWEVER, I am sure that the answer to that is based only on the use of the script above (no need to Peter batch convert script) and changing the line 9 to be a loop for... but again, this is where I come to a grinding halt. Any help would be appreciated.

    Colin

  • flow of data to an xml file

    When I fed the shape of xml data
    "&" like "& amp;".
    How can I convert back in flash &

    & html representation of &, you can use it without modification in an active html textfield. To convert into one & you can use this:

    var text: String = "veni, vidi and vici."
    text = text.split ("&").join("&");)
    trace (Text);

    HTH,
    blemmo

  • Export form data to txt file

    I have created a form in LiveCycle. I need to have the data exported to a txt file. Previously, I've created a form in Word and it imported in LC. If this form has been filled out in Adobe and saved, I was able to export the data in a txt file. The form I'm working on now that I created in LC (instead of Word). When I fill the form in Adobe, save and then choose export to txt file, no data export. I have attached two forms: one that works (Unit_5_Preparate) and one that does not (assessment_template_test).

    Thank you!

    Hello

    It was a learning experience (no pun intended).

    If the LC Designer form is saved as 'static' then you will be able to export the data to a text file. If the form is saved as 'dynamic' then you won't be able to export to text file.

    See the file saved as static.

    Good luck

    Niall

  • Controlling the flow of data

    Hello

    I'm working on a program in which I have to control the flow of data on the wires.

    The task is that the data should not pass until a given value is generated. And the program remains the playback thread until this value is generated.

    While the value received, now the passage of data to all loop regardless the data that is generated on.

    That's why I created two loops while we research this value and the other is the principal who must perform processing when the specified value is generated (taken in the first loop).

    It could also say that "wait until the reception of a certain value.

    The first loop is created just to wait until a value of 3.

    The second loop is the principal who must deal with.


  • How to change the value of string clustered, to implement using the node value of property instead of writing directly on the flow of data or using the variable

    new to labview :-) and I have a problem when I want to change the value of a string in bunches, and I want to implement this using the node value of property instead of writing directly to the stream or by using the variable, enclosed is the picture.   No matter, I have change in cluster (control) or value of Popery out (indicator) cluster, the value (sensor 7) dataflow keeps unchanged even I gave the new value by value of property node. Thank you to give me some advice about this.

    Hi GerdW

    Thanks a lot for your answer. The reason I'm stubbornly tring to break the flow of DATA is: we have a test system that have about 100 screws, they have a few connected flow, some of them will be unbundling a cluster dataflow chain to check the value in order to make the different cases.  Now I want to insert user event by changing the control and influential cases during run time.

    As I initially uses a global variable (to control cases) instead of unbundle string data flow, it works well.  But then, I found there are a lot of screws that are using the string unbundle.  One of the 'lazy' means, I tried is to change the value via the property node (because that way, I did not need to find all the places where using the unbundle string and replace them with the global variable), then I noticed a problem with "dataflow", the value in the stream of cluster in fact will not be changed by changing the value of the property node.

    I did a test with VI simple (like the picture in last post), and after reading your advice, I tell myself that I need to understand the concept of "DATAFLOW" in labview, it seems that my "lazy" way can not work in this scenario.

    I have attached the criterion VI here, have you furthur suggestions on what I can do in this case?

    Mant thanks!

    Minyi

  • Print 3 X 5 HP Officejet 6100 continuous flow labels

    How can I print labels continuous power supply 3 X 5 on my HP Officejet 6100?  Envelopes/labels printing option only allows labels to be fed on the side and the continuous flow is from top to bottom.  I use Windows 7.

    Looks like you are having a problem printing of these labels. Now, to start, I have to ask what program you use to print? Is there only the option to print labels in the program is on the side and the printer only allows up and down, then it seems that the software you are using is not compatible with the mechanics or the printer software.
  • How to convert an Indesign document and convert a continuous flow word document

    How to convert an Indesign document and convert a continuous flow word document?

    Thank you so much worked perfectly.

  • Draw poster with continuous flow of photos

    Does anyone have a plugin or a software to make a poster with a provision of continuous flow, as what we get when we look at our mobile galleries on lightroom.adobe.com?

    ContactSheet page type grid too, I want cells sizes to adapt to this, to avoid spaces between photos.

    flowExample.jpg

    You can do this by using the custom Package and add and drag the photo boxes where you want.  It takes just a little extra work in contrast to the Contact Board.

Maybe you are looking for

  • How to install the OS on my new Satellite P100-347?

    Hello! I just bought a P100-347 last Friday. It was the last cell of its kind in the shop where I bought it and as if I find myself with a view model. No problem with that, the laptop is in very good condition, the only problem is that whenever they

  • Ethernet ports

    Hi, looking at Orbi and Note Although ports RJ45/Ethernet router/Satellites. Currently, I used a Devolo Ethernet power for the AP and other devices in other parts of the House. However, it is fairly low speed)

  • How to change the video icon

    I downloaded short videos from same camera, I converted from MOV to WMV.   In my folder of the windows media video files auto show two different icons. -some videos show as a film strim with a photo in the slide with the arrow, other icons with a gen

  • My computer was being fixed...

    Yes. It has been fixed. And the stupid person who treated, it makes to have Windows XP instead of Vista. I probably have some beta software, so I can't install Vista Transformation Pack. And I want Vista back... How?

  • Windows 7 Ultimate 64 bit - Activation? Help!

    Hello Recently, my computer was stolen, but the installation cd has not taken. I installed again on my new computer, but now he asks me an activation code, which I cannot find in the box, or on any of the manuals. Taken version was Win Ult 7 64-bit E