04-08-2009 11:57 AM
I just got a NI USB-6009 and I'm trying to use simple analog output.
I am running on a Mac, so I am trying to use the NI-DAQmx Base 3.2 C API (downloaded here: http://joule.ni.com/nidu/cds/view/p/id/1078/lang/en). It is the most recent version of NI-DAQmxBase I've been able to find.
I am trying to do continuous analog output on the 6009, which does not have a built in clock. So I was hoping to do the clocking in software, and just output new values whenever I want.
I can't seem to get basic data output to work. From other posts and the Windows example files, (e.g. National Instruments/NI-DAQmx Base/examples/ao/MultVoltUpates-SWTimed.c) it seems that the easiest thing to do would be to use the function DAQmxWriteAnalogScalarF64.
However, this does not seem to be in the Mac version of the NIDAQmxBase C API. There's actually an entry for it in the NIDAQmxBase.h file, but it is commented out. Does anyone know why? Is there any way to use this function for on-demand analog output on the Mac?
Thanks.
Chethan
Solved! Go to Solution.
04-08-2009 05:10 PM
I have NI-DAQmx Base 3.2 installed on a 10.4.11 system. One of the example files "genVoltage.c" calls DAQmxBaseWriteAnalogF64. I've been able to compile and run this example with a USB-6009.
Would the DAQmxBaseWriteAnalogF64 function work for you?
My guess is that since you can write a scalar value with DAQmxBaseWriteAnalogF64, DAQmxBaseWriteAnalogScalarF64 becomes redundant. The example that came with installation shows how to write a single value (i.e. scalar). I pasted NI's code below.
int main(int argc, char *argv[])
{
// Task parameters
int32 error = 0;
TaskHandle taskHandle = 0;
char errBuff[2048]={'\0'};
// Channel parameters
char chan[] = "Dev1/ao0";
float64 min = 0.0;
float64 max = 5.0;
// Timing parameters
uInt64 samplesPerChan = 1;
// Data write parameters
float64 data = 3.25;
int32 pointsWritten;
float64 timeout = 10.0;
DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxBaseCreateAOVoltageChan(taskHandle,chan,"",min,max,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
DAQmxErrChk (DAQmxBaseWriteAnalogF64(taskHandle,samplesPerChan,0,timeout,DAQmx_Val_GroupByChannel,&data,&pointsWritten,NULL));
Error:
if( DAQmxFailed(error) )
DAQmxBaseGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
DAQmxBaseStopTask(taskHandle);
DAQmxBaseClearTask(taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmxBase Error: %s\n",errBuff);
return 0;
}
Hope this helps!!
04-08-2009 08:34 PM
It does help, thanks! I was having trouble using the DAQmxBaseWriteAnalogF64 function, but I was basing my code off the contGeneration.c file, which is setup for a different device. I probably just didn't change all the settings correctly.
But I can now base my code off of genVoltage.c, and it should have the functionalityI was lookingfor with WriteScalar. Excellent.
Thanks for the reply!