10-23-2011 02:22 AM
I try use the C++ to wirte the code to generate the continuous waveform from Digital output terminal. But it can not generate the waveform with more than 100K hz. But it is ok for under 100Khz.
There is no error when ruing the program. But I can not get the waveform uisng the oscilloscope. I try to use the Measurement & Automation Explorer to generate the similar NI-DAQmx task. The task is ok and it can generate the waveform up to 2M Hz. Dose anyone know how to solve this problem? Thanks!
The code is as follows,
DAQmxCreateTask("",&taskHandle_VSync);
DAQmxCreateDOChan(taskHandle_VSync,"Dev1/port0","",DAQmx_Val_ChanForAllLines );
int fre;
fre=200000; //sample_speed;
DAQmxCfgSampClkTiming (taskHandle_VSync, "OnboardClock",fre, DAQmx_Val_Falling , DAQmx_Val_ContSamps,uInt64(fre));
DAQmxCfgOutputBuffer (taskHandle_VSync, 4);
data[0]=128+0;
data[1]=128+0;
data[2]=0+0;
data[3]=0+4;
DAQmxWriteDigitalU32(taskHandle_VSync,4,0,10.0,DAQmx_Val_GroupByChannel ,data, NULL,NULL);
DAQmxStartTask(taskHandle_VSync);
10-23-2011 08:38 PM
In the above code, the line with DAQmxCfgOutputBuffer should be removed. I just make a mistak.
If I set the only on borad memory, the program works!
xx=DAQmxSetDOUseOnlyOnBrdMem(taskHandle_VSync, "Dev1/port0", 1);
But I still dont understand why I can not use the Standard regeneration mode.
10-26-2011 11:30 AM
Hi,
Based on your description above, you can continuously generate a digital output waveform from your PCIe-6363 when you are using Regeneration from the FIFO. You cannot output a waveform with more than 100 KHz when using Regeneration from the memory/PC buffer.
The Regeneration from the memory/PC buffer option is set by default when generating a signal. Have you tried using any Digital Output example? If you have, do you see the same behavior? If you haven´t, I would suggest you to try one. You can go here to see where you can find DAQmx examples.
Regards,
10-26-2011 01:59 PM
I suspect that your issue lies in the fact that the buffer you are regenerating from is so small. I suspect this is limiting the amount of data that can be transferred to the device in one block. To test this, can you try creating a bigger data array (several hundred samples)? One other thing you probably should be doing with a generation is periodically calling DAQmxIsTaskDone. Once you call DAQmxStartTask, there really isn't a good way to tell if the task errors unless you call DAQmxWrite, DAQmxStopTask, or DAQmxIsTaskDone (DAQmxClearTask would not return such errors). I would be surprised if DAQmxIsTaskDone didn't return an error in the case you are not seeing any output (rates >= 100 kHz).
Hope that helps,
Dan
11-06-2011 02:06 PM
I try to use DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL) to trace the error. And I get the following error.
"Onboard device memory underflow. Because of system and/or bus-handwidth limitations, the driver could not write data to the device fast enough to keep up with the device output rate. Reduce your sample rate, or reduce the number of programs your computer is executing concurrently."
I also try the sample code as follows,
uInt32 data[8]={0,1,0,1,0,1,0,1};
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateDOChan(taskHandle,"Dev1/port0","",DAQmx_Val_ChanForAllLines));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"OnboardClock",1000000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000000));
DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));
DAQmxErrChk (DAQmxWriteDigitalU32(taskHandle,2,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));
if the size of data is 8, it can achieve 1Mhz. But if I decrease the size of data to 2 (data[2]={0,1}), I can only get 10KHz. I got the same error when I try to increase the rate. Dose that mean we need a larger size of array to install the data? So it will decrease the frenquency of data writing from PC to DAQ.
11-10-2011 12:03 PM - edited 11-10-2011 12:04 PM
Taoxd,
It appears that the latency of accessing the system memory is getting in the way of regenerating the FIFO. There is a setting you can use that just regenerates from the FIFO without reaccessing the memory. Below is the link for the manual. If you go to page 5-4, it talks about using FIFO regeneration. The limit is the signal must fit in the FIFO which in your case should. It gives the property, UseOnlyOnBoardMemory, to change this setting. This should be what you should look for if you intend on using such small data to regenerate a output signal.