From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

NI usb 6008 DAQmxCreateAIVoltageChan issue

Hi everybody,
 
I was trying to get the voltage (using the sample code) from my USB6008 with borland C++. The piece of code is shown below:
 
#define DAQmxErrChk(functionCall) {if(DAQmxFailed(error=(functionCall))){goto Error;}}
// Task parameters
    int32       error = 0;
    TaskHandle  taskHandle = 0;
    char        errBuff[2048]={'\0'};
// Channel parameters
    char        chan[] = "Dev1/ai0";
    float64     min = -6.0;
    float64     max = 6.0;
// Timing parameters
    uInt64      samplesPerChan = 1;
// Data read parameters
    float64     data;
    int32       pointsToRead = 1;
    int32       pointsRead;
    float64     timeout = 10.0;
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_RSE,min,max,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxStartTask(taskHandle));
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByChannel,&data,samplesPerChan,&pointsRead,NULL));
Error:
    if( DAQmxFailed(error) )
        DAQmxGetExtendedErrorInfo(errBuff,2048);
    if( taskHandle!=0 ) {
        DAQmxStopTask(taskHandle);
        DAQmxClearTask(taskHandle);
    }
    if( DAQmxFailed(error) )
        sprintf(cTemp,"DAQmxBase Error: %s\n",errBuff);
        RichEdit1->Text = AnsiString(cTemp);
 
 
The execution always fails at DAQmxCreateAIVoltageChan function and it returns -200220
Detail of the failure:
DAQmxBase Error: Device identifier is invalid.
Device Specified: Dev1
Task Name: _unnamedTask<0>
Status Code: -200220
 
Can anybody help me by telling me what have I done wrong?
Thanks a lot!
PS: "NIDAQmx.lib" is the version 7.5 for BC++B, downloaded from http://digital.ni.com/public.nsf/websearch/B09727F89DA3A06C86256F430071D88E?OpenDocument
 

0 Kudos
Message 1 of 6
(5,757 Views)
One thing I noticed in your code, is that you are using DAQmx calls, but the error you generated says DAQmxbase. So one thing to check is to make sure that in Measurement and Automation Explorer (MAX) that first the USB 6008 is called device 1 and that it shows up in the DAQmx folder rather then the DAQmxbase folder. If you have had this 6008 around for a while, pre-DAQmx7.5 it could still be configured for DAQmxbase. You can check this and change it in MAX if this is the case. If you need to do this check out the following KB, it walks you through how to do this.

KB-
http://digital.ni.com/public.nsf/websearch/1448A8AC665EE0EA8625703F004A4410?OpenDocument

See if that is the issue.

-GDE

Message 2 of 6
(5,733 Views)

Thanks a lot! Error with DAQmxCreateAIVoltageChan is now solved, but I have another problem now.

DAQmxStartTask (the third function in the sample code) fails this time, the error message is: "Floating Point division by zero".

Detail error message (BC++B 6.0):  Project USB6008.exe raised exception class EZeroDivide with message "Floating point division by zero". Process stopped. Use Step or Run to continue.

Can anybody tell me what is wrong? THanks!

 

0 Kudos
Message 3 of 6
(5,730 Views)
You need to disable floating point exceptions in the compiler. Also, NI-DAQmx 8.0 may have fixed this specific divide-by-zero error.

Hope this helps,
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
Message 4 of 6
(5,718 Views)
Thanks a lot!
The problem is solved, Borland C++ Builder users must use DAQmx 8.0 to avoid fp exception errors.
0 Kudos
Message 5 of 6
(5,675 Views)

Try using the following as an example. Your device and connection info will change depending upon where you have your inputs connected.

Tim

0 Kudos
Message 6 of 6
(3,185 Views)