How to sample multiple sensors in a vital task?

I need to a thermocouple sensor and voltage sensor in a vital task of the sample. My hardware configuration includes a cDAQ-9172 chassis with a NI9211 TC module and a NI9221 voltage input module.

I started with the example C code for thermocouple measurement found here:

Instruments\NI-national DAQ\Examples\DAQmx C\Analog In\Measure Temperature\Cont Thrmcpl samples-Int Clk\ContThrmcplSamps ANSI - IntClk.c

I then added a few lines of code for the measurement of additional tension.

The task runs for about 20 seconds, until the buffer overflow with the error 200279.

I can run task, thermocouple or voltage, indefinitely. It's only when I include them both in the same task as the buffer overflow.

I have tried many combinations of sampling rate, the size of the buffer and DAQmxRegisterEveryNSamplesEvent nSample size.

Below is the code I'm running.  Changes to the original file are marked in bold. I've attached a screenshot of the output of command line.

Can anyone offer a C program example showing how to sample multpile sensors permanently in a task?

#include 
#include 

#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else

int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData);
int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);

int main(void)
{
    int32       error=0;
    TaskHandle  taskHandle=0;
    char        errBuff[2048]={'\0'};

    /*********************************************/
    // DAQmx Configure Code
    /*********************************************/
    DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
    DAQmxErrChk (DAQmxCreateAIThrmcplChan(taskHandle,"cDAQ1Mod1/ai0","",0.0,100.0,DAQmx_Val_DegC,DAQmx_Val_K_Type_TC,DAQmx_Val_BuiltIn,25.0,""));
 DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"cDAQ1Mod4/ai0","",DAQmx_Val_Cfg_Default,-60.0,60.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));

    DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,NULL));
    DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));

    /*********************************************/
    // DAQmx Start Code
    /*********************************************/
    DAQmxErrChk (DAQmxStartTask(taskHandle));

    printf("Acquiring samples continuously. Press Enter to interrupt\n");
    getchar();

Error:
    if( DAQmxFailed(error) )
        DAQmxGetExtendedErrorInfo(errBuff,2048);
    if( taskHandle!=0 ) {
        /*********************************************/
        // DAQmx Stop Code
        /*********************************************/
        DAQmxStopTask(taskHandle);
        DAQmxClearTask(taskHandle);
    }
    if( DAQmxFailed(error) )
        printf("DAQmx Error: %s\n",errBuff);
    printf("End of program, press Enter key to quit\n");
    getchar();
    return 0;
}

int32 CVICALLBACK 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];
 uInt32 i;

    /*********************************************/
    // DAQmx Read Code
    /*********************************************/
    DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,-1,10.0,DAQmx_Val_GroupByScanNumber,data,1000,&read,NULL));

    if( read>0 ) {
 for (i = 0 ; i < 2*read ; i++ ) { printf("%.5f\n", data[i]); }
        printf("Acquired %d samples. Total %d\r",read,totalRead+=read);
        fflush(stdout);
    }

Error:
    if( DAQmxFailed(error) ) {
        DAQmxGetExtendedErrorInfo(errBuff,2048);
        /*********************************************/
        // DAQmx Stop Code
        /*********************************************/
        DAQmxStopTask(taskHandle);
        DAQmxClearTask(taskHandle);
        printf("DAQmx Error: %s\n",errBuff);
    }
    return 0;
}

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);
        DAQmxClearTask(taskHandle);
        printf("DAQmx Error: %s\n",errBuff);
    }
    return 0;
}

One more thing I've noticed is that the size of the data [] has not be increased to include additional channels. Wear in 2000 and also to increase arraySizeInSamps (parameter 5) and 2000 to the DAQmxReadAnalogF64 function call. Given that it was only the value 1000 samples, it will get only 500 samples per channel causing the overflow.

Tags: NI Hardware

