Continuous data acquisition, visual c, excel

 Hi,
I’m trying to build an MFC application with MSVC++6, where I would continuously acquire
samples
from 2 channels of a USB-6289. I’m using the DAQmx C functions. First I
declear the callback fun as static function in the dialog class:
       class DataCollectionWin : public CDialog 
static int32 CVICALLBACK
EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType,
uInt32 nSamples, void *callbackData);
static int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);
CString str;
 char* FileName;
Click "start tracking" to start data collection and save to an excel file:
void DataCollectionWin:nStartTracking()
    // TODO: Add your control notification handler code here
float64 data[2000];
int32    read=0;
int32 errorcode=0;
int i,length;
int32   error=0;
    char    errBuff[2048]={'\0'};
//********Connect DAQ channels***********
    CString    szButtonText;
    CString szFilter = "Excel Files (*.xls)|*.xls|All Files (*.*)|*.*||";
    CFileDialog dlg(FALSE,"Excel",NULL,OFN_OVERWRITEPROMPT,szFilter);
    GetDlgItem( IDStartTracking)->GetWindowText( szButtonText );
    /* if the text read Start, then we start, else we stop tracking */
    if (  szButtonText == "Start Tracking" )
          if(dlg.DoModal()==IDOK)
        str=dlg.GetPathName ();
        UpdateData(TRUE);
        if(!cfData.Open (str,CFile::modeCreate|CFile::modeReadWrite))
 MessageBox("create/read/write file fail","warning",
MB_ICONWARNING | MB_OK);
        length=str.GetLength();
        FileName=new char[length];
        for(i=0;i<length;i++)
        *(FileName+i)=str.GetAt(i);
        *(FileName+length)=NULL;
   DAQmxErrChk(DAQmxCreateTask ("connect", &taskHandle));
DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0,Dev1/ai1","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
 DAQmxErrChk(DAQmxReadAnalogF64(taskHandle,1000,-1,DAQmx_Val_GroupByChannel,data,2000,&read,NULL));
        DAQmxErrChk
(DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,NULL));
        DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));
        Error:
    if( DAQmxFailed(error) ) {
        DAQmxGetExtendedErrorInfo(errBuff,2048);
        MessageBox(errBuff);
        DAQmxStopTask(taskHandle);
        DAQmxClearTask(taskHandle);
            return;
        GetDlgItem( IDStartTracking )->SetWindowText("Stop Tracking");
    else
    //    nStopTracking();
    {    GetDlgItem( IDStartTracking )->SetWindowText("Start Tracking");
    DAQmxStopTask(taskHandle);
    DAQmxClearTask(taskHandle);
     cfData.Close();
static int32 EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
    int32       error=0;
    char    errBuff[2048]={'\0'};
    static int  totalRead=0;
    int32       read=0;
    float64     data[1000];
    FILE *datafile;
    datafile = fopen(FileName,"w+");
    int i;
 if (datafile == NULL )
      printf( "The file was not opened\n" );
    // DAQmx Read Code
    DAQmxErrChk(DAQmxReadAnalogF64(taskHandle,1000,-1,DAQmx_Val_GroupByChannel,data,2000,&read,NULL));
    printf("data number: %d\n",read);
        if( read>0 ) {
    for (i=0;i<2000;i++)
            fprintf(datafile,"%f\n",data[i]);
        fflush(stdout);
             Error:
    if( DAQmxFailed(error) )
        DAQmxGetExtendedErrorInfo(errBuff,2048);
        DAQmxStopTask(taskHandle);
        DAQmxClearTask(taskHandle);
        printf("DAQmx Error: %s\n",errBuff);
            return 0;
static int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData)
    int32   error=0;
    char    errBuff[2048]={'\0'};
    printf("hello"); 
    // Check to see if an error stopped the task.
    DAQmxErrChk (status);
Error:
    if( DAQmxFailed(error) ) {        DAQmxGetExtendedErrorInfo(errBuff,2048);
              DAQmxClearTask(taskHandle);
    return 0;
 Can anyone check the codes for me? when i run the program, no data is save into the excel file. It seems the EveryNCallback
function does not work, because when I put "printf("hello"); "for
checking,nothing happens. Also there is an debug assertion error (see
enclosure). 
Actually how does the callback function work to continuously collect the data? 
Thank you!
kg 
Attachments:
error.JPG ‏31 KB

Loaded symbols for 'C:\WINDOWS\system32\MFC42D.DLL'
Loaded symbols for 'C:\WINDOWS\system32\MSVCRTD.DLL'
Loaded symbols for 'C:\WINDOWS\system32\MFCO42D.DLL'
Loaded 'C:\WINDOWS\system32\shimeng.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\imm32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\lpk.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\usp10.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comctl32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\uxtheme.dll', no matching symbolic information found.
Loaded 'C:\Program Files\Aculearn\AcuSTUDIO5\MsnHookDll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\winmm.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\serwvdrv.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\umdmxfrm.dll', no matching symbolic information found.
Loaded 'C:\Program Files\SweetIM\Messenger\mgAdaptersProxy.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\MSCTF.dll', no matching symbolic information found.
Loaded 'C:\kaiguo\Powerword 2003\Cjktl32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\Downloaded Program Files\BDPlugin.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\apphelp.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\MSCTFIME.IME', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comdlg32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\clbcatq.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comres.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\cscui.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\cscdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\browseui.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\userenv.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ntshrui.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\atl.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\netapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\shdocvw.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\crypt32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msasn1.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\cryptui.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wintrust.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\imagehlp.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wininet.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wldap32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\riched20.dll', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\MAX\mxs.dll', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\MAX\mxsutils.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcp71.dll', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\MAX\mxsout.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\mswsock.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\hnetcfg.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wshtcpip.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\nismslu.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\nidevldu.dll', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\NI6535.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\nics.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\NIDSA.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\niem.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\nies.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\NIFILTER.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\NIHWDB.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\NIMAS.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\NISCXI.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\nisd.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\NISFT.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\niss.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\NISWCH.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\nitio.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\niwf.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\nixs.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\Compat\NI5690.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\Compat\NIDWG.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\Compat\NIHSD.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\Compat\NIPS.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\Compat\NIRFSA.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\Compat\NISL.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\Compat\NISRC.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\Compat\NISYNC.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\Compat\NITNR.sdc', no matching symbolic information found.
Loaded 'C:\Program Files\National Instruments\NI-DAQ\Caps\Compat\NITSU.sdc', no matching symbolic information found.

Similar Messages

  • Acquire continuous data but write to excel at intervals

    I am acquiring continuous data (voltage & temp) from a DAQmx unit. At the same time I would like to record to a spreadsheet X number of samples (say 100) at 1minute intervals only. Also, I would like to really only record two values from those 100 samples (a min & max value). I have a working code, however I cannot figure out how to write to spreadsheet at the 1 minute intervals for X number of samples. So I am stuck. TIA
    Solved!
    Go to Solution.
    Attachments:
    Prog3.vi ‏220 KB

    Thanks for the info. I will have to examine how to modify my code to use the producer/consumer design. Would I simply put my acquisition of data in the first loop, with my graphs etc. Then create a second while loop to record the data. I dont under stand the third part of the diagram "release queue". Sorry I'm a NOOB!

  • How to continuous data acquisition and save to an excel file using vc++

    Hi,
    I’m trying to build an MFC application with MSVC++6, where I would continuously acquire
    samples from 2 channels of a USB-6289. I’m using the DAQmx C functions.  I use the following codes to continuously get data:
    DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0,Dev1/ai1","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk(DAQmxReadAnalogF64(taskHandle,1000,-1,DAQmx_Val_GroupByChannel,data,2000,&read,NULL));
            DAQmxErrChk
    (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,NULL));
            DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));
     static int32 EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
        int32       error=0;
        char    errBuff[2048]={'\0'};
        static int  totalRead=0;
        int32       read=0;
        float64     data[1000];
        // DAQmx Read Code
        DAQmxErrChk(DAQmxReadAnalogF64(taskHandle,1000,-1,DAQmx_Val_GroupByChannel,data,2000,&read,NULL));
       if( read>0 ) {
        fflush(stdout);
            Error:
        if( DAQmxFailed(error) ) {
            DAQmxGetExtendedErrorInfo(errBuff,2048);
            DAQmxStopTask(taskHandle);
            DAQmxClearTask(taskHandle);
                return 0;
    static int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData)
        int32   error=0;
        char    errBuff[2048]={'\0'};
        // Check to see if an error stopped the task.
        DAQmxErrChk (status);
    Error:
        if( DAQmxFailed(error) ) {
            DAQmxGetExtendedErrorInfo(errBuff,2048);
                //MessageBox("errors in DoneCallBack");
            DAQmxClearTask(taskHandle);
            //MessageBox(errBuff);
        return 0;
    I have two questions:
    1. how to save the data into an excel file? Can anyone show me some sample codes please?
    2.Are
    the data acquired from the two channels simultaneously? If I set the
    starting time at 0, sample frequency 1khz, can I directly multiply the
    sample number by 0.001 to calculate time (as shown below)?
    Time    channel1  channel2
    0.001    d11           d21
    0.002    d12           d22
    Thank you! 

    You aren't going to get much help with Visual C++ programing when asking questions in the LabVIEW forum. 
    Try the Measurement Studio for Visual C++ forum.
    Message Edited by Ravens Fan on 12-05-2008 04:24 PM

  • Continuous data acquisition using NiDAQmx with a start and a stop trigger

    I'm sorry if this has been answered many times before, I can't quite seem to find the answer I'm looking for.
    I am using LabWindows CVI version 7 and NiDAQmx with a PCI6023E.
    I wish to acquire data continuously using an external clock as a timebase - I am happy with this.
    I wish the acquisition to start when an external signal (say on PFI7) goes high. I am also happy with this.
    What I also need is for the acquisition to stop when the signal on PFI7 goes low, or possibly when a signal on say PFI8 goes high. I'm not too concerned about which approach to use.
    How do I stop the acquisition with an external signal?
    Thanks in advance,
    Crispie

    I don't have CVI installed, but I've attached screen shots of a LabVIEW program that I believe accomplishes what you are trying to do. Translating it to the C API should be straight forward. I'll try to explain what the program is doing since it's using some of the more advanced features of the driver. Also, the DAQ device you are using doesn't support a true "stop" trigger so I'm using a reference trigger to get as close to the desired functionality as possible.
    First, the program configures a finite acquisition that uses both a start trigger and a reference trigger. The acquisition is using an external sample clock and will acquire 4 samples (2 pre-trigger samples and 2 post-trigger samples). Four may seem like an odd number here, but it allows us to emulate the functionality of a stop trigger as close as possible. Given this configuration, you must acquire at least 2 samples before the "stop" trigger is recognized, and you must acquire 2 more samples after the "stop" trigger is recognized. Hopefully this restriction is acceptable. You can always discard the last two data points after the stop trigger if they're not of interest, but you're stuck always acquiring at least two points between when the start and stop triggers are recognized.
    The program also overrides the default buffer size and read position. By default, the DAQmx driver will pick a buffer size exactly big enough to fit the pre-trigger and post-trigger data (4 samples in this case) and will begin reading data from the start of the pre-trigger data. Explicitly allocating a larger buffer will allow your acquisition to execute without receiving buffer overflow errors, and changing the default read position will allow you to read all of the data between the start and stop triggers as it is acquired and not just the pre-trigger and post-trigger data.
    Finally, the while loop takes care of reading the data. In this case, the loop continues to read data until the task is done and there are no longer samples available for reading from the buffer. The number of samples read per iteration is the lesser of the user specified amount or the number of samples available for reading from the buffer.
    I hope this helps. Good luck.
    Attachments:
    Stop_Trigger1.JPG ‏40 KB
    Stop_Trigger2.JPG ‏43 KB

  • Continuous data acquisition and analysis in real time

    Hi all,
    This is a VI for the continous acquisition of an ECG signal. As far as I understand the DAQmx Analog read VI needs to be placed inside a while loop so it can acquire the data continously, I need to perform filtering and analysis of the waveform in real time. The way I set up the block diagram means that the data stays int the while loop, and as far as I know the data will be transfered out through the data tunnels once the loop finishes executing, clearly this is not real time data processing. 
    The only way I can think of fixing this problem is by placing another while loop that covers the filtering the stage VIs and using some sort of shift registeing to pass the data to the second loop. My questions is whether or not this would introduce some sort of delay, and wether or not this would be considered to be real time processing. Would it be better to place all the VIs (aquicition and filtering) inside one while loop? or is this bad programming practice. Other functions that I need to perform is to save the data i na file but only when the user wants to do so. 
    Any advice would be appriciated. 
    Solved!
    Go to Solution.

    You have two options:
    A.  As you mentioned, you can place code inside your current while loop to do the processing.  If you are clever, you won't need to place another while loop inside your existing one (nested loops).  But that totally depends on the type of processing you are doing.
    B.  Create a second parallel loop to do the processing.  This would decouple the processes to ensure that the processing does not hinder your acquisition.  See here for more info.
    Your choice really depends on the processing that you plan to perform.  If it is processor-intensive, it might introduce delays as you mentioned.  
    I would reccomend you first try to place everything in the first loop, and see if your DAQ buffer overflows (you can monitor the buffer backlog while its running).  If so, then you should decouple the processes into separate loops.
    Regarding whether or not "this would be considered to be real time processing" is a loaded question.  Most people on these forums will say that your system will NEVER be real-time because you are using a desktop PC to perform the processing (note:  I am assuming this is code running on a laptop or desktop?).  It is not a deterministic system and your data is already "old" by the time it exits your DAQ buffer.  But the answer to your question really depends on how you define "real-time processing".  Many lay-people will define it as the processing of "live data" ... but what is "live data"?

  • Data-acquisition with NI 6036E DAQ card & GPIB using an external trigger

    Hi all,
    I hope somebody could give me some help with the following and answer some questions:
    Simple system description:
    Labview 6.1
    PCI-GPIB card
    6036E DAQ card
    In my system, I am using an external analog trigger signal (A) for continuous data-acquisition. Characteristics of the analog trigger signal (A) are: ~40 Hz, signal height +1.48V, triggered by rising edge (the analog trigger signal (A) could be changed to a TTL signal). Each data-acquisition is done within ~1.0 ms after the rising edge of the trigger pulse. The timing of the data-acquisition and analyzing procedure is controlled by execution in a sequence structure placed in a loop.
    Now, I connected a power meter to the system, to measure the laser power during the data-acquisition. The power meter has two options to provide the laser power data:
    a) via analog signal output (voltage corresponds to laser power in watts)
    b) via GPIB (direct output reading of laser power in watts).
    Problem:
    During a certain point in my data-acquisition sequence structure (defined by a frame), I want to use the next occuring analog trigger signal (A) to acquire 1 value from the power meter.
    How do I do this in Labview programming for the following two situations?
    a) If I connect the analog output from the power meter to an analog input channel of the 6036E DAQ card. The analog trigger (A) would be connected to a second analog input channel (In case the analog trigger signal (A) is changed to a TTL signal it would be connected to the PFI0/Trig input pin on the DAQ card).
    b) If I use the GPIB connection of the power meter. The analog trigger (A) would be connected to a second analog input channel (In case the analog trigger signal (A) is changed to a TTL signal it would be connected to the PFI0/Trig input pin on the DAQ card).
    An other possibility would be to trigger the power meter directly, so it outputs constantly power meter values at ~40 Hz. How could I than acquire 1 power meter value (at a certain time im my sequence structure) via analog input at DAQ card or GPIB?
    Additional questions:
    How do I configure the PFI0/Trig pin on the 6036E DAQ board individually as an INPUT?
    How do I use an analog trigger signal (A) as counting signal for a loop, or as an activation signal for a sequence structure which includes GPIB commands?
    It would be very nice if somebody could give me some help.
    Kind regards,
    beam

    Hi beam,
    I just want to verify that I understand your situation correctly:
    An external trigger signal (A) is wired to one of your input channels (e.g. CH0) to trigger data acquisition of a second channel (e.g. CH1). Your power meter is connected to an analog input channel, which you would like to trigger with a certain rising edge at some of your sequence structure.
    Problem:
    During a certain point in my data-acquisition sequence structure (defined by a frame), I want to use the next occuring analog trigger signal (A) to acquire 1 value from the power meter.
    How do I do this in Labview programming for the following two situations?
    a) If I connect the analog output from the power meter to an analog input channel of the 6036E DAQ card. The analog trigger (A) would be connected to a second analog input channel (In case the analog trigger signal (A) is changed to a TTL signal it would be connected to the PFI0/Trig input pin on the DAQ card).
    If a task has been configured to acquire signal from one analog channel, it's not possible to run a second analog input task or to add a second channel on the fly. You had mentioned that it's possible to read from the instrument through GPIB. Is it possible to perform a software trigger such that at a certain frame of your structure, when the trigger signal A reaches voltage "x", a GPIB command is written to your power meter to query a measurement reading?
    Additional questions:
    How do I configure the PFI0/Trig pin on the 6036E DAQ board individually as an INPUT?
    You do not need to explicitly configure the PFI0 line as an input. If you want to use it as an input such that it acts as an analog trigger, simply wire the trigger signal to this pin. When configuring the trigger in your software, specify PFI0 as the trigger source.
    How do I use an analog trigger signal (A) as counting signal for a loop, or as an activation signal for a sequence structure which includes GPIB commands?
    You can try using the Limit VI to find out when the trigger signal reaches a certain level, and count how many times this level is reached. Similarly, you can use this as the condition to execute GPIB commands.
    Hope this helps,
    Lesley

  • Continuous Data Aquisition to SS File

    Recently we used the example from the Labview program "Continuous Data Acquisition to SS File.vi" and modified it a little and tried to keep all
    necessary things in the program to meet our test requirement. Basically we have 8 channels to collect the voltages from the test materials. After a
    test run, I realized that it only display the raw data for the channels (8 columns) but no corresponding time column to it. Can any one tell me how to add this time column. thanks
    Attachments:
    Voltage_Reading.vi ‏107 KB

    I could not open your VI as I do not have version 6.1 installed. So here are some comments...
    You can build a 1-D array of time steps by using a for loop, delta T (the inverse of the ACTUAL scan rate as indicated from the acquire VI), and the number of points (use the Array Size function on one of the data columns).
    Now, since the DAQ VIs output in column major order, first transpose the DAQ record and then use the bulid array fuction to add the new row to the first position.
    Transpose the new array back to column orientation and write to spreadsheet file.

  • Problem with writing continuous data to excel using using Report Generation vi's

    Hey Everyone,
    I am trying to read the data from DAQ and write to excel continuously using Report Generation vi's. 
    But when I run the VI, it writes only one interation of the while loop (gathering data from DAQ continuously) and doesn't append the data into the same file when I run it again after stoping the VI. 
    I have attached the VI i created. Please let me know if you have any idea to solve this issue. 
    Thanks
    Attachments:
    sample 5.vi ‏35 KB

    There are two problems with your VI.  First, the basic logic of writing/appending to a file (Excel, TDMS, anything) should go something like this:  Open the file, position yourself at the end of the file, then, in the loop, acquire data and write it to the file until you are finished with data acquisition.  When you exit the acquire/write to file loop, then close the file.  In particular, the opening and the closing of the file should not be inside the loop.
    As others have pointed out, writing to Excel might not be optimal, particularly if you are acquiring data at a high rate (and would therefore be writing a lot of data). We actually use Excel in our data acquisition routine, mainly reading from a WorkSheet to get the parameters of a particular stimulus, but also writing the outcome of the response to the stimulus.  As it happens, our "acquisition rate" in this example is on the order of several samples per minute, so there's no problem using Excel (we also sample 16 channels of analog data at 1 KHz -- this gets written as a binary file).
    Second, if you really do want to use Excel, use the (existing) Excel file to which you want to append as the "template" argument of the New Report function.  Then use the Excel Get Last Row function to position yourself at "end of file", as noted above.
    Good Luck.
    Bob Schor

  • Data acquisition time not continuous, but starting over and over again

    Hi,
    My data acquisition time is not continuous but loops over and over
    again.  Could someone please take a look at my vi to see if you
    have any thoughts on how to fix this.  Also, I tried to set up my
    vi so that I could take the mean of the signal at any time I
    choose.  However, at the same instance that the data acquistion
    time "starts over" again, the mean is calculated (before I trigger it to take the mean)
    I have attached my vi and my output file as a text file so that what
    I'm trying to say will (hopefully) make a bit more sense. 
    Thanks for your help in advance!
    Sherri
    Attachments:
    Datalog1 71805.vi ‏1252 KB

    Hi,
    Thanks for responding to my question. Attached is the vi with added
    comments as to what I think I am doing.  By DAQ time, I mean the
    first column of data that is in the data file that I attached
    previously.  I am only simulating a signal (at the beginning) so
    that I can program in my office.  I do, however, have the same
    problem as stated above when I change the simulate signal to DAQmx
    using my instrument.
    I hope this clearer.  If not, I'll try again. 
    Thanks so much!
    Sherri
    Attachments:
    Datalog1 71805 83.vi ‏1228 KB

  • How to visualise continues Data aquisition from a PCI 6602 with 2121 BNC connector board in C++ ?

    Hello everyone,
    We are trying to get on the screen the aquired pulses from our  PCI 6602 with a 2121 BNC connector board, from several devices. We are able to read the data and save without problem, but we cannot look at it while we are measuring. Anybody has an idea to how program this in C++ ? Any suggestion is welcome!
    Thanks for the help

    Hi,
    try to look for some example programs and Tutorials:
    Examples Results
    http://search.ni.com/nisearch/app/main/p/bot/no/ap/tech/lang/en/pg/1/sn/catnav:ex/q/DAQmx%20C%2B%2B/...
    Tutorials Results
    http://search.ni.com/nisearch/app/main/p/bot/no/ap/tech/lang/en/pg/1/sn/catnav:tu/q/DAQmx%20C%2B%2B/...
    You should also have a look at the "C Reference Help" which is installed with the NI DAQmx driver.
    Acquire N Scans (Visual C++ 6.0, CW++, NI-DAQ)
    http://zone.ni.com/devzone/cda/epd/p/id/207
    Continuous Analog Acquisition with Producer Consumer Architecture in C#
    https://decibel.ni.com/content/docs/DOC-4253
    Good Luck!
    Matteo

  • Event at a specific moment of a data acquisition

    Hi!
    I'm trying to create a VI which should perform data acquisition during which an event should happen.
    The full problem is:
    I have to do data acquisition (sampling rate up to 100000 samples/sec) of the voltage of a deformed 60 Hz sine wave signal. This data acquisition is saved into a file (Excel or DIAdem compatible) and is not displayed to the user of the VI in real-time (no worrying about displaying a graph). The problem is that after a fixed number of periods has been acquired, at a specific angle of the ideal sine wave (0° being the beginning of the sine wave, 90° the positive maxima...), a digital signal has to be sent to modify part of the circuit we are analysing, while continuing to gather data. I know that using an analog trigger, I can find a 0° point easily, then, knowing the sampling rate and the input signal's frequency, I know the number of samples to wait before the angle. What I don't know though is how to do this event at that specific moment without interrupting the data acquisition.
    I am using LV7.1 with a NI-6110 DAQ device configured with NI-DAQmx. If you need additionnal information to answer, then just ask me.
    Thanks!

    Hi Maxime-
    I'm not sure why your counter would be counting too fast, but it might have something to do with the comparator circuit. Are you able to count edges successfully with your counter? I would suggest using the LabVIEW shipping example "Count Digital Events.vi" that can be found by accessing Help>>Find Examples in LabVIEW and then browsing to Hardware Input and Output>>DAQmx>>Counter Measurements. You will need to connect your comparator output to the source input of the counter.
    If this VI works for you then I have another suggestion along the lines of Kevin's earlier suggestion to use two counters. The counters on your board can be configured to output a pulse once the counter reaches your Terminal Count (i.e. the highest value the counter can reach before rolling over to zero). Your PCI-6110 has 24-bit counters, so the terminal count will be 2^24-1 or 16777215.
    By using the first counter to count zero crossing events from your comparator and setting the initial count to be a certain number of counts less than the Terminal Count you can output a pulse after a user-specified number of rising edges. This output can then be routed to trigger pulse train generation on the second counter of specified frequency and length. Finally, you can route this generated pulse train to be the external clock for your analog input operation.
    I have attached a modified edge counting example that shows how to route the terminal count to a pin that can be used to trigger the pulse train on the second counter. For an example of AI operation with a counter-generated pulse train, check out "Multi-Function-Ctr Retrigg Pulse Train Generation for AI Sample Clock.vi" in the Hardware Input and Output>>DAQmx>>Synchronization>>Multi-Function folder in the Example Finder.
    Thanks-
    Tom W
    National Instruments
    Attachments:
    Count Digital Events with Output Pulse.vi ‏64 KB

  • Data acquisition in a state machine

    I've recently learned how to implement state machines, but I have a question that I haven't been able to find an aswer to.
    Question:
    How do I record uninterupted data (presently i'm using the DAQ assistant to record a single channel at 10kS/s at 1kS intervals) without interfering with my state machine?  
    Background:
    I have a time sensitive test setup (measuring pressure in a rocket chamber), and I'm using labview to both record a single pressure transducer as well as operate the valves (O2, N2, igniter, etc).  I'm using a state machine Labview architecture (just learned how).  Presently, the DAQ assistant sits in the "Idle" state, and timers (valves need to be turned on at specific times) and manual buttons control when the other states are activated.  I have a 10ms timer controlling how often each state is run, and this is the root of my concern.  
    Main concerns:
    I'm worried that:
    1)  I'm forced to change my data recording to 10ms intervals to match the 10ms timer, and
    2)  The 10ms timer will interrupt my data recording when it's in another state.  
    It's very important that the pressure data is recorded without interruption but that I have high time resolution in controlling my valves as well.
    Thoughts:
    1)  Maybe I put the 10ms timer in the "Idle" state only, and this way the other states won't interrupt the data acqusition
    2)  Maybe there is a way to completely isolate the state machine for controlling the valves and the data acqusition.  I'm not sure how to do this.
    3)  People on the forums have been talking about Queuing their data acqusition, but I'm not sure how this would benefit my situation.  
    Thanks to everyone for their feedback!

    The data acquisition and state machine timer do not have to be equal, you should however have the same data write rate as you have data read rate, otherwise over the course of long running programs you can build up a large buffer of data to be written using a lot of memory, or lose data.
    Your data acquisition should be continuous, the most common way of doing this is every time you receive data write it to a queue, then when you are in other states except your data write stage you simply build up data in the queue that is to be written when you enter the write state again.
    Think of it as traffic reaching a set of lights:
    The traffic represents the data acquisition, there is a constant flow of it always coming through, the state of your state machine is the lights, green is the data write state clearing the queue, red is when in any other state, letting the traffic build up behind the lights.
    It is just important that the light is green long enough to let the traffic not build up too much, otherwise you have a jam.
    EDIT: For the basics of how queues work, look at the Queue basics example from the example finder. 

  • Data acquisition on the basis of time

           Hi everyone,
    I want to acquire the radial run-out (radial small displacement) of a rotating spindle using a capacitive sensor. To do so I will use the LabView v. 7.1. The PCI-6036E card from National Instruments (NI) will be utilized for data acquisition. The spindle turns at 100 rpm and a rotational incremental encoder is fixed at rear of spindle. This encoder provides an index digital pulse per revolution. This pulse should be used to start and finish the sampling process. I want to sample on the basis of time, by means of sampling rate of the card (Ksamples/s). So, let us suppose that I want to acquire 500 data/rev. The spindle takes 0.6 sec to complete one revolution. Thus, the required sampling rate is Fs = 500 samples/0.6 s = 833 samples/s. So, I should set the VI in LabView so that it samples only 833 data/s. Therefore, I will have to reduce the sampling rate of the analog-input channels in use. For example, let us suppose that the card provides 100 Ks/s when operating in multiple channels. Let us admit that there are 4 analog-input channels in use. So, the scan rate per channel is 25 Ks/s. This is too much for this application. I only need 833 samples/s. So, I should program the VI so that the card provides that required sample rate. As said earlier, I need to start and end the sampling process at the same point. Thus, to do that the index pulse of the encoder will be used. Also, I want to sample during 5 consecutive revolutions of the spindle. So, by means of a loop in VI, I should count the index pulse of encoder until the number of pulses be equal to 5 (= number of revolutions). At this instant, the sampling process should be stopped. Note: 1) the sampled data should be put in a buffer. After the sampling process is finished, this data should be saved in a file of LabView; 2) In fact, the data acquired by the sensor are voltage analog input. Questions:1) Could you make a VI for this problem, please? Note: you can use the DAQ ASSISTANT EXPRESS VI or DAQmx TASK NAME CONTROL method2) What should I do to stop the data acquisition at the end of 5 revolutions using the index pulse of encoder?3) Could you send examples (VIs) similar to my problem above? In anticipation, thank you very much for any help. My e-mail: [email protected]                                                                                      
     Bruce  

    duplicate post
    Continue in other thread
    Message Edited by smercurio_fc on 11-14-2008 09:10 AM

  • Data acquisition synchronisation Arduino/LabView

    Hello,
    I'm trying to acquire force sensor values using an Arduino board (reading the data and controlling a motor) and LabView. The data acquisition rate is tunable according to the motor condition, meaning a high acquisition rate (short delay) during the ON state of the motor and a low acquisition rate (long delay) during the OFF state of the motor.
    I managed to acquire the data, but till now I always find some "0" values though I'm applying a continuous force on the sensor. I guess the main problem is the synchronisation of the "datarate" on the Arduino board and the acquisition time point in LabView.
    I hope that you could halp me, since I'm trying since weeks to overcome this problem. You will find both the LabView and the Arduino source codes in the attachment.
    Attachments:
    CBR control_opti.vi ‏206 KB
    CBR_Arduino.docx ‏15 KB

    Dear all,
    last week I had some limited time, which I could dedicate to my work with Labview. Unfortunately I'm not able to solve the problem with the Consumer/Producer architecture. It seems to be the appropiate solution, but due to my limited knowledge I'm not capable of doing that.
    I will add my modifications (CBR control_Prod-Cons.vi) to give you an idea about what I've achieved so far. I appriciate any help of you, since this story is driving me crazy. Additionally, I attach a JPG showing the readout I'm obtaining with the old version (CBR control.vi), where the red circles indicate the problem with the "0" values.
    Thank you again,
    Cheers 
    Attachments:
    CBR control_Prod-Cons.vi ‏203 KB
    sensor read out.JPG ‏164 KB
    CBR control.vi ‏206 KB

  • Data acquisition with daq card 6533

    Hi all,
    i need to develop a c++ (visual studio .net, no measurement studio)
    program that performs data acquisition at a sampling rate of 10Khz
    using a windows xp laptop and the daq6533 card.
    The program must sample 8 digital signals. Each signal has a limited
    time duration, say a few seconds, and acquisition should start on the
    first rising edge of a signal, and terminate on user input. Browsing
    through the code provided with the driver, i found the examples in the
    cdio folder. It seems to me they almost do what i actually need.
    Unfortunately, many of the functions used there are not supported by
    the 6533 card, in particular the GPCTR_* family. I've read somewhere
    else that this card does not have an hardware counter, is that exact?
    I'm a beginner in this field, so i don't know what are possible alternative solution to my problem (if any).
    Thanks for any help.
    walter

    Thanks for your reply.
    I don't know actually whether i need to use counter-related functions. My problem is the following:
    I need to sample 8 digital signals with a frequency of 10khz. Every signal have a duration of a few seconds in time, and they come from sensors attached to a train's railway. Acquisition begins on the first rising edge of a signal (which coincide with the passage of the train), and end with user input (which should be after the train has passed).
    It would be of great help if you can point me to a relevant example, or give me some basic guidelines on our to proceed. If you need more information, please just ask.
    thank you very much.
    walter

