Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

6211 NI-DAQmx Base MAC OSX multiple analog output

Hi,

 

I want to generate two simultaneous analog outputs on a NI USB-6211.

 

I'm using NI-DAQmx Base for Mac OS X v.3.4.0 in a Xcode 3.1.3 environment (in C) on a MacOSX 10.5 (intel). -- No Labview.

 

Using the provided example (contGeneration.c), I can get a sine wave with: "Dev1/ao0"

I do not get any ouput when creating a single task for "Dev1/ao0:1" as suggested in many threads on the subject.

 

How can I get the two analog outputs to work at the same time? Ideally, it would allow for the output to be different, and synchronized.

 

Thank you,

 

RT1

 

 

------------------------------------------------------------------------------------------------------------

  // Task parameters

    int32       error = 0;

    TaskHandle  taskHandle = 0;

    int32       i = 0;

    char        errBuff[2048]={'\0'};

    time_t      startTime;

    bool32      done=0;

 

    // Channel parameters

    char        chan[] = "Dev1/ao0:1"; //****************************************************************

    float64     min = -10.0;

    float64     max = 10.0;

 

    // Timing parameters

    #define     bufferSize 512

    uInt64      samplesPerChan = bufferSize;

    float64     sampleRate = 10000.0;

 

    // Data write parameters

    float64     data[bufferSize];

    int32       pointsWritten;

    float64     timeout = 10.0;

 

 

    for(;i<bufferSize;i++)

        data[i] = 9.95*sin((double)i*2.0*PI/(double)bufferSize);

 

    DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));

    DAQmxErrChk (DAQmxBaseCreateAOVoltageChan(taskHandle,chan,"",min,max,DAQmx_Val_Volts,NULL));

    DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,"",sampleRate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,samplesPerChan));

 

    DAQmxErrChk (DAQmxBaseWriteAnalogF64(taskHandle,samplesPerChan,0,timeout,DAQmx_Val_GroupByChannel,data,&pointsWritten,NULL));

 

    DAQmxErrChk (DAQmxBaseStartTask(taskHandle));

    gRunning = 1;

    // The loop will quit after 10 seconds

    startTime = time(NULL);

    while( gRunning && !done && time(NULL)<startTime+10 ) {

        DAQmxErrChk (DAQmxBaseIsTaskDone(taskHandle,&done));

        if( !done )

            usleep(100000);

    }

 

Error:

    if( DAQmxFailed(error) )

        DAQmxBaseGetExtendedErrorInfo(errBuff,2048);

    if( taskHandle!=0 ) {

        DAQmxBaseStopTask(taskHandle);

        DAQmxBaseClearTask(taskHandle);

    }

    if( DAQmxFailed(error) )

printf ("DAQmxBase Error %d: %s\n", error, errBuff);

------------------------------------------------------------------------------------------------------------

0 Kudos
Message 1 of 2
(2,829 Views)

Please ignore previous post.

 

RT1

0 Kudos
Message 2 of 2
(2,827 Views)