Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does my example program fail on DAQmxCreateTask?

system:
HW: NI USB-9263 DAC
driver NI-DAQmx 8.9.5
OS: Windows 7

connectivity:

Using the Measurement & Automation Explorer
I see NI USB-9263:"Dev1" under NI-DAQmx Devices

When I run the test application, VoltUpdate.c, it fails
when DAQmxCreateTask is called.

the complete example follows:

/*********************************************************************
*
* ANSI C Example program:
*    VoltUpdate.c
*
* Example Category:
*    AO
*
* Description:
*    This example demonstrates how to output a single Voltage Update
*    (Sample) to an Analog Output Channel.
*
* Instructions for Running:
*    1. Select the Physical Channel to correspond to where your
*       signal is output on the DAQ device.
*    2. Enter the Minimum and Maximum Voltage Ranges.
*    Note: Use the Acq One Sample example to verify you are
*          generating the correct output on the DAQ device.
*
* Steps:
*    1. Create a task.
*    2. Create an Analog Output Voltage Channel.
*    3. Use the Write function to Output 1 Sample to 1 Channel on the
*       Data Acquisition Card.
*    4. Display an error if any.
*
* I/O Connections Overview:
*    Make sure your signal output terminal matches the Physical
*    Channel I/O Control. For further connection information, refer
*    to your hardware reference manual.
*
*********************************************************************/

/*********************************************************************
* Microsoft Windows Vista User Account Control
* Running certain applications on Microsoft Windows Vista requires
* administrator privileges, because the application name contains keywords
* such as setup, update, or install. To avoid this problem, you must add an
* additional manifest to the application that specifies the privileges
* required to run the application. Some ANSI-C NI-DAQmx examples include
* these keywords. Therefore, these examples are shipped with an additional
* manifest file that you must embed in the example executable. The manifest
* file is named [ExampleName].exe.manifest, where [ExampleName] is the
* NI-provided example name. For information on how to embed the manifest
* file, refer to http://msdn2.microsoft.com/en-us/library/bb756929.aspx.
*********************************************************************/

#include <stdio.h>
#include <NIDAQmx.h>

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

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

    /*********************************************/
    // DAQmx Configure Code
    /*********************************************/
    DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
    DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"Dev1/ao0","",-10.0,10.0,DAQmx_Val_Volts,""));

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

    /*********************************************/
    // DAQmx Write Code
    /*********************************************/
    DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));

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;
}

0 Kudos
Message 1 of 7
(6,773 Views)

Hello,

 

Thanks for all the info!  Within MAX, are you able to create Tasks and use Test Panels with this device?

Mason M
Applications Engineer
National Instruments
0 Kudos
Message 2 of 7
(6,752 Views)

NI LabVIEW SignalExpress 2009 Development System - I do not have a current license.  The current application was developed with Visual Basic in 2009.

0 Kudos
Message 3 of 7
(6,747 Views)

I cannot create a task

0 Kudos
Message 4 of 7
(6,746 Views)

So you cannot create a Task within NI MAX.  What version of DAQmx do you have installed? It should be listed in the Software section of MAX.   

Mason M
Applications Engineer
National Instruments
0 Kudos
Message 5 of 7
(6,736 Views)

8.9.5f6

0 Kudos
Message 6 of 7
(6,730 Views)

Hello,

 

Have you been able to create Tasks in MAX on this computer in the past, or has this behavior just popped up?  You have an older version of NI MAX, you might upgrade to 9.7:

 

http://joule.ni.com/nidu/cds/view/p/id/3811/lang/en

 

This version of DAQmx corresponds to LabVIEW 2009, so should be compatible with your setup.

 

 

Mason M
Applications Engineer
National Instruments
0 Kudos
Message 7 of 7
(6,713 Views)