Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxCfgSampClkTiming problem

I am working with DAQmx on using the function, DAQmxCfgSampClkTiming, and I am having trouble with the RATE parameter.   The purpose of my application is to generate analog output (up to 4 channels), and in my setup i have a section of code for small data array output and a section for larger data arrays of output.  In the larger data array section i have no problems, but when i work with smaller data arrays and try to output them it seems that the rate i specify in DAQmxCfgSampClkTiming doesn't output correctly.  I would enter in 2000 pts per second on an array of 6000 points and it would play the data at least 2 or 3 times faster than what i specified. 
 
I have also thought the problem could be how i stop the task because i have tried generating the waveform of data with Regeneration and without regeneration as well as Finite samples and Continous Samples.  In certain circumstances if i just wait until the task is done then i will recieve an error saying that the output of data stopped to prevent regeneration of old data.  If i then turn off regernation then i will get an error saying that I didn't write to the buffer fast enough. 
 
So, after receiving all of these errors i just started to stop the task based on how many data points had been written or how much write space is available in the buffer.  When i would reach a certain point i would call StopTask, but when i started doing that it wouldn't always play all the data, which led me to believe the RATE parameter wasn't working correctly on my DAQmxCfgSampClkTiming function.
 
Information on my setup:
 
DAQmx version: 7.5
Board: PCI-6711
Windows version: XP
Language: VB 6.0
 
 
0 Kudos
Message 1 of 5
(4,181 Views)
Hello GVanHorn,

Do you see the same problem if you use one of the example programs, such as ContGenVoltWfmIntClk in NI-DAQ\Examples\Visual Basic 6.0\Analog Out\Generate Voltage?  How many channels are you using in your task?  Are you specifying the 2000 as the rate and the 6000 as the number of samples per channel?

Regards,
Micaela
Micaela N
National Instruments
0 Kudos
Message 2 of 5
(4,167 Views)
I was using 2000 as the rate but not 6000 for the buffer.  My buffer is a variable size.  See below:
 

DAQmxErrChk DAQmxCfgSampClkTiming(taskHandle, "", SampleRate, DAQmx_Val_Rising, DAQmx_Val_AcquisitionType_ContSamps, UBound(WaveData))
DAQmxErrChk DAQmxSetBufOutputBufSize(taskHandle, UBound(WholeBuffer))
DAQmxErrChk DAQmxSetWriteRegenMode(taskHandle, DAQmx_Val_RegenerationMode1_DoNotAllowRegen)
DAQmxErrChk DAQmxWriteAnalogF64(taskHandle, (UBound(WaveData) / NumChans), True, 10#, DAQmx_Val_GroupByScanNumber, WaveData(0), sampsPerChanWritten, 0)

I did try the sample program and it seemed to be playing the output correctly.   

 

Thanks,

Gerry

 

Message Edited by GVanHorn on 07-28-2006 12:37 PM

Message Edited by GVanHorn on 07-28-2006 12:38 PM

0 Kudos
Message 3 of 5
(4,158 Views)
I get a run-time error when I use the DAQmxErrChk DAQmxWriteAnalogF64(taskHandle, (UBound(WaveData) / NumChans), True, 10#, DAQmx_Val_GroupByScanNumber, WaveData(0), sampsPerChanWritten, 0).  I have to use: DAQmxErrChk DAQmxWriteAnalogF64(taskHandle, (UBound(WaveData) / NumChans), True, 10#, DAQmx_Val_GroupByScanNumber, WaveData(0), sampsPerChanWritten, ByVal 0&) so that the program would not error out. 

Regards,
Micaela N
National Instruments
0 Kudos
Message 4 of 5
(4,151 Views)
Yeah, i had to use ByVal 0& as well, but i removed it from the post because it made the line wrap around to the next line.  Thanks for the post though.
0 Kudos
Message 5 of 5
(4,148 Views)