Maybe you are looking for

  • Help using right-click to display text in the console/call a pop-up menu

    Hi folks, I hope someone can help me with this problem because, to be honest, I cannot see where I'm going wrong! Basically, I'm trying to create a routine to display a bit of text in the console (and, if I can get this to work, call a pop-up menu) i

  • Satellite A505 Doesn't Recognize HP Printer

    My Satellite A505 laptop doesn't recognize my HP Color LaserJet 2550L printer, when I connect them with a USB line.  I tried going to the HP site to download the drive for the 2550L, but that site said Windows 7 already had it! Suggestions? Solved! G

  • How can I get my apple ID back if my ID were stolen and all of my personal information were changed

    I recently found out if someone else stolen my apple ID then he can login my account on apple's website and change almost every information, like my first and last name, my apple ID, my password, my security question and my birthday... Those informat

  • Small issue in small program(code) that need to be fixed ...

    Hi Guys , i need ur help in some kind of issue( technique thing ;) ). i have done small program that ask for numbers then print them and told u how many Odd numbers. the issue that i have it, is that the program when print the result (the numbers) it

  • How to learn Order Entry modules

    Hi Does anyone has recomendations as to what is the best way to learn about the Order Entry and other Oracle Applications Modules. We are currently using ver 11.0.3 and we will be upgrading during the coming year. I want to learn the current Oracle a