Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Shared clock for ai and ao with USB DAQ?

Hello,
 
I've been using a PCI DAQ (6229) for a while, and have recently switched to a USB DAQ (6211). In the program I've been using, I make use of the "SynchAIAOSharedClock" example, using the clock of the AO to sync with the AI. In the forums I read the USB DAQ doesn't support hardware time AO, so I guess this is why the code doesn't work anymore. Is there a way to share clocks the other way round (using the AI clock to drive the AO...)?
 
The code I'm using is:
 
int32 Configure_SynchAIAOSharedClock(const char *inputChan[], int numChans, const char outputChan[], float64 minIn, float64 minOut, float64 maxIn, float64 maxOut, float64 rate, TaskHandle *inputTaskHandle, TaskHandle *outputTaskHandle)
{
 int32  error=0;
 char  outputClock[256];
 char  outputClockTemp[256];
 int  numBytes, i;
/*********************************************************************
*   1. Set the outputClock to be the sample clock on the
*  device set by the Output Channel parameter
*********************************************************************/ 
 numBytes = FindPattern (outputChan, 0, -1, "/", 0, 0);    
 CopyString (outputClockTemp, 0, outputChan, 0, numBytes);
 sprintf(outputClock,"/%s/ao/SampleClock",outputClockTemp);
/*********************************************************************
*    1. Create a task.
*    2. Create Analog Input Voltage channels.
*    3. Define the Sample Clock source. Additionally, define the sample
*       mode to be continuous.
*********************************************************************/
 DAQmxErrChk (DAQmxCreateTask("",inputTaskHandle));
 for(i=0; i<numChans; i++)
 {
  DAQmxErrChk (DAQmxCreateAIVoltageChan (*inputTaskHandle, inputChan[i], "",
             DAQmx_Val_RSE, minIn, maxIn,
             DAQmx_Val_Volts, NULL));
  //printf("minimum = %lf maximum = %lf\n",minIn[i],maxIn[i]);
 } 
 DAQmxErrChk (DAQmxCfgSampClkTiming (*inputTaskHandle, outputClock, rate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1000));
   
/*********************************************************************
*    1. Create a task.
*    2. Create an Analog Output Voltage channel.
*    3. Define the Sample Clock source. Additionally, define the sample
*       mode to be continuous.
*********************************************************************/
 DAQmxErrChk (DAQmxCreateTask("",outputTaskHandle));
 DAQmxErrChk (DAQmxCreateAOVoltageChan (*outputTaskHandle, outputChan, "", minOut, maxOut, DAQmx_Val_Volts, ""));
 DAQmxErrChk (DAQmxCfgSampClkTiming (*outputTaskHandle, "OnboardClock", rate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1000));
 Error:
 return error;
}
 
And is called using:
 
DAQmxErrChk(Configure_SynchAIAOSharedClock(inputChan, nr_eeg_chan_meas, impedance_out_channel, -impedance_dac_range, -impedance_dac_range, impedance_dac_range, impedance_dac_range, samples_rate, &impedance_inputTaskHandle, &impedance_outputTaskHandle));
DAQmxErrChk(Write_Task(impedance_outputTaskHandle, wfm_data, imp_bufferSize));
DAQmxErrChk(Start_Task(impedance_outputTaskHandle));
DAQmxErrChk(Start_Task(impedance_inputTaskHandle));
 
Best regards,
Ward
0 Kudos
Message 1 of 2
(3,005 Views)

Hello Ward,

I do not know where you got your information from but the Analog Outputs on the USB-6211 are Hardware Timed (max 250 kS/s). I looked into the possibilities of this module and was able to share the AI and AO clocks without any problems in LabVIEW. Can you give me a more specific description of the problems you experiance? For example what are the rates you sepcify, what is the error you are seeing?

Regards,

RikP - National Instruments Applications Engineering

 

Rik Prins, CLA, CLED
Software Development Engineer
0 Kudos
Message 2 of 2
(2,955 Views)