Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxGetWriteSpaceAvail always give me 0 Space Avail

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

 

 

0 Kudos
Message 1 of 16
(4,065 Views)

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;

0 Kudos
Message 2 of 16
(4,062 Views)

Sorry for posting my question too many times. But the codes always cannot show up correctly.

I attach in the attachment this time.

0 Kudos
Message 3 of 16
(4,061 Views)

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!

Gary P.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 16
(4,032 Views)

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!

Gary P.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 16
(4,032 Views)

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

 

0 Kudos
Message 6 of 16
(4,028 Views)

What DAQ card are you using?  I don't see that you mentioned that.

------
Zach Hindes
NI R&D
0 Kudos
Message 7 of 16
(4,009 Views)

Hi,

I am using PCI 6221 right now.Thank you!

liming

0 Kudos
Message 8 of 16
(3,991 Views)

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.

Gary P.
Applications Engineer
National Instruments
0 Kudos
Message 9 of 16
(3,974 Views)

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

0 Kudos
Message 10 of 16
(3,954 Views)