Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxGetWriteSpaceAvail always give me 0 Space Avail

zhoulmnk-

 

     What happens if you change your value of AOBufferSpaceAvail=uint32(0); to AOBufferSpaceAvail=uint32(1);?  Does your buffer size available change to 1?  I wonder if the pointer is not functioning correctly lower in your code.

 

     Also, it doesn't look like you are doing any error handling.  What is the output of the callib line where you call the DAQmxGetWriteSpaceAvail property?  Do you get any associated error codes?

Gary P.
Applications Engineer
National Instruments
0 Kudos
Message 11 of 16
(1,174 Views)

Hi Gary,

I changed AOBufferSpaceAvail=uint32(0); to AOBufferSpaceAvail=uint32(1);.Then the AOBufferSpaceAvail changed to 1. You are right, the pointer didn't work right. But I still don't understand what's wrong with my code. When I use the DAQmxGetWriteSpaceAvail, there is no any error code. The output is 0.

Thank you!

liming 

0 Kudos
Message 12 of 16
(1,171 Views)

Hi liming-

 

     I am unsure how you would use this pointer in MATLAB; this may be an issue with the syntax.  You are passing all the correct parameters to the function.  I would double check that your syntax is correct; this may be a question for MATLAB at this point.  We have verified that your function returns the value as set by the property earlier in the program: DAQmxGetWriteSpaceAvail pulls a value as set by AOBufferSpaceAvail.  I am unsure how the pointer should be setup.

Gary P.
Applications Engineer
National Instruments
0 Kudos
Message 13 of 16
(1,147 Views)

Hi Gary,

Thank you!

Let me know if you find any solution to help me out or if you need more information. By the way, do you know some other way to use the buffer to load the big file?

liming

0 Kudos
Message 14 of 16
(1,141 Views)

Hi liming-

 

     You might take a look at this example to see how they implement an analog output buffer.  When you download it, you get a C Source file.  This may help you craft your MATLAB code.

Gary P.
Applications Engineer
National Instruments
0 Kudos
Message 15 of 16
(1,127 Views)

Old post, but I'm still answering because I ended up in this thread. It maybe helps others.

 

I also got 0 for DAQmxGetWriteSpaceAvail calls, and no error codes. It turned out that there was an error under the hood, but DAQmxGetWriteSpaceAvail did not show it! I called DAQmxIsTaskDone, which returned the error code, correctly (Onboard buffer underflow error, in my case).

 

So I assume what happened in my case is that all samples were written from the buffer, but the task halted and threw an error. It seems a halted/stopped task shows "0" for DAQmxGetWriteSpaceAvail.

I also had DAQmx_Val_HaltOutputAndError configured for DAQmxSetSampClkUnderflowBehavior.

 

Check for errors!

0 Kudos
Message 16 of 16
(411 Views)