02-14-2011 10:49 AM
I try to set up a buffer for my AO. Then I can write the chunk of the big file into the buffer.But when I use the DAQmxGetWriteSpaceAvail, the availabel space is always 0.
I am calling library in Matlab.
Here is my code.
AOBuffer_Size=10000;
AOHalfBuf_Size=AOBuffer_Size/2;
AOBufferSpaceAvail=uint32(0);
while
[a]=calllib(
(counter<=10)'myni','DAQmxGetWriteSpaceAvail',taskSlaveAO,AOBufferSpaceAvail_ptr)end
[a]=calllib(
'myni','DAQmxWriteAnalogF64',taskSlaveAO,5000,0,10,DAQmx_Val_GroupByScanNumber,A_ptr,empty_ptr,reserved)end
fclose(fid);
If someone can give explanation about my problem, I appreciate.
[a]=calllib('myni','DAQmxCfgOutputBuffer',taskSlaveAO,AOBuffer_Size)
[a]=calllib('myni','DAQmxSetWriteRegenMode',taskSlaveAO,DAQmx_Val_DoNotAllowRegen)
AOBufferSpaceAvail_ptr=libpointer('uint32Ptr',AOBufferSpaceAvail)empty_ptr=libpointer('int32Ptr',0);reserved=libpointer('uint32Ptr',[]);
fid=fopen('C:\zhou\PhysDataAcq_v2.02\SquareWaveNew.dat','r');
A=fread(fid,[1,AOHalfBuf_Size],'double');
A_ptr=libpointer('doublePtr',A);
[a]=calllib('myni','DAQmxWriteAnalogF64',taskSlaveAO,5000,0,10,DAQmx_Val_GroupByScanNumber,A_ptr,empty_ptr,reserved)
[a]=calllib('myni','DAQmxStartTask',taskMasterDO)
[a]=calllib('myni','DAQmxStartTask',taskSlaveAO)
[a]=calllib('myni','DAQmxStartTask',taskDev1CO)
counter=1;
if (AOBufferSpaceAvail>AOHalfBuf_Size)
A=fread(fid,[1,AOHalfBuf_Size],'double')
A_ptr=libpointer('doublePtr',A);
counter=counter+1;
while
02-14-2011 11:45 AM
I am setting up a buffer for my AO. So I can write a chunk of a big file into the buffer.
But when I execute the DAQmxGetWriteSpaceAvail, I always got availabe space equals to 0.
Here is my code. I am calling library in Matlab.
AOBuffer_Size=10000;
AOHalfBuf_Size=AOBuffer_Size/2;
AOBufferSpaceAvail=uint32(0);
end
[a]=calllib(
'myni','DAQmxWriteAnalogF64',taskSlaveAO,5000,0,10,DAQmx_Val_GroupByScanNumber,A_ptr,empty_ptr,reserved)end
fclose(fid);
If someone knows the solution,please let me know!
Thanks!
[a]=calllib('myni','DAQmxCfgOutputBuffer',taskSlaveAO,AOBuffer_Size)
[a]=calllib('myni','DAQmxSetWriteRegenMode',taskSlaveAO,DAQmx_Val_DoNotAllowRegen)
AOBufferSpaceAvail_ptr=libpointer('uint32Ptr',AOBufferSpaceAvail);
empty_ptr=libpointer('int32Ptr',0);
reserved=libpointer('uint32Ptr',[]);
fid=fopen('C:\zhou\PhysDataAcq_v2.02\SquareWaveNew.dat','r');
A=fread(fid,[1,AOHalfBuf_Size],'double');
A_ptr=libpointer('doublePtr',A);
[a]=calllib('myni','DAQmxWriteAnalogF64',taskSlaveAO,5000,0,10,DAQmx_Val_GroupByScanNumber,A_ptr,empty_ptr,reserved)
[a]=calllib('myni','DAQmxStartTask',taskDev1CO)
[a]=calllib('myni','DAQmxStartTask',taskMasterDO)
[a]=calllib('myni','DAQmxStartTask',taskSlaveAO)
counter=1;
while (counter<=10)
[a]=calllib('myni','DAQmxGetWriteSpaceAvail',taskSlaveAO,AOBufferSpaceAvail_ptr)
if (AOBufferSpaceAvail>AOHalfBuf_Size)
AOBufferSpaceAvail
A=fread(fid,[1,AOHalfBuf_Size],'double')
A_ptr=libpointer('doublePtr',A);
counter=counter+1;
02-14-2011 11:51 AM
Sorry for posting my question too many times. But the codes always cannot show up correctly.
I attach in the attachment this time.
02-15-2011 10:38 AM
Hi zhoulmnk-
I wonder which version of NI-DAQmx you are using. A very similar issue was reported with NI-DAQmx version 9.0.2 using an X-Series MultifunctionDAQ card to R&D, and we fixed it on the very next release of NI-DAQmx. The most recent version of NI-DAQmx is version 9.2.3, found here.
This issue was originally reported in this discussion forum post. I would go ahead and download NI-DAQmx 9.2.3, and then let us know if the issue still persists. Thanks!
02-15-2011 10:38 AM
Hi zhoulmnk-
I wonder which version of NI-DAQmx you are using. A very similar issue was reported with NI-DAQmx version 9.0.2 using an X-Series MultifunctionDAQ card to R&D, and we fixed it on the very next release of NI-DAQmx. The most recent version of NI-DAQmx is version 9.2.3, found here.
This issue was originally reported in this discussion forum post. I would go ahead and download NI-DAQmx 9.2.3, and then let us know if the issue still persists. Thanks!
02-15-2011 12:07 PM
Hi Gary,
Thank you for reply.
Actually I am using version 9.2.3. The problem is still there. But my matlab version is pretty old. It is R2006a.
liming
02-15-2011 08:35 PM
What DAQ card are you using? I don't see that you mentioned that.
02-16-2011 10:35 AM
Hi,
I am using PCI 6221 right now.Thank you!
liming
02-16-2011 03:29 PM
Hi zhoulmnk-
Take a look at this discussion forum post. It discusses disabling regeneration in order to use the DAQmxGetWriteSpaceAvail function. Let us know if this helps the issue.
02-17-2011 02:29 PM
Hi,
I already saw this post and disable the regeneration. The problem is still there.
I attached my codes to see if anyone can find the problem in my codes.
Thank you!
liming