05-11-2009 05:07 PM
DAQmxCreateTask("",&AOtaskHandle);
DAQmxCreateTask("",&COtaskHandle);
CounterFrequency = 611;
DAQmxCreateAOVoltageChan(AOtaskHandle,"Dev1/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL);
DAQmxCreateCOPulseChanFreq(COtaskHandle,"Dev1/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low,0.0,CounterFrequency, 0.5);
DAQmxCfgDigEdgeStartTrig(COtaskHandle,"ao/SampleClock", DAQmx_Val_RisingSlope);
DAQmxCfgImplicitTiming(COtaskHandle,DAQmx_Val_FiniteSamps,512);
AORate = CounterFrequency/512*1000;
DAQmxCfgSampClkTiming(AOtaskHandle,"",AORate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,2000);
DAQmxWriteAnalogF64(AOtaskHandle,2000,0,10.0,DAQmx_Val_GroupByChannel, pdAOBuffer, NULL, NULL);
While loop
{
DAQmxStartTask(COtaskHandle);
DAQmxStartTask(AOtaskHandle);
DAQmxWaitUntilTaskDone(AOtaskHandle, 2);
DAQmxStopTask(COtaskHandle);
DAQmxStopTask(AOtaskHandle);
}
Question:
If CounterFrequency >= 611, then pulse train handled by COtaskHandle works fine. Otherwise I cannot see any pulse.
I will appreciate it very much if you can give me a solution.
I am using PCI-6111.
05-12-2009 11:55 AM
Hi,
The PCI-6111 should be able to output digital pulses at a frequency less than 611. If you take out the analog output code do you see pulses being output? You would need to add a waituntildone for the counter task (I do not think that you need this though with the analog task because it will always be longer than the counter task). I would recommend to try out some examples to see if you can get the two tasks to work separately.
DAQmx C Examples
Start>>Programs>>National Instruments>>NI-DAQ>>Text Based Code Support
Do you see any errors when you select a sample rate of less than 611Hz (even 610Hz) for your counter task or is there just no ouput? After looking at your code I do not see anything that stands out currently. Also, after calculating the sample times you are under the 2 second timeout limit in the DAQmxWaitUntilTaskDone function.