Similar Questions

  • How to delete multiple addresses?

    How to delete multiple messages at once?

    Have you ever deleted multiple files in both Solution Explorer?
    Thunderbird works the same way.

    Select the first message you want to delete. Press on and hold down SHIFT and select the last message should be deleted. This selects all messages between the first and the last of them.
    The Ctrl key and click on a message, you can select or deselect them individually.
    Then press DELETE to remove all the selected messages.

  • How to stop multiple self-switching to the address bar every time I open a new tab and try typing something anywhere outside the address bar?

    How to stop multiple self-switching to the address bar every time I open a new tab and try typing something anywhere outside the address bar? As something just wants me to use this integrated search when you type something non-Web-address in the address bar and press to enter. And the most ridiculous thing is that happens repeatedly on as every second, as I just got off the address bar and start typing again, but still he passes me in the address bar, then 3, 4 times like that. And the result is that I don't see the address of this page.

    I think that its has something to do with my AVG Antivirus, because it started the same time a Nation AVG started to appear in each new tab I opened (and which is irritating as me, I've read here on support.mozilla.org and it seems that the only solution is to completely reinstall Firefox, but I don't want to lose all my settings) but when I type something in the address bar and press enter It opens the search results in Google.

    Please try to help me, I love Firefox but I have to switch to Chrome until I fix this.

    Thanks in advance

    First of all, please update Firefox 32. 22 is no longer support is not safe. So, let us know if you still have this problem. Update Firefox to the latest version

  • OfficeJet 6700 how to fax multiple pages?

    I was looking at my manual, but I don't see any information on how to fax multiple pages at a time.  I have to keep the Redial and going though all this, and it will only send one page at a time.  Can anyone here tell me how more than a fax?  It is the 6700 OfficeJet and I usually use the copier part to send it.

    Now when you use the scanner should the page that you want to scan facing upwards or downwards?  I'm confused on this.  Thank you for reading my post.

    I get it now... Thanks a lot for your help.

  • How to scan multiple pages into a single document

    I use XP SP3 on the HP 510 laptop and printer HP Photosmart 7510e. How to scan multiple pages in 1 document? PDF is also only available document format?

    Thanks for the tips

    Hello

    Please perform the below mentioned steps that should solve the problem.

    Click the icon of the printer (on the desktop), select the scanned under the side of right, notice in the window of advanced settings under file type is a checkbox called "creating a separate file for each scanned page. Make sure it is not checked.

    Kind regards
    Jabzi

    Give Kudos to say 'Thank you' by clicking on the White Star under my name.

    Click on 'accept as Solution' if it has solved your problem, while others may find it.
    I work for HP

  • How to print multiple images per page

    How to print multiple copies of a single image on a single page

    Duplicate the photo before you print it, and then select all copies, then use ⌘P to print the photo.

    To duplicate the photo select and enter the key ⌘D combination or use the menu entry "Image > Duplicate...» »

  • Someone knows how to change multiple 12.3 items?

    Just moved to a MAC from a PC and I can not understand how to change the type of media from his HOME to FILM or TV SHOW.  I can change a file one at a time, but when I try to change several items, nothing happens.  Is there a way to fix this?

    Thank you

    Do you know how to select multiple items at the same time on a list of items in iTunes?  View the library using the view for a regular list with columns.  For your movie library, it is the view of list of films .

    To select multiple items that are on the list, select the first item, hold down the SHIFT key and select the last item.  The two points that you clicked and all the elements between them are selected at the same time.  Make a selection right click and get information.

    To select multiple items that are not in the list, press the command and Option keys and click on the selected items.  All clicked items remain selected.  To deselect an item, click on an item selected (with the two keys).  Make a selection right click and get information.

    You can use these two methods consecutively.  For example, select the songs listed together, most other distinct songs. Or select the listed together songs and deselect any of them.

  • How to select multiple cells at the same time?

    Hello

    How to select multiple cells at the same time? What is the keyboard shortcut?

    Thank you to.

    Flo, a french guy.

    Hold down the CMD key when you select the cells.

  • HP5643: HP 5643 All in One - how scan you multiple pages

    I can scan my wireless printer unique pages, but for the life of me I can't understand how to scan multiple pages.   I read the other posts on other threads on by clicking on the sign (+) sign to the left of the display after scanning one page, but I don't have a (+) sign to click on.  Someone has this model of printer, that can help me?    Thanks in advance for your help.

    In addition, any way to speed up the scanning process?     My old printer could easily scan a 10 page document in time, that it takes to scan a single page.

    @TXXpress

    Assuming for now your printer to provide the "Document Scan" and the little "+" feature, you don't have to have the "Preview Scan" selected.

    See:

    Scan_Multiple_Documents-combined

    If all else fails, you can try to use a different program to scan multiple pages into a single document.

    Options of the digitization program

    I don't have the same printer model - I can't comment properly on scan "slow".

    • In general, the printers to "do a bit of everything" cheaper still not 'all' as well as more expensive printers, a full service.

    Other things that could cause a "slower than ideal: sweep

    • Wireless, if they are available and used to connect the printer, may cause slow response - which can be attributed to anything between a bad router and a bad signal for a slow wireless card in the printer or the computer.  The answer "slower than snail" may be caused by the network is too busy with other wireless / network diagram.

    Finally, the "so slow I want to die" may be caused by the printing software - programs sometimes even 'good' can develop problems just hanging out on the computer for awhile.  You can remove the program from the printer and then replace it with a new copy of the software service Support full page for the Web site of your printer.

    Printer: printer e-all-in-one HP ENVY 5643

    Full software features:

    File name: EN5640_117.exe

  • How to use HX85BA sensors with NI DAQ system?

    Hello

    I'm trying to connect two sensors of Omega HX85BA moisture to my NI DAQ system. The sensors detect moisture, barometric pressure, and temperature, using three 0 to 10 VDC positive outputs @ 10 mA or less, with a common thread of output. I have a SCXI-1000 chassis with two modules SCXI-1100 cards, 1102 b and a single 1102. Map of 1102 uses a block to connect SCXI-1303, while the other three cards use some 1300 years. The system will mainly use thermocouples for temperature measurements, but there will be other types of sensors, such as the two HX85BAs.

    The manual of the product for the HX85BAs is not very clear on how to connect the sensor to the system. Terminal blocks each have 32 channels with the positive and the negative screw terminals, it doesn't connect three positive sensor outputs to individual channels, with the municipality of output connected to each channel? It will work installation with SCXI cards I have, or I will have to purchase different cards? The system will be expanded to include at least 4 cards in a separate chassis SCXI 1000 more, is not a problem for the purchase of different components to adapt to the HX85BAs.

    Thanks in advance!

    Hi BBalmforth,

    You can connect the sensor to the SCXI-1100 1300 TB. Connect the positive output of CH + and CH - CHSGND. Common output wire must be connected to GND.

  • HP 4630 how to scan multiple pages into 1 pdf document?

    I am using Windows XP Pro and use a HP Officejet 4630 how to scan multiple pages into 1 PDF file?

    You can scan multiple pages into a single file using the HP software. See the section "How to scan multiple pages into a single file" under "How to scan with HP Software" in the document below:
     
    http://support.HP.com/us-en/document/c03517150

    Note: The resolution must be set to 300 dpi or lower for the multiple page scans.

    I hope this helps.

  • HP ENVY 5530 - How can scan multiple pages into 1 pdf file?

    Hello

    Can someone tell me how to scan multiple pages into one pdf document.  Currently, I can only 1 page per pdf which is not ideal for large documents.  I have a HP ENVY 5530 and am running windows 7.

    Many thanks in advance,

    Hi Bert1,

    Welcome to the HP Forums, I hope you enjoy your experience! To help you get the most out of the Forums of HP, I would like to draw your attention to the Guide of the Forums HP first time here? Learn how to publish and more.

    I see that you encounter some problems when trying to scan multiple pages into a single file. I did some research and I found a great Charter which will explain in detail How-to Scan: Windows 7.  Once you have the document open, please scroll down until you see the part dealing with the digitization of several pages in a single file.

    I hope this helps with your question.  If by chance you need more help, feel free to write me again. I'm always happy to help you.

    Thank you for your time.

  • How read datalog multiple files at the same time?

    Hello friends...

    can someone help me to show how read datalog multiple files at the same time?

    Here is the example of my case.

    I have 500 files in a folder. each file contains a waveform and its setting.

    and then I want to do a card spectral these files, because these files have been saved in the order.

    the point is to know how to read these 500 files at once? I made a program to read these files, but the program can read these files in one by one. So it is very uncomfortable to read 500 files one by one. can someone help me solve this problem? Thank you. I hope you can show me the program. Thank you again...

    Hi jojo,

    Well, in the range of functions daughter, you will find a function to list the contents of the folder. This allows to get the names of all the files datalog, and then use a loop FOR to read.

    No one is obliged to provide 500 names of files manually - that's why we use a programming language to let the computer do the stupid work

  • HP Officejet Pro X476dw (nextworked-Windows 7 Pro) how to scan multiple pages into a single file?

    Does anyone know how to scan multiple pages into a single jpegfile?

    When you scan a document of several pages in a file on a network each page gets its own jpeg image scanend file.

    HP standalone scanner allow generally allows you to add the multuple scans in a jpeg file.

    Any help much appreciated!

    Thank you

    Joihn

    Hello

    Well, I don't know how you can read many jpeg files into a SINGLE file. Put scanned images in a folder is a logical way to keep them in one place. From my understanding single jpeg image may be a ONE page document, but many jpeg images cannot be concatinated to be a multiple page document. We can use images, software publishing to put them in a single document, but still only one page (each image is smaller). Using pdf output, you can concatenate/merge a lot of images in a sinlge multi-page file.

    Kind regards.

  • How to scan multiple pages into a single document using the CanoScan LiDE 200?

    How to scan multiple pages into a single document using the CanoScan LiDE 200?

    I can't find a way to get them to analyze all the time, or a way to put together them later.

    Hi dagda24,

    You can scan multiple pages into a single document with the scan PDF option.  Use the following steps to do:

    1. open MP Navigator.

    2. click on a Clcik.

    3. click Save to PC.

    4. change the Type of PDF file to PDF (multiple pages).

    5 other changes, as needed, and then click Scan.

Maybe you are looking for